neo4j version update

This commit is contained in:
Michael Hunger
2011-12-21 05:23:41 +01:00
parent 95037af492
commit 39d31d5864
22 changed files with 116 additions and 58 deletions

View File

@@ -124,8 +124,8 @@
</dependency>
<dependency>
<groupId>com.tinkerpop</groupId>
<artifactId>gremlin</artifactId>
<groupId>com.tinkerpop.gremlin</groupId>
<artifactId>gremlin-groovy</artifactId>
<optional>true</optional>
</dependency>

View File

@@ -66,7 +66,7 @@ public class GremlinQueryEngineTest extends EntityTestBase {
@Test
@Transactional
public void testQueryList() throws Exception {
final String queryString = "t = new Table(); [g.v(michael),g.v(david)].each{ n -> n.as('person.name').as('person.age').table(t,['person.name','person.age']){ it.age }{ it.name } >> -1}; t;" ;
final String queryString = "t = new Table(); [g.v(michael),g.v(david)].each{ n -> n.as('person.name').as('person.age').table(t,['person.name','person.age']){ it.age }{ it.name }.iterate()}; t;" ;
final Collection<Object> result = IteratorUtil.asCollection(queryEngine.query(queryString, MapUtil.map("michael", getNodeId(michael), "david", getNodeId(testTeam.david))));
assertEquals(asList(testTeam.simpleRowFor(michael, "person"), testTeam.simpleRowFor(testTeam.david, "person")), result);

View File

@@ -127,8 +127,8 @@
</dependency>
<dependency>
<groupId>com.tinkerpop</groupId>
<artifactId>gremlin</artifactId>
<groupId>com.tinkerpop.gremlin</groupId>
<artifactId>gremlin-groovy</artifactId>
<optional>true</optional>
</dependency>

View File

@@ -52,7 +52,7 @@ public class DataGraphNamespaceHandlerCrossStoreTest {
Neo4jTemplate template = config.template;
Assert.assertNotNull("template", template);
EmbeddedGraphDatabase graphDatabaseService = (EmbeddedGraphDatabase) template.getGraphDatabaseService();
Assert.assertEquals("store-dir", "target/config-test", graphDatabaseService.getStoreDir());
Assert.assertTrue("store-dir", graphDatabaseService.getStoreDir().endsWith("target/config-test"));
Assert.assertNotNull("graphDatabaseService", config.graphDatabaseService);
Assert.assertNotNull("transactionManager", config.transactionManager);
config.graphDatabaseService.shutdown();

View File

@@ -55,7 +55,6 @@
<bean id="graphDatabaseService" class="org.neo4j.test.ImpermanentGraphDatabase"
destroy-method="shutdown" scope="singleton">
<constructor-arg index="0" value="target/data/recommendation" />
</bean>
<bean id="graphDatabase" class="org.springframework.data.neo4j.support.DelegatingGraphDatabase">

View File

@@ -14,7 +14,7 @@
<spring.version>3.0.6.RELEASE</spring.version>
<slf4j.version>1.6.1</slf4j.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<neo4j.version>1.5</neo4j.version>
<neo4j.version>1.6.M02</neo4j.version>
<spring-data-graph.version>2.0.0.BUILD-SNAPSHOT</spring-data-graph.version>
<org.slf4j-version>1.6.1</org.slf4j-version>
<aspectj.version>1.6.12</aspectj.version>

View File

@@ -124,12 +124,13 @@
<org.mockito.version>1.8.4</org.mockito.version>
<org.slf4j.version>1.6.1</org.slf4j.version>
<org.springframework.version>3.0.6.RELEASE</org.springframework.version>
<data.commons.version>1.2.0.M2</data.commons.version>
<neo4j.version>1.5</neo4j.version>
<data.commons.version>1.2.0.RC1</data.commons.version>
<neo4j.version>1.6.M02</neo4j.version>
<neo4j.spatial.version>0.7-SNAPSHOT</neo4j.spatial.version>
<aspectj.version>1.6.12</aspectj.version>
<blueprints.version>1.0</blueprints.version>
<gremlin.version>1.3</gremlin.version>
<blueprints.version>1.1</blueprints.version>
<gremlin.version>1.4</gremlin.version>
<pipes.version>1.4</pipes.version>
</properties>
<profiles>
<profile>
@@ -334,6 +335,61 @@
</dependency>
<dependency>
<groupId>com.tinkerpop.gremlin</groupId>
<artifactId>gremlin-groovy</artifactId>
<version>${gremlin.version}</version>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ha</artifactId>
</exclusion>
<exclusion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-management</artifactId>
</exclusion>
<!-- Sail support not needed -->
<exclusion>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-sail-graph</artifactId>
</exclusion>
<!-- Maven support in groovy not needed -->
<exclusion>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
</exclusion>
<!-- "readline" not needed - we only expose gremlin through webadmin -->
<exclusion>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-neo4j-graph</artifactId>
<version>${blueprints.version}</version>
<exclusions>
<exclusion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ha</artifactId>
</exclusion>
<exclusion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-management</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-core</artifactId>
@@ -348,8 +404,8 @@
</dependency>
<dependency>
<groupId>com.tinkerpop</groupId>
<artifactId>gremlin</artifactId>
<groupId>com.tinkerpop.gremlin</groupId>
<artifactId>gremlin-groovy</artifactId>
<version>${gremlin.version}</version>
<optional>true</optional>
</dependency>
@@ -410,7 +466,7 @@
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher-dsl</artifactId>
<version>${neo4j.version}</version>
<version>1.5</version>
<!--optional>true</optional-->
</dependency>
<!--dependency>
@@ -435,6 +491,12 @@
<groupId>org.neo4j</groupId>
<artifactId>neo4j-spatial</artifactId>
<version>${neo4j.spatial.version}</version>
<exclusions>
<exclusion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>

View File

@@ -76,7 +76,7 @@
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-rest-graphdb</artifactId>
<version>1.5</version>
<version>1.6-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.neo4j</groupId>
@@ -178,8 +178,8 @@
</dependency>
<dependency>
<groupId>com.tinkerpop</groupId>
<artifactId>gremlin</artifactId>
<groupId>com.tinkerpop.gremlin</groupId>
<artifactId>gremlin-groovy</artifactId>
<optional>true</optional>
</dependency>

View File

@@ -23,7 +23,6 @@ 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.AddressResolver;
import org.neo4j.server.Bootstrapper;
import org.neo4j.server.NeoServerWithEmbeddedWebServer;
import org.neo4j.server.configuration.PropertyFileConfigurator;
@@ -38,7 +37,6 @@ import org.neo4j.server.web.Jetty6WebServer;
import org.neo4j.test.ImpermanentGraphDatabase;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.Arrays;
@@ -78,11 +76,7 @@ public class LocalTestServer {
return new GraphDatabaseFactory() {
@Override
public AbstractGraphDatabase createDatabase(String databaseStoreDirectory, Map<String, String> databaseProperties) {
try {
return new ImpermanentGraphDatabase();
} catch (IOException e) {
throw new RuntimeException(e);
}
return new ImpermanentGraphDatabase();
}
};
}
@@ -97,12 +91,6 @@ public class LocalTestServer {
return serverModules;
}
};
final AddressResolver addressResolver = new AddressResolver() {
@Override
public String getHostname() {
return hostname;
}
};
final JettyStartupListener startupListener = new JettyStartupListener();
final Jetty6WebServer jettyWebServer = new Jetty6WebServer() {
@Override
@@ -123,8 +111,7 @@ public class LocalTestServer {
super.stop();
}
};
neoServer = new NeoServerWithEmbeddedWebServer(bootstrapper
, addressResolver, new StartupHealthCheck(), new PropertyFileConfigurator(new File(url.getPath())), jettyWebServer, serverModules) {
neoServer = new NeoServerWithEmbeddedWebServer(bootstrapper, new StartupHealthCheck(), new PropertyFileConfigurator(new File(url.getPath())), jettyWebServer, serverModules) {
@Override
protected int getWebServerPort() {
return port;

View File

@@ -177,8 +177,8 @@
</dependency>
<dependency>
<groupId>com.tinkerpop</groupId>
<artifactId>gremlin</artifactId>
<groupId>com.tinkerpop.gremlin</groupId>
<artifactId>gremlin-groovy</artifactId>
<optional>true</optional>
</dependency>

View File

@@ -43,6 +43,11 @@ public class NodeGraphRepositoryImpl<T> extends AbstractGraphRepository<Node, T>
return template.createRelationshipBetween(start,end,relationshipEntityClass,relationshipType,false);
}
@Override
public <R> R createDuplicateRelationshipBetween(T start, Object end, Class<R> relationshipEntityClass, String relationshipType) {
return template.createRelationshipBetween(start,end,relationshipEntityClass,relationshipType,true);
}
@Override
public <R> R getRelationshipBetween(T start, Object end, Class<R> relationshipEntityClass, String relationshipType) {
return template.getRelationshipBetween(start,end,relationshipEntityClass,relationshipType);

View File

@@ -21,6 +21,7 @@ package org.springframework.data.neo4j.repository;
*/
public interface RelationshipOperationsRepository<T> {
<R> R createRelationshipBetween(T start, Object end, Class<R> relationshipEntityClass, String relationshipType);
<R> R createDuplicateRelationshipBetween(T start, Object end, Class<R> relationshipEntityClass, String relationshipType);
<R> R getRelationshipBetween(T start, Object end, Class<R> relationshipEntityClass, String relationshipType);
void deleteRelationshipBetween(T start, Object end, String type);
}

View File

@@ -83,13 +83,7 @@ public class SourceStateTransmitter<S extends PropertyContainer> {
}
private <T> T getProperty(BeanWrapper<Neo4jPersistentEntity<Object>, Object> wrapper, Neo4jPersistentProperty property, Class<T> type, boolean fieldAccessOnly) {
try {
return wrapper.getProperty(property, type, fieldAccessOnly);
} catch (IllegalAccessException e) {
throw new MappingException("Error retrieving property " + property.getName() + " from " + wrapper.getBean(), e);
} catch (InvocationTargetException e) {
throw new MappingException("Error retrieving property " + property.getName() + " from " + wrapper.getBean(), e.getTargetException());
}
return wrapper.getProperty(property, type, fieldAccessOnly);
}
private <R> Object getProperty(BeanWrapper<Neo4jPersistentEntity<R>, R> wrapper, Neo4jPersistentProperty property) {

View File

@@ -38,7 +38,7 @@ public class GremlinExecutor {
private volatile ScriptEngine engine;
private ScriptEngine createScriptEngine() {
return new ScriptEngineManager().getEngineByName("gremlin");
return new ScriptEngineManager().getEngineByName("gremlin-groovy");
}
private static final AtomicInteger executionCount = new AtomicInteger();
@@ -62,7 +62,7 @@ public class GremlinExecutor {
private Bindings createBindings(Map<String, Object> params) {
final Bindings bindings = new SimpleBindings();
bindings.put(GRAPH_VARIABLE, new Neo4jGraph(graphDatabaseService));
bindings.put(GRAPH_VARIABLE, new Neo4jGraph(graphDatabaseService,false));
if (params==null) return bindings;
for (Map.Entry<String, Object> entry : params.entrySet()) {
bindings.put(entry.getKey(),entry.getValue());

View File

@@ -18,9 +18,11 @@ package org.springframework.data.neo4j.transaction;
import org.neo4j.helpers.Service;
import org.neo4j.kernel.impl.core.KernelPanicEventGenerator;
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.util.StringLogger;
import org.springframework.beans.factory.annotation.Configurable;
@Configurable
@@ -33,7 +35,7 @@ public class SpringProvider extends TransactionManagerProvider
}
@Override
protected AbstractTransactionManager loadTransactionManager(String s, KernelPanicEventGenerator kernelPanicEventGenerator, TxHook txHook) {
protected AbstractTransactionManager loadTransactionManager(String s, KernelPanicEventGenerator kernelPanicEventGenerator, TxHook txHook, StringLogger stringLogger, FileSystemAbstraction fileSystemAbstraction) {
return new SpringServiceImpl();
}
}

View File

@@ -108,7 +108,7 @@ public class DataGraphNamespaceHandlerTest {
Neo4jTemplate template = config.neo4jTemplate;
Assert.assertNotNull("template", template);
AbstractGraphDatabase graphDatabaseService = (AbstractGraphDatabase) template.getGraphDatabaseService();
Assert.assertEquals("store-dir", "target/config-test", graphDatabaseService.getStoreDir());
Assert.assertTrue("store-dir", graphDatabaseService.getStoreDir().endsWith("target/config-test"));
Assert.assertNotNull("graphDatabaseService",config.graphDatabaseService);
Assert.assertNotNull("transactionManager",config.transactionManager);
config.graphDatabaseService.shutdown();

View File

@@ -16,8 +16,7 @@
package org.springframework.data.neo4j.model;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.*;
import org.springframework.data.neo4j.annotation.*;
import org.springframework.data.neo4j.fieldaccess.DynamicProperties;
import org.springframework.data.neo4j.support.index.IndexType;
@@ -33,6 +32,7 @@ import java.util.Map;
public class Person {
public static final String NAME_INDEX = "name_index";
public static final org.neo4j.graphdb.RelationshipType KNOWS = DynamicRelationshipType.withName("knows");
@GraphId
private Long graphId;
@@ -86,7 +86,7 @@ public class Person {
@Query("start person=node({self}) match (person)<-[:persons]-(team)-[:persons]->(member) return member")
private Iterable<Person> otherTeamMembers;
@Query("start person=node({self}) match (person)<-[:persons]-(team)-[:persons]->(member) return member.name, member.age")
@Query("start person=node({self}) match (person)<-[:persons]-(team)-[:persons]->(member) return member.name?, member.age?")
private Iterable<Map<String,Object>> otherTeamMemberData;
public Person(Node n) {

View File

@@ -22,6 +22,7 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.neo4j.graphdb.Node;
import org.neo4j.helpers.collection.IteratorUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@@ -46,14 +47,13 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.*;
import static org.junit.internal.matchers.IsCollectionContaining.hasItem;
import static org.junit.internal.matchers.IsCollectionContaining.hasItems;
import static org.neo4j.helpers.collection.IteratorUtil.addToCollection;
@@ -145,7 +145,7 @@ public class GraphRepositoryTest {
assertThat( asCollection( teamMembers ), hasItems( testTeam.michael, testTeam.david, testTeam.emil ) );
}
@Test @Transactional
@Test @Transactional
public void testFindIterableOfPersonWithQueryAnnotationSpatial() {
Iterable<Person> teamMembers = personRepository.findWithinBoundingBox("personLayer", 55, 15, 57, 17);
assertThat(asCollection(teamMembers), hasItems(testTeam.michael, testTeam.david));
@@ -224,7 +224,7 @@ public class GraphRepositoryTest {
@Test @Transactional
public void testFindSortedNull() {
Iterable<Person> teamMembers = personRepository.findAllTeamMembersSorted(testTeam.sdg, null);
Collection<Person> teamMembers = IteratorUtil.asCollection(personRepository.findAllTeamMembersSorted(testTeam.sdg, null));
assertThat(teamMembers, hasItems(testTeam.michael, testTeam.emil, testTeam.david));
}
@@ -266,4 +266,11 @@ public class GraphRepositoryTest {
assertEquals(2, IteratorUtil.count(loaded.getFriendships()));
assertThat(loaded.getFriendships(),hasItem(friendship));
}
@Test @Transactional
public void testCreateDuplicateRelationship() {
assertEquals(1, IteratorUtil.count(neo4jTemplate.<Node>getPersistentState(testTeam.michael).getRelationships(Person.KNOWS)));
personRepository.createDuplicateRelationshipBetween(testTeam.michael, testTeam.david, Friendship.class, "knows");
assertEquals(2, IteratorUtil.count(neo4jTemplate.<Node>getPersistentState(testTeam.michael).getRelationships(Person.KNOWS)));
}
}

View File

@@ -34,7 +34,7 @@ import java.util.Map;
* @author Oliver Gierke
* @since 29.03.11
*/
public interface PersonRepository extends GraphRepository<Person>, NamedIndexRepository<Person>, SpatialRepository<Person>, PersonRepositoryFriendship, CypherDslRepository<Person> {
public interface PersonRepository extends GraphRepository<Person>, NamedIndexRepository<Person>, SpatialRepository<Person>, PersonRepositoryFriendship, CypherDslRepository<Person>, RelationshipOperationsRepository<Person> {
@Query("start team=node({p_team}) match (team)-[:persons]->(member) return member")
Iterable<Person> findAllTeamMembers(@Param("p_team") Group team);

View File

@@ -17,6 +17,7 @@ package org.springframework.data.neo4j.support;
import org.junit.Before;
import org.junit.Test;
import org.junit.internal.matchers.IsCollectionContaining;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.neo4j.graphdb.*;
@@ -307,9 +308,9 @@ public class EntityNeo4jTemplateTest extends EntityTestBase {
assertEquals(friendship.getId(),(Long)getNodeState(testTeam.david).getSingleRelationship(KNOWS, OUTGOING).getId());
final List<Friendship> friendships = IteratorUtil.addToCollection(friendshipRepository.findAll(), new ArrayList<Friendship>());
assertEquals(2,friendships.size());
assertEquals(testTeam.friendShip,friendships.get(0));
assertEquals(friendship,friendships.get(1));
assertThat(friendships, IsCollectionContaining.hasItems(testTeam.friendShip, friendship));
}
@Test @Transactional
public void testCreateDuplicateRelationshipBetweenNodes() throws Exception {
neo4jOperations.createRelationshipBetween(testTeam.michael, testTeam.david, Friendship.class, "knows", true);

View File

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 121 KiB

View File

@@ -193,7 +193,7 @@
name can be split into its semantic parts and converted into a cypher query.
<code>@Indexed</code> fields will be converted into index-lookups of the <code>start</code> clause,
navigation along relationships will be reflected in the <code>match</code> clause properties with operators will end up as expressions in the
<code>where</code> clause. Order and limiting of the query will by handled by provided <code>Pageable</code> or <Sort></Sort> parameters.
<code>where</code> clause. Order and limiting of the query will by handled by provided <code>Pageable</code> or <code>Sort</code> parameters.
The other parameters will be used in the order they appear in the method signature so that should align with the expressions stated in the method name.
</para>
<para>