Upgraded Spring Data versions

This commit upgrades the Spring Data versions to the latest snapshots
This commit is contained in:
Michael Minella
2017-04-20 12:24:25 -05:00
parent 3f22b61a66
commit 6f7233222d
6 changed files with 31 additions and 227 deletions

View File

@@ -24,7 +24,6 @@ import org.neo4j.ogm.session.SessionFactory;
import org.springframework.batch.item.ItemReader;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.data.neo4j.template.Neo4jOperations;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -63,7 +62,6 @@ public abstract class AbstractNeo4jItemReader<T> extends
protected Log logger = LogFactory.getLog(getClass());
private Neo4jOperations template;
private SessionFactory sessionFactory;
private String startStatement;
@@ -153,27 +151,6 @@ public abstract class AbstractNeo4jItemReader<T> extends
this.sessionFactory = sessionFactory;
}
/**
* Used to perform operations against the Neo4J database.
*
* @param template the Neo4jOperations instance to use
* @see Neo4jOperations
* @deprecated Use {@link #setSessionFactory(SessionFactory)}
*/
@Deprecated
public void setTemplate(Neo4jOperations template) {
this.template = template;
}
/**
* @return the {@link Neo4jOperations}
* @deprecated Use {@link #getSessionFactory()}
*/
@Deprecated
protected final Neo4jOperations getTemplate() {
return this.template;
}
/**
* The object type to be returned from each call to {@link #read()}
*
@@ -214,8 +191,7 @@ public abstract class AbstractNeo4jItemReader<T> extends
*/
@Override
public void afterPropertiesSet() throws Exception {
Assert.state(template != null || sessionFactory != null,
"A Neo4JOperations implementation or SessionFactory is required");
Assert.state(sessionFactory != null,"A SessionFactory is required");
Assert.state(targetType != null, "The type to be returned is required");
Assert.state(StringUtils.hasText(startStatement), "A START statement is required");
Assert.state(StringUtils.hasText(returnStatement), "A RETURN statement is required");

View File

@@ -21,8 +21,6 @@ import java.util.Iterator;
import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory;
//
//import org.springframework.data.neo4j.conversion.ResultConverter;
/**
* <p>
@@ -39,18 +37,11 @@ public class Neo4jItemReader<T> extends AbstractNeo4jItemReader {
Iterable<T> queryResults;
if(factory != null) {
Session session = factory.openSession();
queryResults = session.query(getTargetType(),
generateLimitCypherQuery(),
getParameterValues());
}
else {
queryResults = getTemplate().queryForObjects(
getTargetType(), generateLimitCypherQuery(), getParameterValues());
}
if(queryResults != null) {
return queryResults.iterator();

View File

@@ -25,7 +25,6 @@ import org.neo4j.ogm.session.SessionFactory;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.data.neo4j.template.Neo4jOperations;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -49,27 +48,12 @@ public class Neo4jItemWriter<T> implements ItemWriter<T>, InitializingBean {
private boolean delete = false;
private Neo4jOperations template;
private SessionFactory sessionFactory;
private boolean useSession = false;
public void setDelete(boolean delete) {
this.delete = delete;
}
/**
* Set the {@link Neo4jOperations} to be used to save items
*
* @param template the template implementation to be used
* @deprecated Use {@link #setSessionFactory(SessionFactory)}
*/
@Deprecated
public void setTemplate(Neo4jOperations template) {
this.template = template;
}
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
@@ -81,10 +65,8 @@ public class Neo4jItemWriter<T> implements ItemWriter<T>, InitializingBean {
*/
@Override
public void afterPropertiesSet() throws Exception {
Assert.state(template != null || this.sessionFactory != null,
"A Neo4JOperations implementation or a SessionFactory is required");
this.useSession = this.sessionFactory != null;
Assert.state(this.sessionFactory != null,
"A SessionFactory is required");
}
/**
@@ -115,28 +97,18 @@ public class Neo4jItemWriter<T> implements ItemWriter<T>, InitializingBean {
}
private void delete(List<? extends T> items) {
if(this.useSession) {
Session session = this.sessionFactory.openSession();
Session session = this.sessionFactory.openSession();
items.forEach(session::delete);
}
else {
for (T item : items) {
this.template.delete(item);
}
for(T item : items) {
session.delete(item);
}
}
private void save(List<? extends T> items) {
if(this.useSession) {
Session session = this.sessionFactory.openSession();
Session session = this.sessionFactory.openSession();
items.forEach(session::save);
}
else {
for (T item : items) {
this.template.save(item);
}
for (T item : items) {
session.save(item);
}
}
}