DATADOC-43 Added Near and Within as part types to support spatial repository queries.

This commit is contained in:
Oliver Gierke
2011-05-03 15:12:22 +02:00
parent 7590f55547
commit ff51b134f9
3 changed files with 31 additions and 3 deletions

View File

@@ -2,6 +2,10 @@
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@@ -158,16 +158,20 @@ public class Part {
NOT_IN("NotIn"),
IN("In"),
NEAR("Near"),
WITHIN("Within"),
NEGATING_SIMPLE_PROPERTY("Not"),
SIMPLE_PROPERTY;
// Need to list them again explicitly as the order is important
// (esp. for IS_NULL, IS_NOT_NULL)
private static final List<Part.Type> ALL = Arrays.asList(IS_NOT_NULL,
IS_NULL, BETWEEN, LESS_THAN, GREATER_THAN, NOT_LIKE, LIKE,
NOT_IN, IN, NEGATING_SIMPLE_PROPERTY, SIMPLE_PROPERTY);
NOT_IN, IN, NEAR, WITHIN, NEGATING_SIMPLE_PROPERTY, SIMPLE_PROPERTY);
private List<String> keywords;
private int numberOfArguments;

View File

@@ -23,6 +23,7 @@ import java.util.Iterator;
import org.junit.Test;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.repository.query.parser.Part.Type;
import org.springframework.data.repository.query.parser.PartTree.OrPart;
@@ -127,6 +128,24 @@ public class PartTreeUnitTests {
assertThat(tree.getSort(), is(new Sort(Direction.DESC, "firstname")));
}
@Test
public void parsesWithinCorrectly () {
PartTree tree = new PartTree("findByLocationWithin", User.class);
for (Part part : tree.getParts()) {
assertThat(part.getType(), is(Type.WITHIN));
assertThat(part.getProperty(), is(new Property("location", User.class)));
}
}
@Test
public void parsesNearCorrectly () {
PartTree tree = new PartTree("findByLocationNear", User.class);
for (Part part : tree.getParts()) {
assertThat(part.getType(), is(Type.NEAR));
assertThat(part.getProperty(), is(new Property("location", User.class)));
}
}
private void assertPart(PartTree tree, Part[]... parts) {
@@ -151,5 +170,6 @@ public class PartTreeUnitTests {
String firstname;
String lastname;
double[] location;
}
}