diff --git a/spring-data-mongodb/Spring Data MongoDB.sonargraph b/spring-data-mongodb/Spring Data MongoDB.sonargraph
index 9c3390d73..02c36b2bd 100644
--- a/spring-data-mongodb/Spring Data MongoDB.sonargraph
+++ b/spring-data-mongodb/Spring Data MongoDB.sonargraph
@@ -5,15 +5,6 @@
-
-
-
-
-
-
-
-
-
@@ -40,10 +31,20 @@
+
+
+
+
+
+
+
+
+
+
@@ -57,41 +58,39 @@
-
-
-
+
-
+
-
+
-
-
+
-
+
+
-
+
-
+
@@ -100,7 +99,7 @@
-
+
@@ -116,6 +115,13 @@
+
+
+
+
+
+
+
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoNamespaceHandler.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoNamespaceHandler.java
index 3a423ec4b..89b6c2f84 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoNamespaceHandler.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoNamespaceHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2013 the original author or authors.
+ * Copyright 2011-2014 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.
@@ -16,9 +16,6 @@
package org.springframework.data.mongodb.config;
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
-import org.springframework.data.mongodb.repository.config.MongoRepositoryConfigurationExtension;
-import org.springframework.data.repository.config.RepositoryBeanDefinitionParser;
-import org.springframework.data.repository.config.RepositoryConfigurationExtension;
/**
* {@link org.springframework.beans.factory.xml.NamespaceHandler} for Mongo DB configuration.
@@ -34,10 +31,6 @@ public class MongoNamespaceHandler extends NamespaceHandlerSupport {
*/
public void init() {
- RepositoryConfigurationExtension extension = new MongoRepositoryConfigurationExtension();
- RepositoryBeanDefinitionParser repositoryBeanDefinitionParser = new RepositoryBeanDefinitionParser(extension);
-
- registerBeanDefinitionParser("repositories", repositoryBeanDefinitionParser);
registerBeanDefinitionParser("mapping-converter", new MappingMongoConverterParser());
registerBeanDefinitionParser("mongo", new MongoParser());
registerBeanDefinitionParser("db-factory", new MongoDbFactoryParser());
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java
index 3f1a85462..e2ed006f0 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java
@@ -52,6 +52,7 @@ import com.mongodb.WriteResult;
* @author Christoph Strobl
* @author Thomas Darimont
*/
+@SuppressWarnings("deprecation")
public interface MongoOperations {
/**
@@ -414,7 +415,7 @@ public interface MongoOperations {
MapReduceOptions mapReduceOptions, Class entityClass);
/**
- * Returns {@link GeoResult} for all entities matching the given {@link NearQuery}. Will consider entity mapping
+ * Returns {@link GeoResults} for all entities matching the given {@link NearQuery}. Will consider entity mapping
* information to determine the collection the query is ran against.
*
* @param near must not be {@literal null}.
@@ -424,7 +425,7 @@ public interface MongoOperations {
GeoResults geoNear(NearQuery near, Class entityClass);
/**
- * Returns {@link GeoResult} for all entities matching the given {@link NearQuery}.
+ * Returns {@link GeoResults} for all entities matching the given {@link NearQuery}.
*
* @param near must not be {@literal null}.
* @param entityClass must not be {@literal null}.
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java
index 9e983b08c..eb12ef577 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java
@@ -130,6 +130,7 @@ import com.mongodb.util.JSONParseException;
* @author Chuong Ngo
* @author Christoph Strobl
*/
+@SuppressWarnings("deprecation")
public class MongoTemplate implements MongoOperations, ApplicationContextAware {
private static final Logger LOGGER = LoggerFactory.getLogger(MongoTemplate.class);
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/CustomConversions.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/CustomConversions.java
index b78bb5dba..a40728a4f 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/CustomConversions.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/CustomConversions.java
@@ -106,8 +106,8 @@ public class CustomConversions {
toRegister.add(URLToStringConverter.INSTANCE);
toRegister.add(StringToURLConverter.INSTANCE);
toRegister.add(DBObjectToStringConverter.INSTANCE);
+
toRegister.addAll(JodaTimeConverters.getConvertersToRegister());
-
toRegister.addAll(GeoConverters.getConvertersToRegister());
for (Object c : toRegister) {
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/GeoConverters.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/GeoConverters.java
index e6a8fcbcc..d9260d4e6 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/GeoConverters.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/GeoConverters.java
@@ -291,6 +291,7 @@ abstract class GeoConverters {
List points = source.getPoints();
List> pointTuples = new ArrayList>(points.size());
+
for (Point point : points) {
pointTuples.add(toList(point));
}
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Sphere.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Sphere.java
index 686034c46..42390af06 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Sphere.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Sphere.java
@@ -30,6 +30,7 @@ import org.springframework.util.Assert;
* @author Thomas Darimont
* @since 1.5
*/
+@SuppressWarnings("deprecation")
public class Sphere implements Shape {
public static final String COMMAND = "$centerSphere";
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java
index ec2499f78..44310ff3a 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java
@@ -25,11 +25,12 @@ import java.util.List;
import java.util.regex.Pattern;
import org.bson.BSON;
+import org.springframework.data.geo.Box;
import org.springframework.data.geo.Circle;
import org.springframework.data.geo.Point;
+import org.springframework.data.geo.Polygon;
import org.springframework.data.geo.Shape;
import org.springframework.data.mongodb.InvalidMongoDbApiUsageException;
-import org.springframework.data.mongodb.core.convert.GeoCommandUtils;
import org.springframework.data.mongodb.core.geo.Sphere;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -385,7 +386,7 @@ public class Criteria implements CriteriaDefinition {
*/
public Criteria withinSphere(Circle circle) {
Assert.notNull(circle);
- criteria.put("$within", GeoCommandUtils.INSTANCE.wrapInCommand(new Sphere(circle)));
+ criteria.put("$within", wrapInCommand(new Sphere(circle)));
return this;
}
@@ -399,7 +400,7 @@ public class Criteria implements CriteriaDefinition {
@Deprecated
public Criteria withinSphere(org.springframework.data.mongodb.core.geo.Circle circle) {
Assert.notNull(circle);
- criteria.put("$within", GeoCommandUtils.INSTANCE.wrapInCommand(new Sphere(circle)));
+ criteria.put("$within", wrapInCommand(new Sphere(circle)));
return this;
}
@@ -413,7 +414,7 @@ public class Criteria implements CriteriaDefinition {
public Criteria within(Shape shape) {
Assert.notNull(shape);
- criteria.put("$within", GeoCommandUtils.INSTANCE.wrapInCommand(shape));
+ criteria.put("$within", wrapInCommand(shape));
return this;
}
@@ -659,6 +660,43 @@ public class Criteria implements CriteriaDefinition {
return ObjectUtils.nullSafeEquals(left, right);
}
+ /**
+ * Wraps the given {@link Shape} in an appropriate MongoDB command.
+ *
+ * @param shape must not be {@literal null}.
+ * @return
+ */
+ private DBObject wrapInCommand(Shape shape) {
+
+ Assert.notNull(shape, "Shape must not be null!");
+
+ return new BasicDBObject(getCommand(shape), shape);
+ }
+
+ /**
+ * Returns the MongoDB command for the given {@link Shape}.
+ *
+ * @param shape must not be {@literal null}.
+ * @return
+ */
+ @SuppressWarnings("deprecation")
+ private String getCommand(Shape shape) {
+
+ Assert.notNull(shape, "Shape must not be null!");
+
+ if (shape instanceof Box) {
+ return org.springframework.data.mongodb.core.geo.Box.COMMAND;
+ } else if (shape instanceof Circle || shape instanceof org.springframework.data.mongodb.core.geo.Circle) {
+ return org.springframework.data.mongodb.core.geo.Circle.COMMAND;
+ } else if (shape instanceof Polygon) {
+ return org.springframework.data.mongodb.core.geo.Polygon.COMMAND;
+ } else if (shape instanceof Sphere) {
+ return org.springframework.data.mongodb.core.geo.Sphere.COMMAND;
+ }
+
+ throw new IllegalArgumentException("Unknown shape: " + shape);
+ }
+
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/NearQuery.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/NearQuery.java
index 3a96914bc..3f34933f1 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/NearQuery.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/NearQuery.java
@@ -343,6 +343,7 @@ public final class NearQuery {
*
* @return
*/
+ @SuppressWarnings("deprecation")
public DBObject toDBObject() {
BasicDBObject dbObject = new BasicDBObject();
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Near.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Near.java
index f8ff08238..adcc73899 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Near.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/Near.java
@@ -1,13 +1,28 @@
+/*
+ * Copyright 2011-2014 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.mongodb.repository;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import java.lang.annotation.Retention;
-
-import org.springframework.data.mongodb.core.geo.Distance;
+import org.springframework.data.geo.Distance;
+import org.springframework.data.geo.Point;
/**
* Annotation to be used for disambiguing method parameters that shall be used to trigger geo near queries. By default
@@ -20,5 +35,4 @@ import org.springframework.data.mongodb.core.geo.Distance;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
public @interface Near {
-
}
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/config/MongoRepositoryConfigNamespaceHandler.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/config/MongoRepositoryConfigNamespaceHandler.java
new file mode 100644
index 000000000..6e059b8ae
--- /dev/null
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/config/MongoRepositoryConfigNamespaceHandler.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2014 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.mongodb.repository.config;
+
+import org.springframework.beans.factory.xml.NamespaceHandler;
+import org.springframework.data.mongodb.config.MongoNamespaceHandler;
+import org.springframework.data.repository.config.RepositoryBeanDefinitionParser;
+import org.springframework.data.repository.config.RepositoryConfigurationExtension;
+
+/**
+ * {@link NamespaceHandler} to register repository configuration.
+ *
+ * @author Oliver Gierke
+ */
+public class MongoRepositoryConfigNamespaceHandler extends MongoNamespaceHandler {
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.data.mongodb.config.MongoNamespaceHandler#init()
+ */
+ @Override
+ public void init() {
+
+ RepositoryConfigurationExtension extension = new MongoRepositoryConfigurationExtension();
+ RepositoryBeanDefinitionParser repositoryBeanDefinitionParser = new RepositoryBeanDefinitionParser(extension);
+
+ registerBeanDefinitionParser("repositories", repositoryBeanDefinitionParser);
+
+ super.init();
+ }
+}
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/AbstractMongoQuery.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/AbstractMongoQuery.java
index ae08fc0b7..824bd8e60 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/AbstractMongoQuery.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/AbstractMongoQuery.java
@@ -24,12 +24,11 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.SliceImpl;
+import org.springframework.data.geo.Distance;
+import org.springframework.data.geo.GeoResult;
+import org.springframework.data.geo.GeoResults;
+import org.springframework.data.geo.Point;
import org.springframework.data.mongodb.core.MongoOperations;
-import org.springframework.data.mongodb.core.geo.Distance;
-import org.springframework.data.mongodb.core.geo.GeoPage;
-import org.springframework.data.mongodb.core.geo.GeoResult;
-import org.springframework.data.mongodb.core.geo.GeoResults;
-import org.springframework.data.mongodb.core.geo.Point;
import org.springframework.data.mongodb.core.query.NearQuery;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.repository.query.ParameterAccessor;
@@ -294,6 +293,7 @@ public abstract class AbstractMongoQuery implements RepositoryQuery {
*
* @author Oliver Gierke
*/
+ @SuppressWarnings("deprecation")
final class GeoNearExecution extends Execution {
private final MongoParameterAccessor accessor;
@@ -325,11 +325,12 @@ public abstract class AbstractMongoQuery implements RepositoryQuery {
MongoEntityMetadata> metadata = method.getEntityInformation();
long count = operations.count(countQuery, metadata.getCollectionName());
- return new GeoPage