made all tests of all modules green again

fixed cross store tests, mainly configuration, moved missing config files
fixed rest tests, update to new index query, update gremlin plugin parameters
This commit is contained in:
Michael Hunger
2011-10-02 23:53:25 +02:00
parent 479e72c8f7
commit be66f16dfd
23 changed files with 173 additions and 61 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
ajcore*
.idea
*.log
.DS_Store

View File

@@ -49,6 +49,7 @@ public class TestTeam {
sdg.addPerson(michael);
sdg.addPerson(emil);
sdg.addPerson(david);
sdg.persist();
}
public Map<String, Object> simpleRowFor(final Person person, String prefix) {

View File

@@ -27,6 +27,7 @@ import org.springframework.core.convert.ConversionService;
import org.springframework.data.neo4j.Person;
import org.springframework.data.neo4j.Personality;
import org.springframework.data.neo4j.annotation.QueryType;
import org.springframework.data.neo4j.conversion.QueryResult;
import org.springframework.data.neo4j.conversion.ResultConverter;
import org.springframework.data.neo4j.core.GraphDatabase;
import org.springframework.data.neo4j.core.NodeBacked;
@@ -96,7 +97,8 @@ public class QueryEngineTest {
@Test
public void testQueryListOfTypeNode() throws Exception {
final String queryString = "start person=(name_index,name,\"%name\") match (person) <-[:boss]- (boss) return boss";
final Collection<Node> result = IteratorUtil.asCollection(queryEngine.query(queryString, michaelsName()).to(Node.class));
final QueryResult<Map<String,Object>> queryResult = queryEngine.query(queryString, michaelsName());
final Collection<Node> result = IteratorUtil.asCollection(queryResult.to(Node.class));
assertEquals(asList(nodeFor(testTeam.emil)),result);
}

View File

@@ -86,6 +86,35 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>server-api</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-core</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-neo4j-graph</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.tinkerpop</groupId>
<artifactId>gremlin</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
@@ -205,6 +234,10 @@
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
<aspectLibrary>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
<source>1.6</source>
<target>1.6</target>

View File

@@ -1,3 +1,18 @@
/**
* Copyright 2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.config;
import org.neo4j.graphdb.Node;
@@ -9,7 +24,7 @@ import org.springframework.data.neo4j.support.EntityInstantiator;
import org.springframework.data.neo4j.support.node.CrossStoreNodeEntityStateFactory;
import org.springframework.data.neo4j.support.node.NodeEntityInstantiator;
import org.springframework.data.neo4j.support.node.NodeEntityStateFactory;
import org.springframework.data.neo4j.support.node.PartialNodeEntityInstantiator;
import org.springframework.data.neo4j.support.node.CrossStoreNodeEntityInstantiator;
import org.springframework.data.neo4j.transaction.ChainedTransactionManager;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
@@ -43,9 +58,9 @@ public class CrossStoreNeo4jConfiguration extends Neo4jAspectConfiguration {
@Bean
protected EntityInstantiator<Node> graphEntityInstantiator() {
if (isUsingCrossStorePersistence()) {
return new PartialNodeEntityInstantiator(new NodeEntityInstantiator(mappingContext), entityManagerFactory);
return new CrossStoreNodeEntityInstantiator(new NodeEntityInstantiator(entityStateHandler()), entityManagerFactory);
} else {
return new NodeEntityInstantiator(mappingContext);
return new NodeEntityInstantiator(entityStateHandler());
}
}

View File

@@ -17,6 +17,7 @@
package org.springframework.data.neo4j.support.node;
import org.neo4j.graphdb.Node;
import org.springframework.data.neo4j.core.NodeBacked;
import org.springframework.data.neo4j.support.EntityInstantiator;
import org.springframework.orm.jpa.EntityManagerFactoryUtils;
@@ -29,13 +30,13 @@ import javax.persistence.EntityManagerFactory;
* @author Michael Hunger
* @since 02.10.2010
*/
public class PartialNodeEntityInstantiator implements EntityInstantiator<Node> {
public class CrossStoreNodeEntityInstantiator implements EntityInstantiator<Node> {
private final NodeEntityInstantiator delegate;
private EntityManagerFactory entityManagerFactory;
public PartialNodeEntityInstantiator(NodeEntityInstantiator delegate, EntityManagerFactory entityManagerFactory) {
public CrossStoreNodeEntityInstantiator(NodeEntityInstantiator delegate, EntityManagerFactory entityManagerFactory) {
this.delegate = delegate;
this.entityManagerFactory = entityManagerFactory;
}
@@ -50,10 +51,10 @@ public class PartialNodeEntityInstantiator implements EntityInstantiator<Node> {
* @return
*/
public <T> T createEntityFromState(Node n, Class<T> entityClass) {
if (n.hasProperty(PartialNodeEntityState.FOREIGN_ID)) {
final Object foreignId = n.getProperty(PartialNodeEntityState.FOREIGN_ID);
if (n.hasProperty(CrossStoreNodeEntityState.FOREIGN_ID)) {
final Object foreignId = n.getProperty(CrossStoreNodeEntityState.FOREIGN_ID);
final T result = entityManager().find(entityClass, foreignId);
result.setPersistentState(n);
((NodeBacked)result).setPersistentState(n);
return result;
}
return delegate.createEntityFromState(n, entityClass);

View File

@@ -38,7 +38,7 @@ import java.util.Collection;
* @author Michael Hunger
* @since 21.09.2010
*/
public class PartialNodeEntityState<ENTITY extends NodeBacked> extends DefaultEntityState<ENTITY, Node> {
public class CrossStoreNodeEntityState<ENTITY extends NodeBacked> extends DefaultEntityState<Node> {
public static final String FOREIGN_ID = "foreignId";
public static final String FOREIGN_ID_INDEX = "foreign_id";
@@ -46,7 +46,7 @@ public class PartialNodeEntityState<ENTITY extends NodeBacked> extends DefaultEn
private final GraphDatabaseContext graphDatabaseContext;
private PersistenceUnitUtil persistenceUnitUtil;
public PartialNodeEntityState(final Node underlyingState, final ENTITY entity, final Class<? extends ENTITY> type, final GraphDatabaseContext graphDatabaseContext, PersistenceUnitUtil persistenceUnitUtil, final PartialNodeDelegatingFieldAccessorFactory delegatingFieldAccessorFactory, final Neo4jPersistentEntity<ENTITY> persistentEntity) {
public CrossStoreNodeEntityState(final Node underlyingState, final ENTITY entity, final Class<? extends ENTITY> type, final GraphDatabaseContext graphDatabaseContext, PersistenceUnitUtil persistenceUnitUtil, final CrossStoreNodeDelegatingFieldAccessorFactory delegatingFieldAccessorFactory, final Neo4jPersistentEntity persistentEntity) {
super(underlyingState, entity, type, delegatingFieldAccessorFactory, persistentEntity);
this.graphDatabaseContext = graphDatabaseContext;
this.persistenceUnitUtil = persistenceUnitUtil;
@@ -55,6 +55,7 @@ public class PartialNodeEntityState<ENTITY extends NodeBacked> extends DefaultEn
// TODO handle non persisted Entity like running outside of an transaction
@Override
public void createAndAssignState() {
@SuppressWarnings("unchecked") ENTITY entity = (ENTITY) this.entity;
if (entity.getPersistentState() != null) return;
try {
final Object id = getId(entity);
@@ -77,17 +78,18 @@ public class PartialNodeEntityState<ENTITY extends NodeBacked> extends DefaultEn
}
}
@SuppressWarnings("unchecked")
@Override
public ENTITY persist() {
if (getPersistentState() == null) {
createAndAssignState();
}
return entity;
return (ENTITY) entity;
}
@Override
public boolean isWritable(Field field) {
final FieldAccessor<ENTITY> accessor = accessorFor(property(field));
final FieldAccessor accessor = accessorFor(property(field));
if (accessor == null) return false; // difference to default behaviour, we don't care for non-managed fields here
return accessor.isWriteable(entity);
}
@@ -112,15 +114,15 @@ public class PartialNodeEntityState<ENTITY extends NodeBacked> extends DefaultEn
return persistenceUnitUtil!=null ? persistenceUnitUtil.getIdentifier(entity) : null;
}
public static class PartialNodeDelegatingFieldAccessorFactory extends DelegatingFieldAccessorFactory {
public static class CrossStoreNodeDelegatingFieldAccessorFactory extends DelegatingFieldAccessorFactory {
public PartialNodeDelegatingFieldAccessorFactory(GraphDatabaseContext graphDatabaseContext) {
public CrossStoreNodeDelegatingFieldAccessorFactory(GraphDatabaseContext graphDatabaseContext) {
super(graphDatabaseContext);
}
@Override
protected Collection<FieldAccessorListenerFactory<?>> createListenerFactories() {
return Arrays.<FieldAccessorListenerFactory<?>>asList(
protected Collection<FieldAccessorListenerFactory> createListenerFactories() {
return Arrays.asList(
new IndexingPropertyFieldAccessorListenerFactory(
getGraphDatabaseContext(),
newPropertyFieldAccessorFactory(),
@@ -134,12 +136,12 @@ public class PartialNodeEntityState<ENTITY extends NodeBacked> extends DefaultEn
}
@Override
protected Collection<? extends FieldAccessorFactory<?>> createAccessorFactories() {
return Arrays.<FieldAccessorFactory<?>>asList(
protected Collection<? extends FieldAccessorFactory> createAccessorFactories() {
return Arrays.asList(
//new IdFieldAccessorFactory(),
//new TransientFieldAccessorFactory(),
new TraversalFieldAccessorFactory(),
new QueryFieldAccessorFactory(),
new TraversalFieldAccessorFactory(graphDatabaseContext),
new QueryFieldAccessorFactory(graphDatabaseContext),
newPropertyFieldAccessorFactory(),
newConvertingNodePropertyFieldAccessorFactory(),
new SingleRelationshipFieldAccessorFactory(getGraphDatabaseContext()) {
@@ -155,7 +157,7 @@ public class PartialNodeEntityState<ENTITY extends NodeBacked> extends DefaultEn
}
private ConvertingNodePropertyFieldAccessorFactory newConvertingNodePropertyFieldAccessorFactory() {
return new ConvertingNodePropertyFieldAccessorFactory(getGraphDatabaseContext().getConversionService()) {
return new ConvertingNodePropertyFieldAccessorFactory(getGraphDatabaseContext()) {
@Override
public boolean accept(Neo4jPersistentProperty property) {
return property.isAnnotationPresent(GraphProperty.class) && super.accept(property);
@@ -164,10 +166,10 @@ public class PartialNodeEntityState<ENTITY extends NodeBacked> extends DefaultEn
}
private PropertyFieldAccessorFactory newPropertyFieldAccessorFactory() {
return new PropertyFieldAccessorFactory(getGraphDatabaseContext().getConversionService()) {
return new PropertyFieldAccessorFactory(getGraphDatabaseContext()) {
@Override
public boolean accept(Neo4jPersistentProperty f) {
return f.isAnnotationPresent(GraphProperty.class) && super.accept(f);
public boolean accept(Neo4jPersistentProperty property) {
return property.isAnnotationPresent(GraphProperty.class) && super.accept(property);
}
};
}

View File

@@ -1,3 +1,18 @@
/**
* Copyright 2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.neo4j.support.node;
import org.neo4j.graphdb.Node;
@@ -16,15 +31,15 @@ import javax.persistence.PersistenceUnitUtil;
* @since 30.09.11
*/
public class CrossStoreNodeEntityStateFactory extends NodeEntityStateFactory {
private PartialNodeEntityState.PartialNodeDelegatingFieldAccessorFactory delegatingFieldAccessorFactory;
private CrossStoreNodeEntityState.CrossStoreNodeDelegatingFieldAccessorFactory delegatingFieldAccessorFactory;
private EntityManagerFactory entityManagerFactory;
public EntityState<Node> getEntityState(final NodeBacked entity) {
public EntityState<Node> getEntityState(final Object entity) {
final Class<?> entityType = entity.getClass();
final NodeEntity graphEntityAnnotation = entityType.getAnnotation(NodeEntity.class); // todo cache ??
final Neo4jPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(entityType);
if (graphEntityAnnotation.partial()) {
final PartialNodeEntityState<NodeBacked> partialNodeEntityState = new PartialNodeEntityState<NodeBacked>(null, entity, entityType, graphDatabaseContext, getPersistenceUnitUtils(), delegatingFieldAccessorFactory, (Neo4jPersistentEntity<NodeBacked>) persistentEntity);
final CrossStoreNodeEntityState<NodeBacked> partialNodeEntityState = new CrossStoreNodeEntityState<NodeBacked>(null, (NodeBacked)entity, (Class<? extends NodeBacked>) entityType, graphDatabaseContext, getPersistenceUnitUtils(), delegatingFieldAccessorFactory, persistentEntity);
return new DetachedEntityState<Node>(partialNodeEntityState, graphDatabaseContext) {
@Override
protected boolean isDetached() {
@@ -32,14 +47,14 @@ public class CrossStoreNodeEntityStateFactory extends NodeEntityStateFactory {
}
};
} else {
NodeEntityState<NodeBacked> nodeEntityState = new NodeEntityState<NodeBacked>(null, entity, entityType, graphDatabaseContext, nodeDelegatingFieldAccessorFactory, (Neo4jPersistentEntity<NodeBacked>) persistentEntity);
NodeEntityState nodeEntityState = new NodeEntityState(null, entity, entityType, graphDatabaseContext, nodeDelegatingFieldAccessorFactory, (Neo4jPersistentEntity) persistentEntity);
// alternative was return new NestedTransactionEntityState<NodeBacked, Node>(nodeEntityState,graphDatabaseContext);
return new DetachedEntityState<Node>(nodeEntityState, graphDatabaseContext);
}
}
private PersistenceUnitUtil getPersistenceUnitUtils() {
if (entityManagerFactory == null) return null;
if (entityManagerFactory == null|| !entityManagerFactory.isOpen()) return null;
return entityManagerFactory.getPersistenceUnitUtil();
}
@@ -49,7 +64,7 @@ public class CrossStoreNodeEntityStateFactory extends NodeEntityStateFactory {
@PostConstruct
private void setUp() {
this.delegatingFieldAccessorFactory = new PartialNodeEntityState.PartialNodeDelegatingFieldAccessorFactory(graphDatabaseContext);
this.delegatingFieldAccessorFactory = new CrossStoreNodeEntityState.CrossStoreNodeDelegatingFieldAccessorFactory(graphDatabaseContext);
}
}

View File

@@ -24,6 +24,6 @@
<property name="password" value=""/>
</bean>
<bean id="config" class="org.springframework.data.neo4j.config.DataGraphNamespaceHandlerTest$Config"/>
<bean id="config" class="org.springframework.data.neo4j.config.DataGraphNamespaceHandlerCrossStoreTest$Config"/>
</beans>

View File

@@ -93,15 +93,24 @@
</property>
<property name="nodeTypeRepresentationStrategy" ref="nodeTypeRepresentationStrategy"/>
<property name="relationshipTypeRepresentationStrategy" ref="relationshipTypeRepresentationStrategy"/>
<property name="entityStateHandler" ref="entityStateHandler"/>
<property name="mappingContext" ref="mappingContext"/>
</bean>
<bean id="graphEntityInstantiator" class="org.springframework.data.neo4j.support.node.PartialNodeEntityInstantiator">
<constructor-arg>
<bean class="org.springframework.data.neo4j.support.node.NodeEntityInstantiator" />
</constructor-arg>
<bean id="graphEntityInstantiator" class="org.springframework.data.neo4j.support.node.CrossStoreNodeEntityInstantiator">
<constructor-arg ref="nodeEntityInstantiator"/>
<constructor-arg ref="entityManagerFactory"/>
</bean>
<bean id="relationshipEntityInstantiator"
class="org.springframework.data.neo4j.support.relationship.RelationshipEntityInstantiator"/>
<bean id="entityStateHandler" class="org.springframework.data.neo4j.support.EntityStateHandler">
<constructor-arg ref="mappingContext"/>
<constructor-arg ref="graphDatabaseService"/>
</bean>
<bean id="relationshipEntityInstantiator" class="org.springframework.data.neo4j.support.relationship.RelationshipEntityInstantiator">
<constructor-arg ref="entityStateHandler"/>
</bean>
<bean id="nodeEntityInstantiator" class="org.springframework.data.neo4j.support.node.NodeEntityInstantiator">
<constructor-arg ref="entityStateHandler"/>
</bean>
<bean id="typeRepresentationStrategyFactory" class="org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory">
<constructor-arg ref="graphDatabaseService"/>
@@ -112,7 +121,7 @@
<bean id="nodeTypeRepresentationStrategy" factory-bean="typeRepresentationStrategyFactory" factory-method="getNodeTypeRepresentationStrategy" />
<bean id="relationshipTypeRepresentationStrategy" factory-bean="typeRepresentationStrategyFactory" factory-method="getRelationshipTypeRepresentationStrategy"/>
<bean id="nodeEntityStateFactory" class="org.springframework.data.neo4j.support.node.NodeEntityStateFactory">
<bean id="nodeEntityStateFactory" class="org.springframework.data.neo4j.support.node.CrossStoreNodeEntityStateFactory">
<property name="nodeDelegatingFieldAccessorFactory">
<bean class="org.springframework.data.neo4j.fieldaccess.NodeDelegatingFieldAccessorFactory">
<constructor-arg ref="graphDatabaseContext"/>

View File

@@ -127,8 +127,8 @@
<data.commons.version>1.2.0.BUILD-SNAPSHOT</data.commons.version>
<neo4j.version>1.5-SNAPSHOT</neo4j.version>
<aspectj.version>1.6.12.M1</aspectj.version>
<blueprints.version>0.8</blueprints.version>
<gremlin.version>1.1</gremlin.version>
<blueprints.version>1.0</blueprints.version>
<gremlin.version>1.3</gremlin.version>
</properties>
<profiles>
<profile>

View File

@@ -9,6 +9,7 @@
</parent>
<artifactId>spring-data-neo4j-rest</artifactId>
<packaging>jar</packaging>
<version>2.0.0.BUILD-SNAPSHOT</version>
<name>Spring Data Neo4j REST Wrapper</name>
<description><![CDATA[Spring Data Neo4j Wrapper for the Neo4j REST API, provides a Graph Database proxy for the remote invocation.
]]></description>
@@ -36,9 +37,10 @@
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<artifactId>spring-data-neo4j-aspects</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -123,6 +125,24 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-core</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-neo4j-graph</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.tinkerpop</groupId>
<artifactId>gremlin</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>

View File

@@ -44,8 +44,8 @@ public class RestGremlinQueryEngine implements QueryEngine<Object> {
@Override
public QueryResult<Object> query(String statement, Map<String, Object> params) {
final String paramsString = JsonHelper.createJsonFrom(params == null ? Collections.emptyMap() : params);
final String data = JsonHelper.createJsonFrom(MapUtil.map("script", statement,"params",paramsString));
//final String paramsString = JsonHelper.createJsonFrom(params == null ? Collections.emptyMap() : params);
final String data = JsonHelper.createJsonFrom(MapUtil.map("script", statement,"params",params));
final RequestResult requestResult = restRequest.get("ext/GremlinPlugin/graphdb/execute_script", data);
final Object result = JsonHelper.readJson(requestResult.getEntity());
if (requestResult.getStatus() == 500) {

View File

@@ -20,8 +20,9 @@ package org.springframework.data.neo4j.rest.index;
import org.neo4j.graphdb.PropertyContainer;
import org.neo4j.graphdb.index.Index;
import org.neo4j.graphdb.index.IndexHits;
import org.neo4j.helpers.collection.MapUtil;
import org.neo4j.index.lucene.ValueContext;
import org.springframework.data.neo4j.rest.*;
import org.springframework.data.neo4j.support.*;
import java.util.Collection;
import java.util.Collections;
@@ -53,7 +54,12 @@ public abstract class RestIndex<T extends PropertyContainer> implements Index<T>
public void add( T entity, String key, Object value ) {
String uri = ( (RestEntity) entity ).getUri();
restRequest.post(indexPath(key, value), JsonHelper.createJsonFrom(uri));
if (value instanceof ValueContext) {
value = ((ValueContext)value).getCorrectValue();
}
final Map<String, Object> data = MapUtil.map("key", key, "value", value, "uri", uri);
final RequestResult result = restRequest.post(indexPath(), JsonHelper.createJsonFrom(data));
if (result.getStatus()!=201) throw new RestResultException(restRequest.toMap(result));
}
protected String indexPath( ) {
@@ -87,6 +93,11 @@ public abstract class RestIndex<T extends PropertyContainer> implements Index<T>
restRequest.delete( indexPath( ));
}
@Override
public boolean isWriteable() {
return true;
}
public IndexHits<T> get( String key, Object value ) {
return query( key, value );
}
@@ -156,5 +167,6 @@ public abstract class RestIndex<T extends PropertyContainer> implements Index<T>
public void remove() {
}
}
}

View File

@@ -24,7 +24,6 @@ import org.codehaus.jackson.map.ObjectMapper;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.data.neo4j.Person;
import org.springframework.data.neo4j.Person;
import org.springframework.data.neo4j.rest.RequestResult;
import org.springframework.data.neo4j.server.ProvidedClassPathXmlApplicationContext;

View File

@@ -16,12 +16,12 @@
package org.springframework.data.neo4j.core;
import java.lang.reflect.Field;
import org.springframework.data.neo4j.fieldaccess.FieldAccessor;
import org.springframework.data.neo4j.mapping.Neo4jPersistentEntity;
import org.springframework.data.neo4j.mapping.Neo4jPersistentProperty;
import java.lang.reflect.Field;
/**
* Interface for classes encapsulating and delegating read and write field access of an GraphBacked entity to a number of field accessors.
* Wraps the entity, the underlying state and also handles the creation of the state (call back).
@@ -72,5 +72,5 @@ public interface EntityState<STATE> {
Object persist();
Neo4jPersistentEntity<Object> getPersistentEntity();
Neo4jPersistentEntity<?> getPersistentEntity();
}

View File

@@ -40,9 +40,9 @@ public abstract class DefaultEntityState<STATE> implements EntityState<STATE> {
private STATE state;
protected final static Log log= LogFactory.getLog(DefaultEntityState.class);
private final FieldAccessorFactoryProviders<Object> fieldAccessorFactoryProviders;
private final Neo4jPersistentEntity<Object> persistentEntity;
private final Neo4jPersistentEntity<?> persistentEntity;
public DefaultEntityState(final STATE underlyingState, final Object entity, final Class<? extends Object> type, final DelegatingFieldAccessorFactory delegatingFieldAccessorFactory, Neo4jPersistentEntity<Object> persistentEntity) {
public DefaultEntityState(final STATE underlyingState, final Object entity, final Class<? extends Object> type, final DelegatingFieldAccessorFactory delegatingFieldAccessorFactory, Neo4jPersistentEntity<?> persistentEntity) {
this.state = underlyingState;
this.entity = entity;
this.type = type;
@@ -79,7 +79,7 @@ public abstract class DefaultEntityState<STATE> implements EntityState<STATE> {
return state;
}
public Neo4jPersistentEntity<Object> getPersistentEntity() {
public Neo4jPersistentEntity<?> getPersistentEntity() {
return persistentEntity;
}

View File

@@ -20,15 +20,12 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.neo4j.graphdb.Transaction;
import org.springframework.data.neo4j.core.EntityState;
import org.springframework.data.neo4j.mapping.Neo4jPersistentEntity;
import org.springframework.data.neo4j.mapping.Neo4jPersistentProperty;
import org.springframework.data.neo4j.support.GraphDatabaseContext;
import org.springframework.util.ObjectUtils;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.HashMap;
import java.util.Map;
@@ -44,7 +41,7 @@ public class DetachedEntityState<STATE> implements EntityState<STATE> {
protected final EntityState<STATE> delegate;
private final static Log log = LogFactory.getLog(DetachedEntityState.class);
private GraphDatabaseContext graphDatabaseContext;
private Neo4jPersistentEntity<Object> persistentEntity;
private Neo4jPersistentEntity<?> persistentEntity;
public DetachedEntityState(final EntityState<STATE> delegate, GraphDatabaseContext graphDatabaseContext) {
this.delegate = delegate;
@@ -73,7 +70,7 @@ public class DetachedEntityState<STATE> implements EntityState<STATE> {
}
@Override
public Neo4jPersistentEntity<Object> getPersistentEntity() {
public Neo4jPersistentEntity<?> getPersistentEntity() {
return persistentEntity;
}

View File

@@ -36,6 +36,7 @@ import org.springframework.data.neo4j.mapping.Neo4jPersistentProperty;
import org.springframework.data.neo4j.support.query.CypherQueryExecutor;
import org.springframework.data.util.TypeInformation;
import javax.annotation.PostConstruct;
import javax.transaction.Status;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
@@ -299,9 +300,13 @@ public class GraphDatabaseContext {
public void setGraphDatabaseService(GraphDatabaseService graphDatabaseService) {
this.graphDatabaseService = graphDatabaseService;
this.cypherQueryExecutor = new CypherQueryExecutor(this);
}
@PostConstruct
public void createCypherExecutor() {
this.cypherQueryExecutor = new CypherQueryExecutor(this);
}
public NodeTypeRepresentationStrategy getNodeTypeRepresentationStrategy() {
return nodeTypeRepresentationStrategy;
}

View File

@@ -30,7 +30,7 @@ public class NodeEntityStateFactory {
protected GraphDatabaseContext graphDatabaseContext;
private DelegatingFieldAccessorFactory nodeDelegatingFieldAccessorFactory;
protected DelegatingFieldAccessorFactory nodeDelegatingFieldAccessorFactory;
protected Neo4jMappingContext mappingContext;

View File

@@ -21,7 +21,7 @@ import com.tinkerpop.blueprints.pgm.Vertex;
import com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jEdge;
import com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jGraph;
import com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jVertex;
import com.tinkerpop.gremlin.pipes.util.Table;
import com.tinkerpop.pipes.util.Table;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.helpers.collection.IterableWrapper;