diff --git a/pom.xml b/pom.xml index e5e5b77c4..54ab8f27a 100644 --- a/pom.xml +++ b/pom.xml @@ -56,8 +56,8 @@ neo22 - 2.2.2 - 0.14-neo4j-2.2.0 + 2.2.3 + 0.14-neo4j-2.2.3 diff --git a/spring-data-neo4j-cross-store/pom.xml b/spring-data-neo4j-cross-store/pom.xml index 638cd98f9..eb7154340 100644 --- a/spring-data-neo4j-cross-store/pom.xml +++ b/spring-data-neo4j-cross-store/pom.xml @@ -50,12 +50,6 @@ spring-data-neo4j-aspects 3.4.0.BUILD-SNAPSHOT - - - org.springframework.data - spring-data-neo4j-tx - 3.4.0.BUILD-SNAPSHOT - org.springframework.data spring-data-neo4j diff --git a/spring-data-neo4j-examples/cineasts/pom.xml b/spring-data-neo4j-examples/cineasts/pom.xml index e6c06e245..b113f04b2 100644 --- a/spring-data-neo4j-examples/cineasts/pom.xml +++ b/spring-data-neo4j-examples/cineasts/pom.xml @@ -4,17 +4,17 @@ org.neo4j.examples cineasts - 3.2.1.RELEASE + 3.3.2.BUILD-SNAPSHOT war Cineasts.net UTF-8 - 4.0.7.RELEASE + 4.0.9.RELEASE 1.7.10 ${project.version} - 2.1.5 + 2.1.7 @@ -32,6 +32,21 @@ + + neo22 + + 2.2.3 + + + + org.neo4j + neo4j-io + ${neo4j.version} + test-jar + test + + + rest @@ -224,6 +239,12 @@ test + + org.neo4j + neo4j + ${neo4j.version} + + junit junit diff --git a/spring-data-neo4j-rest/src/main/java/org/neo4j/graphdb/Result.java b/spring-data-neo4j-rest/src/main/java/org/neo4j/graphdb/Result.java new file mode 100644 index 000000000..fdaf65992 --- /dev/null +++ b/spring-data-neo4j-rest/src/main/java/org/neo4j/graphdb/Result.java @@ -0,0 +1,79 @@ +package org.neo4j.graphdb; + +import java.io.PrintWriter; +import java.util.List; +import java.util.Map; + +public interface Result extends ResourceIterator> +{ + /** + * The exact names used to represent each column in the result set. + * + * @return List of the column names. + */ + List columns(); + + /** + * Returns an iterator with the result objects from a single column of the result set. This method is best used for + * single column results. + * + *

To ensure that any resources, including transactions bound to it, are properly closed, the iterator must + * either be fully exhausted, or the {@link ResourceIterator#close() close()} method must be + * called.

+ * + * @param name exact name of the column, as it appeared in the original query + * @param desired type cast for the result objects + * @return an iterator of the result objects, possibly empty + * @throws ClassCastException when the result object can not be cast to the requested type + * @throws NotFoundException when the column name does not appear in the original query + */ + ResourceIterator columnAs(String name); + + /** + * Denotes there being more rows available in this result. These rows must either be consumed, by invoking + * {@link #next()}, or the result has to be {@link #close() closed}. + * + * @return {@code true} if there is more rows available in this result, {@code false} otherwise. + */ + boolean hasNext(); + + /** + * Returns the next row in this result. + * + * @return the next row in this result. + */ + Map next(); + + /** + * Closes the result, freeing up any resources held by the result. + * + * This is an idempotent operation, invoking it multiple times has the same effect as invoking it exactly once. + * It is thus safe (and even encouraged, for style and simplicity) to invoke this method even after consuming all + * rows in the result through the {@link #next() next-method}. + */ + void close(); + + /** + * Provides a textual representation of the query result. + *

+ * The execution result represented by this object will be consumed in its entirety after this method is called. + * Calling any of the other iterating methods on it should not be expected to return any results. + *

+ * + * @return the execution result formatted as a string + */ + String resultAsString(); + + /** + * Provides a textual representation of the query result to the provided {@link PrintWriter}. + *

+ * The execution result represented by this object will be consumed in its entirety after this method is called. + * Calling any of the other iterating methods on it should not be expected to return any results. + *

+ * @param writer the {@link PrintWriter} to receive the textual representation of the query result. + */ + void writeAsStringTo(PrintWriter writer); + + /** Removing rows from the result is not supported. */ + void remove(); +} diff --git a/spring-data-neo4j-rest/src/main/java/org/neo4j/rest/graphdb/AbstractRemoteDatabase.java b/spring-data-neo4j-rest/src/main/java/org/neo4j/rest/graphdb/AbstractRemoteDatabase.java index c671ac4f7..05274624d 100644 --- a/spring-data-neo4j-rest/src/main/java/org/neo4j/rest/graphdb/AbstractRemoteDatabase.java +++ b/spring-data-neo4j-rest/src/main/java/org/neo4j/rest/graphdb/AbstractRemoteDatabase.java @@ -20,10 +20,13 @@ package org.neo4j.rest.graphdb; import org.neo4j.graphdb.GraphDatabaseService; +import org.neo4j.graphdb.Result; import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.event.KernelEventHandler; import org.neo4j.graphdb.event.TransactionEventHandler; import org.neo4j.rest.graphdb.transaction.NullTransaction; +import java.util.Map; + abstract class AbstractRemoteDatabase implements GraphDatabaseService { public Transaction beginTx() { @@ -46,6 +49,9 @@ abstract class AbstractRemoteDatabase implements GraphDatabaseService { throw new UnsupportedOperationException(); } + public abstract Result execute(String s, Map map); + public abstract Result execute(String s); + @Override public void shutdown() { } diff --git a/spring-data-neo4j-rest/src/main/java/org/neo4j/rest/graphdb/CypherRestGraphDatabase.java b/spring-data-neo4j-rest/src/main/java/org/neo4j/rest/graphdb/CypherRestGraphDatabase.java index 41d3e40fc..74d050519 100644 --- a/spring-data-neo4j-rest/src/main/java/org/neo4j/rest/graphdb/CypherRestGraphDatabase.java +++ b/spring-data-neo4j-rest/src/main/java/org/neo4j/rest/graphdb/CypherRestGraphDatabase.java @@ -23,6 +23,7 @@ package org.neo4j.rest.graphdb; import org.neo4j.graphdb.*; import org.neo4j.graphdb.schema.Schema; import org.neo4j.graphdb.traversal.BidirectionalTraversalDescription; +import org.neo4j.helpers.collection.IteratorUtil; import org.neo4j.rest.graphdb.entity.RestNode; import org.neo4j.rest.graphdb.index.RestIndexManager; import org.neo4j.rest.graphdb.query.RestCypherTransactionManager; @@ -142,6 +143,31 @@ public class CypherRestGraphDatabase extends AbstractRemoteDatabase implements R }; } + public ResourceIterator findNodes(Label label, String property, Object value) { + return findNodesByLabelAndProperty(label, property,value).iterator(); + } + + public Node findNode(Label label, String property, Object value) { + return IteratorUtil.single(findNodes(label,property,value)); + } + + public ResourceIterator findNodes(Label label) { + Iterable nodes = restAPI.getNodesByLabel(label.name()); + return new ResourceIterableWrapper(nodes) { + protected Node underlyingObjectToObject(RestNode node) { + return node; + } + }.iterator(); + } + + public Result execute(String s) { + throw new UnsupportedOperationException(); + } + + public Result execute(String s, Map map) { + throw new UnsupportedOperationException(); + } + @Override public Schema schema() { throw new UnsupportedOperationException(); @@ -160,25 +186,5 @@ public class CypherRestGraphDatabase extends AbstractRemoteDatabase implements R public Collection getAllLabelNames() { return restAPI.getAllLabelNames(); } - - public ResourceIterator findNodes(Label label, String s, Object o) { - return null; - } - - public Node findNode(Label label, String s, Object o) { - return null; - } - - public ResourceIterator findNodes(Label label) { - return null; - } - - public Result execute(String s) { - return null; - } - - public Result execute(String s, Map map) { - return null; - } } diff --git a/spring-data-neo4j-rest/src/main/java/org/neo4j/rest/graphdb/RestGraphDatabase.java b/spring-data-neo4j-rest/src/main/java/org/neo4j/rest/graphdb/RestGraphDatabase.java index 3714c87c1..f9358d2dd 100644 --- a/spring-data-neo4j-rest/src/main/java/org/neo4j/rest/graphdb/RestGraphDatabase.java +++ b/spring-data-neo4j-rest/src/main/java/org/neo4j/rest/graphdb/RestGraphDatabase.java @@ -139,6 +139,31 @@ public class RestGraphDatabase extends AbstractRemoteDatabase implements RestAPI }; } + public ResourceIterator findNodes(Label label, String property, Object value) { + return findNodesByLabelAndProperty(label, property,value).iterator(); + } + + public Node findNode(Label label, String property, Object value) { + return IteratorUtil.single(findNodes(label,property,value)); + } + + public ResourceIterator findNodes(Label label) { + Iterable nodes = restAPI.getNodesByLabel(label.name()); + return new ResourceIterableWrapper(nodes) { + protected Node underlyingObjectToObject(RestNode node) { + return node; + } + }.iterator(); + } + + public Result execute(String s) { + throw new UnsupportedOperationException(); + } + + public Result execute(String s, Map map) { + throw new UnsupportedOperationException(); + } + @Override public Schema schema() { throw new UnsupportedOperationException(); @@ -158,25 +183,5 @@ public class RestGraphDatabase extends AbstractRemoteDatabase implements RestAPI return restAPI.getAllLabelNames(); } - public ResourceIterator findNodes(Label label, String property, Object value) { - return findNodesByLabelAndProperty(label,property,value).iterator(); - } - - public Node findNode(Label label, String property, Object value) { - return IteratorUtil.singleOrNull(findNodesByLabelAndProperty(label,property,value)); - } - - public ResourceIterator findNodes(Label label) { - return null; - } - - public Result execute(String statement) { - return execute(statement,null); - } - - public Result execute(String statement, Map params) { -// return cypherQueryEngine.query(statement,params); - return null; - } } diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/config/JtaTransactionManagerFactoryBean.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/config/JtaTransactionManagerFactoryBean.java index bfc4f9bb9..4831124a0 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/config/JtaTransactionManagerFactoryBean.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/config/JtaTransactionManagerFactoryBean.java @@ -77,7 +77,7 @@ public class JtaTransactionManagerFactoryBean implements FactoryBean