@@ -1,207 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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
|
||||
*
|
||||
* https://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.batch.item.data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.neo4j.ogm.session.SessionFactory;
|
||||
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Restartable {@link ItemReader} that reads objects from the graph database Neo4j
|
||||
* via a paging technique.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* It executes cypher queries built from the statement fragments provided to
|
||||
* retrieve the requested data. The query is executed using paged requests of
|
||||
* a size specified in {@link #setPageSize(int)}. Additional pages are requested
|
||||
* as needed when the {@link #read()} method is called. On restart, the reader
|
||||
* will begin again at the same number item it left off at.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Performance is dependent on your Neo4J configuration (embedded or remote) as
|
||||
* well as page size. Setting a fairly large page size and using a commit
|
||||
* interval that matches the page size should provide better performance.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* This implementation is thread-safe between calls to
|
||||
* {@link #open(org.springframework.batch.item.ExecutionContext)}, however you
|
||||
* should set <code>saveState=false</code> if used in a multi-threaded
|
||||
* environment (no restart available).
|
||||
* </p>
|
||||
*
|
||||
* @author Michael Minella
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @since 3.07
|
||||
* @deprecated Extend {@link Neo4jItemReader} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class AbstractNeo4jItemReader<T> extends
|
||||
AbstractPaginatedDataItemReader<T> implements InitializingBean {
|
||||
|
||||
protected Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
private String startStatement;
|
||||
private String returnStatement;
|
||||
private String matchStatement;
|
||||
private String whereStatement;
|
||||
private String orderByStatement;
|
||||
|
||||
private Class<T> targetType;
|
||||
|
||||
private Map<String, Object> parameterValues;
|
||||
|
||||
/**
|
||||
* Optional parameters to be used in the cypher query.
|
||||
*
|
||||
* @param parameterValues the parameter values to be used in the cypher query
|
||||
*/
|
||||
public void setParameterValues(Map<String, Object> parameterValues) {
|
||||
this.parameterValues = parameterValues;
|
||||
}
|
||||
|
||||
protected final Map<String, Object> getParameterValues() {
|
||||
return this.parameterValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* The start segment of the cypher query. START is prepended
|
||||
* to the statement provided and should <em>not</em> be
|
||||
* included.
|
||||
*
|
||||
* @param startStatement the start fragment of the cypher query.
|
||||
*/
|
||||
public void setStartStatement(String startStatement) {
|
||||
this.startStatement = startStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* The return statement of the cypher query. RETURN is prepended
|
||||
* to the statement provided and should <em>not</em> be
|
||||
* included
|
||||
*
|
||||
* @param returnStatement the return fragment of the cypher query.
|
||||
*/
|
||||
public void setReturnStatement(String returnStatement) {
|
||||
this.returnStatement = returnStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* An optional match fragment of the cypher query. MATCH is
|
||||
* prepended to the statement provided and should <em>not</em>
|
||||
* be included.
|
||||
*
|
||||
* @param matchStatement the match fragment of the cypher query
|
||||
*/
|
||||
public void setMatchStatement(String matchStatement) {
|
||||
this.matchStatement = matchStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* An optional where fragment of the cypher query. WHERE is
|
||||
* prepended to the statement provided and should <em>not</em>
|
||||
* be included.
|
||||
*
|
||||
* @param whereStatement where fragment of the cypher query
|
||||
*/
|
||||
public void setWhereStatement(String whereStatement) {
|
||||
this.whereStatement = whereStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of properties to order the results by. This is
|
||||
* required so that subsequent page requests pull back the
|
||||
* segment of results correctly. ORDER BY is prepended to
|
||||
* the statement provided and should <em>not</em> be included.
|
||||
*
|
||||
* @param orderByStatement order by fragment of the cypher query.
|
||||
*/
|
||||
public void setOrderByStatement(String orderByStatement) {
|
||||
this.orderByStatement = orderByStatement;
|
||||
}
|
||||
|
||||
protected SessionFactory getSessionFactory() {
|
||||
return sessionFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establish the session factory for the reader.
|
||||
* @param sessionFactory the factory to use for the reader.
|
||||
*/
|
||||
public void setSessionFactory(SessionFactory sessionFactory) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* The object type to be returned from each call to {@link #read()}
|
||||
*
|
||||
* @param targetType the type of object to return.
|
||||
*/
|
||||
public void setTargetType(Class<T> targetType) {
|
||||
this.targetType = targetType;
|
||||
}
|
||||
|
||||
protected final Class<T> getTargetType() {
|
||||
return this.targetType;
|
||||
}
|
||||
|
||||
protected String generateLimitCypherQuery() {
|
||||
StringBuilder query = new StringBuilder(128);
|
||||
|
||||
query.append("START ").append(startStatement);
|
||||
query.append(matchStatement != null ? " MATCH " + matchStatement : "");
|
||||
query.append(whereStatement != null ? " WHERE " + whereStatement : "");
|
||||
query.append(" RETURN ").append(returnStatement);
|
||||
query.append(" ORDER BY ").append(orderByStatement);
|
||||
query.append(" SKIP " + (pageSize * page));
|
||||
query.append(" LIMIT " + pageSize);
|
||||
|
||||
String resultingQuery = query.toString();
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(resultingQuery);
|
||||
}
|
||||
|
||||
return resultingQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks mandatory properties
|
||||
*
|
||||
* @see InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
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");
|
||||
Assert.state(StringUtils.hasText(orderByStatement), "A ORDER BY statement is required");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -18,17 +18,191 @@ package org.springframework.batch.item.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.neo4j.ogm.session.Session;
|
||||
import org.neo4j.ogm.session.SessionFactory;
|
||||
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Extensions of the {@link AbstractNeo4jItemReader}.
|
||||
* Restartable {@link ItemReader} that reads objects from the graph database Neo4j
|
||||
* via a paging technique.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* It executes cypher queries built from the statement fragments provided to
|
||||
* retrieve the requested data. The query is executed using paged requests of
|
||||
* a size specified in {@link #setPageSize(int)}. Additional pages are requested
|
||||
* as needed when the {@link #read()} method is called. On restart, the reader
|
||||
* will begin again at the same number item it left off at.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Performance is dependent on your Neo4J configuration (embedded or remote) as
|
||||
* well as page size. Setting a fairly large page size and using a commit
|
||||
* interval that matches the page size should provide better performance.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* This implementation is thread-safe between calls to
|
||||
* {@link #open(org.springframework.batch.item.ExecutionContext)}, however you
|
||||
* should set <code>saveState=false</code> if used in a multi-threaded
|
||||
* environment (no restart available).
|
||||
* </p>
|
||||
*
|
||||
* @author Michael Minella
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public class Neo4jItemReader<T> extends AbstractNeo4jItemReader<T> {
|
||||
public class Neo4jItemReader<T> extends AbstractPaginatedDataItemReader<T> implements InitializingBean {
|
||||
|
||||
protected Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
private String startStatement;
|
||||
private String returnStatement;
|
||||
private String matchStatement;
|
||||
private String whereStatement;
|
||||
private String orderByStatement;
|
||||
|
||||
private Class<T> targetType;
|
||||
|
||||
private Map<String, Object> parameterValues;
|
||||
|
||||
/**
|
||||
* Optional parameters to be used in the cypher query.
|
||||
*
|
||||
* @param parameterValues the parameter values to be used in the cypher query
|
||||
*/
|
||||
public void setParameterValues(Map<String, Object> parameterValues) {
|
||||
this.parameterValues = parameterValues;
|
||||
}
|
||||
|
||||
protected final Map<String, Object> getParameterValues() {
|
||||
return this.parameterValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* The start segment of the cypher query. START is prepended
|
||||
* to the statement provided and should <em>not</em> be
|
||||
* included.
|
||||
*
|
||||
* @param startStatement the start fragment of the cypher query.
|
||||
*/
|
||||
public void setStartStatement(String startStatement) {
|
||||
this.startStatement = startStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* The return statement of the cypher query. RETURN is prepended
|
||||
* to the statement provided and should <em>not</em> be
|
||||
* included
|
||||
*
|
||||
* @param returnStatement the return fragment of the cypher query.
|
||||
*/
|
||||
public void setReturnStatement(String returnStatement) {
|
||||
this.returnStatement = returnStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* An optional match fragment of the cypher query. MATCH is
|
||||
* prepended to the statement provided and should <em>not</em>
|
||||
* be included.
|
||||
*
|
||||
* @param matchStatement the match fragment of the cypher query
|
||||
*/
|
||||
public void setMatchStatement(String matchStatement) {
|
||||
this.matchStatement = matchStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* An optional where fragment of the cypher query. WHERE is
|
||||
* prepended to the statement provided and should <em>not</em>
|
||||
* be included.
|
||||
*
|
||||
* @param whereStatement where fragment of the cypher query
|
||||
*/
|
||||
public void setWhereStatement(String whereStatement) {
|
||||
this.whereStatement = whereStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of properties to order the results by. This is
|
||||
* required so that subsequent page requests pull back the
|
||||
* segment of results correctly. ORDER BY is prepended to
|
||||
* the statement provided and should <em>not</em> be included.
|
||||
*
|
||||
* @param orderByStatement order by fragment of the cypher query.
|
||||
*/
|
||||
public void setOrderByStatement(String orderByStatement) {
|
||||
this.orderByStatement = orderByStatement;
|
||||
}
|
||||
|
||||
protected SessionFactory getSessionFactory() {
|
||||
return sessionFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establish the session factory for the reader.
|
||||
* @param sessionFactory the factory to use for the reader.
|
||||
*/
|
||||
public void setSessionFactory(SessionFactory sessionFactory) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* The object type to be returned from each call to {@link #read()}
|
||||
*
|
||||
* @param targetType the type of object to return.
|
||||
*/
|
||||
public void setTargetType(Class<T> targetType) {
|
||||
this.targetType = targetType;
|
||||
}
|
||||
|
||||
protected final Class<T> getTargetType() {
|
||||
return this.targetType;
|
||||
}
|
||||
|
||||
protected String generateLimitCypherQuery() {
|
||||
StringBuilder query = new StringBuilder(128);
|
||||
|
||||
query.append("START ").append(startStatement);
|
||||
query.append(matchStatement != null ? " MATCH " + matchStatement : "");
|
||||
query.append(whereStatement != null ? " WHERE " + whereStatement : "");
|
||||
query.append(" RETURN ").append(returnStatement);
|
||||
query.append(" ORDER BY ").append(orderByStatement);
|
||||
query.append(" SKIP " + (pageSize * page));
|
||||
query.append(" LIMIT " + pageSize);
|
||||
|
||||
String resultingQuery = query.toString();
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(resultingQuery);
|
||||
}
|
||||
|
||||
return resultingQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks mandatory properties
|
||||
*
|
||||
* @see InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
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");
|
||||
Assert.state(StringUtils.hasText(orderByStatement), "A ORDER BY statement is required");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2020 the original author or authors.
|
||||
* Copyright 2006-2021 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.
|
||||
@@ -413,16 +413,6 @@ implements InitializingBean {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up resources.
|
||||
* @throws Exception If unable to clean up resources
|
||||
* @deprecated This method is deprecated in favor of
|
||||
* {@link AbstractCursorItemReader#cleanupOnClose(java.sql.Connection)} and
|
||||
* will be removed in a future release
|
||||
*/
|
||||
@Deprecated
|
||||
protected abstract void cleanupOnClose() throws Exception;
|
||||
|
||||
/**
|
||||
* Clean up resources.
|
||||
* @param connection to the database
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2017 the original author or authors.
|
||||
* Copyright 2006-2021 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.
|
||||
@@ -43,6 +43,7 @@ import org.springframework.util.Assert;
|
||||
* @author Dave Syer
|
||||
* @author Thomas Risberg
|
||||
* @author Michael Minella
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
public class HibernateItemWriter<T> implements ItemWriter<T>, InitializingBean {
|
||||
@@ -129,40 +130,4 @@ public class HibernateItemWriter<T> implements ItemWriter<T>, InitializingBean {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do perform the actual write operation using {@link HibernateOperations}.
|
||||
* This can be overridden in a subclass if necessary.
|
||||
*
|
||||
* @param hibernateTemplate
|
||||
* the HibernateTemplate to use for the operation
|
||||
* @param items
|
||||
* the list of items to use for the write
|
||||
* @deprecated As of 2.2 in favor of using Hibernate's session management APIs directly
|
||||
*/
|
||||
@Deprecated
|
||||
protected void doWrite(HibernateOperations hibernateTemplate,
|
||||
List<? extends T> items) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Writing to Hibernate with " + items.size()
|
||||
+ " items.");
|
||||
}
|
||||
|
||||
if (!items.isEmpty()) {
|
||||
long saveOrUpdateCount = 0;
|
||||
for (T item : items) {
|
||||
if (!hibernateTemplate.contains(item)) {
|
||||
hibernateTemplate.saveOrUpdate(item);
|
||||
saveOrUpdateCount++;
|
||||
}
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(saveOrUpdateCount + " entities saved/updated.");
|
||||
logger.debug((items.size() - saveOrUpdateCount)
|
||||
+ " entities found in session.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2020 the original author or authors.
|
||||
* Copyright 2006-2021 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.
|
||||
@@ -142,18 +142,6 @@ public class JdbcCursorItemReader<T> extends AbstractCursorItemReader<T> {
|
||||
return rowMapper.mapRow(rs, currentRow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the cursor and database connection.
|
||||
* @deprecated This method is deprecated in favor of
|
||||
* {@link JdbcCursorItemReader#cleanupOnClose(java.sql.Connection)} and will
|
||||
* be removed in a future release
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
protected void cleanupOnClose() throws Exception {
|
||||
JdbcUtils.closeStatement(this.preparedStatement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the cursor and database connection.
|
||||
* @param connection to the database
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2020 the original author or authors.
|
||||
* Copyright 2006-2021 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.
|
||||
@@ -238,18 +238,6 @@ public class StoredProcedureItemReader<T> extends AbstractCursorItemReader<T> {
|
||||
return rowMapper.mapRow(rs, currentRow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the cursor and database connection.
|
||||
* @deprecated This method is deprecated in favor of
|
||||
* {@link StoredProcedureItemReader#cleanupOnClose(java.sql.Connection)} and
|
||||
* will be removed in a future release
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
protected void cleanupOnClose() throws Exception {
|
||||
JdbcUtils.closeStatement(this.callableStatement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the cursor and database connection.
|
||||
* @param connection to the database
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2018 the original author or authors.
|
||||
* Copyright 2017-2021 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.
|
||||
@@ -217,22 +217,6 @@ public class HibernatePagingItemReaderBuilder<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicator for whether to use a {@link org.hibernate.StatelessSession}
|
||||
* (<code>true</code>) or a {@link org.hibernate.Session} (<code>false</code>).
|
||||
*
|
||||
* @param useStatelessSession Defaults to false
|
||||
* @return this instance for method chaining
|
||||
* @see HibernatePagingItemReader#setUseStatelessSession(boolean)
|
||||
* @deprecated This method is deprecated in favor of
|
||||
* {@link HibernatePagingItemReaderBuilder#useStatelessSession} and will be
|
||||
* removed in a future version.
|
||||
*/
|
||||
@Deprecated
|
||||
public HibernatePagingItemReaderBuilder<T> useSatelessSession(boolean useStatelessSession) {
|
||||
return useStatelessSession(useStatelessSession);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicator for whether to use a {@link org.hibernate.StatelessSession}
|
||||
* (<code>true</code>) or a {@link org.hibernate.Session} (<code>false</code>).
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2019 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
|
||||
*
|
||||
* https://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.batch.item.database.support;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.item.database.JdbcCursorItemReader;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.jdbc.core.PreparedStatementSetter;
|
||||
import org.springframework.jdbc.core.SqlTypeValue;
|
||||
import org.springframework.jdbc.core.StatementCreatorUtils;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Implementation of the {@link PreparedStatementSetter} interface that accepts
|
||||
* a list of values to be set on a PreparedStatement. This is usually used in
|
||||
* conjunction with the {@link JdbcCursorItemReader} to allow for the replacement
|
||||
* of bind variables when generating the cursor. The order of the list will be
|
||||
* used to determine the ordering of setting variables. For example, the first
|
||||
* item in the list will be the first bind variable set. (i.e. it will
|
||||
* correspond to the first '?' in the SQL statement)
|
||||
*
|
||||
* @deprecated use {@link org.springframework.jdbc.core.ArgumentPreparedStatementSetter}
|
||||
* instead.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class ListPreparedStatementSetter implements
|
||||
PreparedStatementSetter, InitializingBean {
|
||||
|
||||
private List<?> parameters;
|
||||
|
||||
public ListPreparedStatementSetter() {}
|
||||
|
||||
public ListPreparedStatementSetter(List<?> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValues(PreparedStatement ps) throws SQLException {
|
||||
for (int i = 0; i < parameters.size(); i++) {
|
||||
StatementCreatorUtils.setParameterValue(ps, i + 1, SqlTypeValue.TYPE_UNKNOWN, parameters.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The parameter values that will be set on the PreparedStatement.
|
||||
* It is assumed that their order in the List is the order of the parameters
|
||||
* in the PreparedStatement.
|
||||
*
|
||||
* @param parameters list containing the parameter values to be used.
|
||||
* @deprecated In favor of the constructor
|
||||
*/
|
||||
@Deprecated
|
||||
public void setParameters(List<?> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(parameters, "Parameters must be provided");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2020 the original author or authors.
|
||||
* Copyright 2006-2021 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.
|
||||
@@ -142,7 +142,7 @@ public class MultiResourceItemReader<T> extends AbstractItemStreamItemReader<T>
|
||||
private T readFromDelegate() throws Exception {
|
||||
T item = delegate.read();
|
||||
if(item instanceof ResourceAware){
|
||||
((ResourceAware) item).setResource(getCurrentResource());
|
||||
((ResourceAware) item).setResource(resources[currentResource]);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
@@ -247,20 +247,4 @@ public class MultiResourceItemReader<T> extends AbstractItemStreamItemReader<T>
|
||||
this.resources = Arrays.asList(resources).toArray(new Resource[resources.length]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the current resource.
|
||||
* @return the current resource or {@code null} if all resources have been
|
||||
* processed or the first resource has not been assigned yet.
|
||||
*
|
||||
* @deprecated In favor of using {@link ResourceAware} instead.
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
public Resource getCurrentResource() {
|
||||
if (currentResource >= resources.length || currentResource < 0) {
|
||||
return null;
|
||||
}
|
||||
return resources[currentResource];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2020 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
|
||||
*
|
||||
* https://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.batch.item.file.transform;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
* @deprecated Use {@link FormatterLineAggregator#setFormat(java.lang.String)}
|
||||
* for alignment (See examples in {@code FormatterLineAggregatorTests})
|
||||
*/
|
||||
@Deprecated
|
||||
public enum Alignment {
|
||||
CENTER("CENTER", "center"),
|
||||
RIGHT("RIGHT", "right"),
|
||||
LEFT("LEFT", "left");
|
||||
|
||||
private String code;
|
||||
private String label;
|
||||
|
||||
private Alignment(String code, String label) {
|
||||
Assert.notNull(code, "'code' must not be null");
|
||||
|
||||
this.code = code;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public Comparable<String> getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getStringCode() {
|
||||
return (String) getCode();
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
if (this.label != null) {
|
||||
return label;
|
||||
}
|
||||
|
||||
return getCode().toString();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2021 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.
|
||||
@@ -26,6 +26,7 @@ import org.springframework.util.Assert;
|
||||
* Utility methods for files used in batch processing.
|
||||
*
|
||||
* @author Peter Zozom
|
||||
* @author Mahmoud Ben Hassine
|
||||
*/
|
||||
public final class FileUtils {
|
||||
|
||||
@@ -89,28 +90,6 @@ public final class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up output file for batch processing. This method implements common logic for handling output files when
|
||||
* starting or restarting file I/O. When starting output file processing, creates/overwrites new file. When
|
||||
* restarting output file processing, checks whether file is writable.
|
||||
*
|
||||
* @param file file to be set up
|
||||
* @param restarted true signals that we are restarting output file processing
|
||||
* @param overwriteOutputFile If set to true, output file will be overwritten (this flag is ignored when processing
|
||||
* is restart)
|
||||
*
|
||||
* @throws IllegalArgumentException when file is null
|
||||
* @throws ItemStreamException when starting output file processing, file exists and flag "overwriteOutputFile" is
|
||||
* set to false
|
||||
* @throws ItemStreamException when unable to create file or file is not writable
|
||||
*
|
||||
* @deprecated use the version with explicit append parameter instead. Here append=false is assumed.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setUpOutputFile(File file, boolean restarted, boolean overwriteOutputFile) {
|
||||
setUpOutputFile(file, restarted, false, overwriteOutputFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new file if it doesn't already exist.
|
||||
*
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006-2020 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
|
||||
*
|
||||
* https://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.batch.item.xml;
|
||||
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLEventWriter;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.stax.StAXResult;
|
||||
import javax.xml.transform.stax.StAXSource;
|
||||
|
||||
|
||||
/**
|
||||
* StAX utility methods.
|
||||
* <br>
|
||||
* This class is thread-safe.
|
||||
*
|
||||
* @author Josh Long
|
||||
* @author Mahmoud Ben Hassine
|
||||
*
|
||||
* @deprecated in favor of {@link org.springframework.util.xml.StaxUtils}
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class StaxUtils {
|
||||
|
||||
public static Source getSource(XMLEventReader r) throws XMLStreamException {
|
||||
return new StAXSource(r);
|
||||
}
|
||||
|
||||
public static Result getResult(XMLEventWriter w) {
|
||||
return new StAXResult(w);
|
||||
}
|
||||
|
||||
public static XMLInputFactory createXmlInputFactory() {
|
||||
XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
|
||||
xmlInputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
|
||||
xmlInputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
|
||||
return xmlInputFactory;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user