diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/BasicQuery.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/BasicQuery.java deleted file mode 100644 index 296b51307..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/BasicQuery.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.document.mongodb.query; - -import com.mongodb.DBObject; -import com.mongodb.util.JSON; - -public class BasicQuery implements Query { - - private DBObject dbo = null; - - - public BasicQuery(String query) { - super(); - this.dbo = (DBObject) JSON.parse(query); - } - - public BasicQuery(DBObject dbo) { - super(); - this.dbo = dbo; - } - - public DBObject getQueryObject() { - return dbo; - } - -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/Criteria.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/Criteria.java deleted file mode 100644 index 5acf58f04..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/Criteria.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.document.mongodb.query; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; - -import org.springframework.data.document.InvalidDocumentStoreApiUageException; - -import com.mongodb.BasicDBObject; -import com.mongodb.DBObject; - -public class Criteria implements CriteriaSpec { - - private QueryBuilder qb = null; - - private LinkedHashMap criteria = new LinkedHashMap(); - - private Object isValue = null; - - - public Criteria(QueryBuilder qb) { - super(); - this.qb = qb; - } - - - public Criteria and(String key) { - return qb.find(key); - } - - - public Criteria is(Object o) { - if (isValue != null) { - throw new InvalidDocumentStoreApiUageException("Multiple 'is' values declared."); - } - this.isValue = o; - return this; - } - - public Criteria lt(Object o) { - criteria.put("$lt", o); - return this; - } - - public Criteria lte(Object o) { - criteria.put("$lte", o); - return this; - } - - public Criteria gt(Object o) { - criteria.put("$gt", o); - return this; - } - - public Criteria gte(Object o) { - criteria.put("$gte", o); - return this; - } - - public Criteria in(Object... o) { - criteria.put("$in", o); - return this; - } - - public Criteria nin(Object... o) { - criteria.put("$min", o); - return this; - } - - public Criteria mod(Number value, Number remainder) { - List l = new ArrayList(); - l.add(value); - l.add(remainder); - criteria.put("$mod", l); - return this; - } - - public Criteria all(Object o) { - criteria.put("$is", o); - return this; - } - - public Criteria size(Object o) { - criteria.put("$is", o); - return this; - } - - public Criteria exists(boolean b) { - return this; - } - - public Criteria type(int t) { - return this; - } - - public Criteria not() { - criteria.put("$not", null); - return this; - } - - public Criteria regExp(String re) { - return this; - } - - public void or(List queries) { - criteria.put("$or", queries); - } - - public Query build() { - return qb.build(); - } - - /* (non-Javadoc) - * @see org.springframework.datastore.document.mongodb.query.Criteria#getCriteriaObject(java.lang.String) - */ - public DBObject getCriteriaObject(String key) { - DBObject dbo = new BasicDBObject(); - boolean not = false; - for (String k : criteria.keySet()) { - if (not) { - DBObject notDbo = new BasicDBObject(); - notDbo.put(k, criteria.get(k)); - dbo.put("$not", notDbo); - not = false; - } - else { - if ("$not".equals(k)) { - not = true; - } - else { - dbo.put(k, criteria.get(k)); - } - } - } - DBObject queryCriteria = new BasicDBObject(); - if (isValue != null) { - queryCriteria.put(key, isValue); - queryCriteria.putAll(dbo); - } - else { - queryCriteria.put(key, dbo); - } - return queryCriteria; - } - -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/CriteriaSpec.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/CriteriaSpec.java deleted file mode 100644 index d0837050f..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/CriteriaSpec.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.document.mongodb.query; - -import com.mongodb.DBObject; - -public interface CriteriaSpec { - - DBObject getCriteriaObject(String key); - -} \ No newline at end of file diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/FieldSpecification.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/FieldSpecification.java deleted file mode 100644 index a1987f274..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/FieldSpecification.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.document.mongodb.query; - - -public class FieldSpecification { - - public FieldSpecification include(String key) { - return this; - } - - public FieldSpecification exclude(String key) { - return this; - } - -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/OrCriteria.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/OrCriteria.java deleted file mode 100644 index 966740b07..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/OrCriteria.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.document.mongodb.query; - -import org.bson.types.BasicBSONList; - -import com.mongodb.BasicDBObject; -import com.mongodb.DBObject; - -public class OrCriteria implements CriteriaSpec { - - Query[] queries = null; - - public OrCriteria(Query[] queries) { - super(); - this.queries = queries; - } - - - /* (non-Javadoc) - * @see org.springframework.datastore.document.mongodb.query.Criteria#getCriteriaObject(java.lang.String) - */ - public DBObject getCriteriaObject(String key) { - DBObject dbo = new BasicDBObject(); - BasicBSONList l = new BasicBSONList(); - for (Query q : queries) { - l.add(q.getQueryObject()); - } - dbo.put(key, l); - return dbo; - } - -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/Query.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/Query.java deleted file mode 100644 index dcd87797a..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/Query.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.document.mongodb.query; - -import com.mongodb.DBObject; - - -public interface Query { - - DBObject getQueryObject(); - -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/QueryBuilder.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/QueryBuilder.java deleted file mode 100644 index e6486b7f9..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/QueryBuilder.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.document.mongodb.query; - -import java.util.LinkedHashMap; - -import com.mongodb.BasicDBObject; -import com.mongodb.DBObject; - -public class QueryBuilder implements Query { - - private LinkedHashMap criteria = new LinkedHashMap(); - - public Criteria find(String key) { - Criteria c = new Criteria(this); - this.criteria.put(key, c); - return c; - } - - public QueryBuilder or(Query... queries) { - this.criteria.put("$or", new OrCriteria(queries)); - return this; - } - - public FieldSpecification fields() { - return new FieldSpecification(); - } - - public SliceSpecification slice() { - return new SliceSpecification(); - } - - public SortSpecification sort() { - return new SortSpecification(); - } - - public QueryBuilder limit(int limit) { - return this; - } - - public Query build() { - return this; - } - - public DBObject getQueryObject() { - DBObject dbo = new BasicDBObject(); - for (String k : criteria.keySet()) { - CriteriaSpec c = criteria.get(k); - DBObject cl = c.getCriteriaObject(k); - dbo.putAll(cl); - } - return dbo; - } - -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/SliceSpecification.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/SliceSpecification.java deleted file mode 100644 index d2dfdc8ac..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/SliceSpecification.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.document.mongodb.query; - - -public class SliceSpecification { - - public SliceSpecification on(String key, int size) { - return this; - } - -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/SortSpecification.java b/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/SortSpecification.java deleted file mode 100644 index 3d2c4b3c7..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/SortSpecification.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.document.mongodb.query; - - -public class SortSpecification { - - public enum SortOrder { - ASCENDING, DESCENDING - } - - public SortSpecification on(String key, SortOrder order) { - return this; - } - -}