Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ public interface EntityPersister {
<S extends PropertyContainer, T> T createEntityFromState(S state, Class<T> type);
<S extends PropertyContainer, T> T createEntityFromStoredType(S state);
boolean isNodeEntity(Class<?> targetType);
boolean isRelationshipEntity(Class targetType);
boolean isRelationshipEntity(Class<?> targetType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.springframework.data.neo4j.annotation.QueryType;
import org.springframework.data.neo4j.conversion.QueryResultBuilder;
import org.springframework.data.neo4j.conversion.Result;
import org.springframework.data.neo4j.conversion.ResultConverter;
import org.springframework.data.neo4j.core.GraphDatabase;
import org.springframework.data.neo4j.core.TypeRepresentationStrategy;
import org.springframework.data.neo4j.core.UncategorizedGraphStoreException;
Expand Down Expand Up @@ -96,11 +95,10 @@ public Neo4jTemplate(MappingInfrastructure infrastructure) {


@Override
@SuppressWarnings({"unchecked"})
public <T> GraphRepository<T> repositoryFor(Class<T> clazz) {
notNull(clazz,"entity type");
if (isNodeEntity(clazz)) return new NodeGraphRepository(clazz, this);
if (isRelationshipEntity(clazz)) return new RelationshipGraphRepository(clazz, this);
if (isNodeEntity(clazz)) return new NodeGraphRepository<T>(clazz, this);
if (isRelationshipEntity(clazz)) return new RelationshipGraphRepository<T>(clazz, this);
throw new IllegalArgumentException("Can't create graph repository for non graph entity of type " + clazz);
}

Expand All @@ -120,7 +118,6 @@ public <S extends PropertyContainer, T> Index<S> getIndex(Class<T> type, String
return infrastructure.getIndexProvider().getIndex(type, indexName, null);
}

@SuppressWarnings("unchecked")
public <S extends PropertyContainer, T> Index<S> getIndex(Class<T> type, String indexName, Boolean fullText) {
return infrastructure.getIndexProvider().getIndex(type, indexName, fullText);
}
Expand Down Expand Up @@ -160,11 +157,13 @@ public <T> long count(final Class<T> entityClass) {
return infrastructure.getTypeRepresentationStrategies().count(entityClass);
}

@Override
public <S extends PropertyContainer, T> T createEntityFromStoredType(S state) {
notNull(state,"node or relationship");
return infrastructure.getEntityPersister().createEntityFromStoredType(state);
}

@Override
public <S extends PropertyContainer, T> T createEntityFromState(S state, Class<T> type) {
notNull(state,"node or relationship",type,"entity class");
return infrastructure.getEntityPersister().createEntityFromState(state, type);
Expand All @@ -177,13 +176,11 @@ public <T> T projectTo(Object entity, Class<T> targetType) {
}

@Override
@SuppressWarnings("unchecked")
public <S extends PropertyContainer> S getPersistentState(Object entity) {
notNull(entity,"entity");
return infrastructure.getEntityPersister().getPersistentState(entity);
}

@SuppressWarnings("unchecked")
public <S extends PropertyContainer, T> T setPersistentState(T entity, S state) {
notNull(entity,"entity",state,"node or relationship");
infrastructure.getEntityPersister().setPersistentState(entity, state);
Expand Down Expand Up @@ -231,6 +228,7 @@ public <T> T createNodeAs(Class<T> target, Map<String, Object> properties) {
return convert(node, target);
}

@SuppressWarnings("unused")
private <T> Node createNode(Map<String, Object> properties, Class<T> target, TypeRepresentationStrategy<Node> nodeTypeRepresentationStrategy) {
final Node node = createNode(properties);
if (nodeTypeRepresentationStrategy != null) {
Expand All @@ -242,22 +240,24 @@ private <T> Node createNode(Map<String, Object> properties, Class<T> target, Typ
/**
* Delegates to {@link GraphDatabaseService}
*/
public Transaction beginTx() { // todo remove !
public Transaction beginTx() { // TODO remove !
return infrastructure.getGraphDatabaseService().beginTx();
}

@SuppressWarnings("unused")
@PostConstruct
public Neo4jTemplate postConstruct() {
infrastructure.postConstruct();
return this;
}


@Override
public boolean isNodeEntity(Class<?> targetType) {
return infrastructure.getMappingContext().isNodeEntity(targetType);
}

public boolean isRelationshipEntity(Class targetType) {
@Override
public boolean isRelationshipEntity(Class<?> targetType) {
return infrastructure.getMappingContext().isRelationshipEntity(targetType);
}

Expand Down Expand Up @@ -350,14 +350,14 @@ public <T> T exec(final GraphCallback<T> callback) {

TransactionTemplate template = new TransactionTemplate(infrastructure.getTransactionManager());
return template.execute(new TransactionCallback<T>() {
@Override
public T doInTransaction(TransactionStatus status) {
return doExecute(callback);
}
});
}

@Override
@SuppressWarnings("unchecked")
public Node getReferenceNode() {
try {
return infrastructure.getGraphDatabase().getReferenceNode();
Expand Down Expand Up @@ -408,7 +408,7 @@ public void doWithGraphWithoutResult(GraphDatabase graph) throws Exception {
@Override
@SuppressWarnings("unchecked")
public <T> Result<T> convert(Iterable<T> iterable) {
return new QueryResultBuilder<T>(iterable, (ResultConverter<T, ?>) infrastructure.getResultConverter());
return new QueryResultBuilder<T>(iterable, infrastructure.getResultConverter());
}

@Override
Expand Down