DATAGRAPH-713 - Add Support for Neo4j 2.2.3.
This commit is contained in:
4
pom.xml
4
pom.xml
@@ -56,8 +56,8 @@
|
||||
<profile>
|
||||
<id>neo22</id>
|
||||
<properties>
|
||||
<neo4j.version>2.2.2</neo4j.version>
|
||||
<neo4j.spatial.version>0.14-neo4j-2.2.0</neo4j.spatial.version>
|
||||
<neo4j.version>2.2.3</neo4j.version>
|
||||
<neo4j.spatial.version>0.14-neo4j-2.2.3</neo4j.spatial.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -50,12 +50,6 @@
|
||||
<artifactId>spring-data-neo4j-aspects</artifactId>
|
||||
<version>3.4.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-tx</artifactId>
|
||||
<version>3.4.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j</artifactId>
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
|
||||
<groupId>org.neo4j.examples</groupId>
|
||||
<artifactId>cineasts</artifactId>
|
||||
<version>3.2.1.RELEASE</version>
|
||||
<version>3.3.2.BUILD-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<name>Cineasts.net</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.version>4.0.7.RELEASE</spring.version>
|
||||
<spring.version>4.0.9.RELEASE</spring.version>
|
||||
<slf4j.version>1.7.10</slf4j.version>
|
||||
<spring-data-neo4j.version>${project.version}</spring-data-neo4j.version>
|
||||
<neo4j.version>2.1.5</neo4j.version>
|
||||
<neo4j.version>2.1.7</neo4j.version>
|
||||
<jetty-args></jetty-args>
|
||||
</properties>
|
||||
|
||||
@@ -32,6 +32,21 @@
|
||||
</repositories>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>neo22</id>
|
||||
<properties>
|
||||
<neo4j.version>2.2.3</neo4j.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.neo4j</groupId>
|
||||
<artifactId>neo4j-io</artifactId>
|
||||
<version>${neo4j.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>rest</id>
|
||||
<properties>
|
||||
@@ -224,6 +239,12 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.neo4j</groupId>
|
||||
<artifactId>neo4j</artifactId>
|
||||
<version>${neo4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
||||
@@ -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<Map<String, Object>>
|
||||
{
|
||||
/**
|
||||
* The exact names used to represent each column in the result set.
|
||||
*
|
||||
* @return List of the column names.
|
||||
*/
|
||||
List<String> 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.
|
||||
*
|
||||
* <p><b>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.</b></p>
|
||||
*
|
||||
* @param name exact name of the column, as it appeared in the original query
|
||||
* @param <T> 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
|
||||
*/
|
||||
<T> ResourceIterator<T> 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<String, Object> 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.
|
||||
* <p><b>
|
||||
* 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.
|
||||
* </b></p>
|
||||
*
|
||||
* @return the execution result formatted as a string
|
||||
*/
|
||||
String resultAsString();
|
||||
|
||||
/**
|
||||
* Provides a textual representation of the query result to the provided {@link PrintWriter}.
|
||||
* <p><b>
|
||||
* 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.
|
||||
* </b></p>
|
||||
* @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();
|
||||
}
|
||||
@@ -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<String, Object> map);
|
||||
public abstract Result execute(String s);
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
}
|
||||
|
||||
@@ -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<Node> 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<Node> findNodes(Label label) {
|
||||
Iterable<RestNode> nodes = restAPI.getNodesByLabel(label.name());
|
||||
return new ResourceIterableWrapper<Node,RestNode>(nodes) {
|
||||
protected Node underlyingObjectToObject(RestNode node) {
|
||||
return node;
|
||||
}
|
||||
}.iterator();
|
||||
}
|
||||
|
||||
public Result execute(String s) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Result execute(String s, Map<String, Object> map) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Schema schema() {
|
||||
throw new UnsupportedOperationException();
|
||||
@@ -160,25 +186,5 @@ public class CypherRestGraphDatabase extends AbstractRemoteDatabase implements R
|
||||
public Collection<String> getAllLabelNames() {
|
||||
return restAPI.getAllLabelNames();
|
||||
}
|
||||
|
||||
public ResourceIterator<Node> findNodes(Label label, String s, Object o) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Node findNode(Label label, String s, Object o) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ResourceIterator<Node> findNodes(Label label) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Result execute(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Result execute(String s, Map<String, Object> map) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +139,31 @@ public class RestGraphDatabase extends AbstractRemoteDatabase implements RestAPI
|
||||
};
|
||||
}
|
||||
|
||||
public ResourceIterator<Node> 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<Node> findNodes(Label label) {
|
||||
Iterable<RestNode> nodes = restAPI.getNodesByLabel(label.name());
|
||||
return new ResourceIterableWrapper<Node,RestNode>(nodes) {
|
||||
protected Node underlyingObjectToObject(RestNode node) {
|
||||
return node;
|
||||
}
|
||||
}.iterator();
|
||||
}
|
||||
|
||||
public Result execute(String s) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Result execute(String s, Map<String, Object> 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<Node> 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<Node> findNodes(Label label) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Result execute(String statement) {
|
||||
return execute(statement,null);
|
||||
}
|
||||
|
||||
public Result execute(String statement, Map<String, Object> params) {
|
||||
// return cypherQueryEngine.query(statement,params);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public class JtaTransactionManagerFactoryBean implements FactoryBean<JtaTransact
|
||||
} catch (Exception e) {
|
||||
// throw new RuntimeException(e);
|
||||
}
|
||||
return createNullJtaTransactionManager();
|
||||
return createEmbeddedJtaTransactionManager(gds);
|
||||
}
|
||||
|
||||
private JtaTransactionManager createJtaTransactionManager(GraphDatabase gdb) {
|
||||
@@ -98,7 +98,15 @@ public class JtaTransactionManagerFactoryBean implements FactoryBean<JtaTransact
|
||||
|
||||
return new JtaTransactionManager( userTransaction, transactionManager );
|
||||
}
|
||||
/*
|
||||
|
||||
private JtaTransactionManager createEmbeddedJtaTransactionManager(GraphDatabaseService gds)
|
||||
{
|
||||
TransactionManager transactionManager = new Neo4jEmbeddedTransactionManager(gds);
|
||||
UserTransaction userTransaction = new UserTransactionAdapter( transactionManager );
|
||||
|
||||
return new JtaTransactionManager( userTransaction, transactionManager );
|
||||
}
|
||||
|
||||
private JtaTransactionManager createJtaTransactionManager( GraphDatabaseService gds )
|
||||
{
|
||||
TransactionManager transactionManager = createTransactionManagerForOnePointEight( gds );
|
||||
@@ -125,7 +133,6 @@ public class JtaTransactionManagerFactoryBean implements FactoryBean<JtaTransact
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
private boolean classExists(String name) {
|
||||
try {
|
||||
Class.forName(name);
|
||||
|
||||
@@ -64,7 +64,9 @@ public class Neo4jExceptionTranslator implements PersistenceExceptionTranslator
|
||||
throw new ConcurrencyFailureException(e.getMessage(),e);
|
||||
if (exceptionName.equals("org.neo4j.kernel.impl.core.ReadOnlyDbException"))
|
||||
throw new InvalidDataAccessResourceUsageException(e.getMessage(), e);
|
||||
if (exceptionName.equals("org.neo4j.kernel.impl.nioneo.store.StoreFailureException"))
|
||||
if (e.getClass().getName().equals("org.neo4j.index.impl.lucene.QueryNotPossibleException"))
|
||||
throw new ConcurrencyFailureException(e.getMessage(), e);
|
||||
if (e.getClass().getName().equals("org.neo4j.kernel.impl.nioneo.store.StoreFailureException"))
|
||||
throw new DataAccessResourceFailureException(e.getMessage(), e);
|
||||
if (exceptionName.equals("org.neo4j.kernel.impl.persistence.IdGenerationFailedException"))
|
||||
throw new NonTransientDataAccessResourceException(e.getMessage(), e);
|
||||
|
||||
@@ -42,6 +42,8 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution
|
||||
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.dao.DataRetrievalFailureException;
|
||||
import org.springframework.data.neo4j.model.Car;
|
||||
import org.springframework.data.neo4j.model.Volvo;
|
||||
import org.springframework.data.neo4j.support.Neo4jTemplate;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -54,7 +55,7 @@ public class ReadWriteTests {
|
||||
} finally {
|
||||
ctx.close();
|
||||
if (delete) {
|
||||
FileUtils.deleteDirectory(new File("target/read-write.db"));
|
||||
FileSystemUtils.deleteRecursively(new File("target/read-write.db"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.neo4j.graphdb.traversal.TraversalDescription;
|
||||
import org.neo4j.kernel.Traversal;
|
||||
import org.neo4j.test.TestGraphDatabaseFactory;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.neo4j.config.JtaTransactionManagerFactoryBean;
|
||||
import org.springframework.data.neo4j.conversion.ResultConverter;
|
||||
import org.springframework.data.neo4j.core.GraphDatabase;
|
||||
import org.springframework.data.neo4j.support.DelegatingGraphDatabase;
|
||||
@@ -84,7 +85,7 @@ public class Neo4jTemplateApiTests {
|
||||
}
|
||||
|
||||
protected PlatformTransactionManager createTransactionManager() {
|
||||
return new JtaTransactionManager(new Neo4jEmbeddedTransactionManager(graphDatabaseService));
|
||||
return new JtaTransactionManagerFactoryBean(graphDatabaseService).getObject();
|
||||
}
|
||||
|
||||
private void createData() {
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.neo4j.graphdb.*;
|
||||
import org.neo4j.kernel.GraphDatabaseAPI;
|
||||
import org.neo4j.test.TestGraphDatabaseFactory;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.neo4j.config.JtaTransactionManagerFactoryBean;
|
||||
import org.springframework.data.neo4j.core.GraphDatabase;
|
||||
import org.springframework.data.neo4j.model.Person;
|
||||
import org.springframework.data.neo4j.support.DelegatingGraphDatabase;
|
||||
@@ -102,7 +103,7 @@ public class Neo4jTemplateApiTransactionTests {
|
||||
}
|
||||
|
||||
protected PlatformTransactionManager createTransactionManager() {
|
||||
return new JtaTransactionManager(new Neo4jEmbeddedTransactionManager((GraphDatabaseAPI)graphDatabaseService));
|
||||
return new JtaTransactionManagerFactoryBean(graphDatabaseService).getObject();
|
||||
}
|
||||
|
||||
private void createData() {
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.neo4j.graphdb.GraphDatabaseService;
|
||||
import org.neo4j.kernel.GraphDatabaseAPI;
|
||||
import org.neo4j.test.TestGraphDatabaseFactory;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.neo4j.config.JtaTransactionManagerFactoryBean;
|
||||
import org.springframework.data.neo4j.core.GraphDatabase;
|
||||
import org.springframework.data.neo4j.fieldaccess.Neo4jConversionServiceFactoryBean;
|
||||
import org.springframework.data.neo4j.support.DelegatingGraphDatabase;
|
||||
@@ -51,9 +52,8 @@ public abstract class NeoApiTests {
|
||||
return new Neo4jConversionServiceFactoryBean().getObject();
|
||||
}
|
||||
|
||||
protected PlatformTransactionManager createTransactionManager()
|
||||
{
|
||||
return new JtaTransactionManager(new Neo4jEmbeddedTransactionManager(graphDatabaseService));
|
||||
protected PlatformTransactionManager createTransactionManager() {
|
||||
return new JtaTransactionManagerFactoryBean(graphDatabaseService).getObject();
|
||||
}
|
||||
|
||||
protected GraphDatabase createGraphDatabase() throws Exception
|
||||
|
||||
Reference in New Issue
Block a user