From 0719616a2813d65a8932a82626bc75fc83248455 Mon Sep 17 00:00:00 2001 From: Michael Hunger Date: Sat, 12 Feb 2011 01:39:56 +0100 Subject: [PATCH] generified methods for both aspects --- .../neo4j/support/node/Neo4jNodeBacking.aj | 27 +++---------------- .../relationship/Neo4jRelationshipBacking.aj | 4 +-- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/support/node/Neo4jNodeBacking.aj b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/support/node/Neo4jNodeBacking.aj index ab637b903..46c4f22ac 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/support/node/Neo4jNodeBacking.aj +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/support/node/Neo4jNodeBacking.aj @@ -134,9 +134,7 @@ public aspect Neo4jNodeBacking { // extends AbstractTypeAnnotatingMixinFields targetType) { -// return Neo4jNodeBacking.aspectOf().graphDatabaseContext.projectTo(this, targetType); -// } + public T NodeBacked.projectTo(Class targetType) { return (T)Neo4jNodeBacking.aspectOf().graphDatabaseContext.projectTo( this, targetType); } @@ -166,18 +164,13 @@ public aspect Neo4jNodeBacking { // extends AbstractTypeAnnotatingMixinFields Iterable NodeBacked.findAllByTraversal(final Class targetType, TraversalDescription traversalDescription) { -// if (!hasUnderlyingNode()) throw new IllegalStateException("No node attached to " + this); -// final Traverser traverser = traversalDescription.traverse(this.getUnderlyingState()); -// return new NodeBackedNodeIterableWrapper(traverser, targetType, Neo4jNodeBacking.aspectOf().graphDatabaseContext); -// } - - public Iterable NodeBacked.findAllByTraversal(final Class targetType, TraversalDescription traversalDescription) { + public Iterable NodeBacked.findAllByTraversal(final Class targetType, TraversalDescription traversalDescription) { if (!hasUnderlyingNode()) throw new IllegalStateException("No node attached to " + this); final Traverser traverser = traversalDescription.traverse(this.getUnderlyingState()); - return (Iterable)new NodeBackedNodeIterableWrapper(traverser, targetType, Neo4jNodeBacking.aspectOf().graphDatabaseContext); + return new NodeBackedNodeIterableWrapper(traverser, targetType, Neo4jNodeBacking.aspectOf().graphDatabaseContext); } + // public Iterable NodeBacked.traverse(TraversalDescription traversalDescription) { // final Class target = this.getClass(); // return this.traverse(target,traversalDescription); @@ -195,10 +188,6 @@ public aspect Neo4jNodeBacking { // extends AbstractTypeAnnotatingMixinFields relationshipClass, String relationshipType) { -// Relationship rel = this.getUnderlyingState().createRelationshipTo(target.getUnderlyingState(), DynamicRelationshipType.withName(relationshipType)); -// return Neo4jNodeBacking.aspectOf().graphDatabaseContext.createEntityFromState(rel, relationshipClass); -// } /** * removes the entity using @{link GraphDatabaseContext.removeNodeEntity} @@ -239,14 +228,6 @@ public aspect Neo4jNodeBacking { // extends AbstractTypeAnnotatingMixinFields relationshipClass, String type) { -// Node myNode=this.getUnderlyingState(); -// Node otherNode=node.getUnderlyingState(); -// for (Relationship rel : this.getUnderlyingState().getRelationships(DynamicRelationshipType.withName(type))) { -// if (rel.getOtherNode(myNode).equals(otherNode)) return Neo4jNodeBacking.aspectOf().graphDatabaseContext.createEntityFromState(rel, relationshipClass); -// } -// return null; -// } /** * @param obj diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/support/relationship/Neo4jRelationshipBacking.aj b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/support/relationship/Neo4jRelationshipBacking.aj index 68cd08375..e3fdc77b5 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/support/relationship/Neo4jRelationshipBacking.aj +++ b/spring-data-neo4j/src/main/java/org/springframework/data/graph/neo4j/support/relationship/Neo4jRelationshipBacking.aj @@ -125,8 +125,8 @@ public aspect Neo4jRelationshipBacking { Neo4jRelationshipBacking.aspectOf().graphDatabaseContext.removeRelationshipEntity(this); } - public RelationshipBacked RelationshipBacked.projectTo(Class targetType) { - return Neo4jRelationshipBacking.aspectOf().graphDatabaseContext.projectTo(this, targetType); + public R RelationshipBacked.projectTo(Class targetType) { + return (R)Neo4jRelationshipBacking.aspectOf().graphDatabaseContext.projectTo(this, targetType); } Object around(RelationshipBacked entity): entityFieldGet(entity) {