Merge branch 'master' into new

This commit is contained in:
Michael Hunger
2011-10-10 10:38:09 +02:00
4 changed files with 98 additions and 53 deletions

View File

@@ -492,11 +492,56 @@
</excludes>
</testResource>
</testResources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.0.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<version>1.9.0</version>
</plugin>
<plugin>
<groupId>com.springsource.bundlor</groupId>
<artifactId>com.springsource.bundlor.maven</artifactId>
<version>1.0.0.RELEASE</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
@@ -508,7 +553,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<!--debugForkedProcess>true</debugForkedProcess-->
<forkMode>once</forkMode>
@@ -527,7 +571,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<useDefaultManifestFile>true</useDefaultManifestFile>
</configuration>
@@ -535,7 +578,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<id>attach-sources</id>
@@ -549,7 +591,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>javadoc</id>
@@ -563,7 +604,6 @@
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<version>1.9.0</version>
<executions>
<execution>
<id>check-licenses</id>
@@ -609,7 +649,6 @@
<plugin>
<groupId>com.springsource.bundlor</groupId>
<artifactId>com.springsource.bundlor.maven</artifactId>
<version>1.0.0.RELEASE</version>
<configuration>
<failOnWarnings>true</failOnWarnings>
</configuration>

View File

@@ -83,6 +83,11 @@
<version>${neo4j.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>

View File

@@ -16,10 +16,10 @@
package org.springframework.data.neo4j.repository.query;
import org.springframework.data.mapping.PropertyPath;
import org.springframework.data.neo4j.mapping.Neo4jMappingContext;
import org.springframework.data.neo4j.mapping.Neo4jPersistentProperty;
import org.springframework.data.neo4j.mapping.RelationshipInfo;
import org.springframework.data.repository.query.parser.Property;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -33,18 +33,18 @@ class MatchClause {
private final Iterable<Neo4jPersistentProperty> properties;
/**
* Creates a new {@link MatchClause} using the given {@link org.springframework.data.neo4j.mapping.Neo4jMappingContext} and {@link Property}.
* Creates a new {@link MatchClause} using the given
* {@link org.springframework.data.neo4j.mapping.Neo4jMappingContext} and {@link PropertyPath}.
*
* @param context must not be {@literal null}.
* @param property must not be {@literal null}.
*/
public MatchClause(Neo4jMappingContext context, Property property) {
public MatchClause(Neo4jMappingContext context, PropertyPath property) {
Assert.notNull(context);
Assert.notNull(property);
Class<?> rootType = property.getOwningType().getType();
this.properties = context.getPersistentPropertyPath(rootType, property.toDotPath());
this.properties = context.getPersistentPropertyPath(property);
}
/*
@@ -65,9 +65,10 @@ class MatchClause {
RelationshipInfo info = property.getRelationshipInfo();
Class<?> ownerType = property.getOwner().getType();
intermediate = intermediate == null ? asVariableReference(StringUtils.uncapitalize(ownerType.getSimpleName()))
: intermediate;
intermediate = String.format(getPattern(info), intermediate, info.getType(), asVariableReference(property.getName()));
intermediate = intermediate == null ? asVariableReference(StringUtils.uncapitalize(ownerType
.getSimpleName())) : intermediate;
intermediate = String.format(getPattern(info), intermediate, info.getType(),
asVariableReference(property.getName()));
}
return intermediate.toString();

View File

@@ -25,11 +25,11 @@ import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.neo4j.graphdb.Direction;
import org.springframework.data.mapping.PropertyPath;
import org.springframework.data.neo4j.annotation.Indexed;
import org.springframework.data.neo4j.annotation.NodeEntity;
import org.springframework.data.neo4j.annotation.RelatedTo;
import org.springframework.data.neo4j.mapping.Neo4jMappingContext;
import org.springframework.data.repository.query.parser.Property;
/**
*
@@ -37,52 +37,52 @@ import org.springframework.data.repository.query.parser.Property;
*/
public class MatchClauseUnitTest {
Neo4jMappingContext context;
Neo4jMappingContext context;
@Before
public void setUp() {
context = new Neo4jMappingContext();
context.setInitialEntitySet(Collections.singleton(Person.class));
context.afterPropertiesSet();
}
@Before
public void setUp() {
context = new Neo4jMappingContext();
context.setInitialEntitySet(Collections.singleton(Person.class));
context.afterPropertiesSet();
}
@Test
public void buildsMatchExpressionForSimpleTraversalCorrectly() {
@Test
public void buildsMatchExpressionForSimpleTraversalCorrectly() {
MatchClause clause = new MatchClause(context, Property.from("group", Person.class));
assertThat(clause.toString(), is("(person)<-[:members]-(group)"));
}
MatchClause clause = new MatchClause(context, PropertyPath.from("group", Person.class));
assertThat(clause.toString(), is("(person)<-[:members]-(group)"));
}
@Test
public void createsMatchClassForDeepTraversal() {
@Test
public void createsMatchClassForDeepTraversal() {
MatchClause clause = new MatchClause(context, Property.from("group.members.age", Person.class));
assertThat(clause.toString(), is("(person)<-[:members]-(group)-[:members]->(members)"));
}
MatchClause clause = new MatchClause(context, PropertyPath.from("group.members.age", Person.class));
assertThat(clause.toString(), is("(person)<-[:members]-(group)-[:members]->(members)"));
}
@Test
public void stopsAtNonRelationShipProperty() {
@Test
public void stopsAtNonRelationShipPropertyPath() {
MatchClause clause = new MatchClause(context, Property.from("group.name", Person.class));
assertThat(clause.toString(), is("(person)<-[:members]-(group)"));
}
@NodeEntity
class Person {
private int age;
@RelatedTo(type = "members", direction = Direction.INCOMING)
private Group group;
}
MatchClause clause = new MatchClause(context, PropertyPath.from("group.name", Person.class));
assertThat(clause.toString(), is("(person)<-[:members]-(group)"));
}
@NodeEntity
class Group {
class Person {
@Indexed
private String name;
private int age;
@RelatedTo(type = "members", direction = Direction.OUTGOING)
private Set<Person> members;
}
@RelatedTo(type = "members", direction = Direction.INCOMING)
private Group group;
}
@NodeEntity
class Group {
@Indexed
private String name;
@RelatedTo(type = "members", direction = Direction.OUTGOING)
private Set<Person> members;
}
}