From 3b4f50607ef695db2af525d2751630dfda80cff5 Mon Sep 17 00:00:00 2001 From: Andreas Kollegger Date: Fri, 7 Oct 2011 08:42:25 -0700 Subject: [PATCH 1/4] added a pluginManagement section to the parent pom, to manage versions of plugins in each module --- spring-data-neo4j-parent/pom.xml | 61 ++++++++++++++++++++++++++------ spring-data-neo4j/pom.xml | 1 - 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/spring-data-neo4j-parent/pom.xml b/spring-data-neo4j-parent/pom.xml index 1a91d9aae..ad14990e7 100644 --- a/spring-data-neo4j-parent/pom.xml +++ b/spring-data-neo4j-parent/pom.xml @@ -125,10 +125,10 @@ 1.6.1 3.0.5.RELEASE 1.2.0.BUILD-SNAPSHOT - 1.4.1 - 1.6.12.M1 - 0.8 - 1.1 + 1.4.1 + 1.6.12.M1 + 0.8 + 1.1 @@ -487,11 +487,56 @@ + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.6 + + + org.apache.maven.plugins + maven-jar-plugin + 2.3.1 + + + org.apache.maven.plugins + maven-source-plugin + 2.0.4 + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + + com.mycila.maven-license-plugin + maven-license-plugin + 1.9.0 + + + com.springsource.bundlor + com.springsource.bundlor.maven + 1.0.0.RELEASE + + + org.codehaus.mojo + aspectj-maven-plugin + 1.2 + + + + org.apache.maven.plugins maven-compiler-plugin - 2.3.2 1.6 1.6 @@ -503,7 +548,6 @@ org.apache.maven.plugins maven-surefire-plugin - 2.6 once @@ -522,7 +566,6 @@ org.apache.maven.plugins maven-jar-plugin - 2.3.1 true @@ -530,7 +573,6 @@ org.apache.maven.plugins maven-source-plugin - 2.0.4 attach-sources @@ -544,7 +586,6 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.8 javadoc @@ -558,7 +599,6 @@ com.mycila.maven-license-plugin maven-license-plugin - 1.9.0 check-licenses @@ -604,7 +644,6 @@ --> com.springsource.bundlor com.springsource.bundlor.maven - 1.0.0.RELEASE true diff --git a/spring-data-neo4j/pom.xml b/spring-data-neo4j/pom.xml index a015e1900..cf9839e6f 100644 --- a/spring-data-neo4j/pom.xml +++ b/spring-data-neo4j/pom.xml @@ -213,7 +213,6 @@ org.codehaus.mojo aspectj-maven-plugin - 1.2 org.aspectj From bdf59ea18a99dd401c0b912ee474ad2896e61779 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Fri, 7 Oct 2011 20:58:30 +0200 Subject: [PATCH 2/4] DATACMNS-84 - Adapted refactorings in SD Commons. --- .../neo4j/repository/query/MatchClause.java | 17 +++-- .../repository/query/MatchClauseUnitTest.java | 76 +++++++++---------- 2 files changed, 47 insertions(+), 46 deletions(-) diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/MatchClause.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/MatchClause.java index 201121d18..770c96ccd 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/MatchClause.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/repository/query/MatchClause.java @@ -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 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(); diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/MatchClauseUnitTest.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/MatchClauseUnitTest.java index 0f495c763..184586818 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/MatchClauseUnitTest.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/query/MatchClauseUnitTest.java @@ -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 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 members; + } } From 1e9c845abbb4265ae5b451c2a7c90b8fd39aeb69 Mon Sep 17 00:00:00 2001 From: Michael Hunger Date: Fri, 7 Oct 2011 21:14:30 +0200 Subject: [PATCH 3/4] fixed slf4j recursion by excluding dependency from neo4j-server --- spring-data-neo4j-rest/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spring-data-neo4j-rest/pom.xml b/spring-data-neo4j-rest/pom.xml index 9039c7203..14a8b7d96 100644 --- a/spring-data-neo4j-rest/pom.xml +++ b/spring-data-neo4j-rest/pom.xml @@ -83,6 +83,11 @@ ${neo4j.version} test + + org.slf4j + log4j-over-slf4j + + org.neo4j neo4j From a4f0e556aae0f9d19ab5e6f31c99df0c492ddb72 Mon Sep 17 00:00:00 2001 From: Michael Hunger Date: Sat, 8 Oct 2011 01:29:17 +0300 Subject: [PATCH 4/4] fixing root directory detection --- .../test/DocumentingTestBase.java | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/spring-data-neo4j/src/test/java/org/springframework/test/DocumentingTestBase.java b/spring-data-neo4j/src/test/java/org/springframework/test/DocumentingTestBase.java index a346a607c..840a897ef 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/test/DocumentingTestBase.java +++ b/spring-data-neo4j/src/test/java/org/springframework/test/DocumentingTestBase.java @@ -24,6 +24,8 @@ import static org.junit.Assert.fail; public abstract class DocumentingTestBase { + private static final String DOCBOOK_DIR = "src/docbkx"; + private static final String SRC_TEST_JAVA = "src/test/java"; protected String title; protected String snippetTitle; protected String snippet; @@ -31,7 +33,7 @@ public abstract class DocumentingTestBase { @After public void outputDocs() throws IOException { - final File directory = new File("src/docbkx/snippets"); + final File directory = new File(docbookDirectory(),"snippets"); if (directory.isFile() || !directory.exists() && !directory.mkdirs()) throw new RuntimeException("Could not create directory "+directory); final String name = getClass().getSimpleName(); final PrintWriter writer = new PrintWriter(new FileWriter(getSnippetFileName(directory,name))); @@ -43,6 +45,10 @@ public abstract class DocumentingTestBase { writer.close(); } + private File docbookDirectory() { + return new File(determineRoot(),DOCBOOK_DIR); + } + protected File getSnippetFileName(File directory, String name) { return new File(directory, name + ".xml"); } @@ -83,7 +89,7 @@ public abstract class DocumentingTestBase { StringBuilder snippetText = new StringBuilder(); boolean inSnippet = false; while ((line = reader.readLine()) != null) { - if (line.matches(".*//.+SNIPPET\\s+"+snippet+".*")) { + if (line.matches(".*//.+SNIPPET\\s+.*\\b"+snippet+"\\b.*")) { inSnippet = !inSnippet; continue; } @@ -100,28 +106,27 @@ public abstract class DocumentingTestBase { protected File getJavaFile() { final String javaFileName = getClass().getName().replaceAll("\\.", File.separator) + ".java"; - final File javaFile = new File(directoryPrefix() + "src/test/java", javaFileName); + final File javaFile = new File(testSourceDirectory(), javaFileName); if (!javaFile.exists()) fail("Snippet File " + javaFile + " does not exist "); return javaFile; } - private String directoryPrefix() { - final boolean isAlreadyInDirectory = moduleWithParent().equals(currentDirectoryWithParent()); - return isAlreadyInDirectory ? "" : module()+"/"; + private File testSourceDirectory() { + return new File(new File(determineRoot(),module()),SRC_TEST_JAVA); } - - private String moduleWithParent() { - return ("spring-data-neo4j/"+module()); - } - - private String currentDirectoryWithParent() { - final File currentDir = new File(".").getAbsoluteFile(); - System.err.println("pwd "+currentDir); - return currentDir.getParentFile().getParentFile().getName() + "/" + currentDir.getParentFile().getName(); + private File currentDirectory() { + return new File(".").getAbsoluteFile().getParentFile(); } protected String module() { return "spring-data-neo4j"; } + protected File determineRoot() { + File currentDirectory = currentDirectory(); + if (new File(currentDirectory,DOCBOOK_DIR).exists()) return currentDirectory; + currentDirectory = currentDirectory.getParentFile(); + if (new File(currentDirectory,DOCBOOK_DIR).exists()) return currentDirectory; + throw new IllegalStateException("Can't determine root directory, started at "+currentDirectory()); + } }