diff --git a/.classpath b/.classpath index 87334e81b..320153234 100644 --- a/.classpath +++ b/.classpath @@ -1,38 +1,35 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project index a9dc0747e..3c4dbb279 100644 --- a/.project +++ b/.project @@ -9,9 +9,36 @@ org.maven.ide.eclipse.maven2Builder + + org.eclipse.ajdt.core.ajbuilder + + + org.eclipse.wst.common.project.facet.core.builder + + + org.eclipse.wst.validation.validationbuilder + + + org.eclipse.ajdt.core.ajbuilder + + + aspectPath + org.springframework.aspects + + + + + org.springframework.ide.eclipse.core.springbuilder + org.eclipse.jdt.core.javanature org.maven.ide.eclipse.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.ajdt.ui.ajnature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jem.workbench.JavaEMFNature + com.springsource.sts.roo.core.nature + org.springframework.ide.eclipse.core.springnature \ No newline at end of file diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 7f90a1fbf..51e37235d 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,13 +1,13 @@ -#Fri Jul 23 13:12:34 EDT 2010 +#Tue Jul 27 15:30:59 EDT 2010 org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.debug.lineNumber=generate eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000..caf0f5ae0 --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000..be3b0394b --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.springBeans b/.springBeans new file mode 100644 index 000000000..4dff64763 --- /dev/null +++ b/.springBeans @@ -0,0 +1,13 @@ + + + 1 + + + + + + + + + + diff --git a/pom.xml b/pom.xml index be2cb3dbb..d4db32ec5 100644 --- a/pom.xml +++ b/pom.xml @@ -11,6 +11,7 @@ UTF-8 3.0.0.RELEASE + 1.6.9 1.6.0 @@ -118,6 +119,11 @@ spring-tx ${spring.version} + + org.aspectj + aspectjrt + ${aspectj.version} + org.springframework.data @@ -131,10 +137,111 @@ org.apache.maven.plugins maven-compiler-plugin - 2.0.2 + 2.1 - 1.5 - 1.5 + 1.6 + 1.6 + + + + org.codehaus.mojo + aspectj-maven-plugin + 1.0 + + + + org.aspectj + aspectjrt + ${aspectj.version} + + + org.aspectj + aspectjtools + ${aspectj.version} + + + + + + compile + test-compile + + + + + true + + + org.springframework + spring-aspects + + + 1.6 + 1.6 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.4.3 + + org.junit:com.springsource.org.junit + + **/*_Roo_* + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.1 + + + + jar-with-dependencies + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.4 + + + + org.apache.maven.plugins + maven-eclipse-plugin + 2.7 + + true + false + 2.0 + + + org.eclipse.ajdt.core.ajbuilder + + org.springframework.aspects + + + + org.springframework.ide.eclipse.core.springbuilder + + + + org.eclipse.ajdt.ui.ajnature + com.springsource.sts.roo.core.nature + org.springframework.ide.eclipse.core.springnature + + + + + org.apache.maven.plugins + maven-idea-plugin + 2.2 + + true + true diff --git a/src/main/java/org/springframework/datastore/graph/GraphUtils.java b/src/main/java/org/springframework/datastore/graph/GraphUtils.java deleted file mode 100644 index b8dd4a59c..000000000 --- a/src/main/java/org/springframework/datastore/graph/GraphUtils.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.springframework.datastore.graph; - -public class GraphUtils { - -} diff --git a/src/main/java/org/springframework/datastore/neo4j/Neo4jConnectionFactory.java b/src/main/java/org/springframework/datastore/graph/neo4j/Neo4jConnectionFactory.java similarity index 97% rename from src/main/java/org/springframework/datastore/neo4j/Neo4jConnectionFactory.java rename to src/main/java/org/springframework/datastore/graph/neo4j/Neo4jConnectionFactory.java index b00c8dfdc..d37dc67fc 100644 --- a/src/main/java/org/springframework/datastore/neo4j/Neo4jConnectionFactory.java +++ b/src/main/java/org/springframework/datastore/graph/neo4j/Neo4jConnectionFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.datastore.neo4j; +package org.springframework.datastore.graph.neo4j; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/src/main/java/org/springframework/datastore/neo4j/Neo4jDatastoreTemplate.java b/src/main/java/org/springframework/datastore/graph/neo4j/Neo4jDatastoreTemplate.java similarity index 96% rename from src/main/java/org/springframework/datastore/neo4j/Neo4jDatastoreTemplate.java rename to src/main/java/org/springframework/datastore/graph/neo4j/Neo4jDatastoreTemplate.java index 491eeb964..2bec5b5f4 100644 --- a/src/main/java/org/springframework/datastore/neo4j/Neo4jDatastoreTemplate.java +++ b/src/main/java/org/springframework/datastore/graph/neo4j/Neo4jDatastoreTemplate.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.datastore.neo4j; +package org.springframework.datastore.graph.neo4j; import java.util.List; diff --git a/src/main/java/org/springframework/persistence/graph/Direction.java b/src/main/java/org/springframework/persistence/graph/Direction.java new file mode 100644 index 000000000..6d471955a --- /dev/null +++ b/src/main/java/org/springframework/persistence/graph/Direction.java @@ -0,0 +1,16 @@ +package org.springframework.persistence.graph; + +public enum Direction { + + OUTGOING(org.neo4j.graphdb.Direction.OUTGOING), INCOMING(org.neo4j.graphdb.Direction.INCOMING), BOTH(org.neo4j.graphdb.Direction.BOTH); + + private org.neo4j.graphdb.Direction neo4jDirection; + private Direction( org.neo4j.graphdb.Direction neo4jDirection ) { + this.neo4jDirection = neo4jDirection; + } + + public org.neo4j.graphdb.Direction toNeo4jDir() { + return this.neo4jDirection; + } + +} diff --git a/src/main/java/org/springframework/persistence/graph/GraphEntity.java b/src/main/java/org/springframework/persistence/graph/GraphEntity.java new file mode 100644 index 000000000..70d24538e --- /dev/null +++ b/src/main/java/org/springframework/persistence/graph/GraphEntity.java @@ -0,0 +1,18 @@ +package org.springframework.persistence.graph; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation to denote an object that should be transparently persisted + * using Neo4j. + * @author Rod Johnson + * + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface GraphEntity { + +} diff --git a/src/main/java/org/springframework/persistence/graph/Relationship.java b/src/main/java/org/springframework/persistence/graph/Relationship.java new file mode 100644 index 000000000..7f0c119a5 --- /dev/null +++ b/src/main/java/org/springframework/persistence/graph/Relationship.java @@ -0,0 +1,16 @@ +package org.springframework.persistence.graph; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface Relationship { + + String type(); + + Direction direction(); + +} diff --git a/src/main/java/org/springframework/persistence/graph/neo4j/Neo4jHelper.java b/src/main/java/org/springframework/persistence/graph/neo4j/Neo4jHelper.java new file mode 100644 index 000000000..e2b4faa12 --- /dev/null +++ b/src/main/java/org/springframework/persistence/graph/neo4j/Neo4jHelper.java @@ -0,0 +1,30 @@ +package org.springframework.persistence.graph.neo4j; + +import org.neo4j.graphdb.DynamicRelationshipType; +import org.neo4j.graphdb.GraphDatabaseService; +import org.neo4j.graphdb.Node; +import org.neo4j.graphdb.RelationshipType; +import org.neo4j.util.GraphDatabaseUtil; + +public abstract class Neo4jHelper { + + /** + * Relationship from a node representing a GraphEntity to the reference node for that class. + */ + public final static RelationshipType INSTANCE_OF_RELATIONSHIP_TYPE = DynamicRelationshipType.withName("INSTANCE_OF"); + + public final static String SUBREFERENCE_NODE_COUNTER_KEY = "count"; + + public static Node findSubreferenceNode(Class entityClass, GraphDatabaseService gds) { + RelationshipType subRefRelType = DynamicRelationshipType.withName("SUBREF_" + entityClass.getName()); + return new GraphDatabaseUtil(gds).getOrCreateSubReferenceNode(subRefRelType); + } + +// public static long count(Class entityClass, GraphDatabaseService gds) { +// Node subrefNode = findSubreferenceNode(Person.class, gds); +// // If the subref node is new, there are 0 instances of this entity class +// int count = ((Integer) subrefNode.getProperty(SUBREFERENCE_NODE_COUNTER_KEY, 0)); +// return count; +// } + +} diff --git a/src/main/java/org/springframework/persistence/graph/neo4j/NodeBacked.java b/src/main/java/org/springframework/persistence/graph/neo4j/NodeBacked.java new file mode 100644 index 000000000..1dba34744 --- /dev/null +++ b/src/main/java/org/springframework/persistence/graph/neo4j/NodeBacked.java @@ -0,0 +1,14 @@ +package org.springframework.persistence.graph.neo4j; + +import org.neo4j.graphdb.Node; + +/** + * Interface introduced to objects annotated with GraphEntity + * annotation, to hold underlying Neo4j Node state. + * @author Rod Johnson + */ +public interface NodeBacked { + + Node getUnderlyingNode(); + +}