Updates to stable versions of Neo4j 1.8.M06, spatial, cypher-dsl and java-rest-binding, adopted to API changes
This commit is contained in:
@@ -20,6 +20,7 @@ import org.neo4j.graphdb.Direction;
|
||||
import org.neo4j.graphdb.DynamicRelationshipType;
|
||||
import org.neo4j.graphdb.Node;
|
||||
import org.neo4j.graphdb.Relationship;
|
||||
import org.neo4j.graphdb.traversal.Evaluators;
|
||||
import org.neo4j.graphdb.traversal.TraversalDescription;
|
||||
import org.neo4j.kernel.Traversal;
|
||||
import org.neo4j.kernel.impl.traversal.TraversalDescriptionImpl;
|
||||
@@ -184,7 +185,7 @@ public class Group {
|
||||
public TraversalDescription build(Object start, Neo4jPersistentProperty property, String...params) {
|
||||
return new TraversalDescriptionImpl()
|
||||
.relationships(DynamicRelationshipType.withName(params[0]))
|
||||
.filter(Traversal.returnAllButStartNode());
|
||||
.evaluator(Evaluators.excludeStartPosition());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ public class NodeEntityQueryTest extends EntityTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyQueryReturnsNull() {
|
||||
public void testEmptyQueryReturnsZero() {
|
||||
final Group group = neo4jTemplate.save(new Group());
|
||||
assertNull("empty result leads to null value", group.getMemberCount());
|
||||
assertEquals("empty result leads to zero",(Long)0L, group.getMemberCount());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.data.neo4j.aspects.support;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.neo4j.graphdb.Transaction;
|
||||
@@ -212,6 +213,13 @@ public class NodeEntityTest extends EntityTestBase {
|
||||
attribute.setValue("test");
|
||||
persist(attribute);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testNotEqualToNonNodebackedObject() {
|
||||
final Attribute<String> attribute = new Attribute<String>();
|
||||
assertEquals(false, persist(attribute).equals("foo"));
|
||||
}
|
||||
@Test
|
||||
public void testAccessReadOnlyCollectionMakesEntityDirty() {
|
||||
Group g = new Group();
|
||||
|
||||
@@ -112,7 +112,7 @@ public class TraversalTest extends EntityTestBase {
|
||||
Group group = persist(new Group());
|
||||
group.setName("dev");
|
||||
group.addPerson(p);
|
||||
final TraversalDescription traversalDescription = new TraversalDescriptionImpl().relationships(DynamicRelationshipType.withName("persons")).filter(Traversal.returnAllButStartNode());
|
||||
final TraversalDescription traversalDescription = new TraversalDescriptionImpl().relationships(DynamicRelationshipType.withName("persons")).evaluator(Evaluators.excludeStartPosition());
|
||||
Iterable<Person> people = finder.findAllByTraversal(group, traversalDescription);
|
||||
final HashSet<Person> found = new HashSet<Person>();
|
||||
for (Person person : people) {
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
<profile>
|
||||
<id>1.8-SNAPSHOT</id>
|
||||
<properties>
|
||||
<neo4j.version>1.8-SNAPSHOT</neo4j.version>
|
||||
<neo4j.version>1.8.M06</neo4j.version>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
@@ -11,12 +11,11 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.version>3.0.7.RELEASE</spring.version>
|
||||
<spring.version>3.1.0.RELEASE</spring.version>
|
||||
<slf4j.version>1.6.1</slf4j.version>
|
||||
<neo4j.version>1.7</neo4j.version>
|
||||
<neo4j.version>1.8.M06</neo4j.version>
|
||||
<spring-data-neo4j.version>${project.version}</spring-data-neo4j.version>
|
||||
<aspectj.version>1.6.12</aspectj.version>
|
||||
<org.slf4j-version>1.6.1</org.slf4j-version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
@@ -153,17 +152,17 @@
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${org.slf4j-version}</version>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>${org.slf4j-version}</version>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>${org.slf4j-version}</version>
|
||||
<version>${slf4j.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
||||
http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
|
||||
|
||||
<context:annotation-config/>
|
||||
<context:spring-configured/>
|
||||
|
||||
@@ -11,12 +11,11 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.version>3.0.7.RELEASE</spring.version>
|
||||
<spring.version>3.1.0.RELEASE</spring.version>
|
||||
<slf4j.version>1.6.1</slf4j.version>
|
||||
<neo4j.version>1.7</neo4j.version>
|
||||
<neo4j.version>1.8.M06</neo4j.version>
|
||||
<spring-data-neo4j.version>${project.version}</spring-data-neo4j.version>
|
||||
<aspectj.version>1.6.12</aspectj.version>
|
||||
<org.slf4j-version>1.6.1</org.slf4j-version>
|
||||
<jersey.version>1.4</jersey.version>
|
||||
</properties>
|
||||
|
||||
@@ -166,17 +165,17 @@
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${org.slf4j-version}</version>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>${org.slf4j-version}</version>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>${org.slf4j-version}</version>
|
||||
<version>${slf4j.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -400,6 +399,7 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<forkMode>once</forkMode>
|
||||
<useFile>true</useFile>
|
||||
<includes>
|
||||
<include>**/*Tests.java</include>
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
||||
http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
|
||||
|
||||
<context:annotation-config/>
|
||||
<context:spring-configured/>
|
||||
|
||||
@@ -11,12 +11,11 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.version>3.0.7.RELEASE</spring.version>
|
||||
<spring.version>3.1.0.RELEASE</spring.version>
|
||||
<slf4j.version>1.6.1</slf4j.version>
|
||||
<spring-data-neo4j.version>${project.version}</spring-data-neo4j.version>
|
||||
<org.slf4j-version>1.6.1</org.slf4j-version>
|
||||
<aspectj.version>1.6.12</aspectj.version>
|
||||
<neo4j.version>1.7</neo4j.version>
|
||||
<neo4j.version>1.8.M06</neo4j.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
@@ -153,17 +152,17 @@
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${org.slf4j-version}</version>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>${org.slf4j-version}</version>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>${org.slf4j-version}</version>
|
||||
<version>${slf4j.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
||||
http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
|
||||
|
||||
<context:annotation-config/>
|
||||
<context:component-scan base-package="org.neo4j.cineasts">
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.neo4j.examples.imdb.domain;
|
||||
import org.neo4j.graphalgo.GraphAlgoFactory;
|
||||
import org.neo4j.graphdb.Node;
|
||||
import org.neo4j.graphdb.Path;
|
||||
import org.neo4j.graphdb.PathExpander;
|
||||
import org.neo4j.kernel.StandardExpander;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.neo4j.support.Neo4jTemplate;
|
||||
@@ -71,7 +72,7 @@ class ImdbServiceImpl implements ImdbService {
|
||||
|
||||
Actor bacon = actorRepository.findByPropertyValue("name", "Bacon, Kevin");
|
||||
|
||||
Path path = GraphAlgoFactory.shortestPath(StandardExpander.DEFAULT.add(RelTypes.ACTS_IN), 10).findSinglePath(bacon.getPersistentState(), actor.getPersistentState());
|
||||
Path path = GraphAlgoFactory.shortestPath((PathExpander)StandardExpander.DEFAULT.add(RelTypes.ACTS_IN), 10).findSinglePath(bacon.getPersistentState(), actor.getPersistentState());
|
||||
if (path==null) return Collections.emptyList();
|
||||
return convertNodesToActorsAndMovies(path);
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
|
||||
http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd">
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
|
||||
http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd">
|
||||
<context:annotation-config />
|
||||
<context:spring-configured/>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<spring-data-neo4j.version>${project.version}</spring-data-neo4j.version>
|
||||
<aspectj.version>1.6.12</aspectj.version>
|
||||
<slf4j.version>1.6.1</slf4j.version>
|
||||
<neo4j.version>1.7</neo4j.version>
|
||||
<neo4j.version>1.8.M06</neo4j.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring-security.version>3.1.0.RELEASE</spring-security.version>
|
||||
</properties>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.springone.myrestaurants.domain;
|
||||
|
||||
import org.neo4j.graphdb.*;
|
||||
import org.neo4j.graphdb.traversal.TraversalDescription;
|
||||
import org.neo4j.graphdb.traversal.*;
|
||||
import org.neo4j.graphdb.traversal.Traverser;
|
||||
import org.neo4j.helpers.Predicate;
|
||||
import org.neo4j.kernel.Traversal;
|
||||
@@ -28,8 +28,8 @@ public class TopRatedRestaurantFinder {
|
||||
final Node userNode=user.getPersistentState();
|
||||
final TraversalDescription traversalDescription = new TraversalDescriptionImpl()
|
||||
.order(Traversal.postorderBreadthFirst())
|
||||
.prune(Traversal.pruneAfterDepth(MAXIMUM_DEPTH))
|
||||
.filter(calculateRatingPredicate)
|
||||
.evaluator(Evaluators.toDepth(MAXIMUM_DEPTH))
|
||||
.evaluator(calculateRatingPredicate)
|
||||
.relationships(DynamicRelationshipType.withName("friends"));
|
||||
final Traverser traverser = traversalDescription.traverse(userNode);
|
||||
final Iterator<Node> it = traverser.nodes().iterator();
|
||||
@@ -39,7 +39,8 @@ public class TopRatedRestaurantFinder {
|
||||
return calculateRatingPredicate.getRecommendedRestaurants(n);
|
||||
}
|
||||
|
||||
private class CalculateRatingPredicate implements Predicate<Path> {
|
||||
private class CalculateRatingPredicate implements Evaluator {
|
||||
|
||||
class AggregatedRecommendation implements Comparable<AggregatedRecommendation> {
|
||||
private Node restaurant;
|
||||
private Collection<Relationship> recommendations=new HashSet<Relationship>();
|
||||
@@ -77,7 +78,8 @@ public class TopRatedRestaurantFinder {
|
||||
public CalculateRatingPredicate() {
|
||||
}
|
||||
|
||||
public boolean accept(final Path path) {
|
||||
@Override
|
||||
public Evaluation evaluate(Path path) {
|
||||
final int distance = path.length();
|
||||
final Node friend = path.endNode();
|
||||
for (final Relationship recommendation : friend.getRelationships(DynamicRelationshipType.withName("recommends"))) {
|
||||
@@ -87,7 +89,7 @@ public class TopRatedRestaurantFinder {
|
||||
}
|
||||
recommendedRestaurants.get(restaurant).add(recommendation,distance);
|
||||
}
|
||||
return true;
|
||||
return Evaluation.INCLUDE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
public Collection<RatedRestaurant> getRecommendedRestaurants(final int n) {
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.springone.myrestaurants.domain;
|
||||
|
||||
import org.neo4j.graphdb.DynamicRelationshipType;
|
||||
import org.neo4j.graphdb.traversal.BranchOrderingPolicy;
|
||||
import org.neo4j.graphdb.traversal.BranchSelector;
|
||||
import org.neo4j.graphdb.traversal.TraversalBranch;
|
||||
import org.neo4j.graphdb.traversal.TraversalDescription;
|
||||
import org.neo4j.graphdb.PathExpander;
|
||||
import org.neo4j.graphdb.traversal.*;
|
||||
import org.neo4j.kernel.impl.traversal.TraversalDescriptionImpl;
|
||||
import org.springframework.data.neo4j.core.FieldTraversalDescriptionBuilder;
|
||||
import org.springframework.data.neo4j.mapping.Neo4jPersistentProperty;
|
||||
@@ -23,17 +21,18 @@ class TopRatedRestaurantTraverser implements FieldTraversalDescriptionBuilder {
|
||||
.relationships(DynamicRelationshipType.withName("friends"))
|
||||
.order(new BranchOrderingPolicy() {
|
||||
@Override
|
||||
public BranchSelector create(final TraversalBranch startBranch) {
|
||||
public BranchSelector create(final TraversalBranch startBranch, final PathExpander expander) {
|
||||
return new BranchSelector(){
|
||||
@Override
|
||||
public TraversalBranch next() {
|
||||
public TraversalBranch next(TraversalContext metadata) {
|
||||
TraversalBranch branch=startBranch;
|
||||
while (branch!=null) {
|
||||
if (branch.depth()<branch.next().depth()) return branch;
|
||||
branch=branch.next();
|
||||
if (branch.length()<branch.next(expander,metadata).length()) return branch;
|
||||
branch=branch.next(expander,metadata);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:jee="http://www.springframework.org/schema/jee"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
|
||||
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd">
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd">
|
||||
<!--
|
||||
This will automatically locate any and all property files you have
|
||||
within your classpath, provided they fall under the META-INF/spring
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<neo4j.version>1.7</neo4j.version>
|
||||
<spring.version>3.0.7.RELEASE</spring.version>
|
||||
<neo4j.version>1.8.M06</neo4j.version>
|
||||
<spring.version>3.1.0.RELEASE</spring.version>
|
||||
<spring-data-neo4j.version>${project.version}</spring-data-neo4j.version>
|
||||
<aspectj.version>1.6.12</aspectj.version>
|
||||
<slf4j.version>1.6.1</slf4j.version>
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/data/neo4j
|
||||
http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd
|
||||
http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd
|
||||
http://www.springframework.org/schema/tx
|
||||
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
|
||||
http://www.springframework.org/schema/tx/spring-tx.xsd">
|
||||
|
||||
<neo4j:repositories base-package="org.neo4j.app.todos"/>
|
||||
<tx:annotation-driven mode="aspectj"/>
|
||||
|
||||
@@ -128,8 +128,8 @@
|
||||
<!--<org.springframework.version>[${org.springframework.version.30}, ${org.springframework.version.40})-->
|
||||
<org.springframework.version>3.1.2.RELEASE</org.springframework.version>
|
||||
<data.commons.version>1.4.0.M1</data.commons.version>
|
||||
<neo4j.version>1.7.1</neo4j.version>
|
||||
<neo4j.spatial.version>0.8</neo4j.spatial.version>
|
||||
<neo4j.version>1.8.M06</neo4j.version>
|
||||
<neo4j.spatial.version>0.9.M01</neo4j.spatial.version>
|
||||
<aspectj.version>1.6.12</aspectj.version>
|
||||
<blueprints.version>1.2</blueprints.version>
|
||||
<gremlin.version>1.5</gremlin.version>
|
||||
@@ -443,12 +443,6 @@
|
||||
<groupId>org.neo4j</groupId>
|
||||
<artifactId>neo4j</artifactId>
|
||||
<version>${neo4j.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.neo4j</groupId>
|
||||
<artifactId>neo4j-cypher</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -471,11 +465,10 @@
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.neo4j</groupId>
|
||||
<artifactId>neo4j-cypher-dsl</artifactId>
|
||||
<version>1.7</version>
|
||||
<!-- TODO -->
|
||||
<!--optional>true</optional-->
|
||||
<groupId>org.neo4j</groupId>
|
||||
<artifactId>neo4j-cypher-dsl</artifactId>
|
||||
<version>1.8.M06</version>
|
||||
<!--optional>true</optional-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.neo4j</groupId>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<dependency>
|
||||
<groupId>org.neo4j</groupId>
|
||||
<artifactId>neo4j-rest-graphdb</artifactId>
|
||||
<version>1.7</version>
|
||||
<version>1.8.M06</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.neo4j</groupId>
|
||||
@@ -163,12 +163,12 @@
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-jaxrs</artifactId>
|
||||
<version>1.6.1</version>
|
||||
<version>1.8.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
<version>1.6.1</version>
|
||||
<version>1.8.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
@@ -233,7 +233,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j</artifactId>
|
||||
<version>2.1.0.BUILD-SNAPSHOT</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
<type>test-jar</type>
|
||||
</dependency>
|
||||
@@ -241,7 +241,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-aspects</artifactId>
|
||||
<version>2.1.0.BUILD-SNAPSHOT</version>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
<type>test-jar</type>
|
||||
</dependency>
|
||||
|
||||
@@ -18,17 +18,17 @@ package org.springframework.data.neo4j.rest;
|
||||
import org.neo4j.graphdb.*;
|
||||
import org.neo4j.graphdb.index.Index;
|
||||
import org.neo4j.graphdb.traversal.TraversalDescription;
|
||||
import org.neo4j.rest.graphdb.ExecutingRestRequest;
|
||||
import org.neo4j.rest.graphdb.RestAPI;
|
||||
import org.neo4j.rest.graphdb.RestRequest;
|
||||
import org.neo4j.rest.graphdb.RestAPIFacade;
|
||||
import org.neo4j.rest.graphdb.entity.RestNode;
|
||||
import org.neo4j.rest.graphdb.index.RestIndex;
|
||||
import org.neo4j.rest.graphdb.index.RestIndexManager;
|
||||
import org.neo4j.rest.graphdb.query.RestCypherQueryEngine;
|
||||
import org.neo4j.rest.graphdb.query.RestGremlinQueryEngine;
|
||||
import org.neo4j.rest.graphdb.transaction.NullTransaction;
|
||||
import org.neo4j.rest.graphdb.transaction.NullTransactionManager;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.data.neo4j.annotation.QueryType;
|
||||
import org.springframework.data.neo4j.config.NullTransactionManager;
|
||||
import org.springframework.data.neo4j.conversion.DefaultConverter;
|
||||
import org.springframework.data.neo4j.conversion.ResultConverter;
|
||||
import org.springframework.data.neo4j.core.GraphDatabase;
|
||||
@@ -48,15 +48,11 @@ public class SpringRestGraphDatabase extends org.neo4j.rest.graphdb.RestGraphDat
|
||||
}
|
||||
|
||||
public SpringRestGraphDatabase( String uri ) {
|
||||
this( new ExecutingRestRequest( uri ));
|
||||
this( new RestAPIFacade( uri ) );
|
||||
}
|
||||
|
||||
public SpringRestGraphDatabase( String uri, String user, String password ) {
|
||||
this(new ExecutingRestRequest( uri, user, password ));
|
||||
}
|
||||
|
||||
public SpringRestGraphDatabase( RestRequest restRequest){
|
||||
this(new RestAPI(restRequest));
|
||||
this(new RestAPIFacade( uri, user, password ));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,6 +60,17 @@ public class SpringRestGraphDatabase extends org.neo4j.rest.graphdb.RestGraphDat
|
||||
return super.getRestAPI().createNode(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction beginTx() {
|
||||
// return super.beginTx();
|
||||
return new NullTransaction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransactionManager getTxManager() {
|
||||
return new NullTransactionManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getOrCreateNode(String indexName, String key, Object value, final Map<String,Object> properties) {
|
||||
if (indexName ==null || key == null || value==null) throw new IllegalArgumentException("Unique index "+ indexName +" key "+key+" value must not be null");
|
||||
|
||||
@@ -16,45 +16,35 @@
|
||||
|
||||
package org.springframework.data.neo4j.rest.support;
|
||||
|
||||
import org.apache.commons.configuration.Configuration;
|
||||
import org.mortbay.component.LifeCycle;
|
||||
import org.mortbay.jetty.NCSARequestLog;
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.handler.RequestLogHandler;
|
||||
import org.neo4j.graphdb.GraphDatabaseService;
|
||||
import org.neo4j.kernel.AbstractGraphDatabase;
|
||||
import org.neo4j.server.Bootstrapper;
|
||||
import org.neo4j.server.NeoServerWithEmbeddedWebServer;
|
||||
import org.neo4j.server.CommunityNeoServer;
|
||||
import org.neo4j.server.configuration.PropertyFileConfigurator;
|
||||
import org.neo4j.server.database.Database;
|
||||
import org.neo4j.server.database.GraphDatabaseFactory;
|
||||
import org.neo4j.server.database.WrappingDatabase;
|
||||
import org.neo4j.server.modules.RESTApiModule;
|
||||
import org.neo4j.server.modules.ServerModule;
|
||||
import org.neo4j.server.modules.ThirdPartyJAXRSModule;
|
||||
import org.neo4j.server.startup.healthcheck.StartupHealthCheck;
|
||||
import org.neo4j.server.startup.healthcheck.StartupHealthCheckRule;
|
||||
import org.neo4j.server.web.Jetty6WebServer;
|
||||
import org.neo4j.server.web.WebServer;
|
||||
import org.neo4j.test.ImpermanentGraphDatabase;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author mh
|
||||
* @since 24.03.11
|
||||
*/
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
public class LocalTestServer {
|
||||
private NeoServerWithEmbeddedWebServer neoServer;
|
||||
private CommunityNeoServer neoServer;
|
||||
private final int port;
|
||||
private final String hostname;
|
||||
protected String propertiesFile = "test-db.properties";
|
||||
private final ImpermanentGraphDatabase graphDatabase;
|
||||
|
||||
public LocalTestServer() {
|
||||
this("localhost",7473);
|
||||
@@ -63,69 +53,69 @@ public class LocalTestServer {
|
||||
public LocalTestServer(String hostname, int port) {
|
||||
this.port = port;
|
||||
this.hostname = hostname;
|
||||
graphDatabase = new ImpermanentGraphDatabase();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (neoServer!=null) throw new IllegalStateException("Server already running");
|
||||
URL url = getClass().getResource("/" + propertiesFile);
|
||||
if (url==null) throw new IllegalArgumentException("Could not resolve properties file "+propertiesFile);
|
||||
final List<Class<? extends ServerModule>> serverModules = Arrays.asList(RESTApiModule.class, ThirdPartyJAXRSModule.class);
|
||||
final Bootstrapper bootstrapper = new Bootstrapper() {
|
||||
@Override
|
||||
protected GraphDatabaseFactory getGraphDatabaseFactory(Configuration configuration) {
|
||||
return new GraphDatabaseFactory() {
|
||||
@Override
|
||||
public AbstractGraphDatabase createDatabase(String databaseStoreDirectory, Map<String, String> databaseProperties) {
|
||||
return new ImpermanentGraphDatabase();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<StartupHealthCheckRule> getHealthCheckRules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<Class<? extends ServerModule>> getServerModules() {
|
||||
return serverModules;
|
||||
}
|
||||
};
|
||||
final JettyStartupListener startupListener = new JettyStartupListener();
|
||||
final Jetty6WebServer jettyWebServer = new Jetty6WebServer() {
|
||||
@Override
|
||||
protected void startJetty() {
|
||||
final Server jettyServer = getJetty();
|
||||
jettyServer.setStopAtShutdown(true);
|
||||
final Server server = jettyServer.getServer();
|
||||
server.addLifeCycleListener(startupListener);
|
||||
// addAccessLogHandler(server);
|
||||
final JettyStartupListener startupListener = new JettyStartupListener();
|
||||
jettyServer.getServer().addLifeCycleListener(startupListener);
|
||||
// System.err.println("jetty is started before notification " + jettyServer.isStarted());
|
||||
|
||||
super.startJetty();
|
||||
|
||||
startupListener.await();
|
||||
jettyServer.removeLifeCycleListener(startupListener);
|
||||
// System.err.println("jetty is started after notification " + jettyServer.isStarted());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
getJetty().setStopAtShutdown(false);
|
||||
final Server jettyServer = getJetty();
|
||||
final JettyStartupListener listener = new JettyStartupListener();
|
||||
jettyServer.getServer().addLifeCycleListener(listener);
|
||||
|
||||
super.stop();
|
||||
|
||||
listener.await();
|
||||
jettyServer.removeLifeCycleListener(listener);
|
||||
}
|
||||
};
|
||||
neoServer = new NeoServerWithEmbeddedWebServer(bootstrapper, new StartupHealthCheck(), new PropertyFileConfigurator(new File(url.getPath())), jettyWebServer, serverModules) {
|
||||
neoServer = new CommunityNeoServer(new PropertyFileConfigurator(new File(url.getPath()))) {
|
||||
@Override
|
||||
protected int getWebServerPort() {
|
||||
return port;
|
||||
}
|
||||
};
|
||||
System.err.println(neoServer.getConfiguration());
|
||||
neoServer.start();
|
||||
}
|
||||
|
||||
private void addAccessLogHandler(Server server) {
|
||||
final RequestLogHandler logHandler = new RequestLogHandler();
|
||||
final NCSARequestLog requestLog = new NCSARequestLog("/tmp/NCSARequestLog.log");
|
||||
logHandler.setRequestLog(requestLog);
|
||||
server.addHandler(logHandler);
|
||||
@Override
|
||||
protected StartupHealthCheck createHealthCheck() {
|
||||
return new StartupHealthCheck();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Database createDatabase() {
|
||||
return new WrappingDatabase(graphDatabase);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected WebServer createWebServer() {
|
||||
return jettyWebServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<ServerModule> createServerModules() {
|
||||
return asList(new RESTApiModule(webServer,database,configurator.configuration()),new ThirdPartyJAXRSModule(webServer,configurator));
|
||||
}
|
||||
};
|
||||
neoServer.start();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
@@ -170,35 +160,39 @@ public class LocalTestServer {
|
||||
CountDownLatch latch=new CountDownLatch(1);
|
||||
public void await() {
|
||||
try {
|
||||
latch.await(5, TimeUnit.SECONDS);
|
||||
latch.await(10, TimeUnit.SECONDS);
|
||||
} catch(InterruptedException ie) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new RuntimeException(ie);
|
||||
System.err.println("ERROR startup took too long - await()");
|
||||
throw new RuntimeException("Jetty did not start correctly",ie);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lifeCycleStarting(LifeCycle event) {
|
||||
System.err.println("STARTING");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lifeCycleStarted(LifeCycle event) {
|
||||
System.err.println("STARTED");
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lifeCycleFailure(LifeCycle event, Throwable cause) {
|
||||
System.out.println("FAILURE "+cause.getMessage());
|
||||
latch.countDown();
|
||||
throw new RuntimeException(cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lifeCycleStopping(LifeCycle event) {
|
||||
|
||||
System.err.println("STOPPING");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lifeCycleStopped(LifeCycle event) {
|
||||
System.err.println("STOPPED");
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,13 @@ import org.neo4j.graphdb.Direction;
|
||||
import org.neo4j.graphdb.GraphDatabaseService;
|
||||
import org.neo4j.graphdb.Node;
|
||||
import org.neo4j.graphdb.Relationship;
|
||||
import org.neo4j.rest.graphdb.ExecutingRestRequest;
|
||||
import org.neo4j.rest.graphdb.RequestResult;
|
||||
import org.neo4j.rest.graphdb.RestRequest;
|
||||
import org.springframework.data.neo4j.rest.SpringRestGraphDatabase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class RestTestBase {
|
||||
|
||||
protected SpringRestGraphDatabase restGraphDatabase;
|
||||
@@ -41,6 +46,23 @@ public class RestTestBase {
|
||||
public static void startDb() throws Exception {
|
||||
BasicConfigurator.configure();
|
||||
neoServer.start();
|
||||
|
||||
tryConnect();
|
||||
}
|
||||
|
||||
private static void tryConnect() throws InterruptedException {
|
||||
int retryCount = 3;
|
||||
for (int i = 0; i < retryCount; i++) {
|
||||
try {
|
||||
RequestResult result = new ExecutingRestRequest(SERVER_ROOT_URI).get("");
|
||||
assertEquals(200, result.getStatus());
|
||||
System.err.println("Successful HTTP connection to "+SERVER_ROOT_URI);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error retrieving ROOT URI " + e.getMessage());
|
||||
Thread.sleep(500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ServerPluginTest extends RestTestBase {
|
||||
Person person = persistedPerson("Michael", 35);
|
||||
final RequestResult requestResult = RequestResult.extractFrom(createRequest("ext/TestServerPlugin/graphdb/person").post(ClientResponse.class, "{\"name\":\"" + person.getName() + "\"}"));
|
||||
assertEquals(200, requestResult.getStatus());
|
||||
final String result = requestResult.getEntity();
|
||||
final String result = requestResult.getText();
|
||||
final Map data = (Map) new ObjectMapper().readValue(result, Object.class);
|
||||
assertEquals(person.getName(),((Map)data.get("data")).get("name"));
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.neo4j.kernel.impl.nioneo.store.FileSystemAbstraction;
|
||||
import org.neo4j.kernel.impl.transaction.AbstractTransactionManager;
|
||||
import org.neo4j.kernel.impl.transaction.TransactionManagerProvider;
|
||||
import org.neo4j.kernel.impl.transaction.TxHook;
|
||||
import org.neo4j.kernel.impl.transaction.XaDataSourceManager;
|
||||
import org.neo4j.kernel.impl.util.StringLogger;
|
||||
import org.springframework.beans.factory.annotation.Configurable;
|
||||
|
||||
@@ -35,7 +36,7 @@ public class SpringProvider extends TransactionManagerProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractTransactionManager loadTransactionManager(String s, KernelPanicEventGenerator kernelPanicEventGenerator, TxHook txHook, StringLogger stringLogger, FileSystemAbstraction fileSystemAbstraction) {
|
||||
public AbstractTransactionManager loadTransactionManager(String txLogDir, XaDataSourceManager xaDataSourceManager, KernelPanicEventGenerator kpe, TxHook rollbackHook, StringLogger msgLog, FileSystemAbstraction fileSystem) {
|
||||
return new SpringServiceImpl();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class JOTMIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void databaseConfiguredWithSpringJtaShouldUseJtaTransactionManager() throws SystemException, NotSupportedException {
|
||||
final Config config = ((AbstractGraphDatabase) gds).getConfig();
|
||||
final Config config = ((AbstractGraphDatabase) gds).getKernelData().getConfig();
|
||||
Assert.assertEquals("spring-jta", config.getParams().get(Config.TXMANAGER_IMPLEMENTATION));
|
||||
|
||||
JtaTransactionManager tm = ctx.getBean("transactionManager", JtaTransactionManager.class);
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.data.neo4j.repository;
|
||||
|
||||
import org.apache.lucene.search.NumericRangeQuery;
|
||||
import org.neo4j.cypherdsl.Execute;
|
||||
import org.neo4j.cypherdsl.Skip;
|
||||
import org.neo4j.cypherdsl.grammar.Execute;
|
||||
import org.neo4j.cypherdsl.grammar.Skip;
|
||||
import org.neo4j.graphdb.NotFoundException;
|
||||
import org.neo4j.graphdb.PropertyContainer;
|
||||
import org.neo4j.graphdb.index.IndexHits;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.neo4j.repository;
|
||||
|
||||
import org.neo4j.cypherdsl.Execute;
|
||||
import org.neo4j.cypherdsl.grammar.Execute;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.neo4j.conversion.EndResult;
|
||||
|
||||
@@ -90,6 +90,9 @@ public class EntityStateHandler {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <S extends PropertyContainer> S getPersistentState(Object entity) {
|
||||
return getPersistentState(entity,true);
|
||||
}
|
||||
public <S extends PropertyContainer> S getPersistentState(Object entity, boolean check) {
|
||||
if (entity instanceof PropertyContainer) {
|
||||
return (S) entity;
|
||||
}
|
||||
@@ -106,7 +109,8 @@ public class EntityStateHandler {
|
||||
if (persistentEntity.isRelationshipEntity()) {
|
||||
return (S) graphDatabase.getRelationshipById(graphId);
|
||||
}
|
||||
throw new IllegalArgumentException("The entity " + persistentEntity.getEntityName() + " has to be either annotated with @NodeEntity or @RelationshipEntity");
|
||||
if (check) throw new IllegalArgumentException("The entity " + persistentEntity.getEntityName() + " has to be either annotated with @NodeEntity or @RelationshipEntity");
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isNodeEntity(Class<?> targetType) {
|
||||
@@ -255,9 +259,9 @@ public class EntityStateHandler {
|
||||
public final boolean equals(Object first, Object second) {
|
||||
if (second == first) return true;
|
||||
if (second == null) return false;
|
||||
final PropertyContainer firstState = getPersistentState(first);
|
||||
final PropertyContainer firstState = getPersistentState(first,false);
|
||||
if (firstState == null) return false;
|
||||
final PropertyContainer secondState = getPersistentState(second);
|
||||
final PropertyContainer secondState = getPersistentState(second,false);
|
||||
if (secondState == null) return false;
|
||||
return firstState.equals(secondState);
|
||||
}
|
||||
|
||||
@@ -122,6 +122,16 @@ public class ConvertingEntityPath<S,E> implements EntityPath<S,E> {
|
||||
return delegate.relationships();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Relationship> reverseRelationships() {
|
||||
return delegate.reverseRelationships();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Node> reverseNodes() {
|
||||
return delegate.reverseNodes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Node> nodes() {
|
||||
return delegate.nodes();
|
||||
|
||||
@@ -58,11 +58,21 @@ public class NodePath implements Path {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Relationship> reverseRelationships() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Node> nodes() {
|
||||
return asList(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Node> reverseNodes() {
|
||||
return asList(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 0;
|
||||
|
||||
@@ -57,11 +57,21 @@ public class RelationshipPath implements Path {
|
||||
return asList(relationship);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Relationship> reverseRelationships() {
|
||||
return relationships();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Node> nodes() {
|
||||
return asList(startNode(),endNode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Node> reverseNodes() {
|
||||
return asList(endNode(),startNode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 1;
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.junit.Test;
|
||||
import org.neo4j.graphdb.GraphDatabaseService;
|
||||
import org.neo4j.kernel.AbstractGraphDatabase;
|
||||
import org.neo4j.kernel.EmbeddedGraphDatabase;
|
||||
import org.neo4j.kernel.GraphDatabaseAPI;
|
||||
import org.neo4j.kernel.HighlyAvailableGraphDatabase;
|
||||
import org.neo4j.kernel.configuration.Config;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -82,9 +83,9 @@ public class DataGraphNamespaceHandlerTest {
|
||||
@Test
|
||||
public void injectionForExistingGraphDatabaseService() {
|
||||
final Config config = assertInjected("-external-embedded");
|
||||
final AbstractGraphDatabase gds = (AbstractGraphDatabase) config.graphDatabaseService;
|
||||
final GraphDatabaseAPI gds = (GraphDatabaseAPI) config.graphDatabaseService;
|
||||
assertEquals(EmbeddedGraphDatabase.class, gds.getClass());
|
||||
final org.neo4j.kernel.configuration.Config neoConfig = gds.getConfig();
|
||||
final org.neo4j.kernel.configuration.Config neoConfig = gds.getKernelData().getConfig();
|
||||
assertEquals("true", neoConfig.getParams().get("allow_store_upgrade"));
|
||||
}
|
||||
@Test
|
||||
@@ -92,7 +93,7 @@ public class DataGraphNamespaceHandlerTest {
|
||||
public void injectionForExistingHighlyAvailableGraphDatabaseService() {
|
||||
final Config config = assertInjected("-external-ha");
|
||||
final AbstractGraphDatabase gds = (AbstractGraphDatabase) config.graphDatabaseService;
|
||||
final org.neo4j.kernel.configuration.Config neoConfig = gds.getConfig();
|
||||
final org.neo4j.kernel.configuration.Config neoConfig = gds.getKernelData().getConfig();
|
||||
assertEquals(HighlyAvailableGraphDatabase.class, gds.getClass());
|
||||
assertEquals("1", neoConfig.getParams().get("ha.server_id"));
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.data.neo4j.model;
|
||||
|
||||
import org.neo4j.graphdb.Direction;
|
||||
import org.neo4j.graphdb.DynamicRelationshipType;
|
||||
import org.neo4j.graphdb.traversal.Evaluators;
|
||||
import org.neo4j.graphdb.traversal.TraversalDescription;
|
||||
import org.neo4j.kernel.Traversal;
|
||||
import org.neo4j.kernel.impl.traversal.TraversalDescriptionImpl;
|
||||
@@ -157,9 +158,8 @@ public class Group implements IGroup {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public TraversalDescription build(Object start, Neo4jPersistentProperty property, String... params) {
|
||||
return new TraversalDescriptionImpl().relationships(DynamicRelationshipType.withName(params[0])).filter(
|
||||
Traversal.returnAllButStartNode());
|
||||
|
||||
//return new TraversalDescriptionImpl().relationships(DynamicRelationshipType.withName(params[0])).filter(Traversal.returnAllButStartNode());
|
||||
return new TraversalDescriptionImpl().relationships(DynamicRelationshipType.withName(params[0])).evaluator(Evaluators.excludeStartPosition());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import static org.neo4j.cypherdsl.CypherQuery.*;
|
||||
import static org.neo4j.cypherdsl.querydsl.CypherQueryDSL.*;
|
||||
import org.neo4j.cypherdsl.Execute;
|
||||
import org.neo4j.cypherdsl.grammar.Execute;
|
||||
import org.neo4j.cypherdsl.querydsl.CypherQueryDSL;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -59,9 +59,9 @@ public class CypherDslRepositoryTest {
|
||||
@Autowired Neo4jOperations template;
|
||||
private TestTeam team;
|
||||
private Map<String,Object> peopleParams;
|
||||
private Execute query = start(node("n", "people")).returns(identifier("n"));
|
||||
private Execute query2 = CypherQueryDSL.start(CypherQueryDSL.node(QPerson.person, "people")).
|
||||
where(QPerson.person.name.eq("Michael")).
|
||||
private Execute query = start(nodeByParameter("n", "people")).returns(identifier("n"));
|
||||
private Execute query2 = CypherQueryDSL.start(CypherQueryDSL.nodeByparameter(identifier(QPerson.person), "people")).
|
||||
where(toBooleanExpression(QPerson.person.name.eq("Michael"))).
|
||||
returns(identifier(QPerson.person));
|
||||
|
||||
@Before
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.neo4j.graphdb.*;
|
||||
import org.neo4j.graphdb.index.Index;
|
||||
import org.neo4j.graphdb.traversal.Evaluators;
|
||||
import org.neo4j.graphdb.traversal.TraversalDescription;
|
||||
import org.neo4j.helpers.collection.IteratorUtil;
|
||||
import org.neo4j.helpers.collection.MapUtil;
|
||||
@@ -361,7 +362,8 @@ public class EntityNeo4jTemplateTest extends EntityTestBase {
|
||||
|
||||
@Test @Transactional
|
||||
public void testTraverse() throws Exception {
|
||||
final TraversalDescription traversalDescription = neo4jOperations.traversalDescription().relationships(DynamicRelationshipType.withName("knows"), Direction.OUTGOING).filter(Traversal.returnAllButStartNode());
|
||||
// final TraversalDescription traversalDescription = neo4jOperations.traversalDescription().relationships(DynamicRelationshipType.withName("knows"), Direction.OUTGOING).filter(Traversal.returnAllButStartNode());
|
||||
final TraversalDescription traversalDescription = neo4jOperations.traversalDescription().relationships(DynamicRelationshipType.withName("knows"), Direction.OUTGOING).evaluator(Evaluators.excludeStartPosition());
|
||||
final Person knows = neo4jOperations.traverse(testTeam.michael, traversalDescription).to(Person.class).single();
|
||||
assertEquals(testTeam.david.getName(), knows.getName());
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.neo4j.graphdb.*;
|
||||
import org.neo4j.graphdb.index.Index;
|
||||
import org.neo4j.graphdb.traversal.Evaluators;
|
||||
import org.neo4j.graphdb.traversal.TraversalDescription;
|
||||
import org.neo4j.kernel.Traversal;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -280,7 +281,8 @@ public class FullNeo4jTemplateTest {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testTraverse() throws Exception {
|
||||
final TraversalDescription description = Traversal.description().relationships(KNOWS).prune(Traversal.pruneAfterDepth(1)).filter(Traversal.returnAllButStartNode());
|
||||
//final TraversalDescription description = Traversal.description().relationships(KNOWS).prune(Traversal.pruneAfterDepth(1)).filter(Traversal.returnAllButStartNode());
|
||||
final TraversalDescription description = Traversal.description().relationships(KNOWS).evaluator(Evaluators.toDepth(1)).evaluator(Evaluators.excludeStartPosition());
|
||||
assertSingleResult("node1", neo4jTemplate.traverse(referenceNode, description).to(String.class, new PathNodeNameMapper()));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.junit.*;
|
||||
import org.neo4j.graphdb.*;
|
||||
import org.neo4j.graphdb.traversal.Evaluators;
|
||||
import org.neo4j.kernel.GraphDatabaseAPI;
|
||||
import org.neo4j.graphdb.index.Index;
|
||||
import org.neo4j.graphdb.traversal.TraversalDescription;
|
||||
@@ -300,7 +301,8 @@ public class Neo4jTemplateApiTest {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
public void testTraverse() throws Exception {
|
||||
final TraversalDescription description = Traversal.description().relationships(KNOWS).prune(Traversal.pruneAfterDepth(1)).filter(Traversal.returnAllButStartNode());
|
||||
//final TraversalDescription description = Traversal.description().relationships(KNOWS).prune(Traversal.pruneAfterDepth(1)).filter(Traversal.returnAllButStartNode());
|
||||
final TraversalDescription description = Traversal.description().relationships(KNOWS).evaluator(Evaluators.toDepth(1)).evaluator(Evaluators.excludeStartPosition());
|
||||
assertSingleResult("node1",template.traverse(referenceNode, description).to(String.class,new PathNodeNameMapper()));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.junit.Test;
|
||||
import org.neo4j.graphdb.Node;
|
||||
import org.neo4j.graphdb.Path;
|
||||
import org.neo4j.graphdb.RelationshipType;
|
||||
import org.neo4j.graphdb.traversal.Evaluators;
|
||||
import org.neo4j.graphdb.traversal.TraversalDescription;
|
||||
import org.neo4j.kernel.Traversal;
|
||||
import org.springframework.data.neo4j.conversion.Handler;
|
||||
@@ -32,7 +33,7 @@ import java.util.Set;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.neo4j.helpers.collection.MapUtil.map;
|
||||
import static org.neo4j.kernel.Traversal.returnAllButStartNode;
|
||||
// TODO import static org.neo4j.kernel.Traversal.returnAllButStartNode;
|
||||
import static org.springframework.data.neo4j.template.NeoTraversalTest.Type.HAS;
|
||||
|
||||
public class NeoTraversalTest extends NeoApiTest {
|
||||
@@ -51,7 +52,9 @@ public class NeoTraversalTest extends NeoApiTest {
|
||||
});
|
||||
|
||||
final Set<String> resultSet = new HashSet<String>();
|
||||
@SuppressWarnings("deprecation") final TraversalDescription description = Traversal.description().relationships(HAS).filter(returnAllButStartNode()).prune(Traversal.pruneAfterDepth(2));
|
||||
// @SuppressWarnings("deprecation") final TraversalDescription description = Traversal.description().relationships(HAS).filter(returnAllButStartNode()).prune(Traversal.pruneAfterDepth(2));
|
||||
final TraversalDescription description = Traversal.description().relationships(HAS).evaluator(Evaluators.excludeStartPosition()).evaluator(Evaluators.toDepth(2));
|
||||
|
||||
final Result<Path> result = template.traverse(template.getReferenceNode(), description);
|
||||
result.handle(new Handler<Path>() {
|
||||
@Override
|
||||
|
||||
@@ -134,11 +134,11 @@ public class UserAccount {
|
||||
xmlns:datagraph="http://www.springframework.org/schema/data/neo4j"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
||||
http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/data/neo4j
|
||||
http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd
|
||||
http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd
|
||||
">
|
||||
|
||||
<context:annotation-config/>
|
||||
|
||||
@@ -106,7 +106,7 @@ public void foo( @Context WorldRepository repo ) {
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-rest</artifactId>
|
||||
<version>2.1.0.RC1</version>
|
||||
<version>2.1.0.RC3</version>
|
||||
</dependency>
|
||||
]]></programlisting>
|
||||
</example>
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
<section>
|
||||
<title>Dependencies for Spring Data Neo4j Simple Mapping</title>
|
||||
<para>
|
||||
For the simple POJO mapping it is enough to add the <code>org.springframework.data:spring-data-neo4j:2.1.0.RC1</code> dependency
|
||||
to your project. If you want to use the Cypher query language please add <code>org.neo4j:neo4j-cypher:1.7</code>
|
||||
For the simple POJO mapping it is enough to add the <code>org.springframework.data:spring-data-neo4j:2.1.0.RC3</code> dependency
|
||||
to your project.
|
||||
</para>
|
||||
<example>
|
||||
<title>Maven dependencies for Spring Data Neo4j</title>
|
||||
<programlisting language="xml"><![CDATA[<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j</artifactId>
|
||||
<version>2.1.0.RC1</version>
|
||||
<version>2.1.0.RC3</version>
|
||||
</dependency>
|
||||
]]></programlisting>
|
||||
</example>
|
||||
@@ -43,8 +43,8 @@
|
||||
<programlisting language="java"><![CDATA[sourceCompatibility = 1.6
|
||||
targetCompatibility = 1.6
|
||||
|
||||
springVersion = "3.0.7.RELEASE"
|
||||
springDataNeo4jVersion = "2.1.0.RC1"
|
||||
springVersion = "3.1.0.RELEASE"
|
||||
springDataNeo4jVersion = "2.1.0.RC3"
|
||||
aspectjVersion = "1.6.12"
|
||||
|
||||
apply from:'https://github.com/SpringSource/spring-data-neo4j/raw/master/build/
|
||||
@@ -120,7 +120,7 @@ repositories {
|
||||
Spring Framework (core, context, aop, aspects, tx), AspectJ, Neo4j, and Spring Data Commons. If you
|
||||
already use these (or different versions of these) in your project, then include those dependencies
|
||||
on your own. In this case, please make sure that the versions match.
|
||||
If you want to use Cypher or Gremlin, please add the dependencies (which are optional in SDN)
|
||||
If you want to use Gremlin, please add the dependency (which is optional in SDN)
|
||||
accordingly.
|
||||
</para>
|
||||
<example>
|
||||
@@ -128,7 +128,7 @@ repositories {
|
||||
<programlisting language="xml"><![CDATA[<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-aspects</artifactId>
|
||||
<version>2.1.0.RC1</version>
|
||||
<version>2.1.0.RC3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -136,11 +136,6 @@ repositories {
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
<version>1.6.12</version>
|
||||
</dependency>
|
||||
[<dependency>
|
||||
<groupId>org.neo4j</groupId>
|
||||
<artifactId>neo4j-cypher</artifactId>
|
||||
<version>1.7</version>
|
||||
</dependency>]
|
||||
]]></programlisting>
|
||||
</example>
|
||||
</section>
|
||||
@@ -226,11 +221,11 @@ repositories {
|
||||
xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
||||
http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/data/neo4j
|
||||
http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd">
|
||||
http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd">
|
||||
|
||||
<context:annotation-config/>
|
||||
<neo4j:config storeDirectory="target/config-test"/>
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-rest</artifactId>
|
||||
<version>2.1.0.RC1</version>
|
||||
<version>2.1.0.RC3</version>
|
||||
</dependency>
|
||||
]]></programlisting>
|
||||
</example>
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<programlisting language="xml" ><![CDATA[<dependency>
|
||||
<groupId>org.neo4j</groupId>
|
||||
<artifactId>neo4j</artifactId>
|
||||
<version>1.7</version>
|
||||
<version>1.8.M06</version>
|
||||
</dependency>
|
||||
]]></programlisting>
|
||||
</example>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j-aspects</artifactId>
|
||||
<version>2.1.0.RC1</version>
|
||||
<version>2.1.0.RC3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -87,7 +87,7 @@
|
||||
<programlisting language="xml"><![CDATA[<beans xmlns="http://www.springframework.org/schema/beans" ...
|
||||
xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
|
||||
xsi:schemaLocation="... http://www.springframework.org/schema/data/neo4j
|
||||
http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd">
|
||||
http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd">
|
||||
...
|
||||
<neo4j:config storeDirectory="data/graph.db"/>
|
||||
...
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<programlisting language="xml"><![CDATA[<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j</artifactId>
|
||||
<version>2.1.0.RC1</version>
|
||||
<version>2.1.0.RC3</version>
|
||||
</dependency>]]></programlisting>
|
||||
</example>
|
||||
</para>
|
||||
@@ -34,7 +34,7 @@
|
||||
<programlisting language="xml"><![CDATA[<beans xmlns="http://www.springframework.org/schema/beans" ...
|
||||
xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
|
||||
xsi:schemaLocation="... http://www.springframework.org/schema/data/neo4j
|
||||
http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd">
|
||||
http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd">
|
||||
...
|
||||
<neo4j:config storeDirectory="data/graph.db"/>
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user