proj_name
stringclasses
131 values
relative_path
stringlengths
30
228
class_name
stringlengths
1
68
func_name
stringlengths
1
48
masked_class
stringlengths
78
9.82k
func_body
stringlengths
46
9.61k
len_input
int64
29
2.01k
len_output
int64
14
1.94k
total
int64
55
2.05k
relevant_context
stringlengths
0
38.4k
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/JmsRedeliveredExtractor.java
JmsRedeliveredExtractor
extract
class JmsRedeliveredExtractor { private static final Log logger = LogFactory.getLog(JmsRedeliveredExtractor.class); public ChunkResponse extract(ChunkResponse input, @Header(JmsHeaders.REDELIVERED) boolean redelivered) {<FILL_FUNCTION_BODY>} }
if (logger.isDebugEnabled()) { logger.debug("Extracted redelivered flag for response, value=" + redelivered); } return new ChunkResponse(input, redelivered);
82
55
137
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/MessageSourcePollerInterceptor.java
MessageSourcePollerInterceptor
preReceive
class MessageSourcePollerInterceptor implements ChannelInterceptor, InitializingBean { private static final Log logger = LogFactory.getLog(MessageSourcePollerInterceptor.class); private MessageSource<?> source; private MessageChannel channel; /** * Convenient default constructor for configuration purposes. ...
Message<?> message = source.receive(); if (message != null) { if (this.channel != null) { channel = this.channel; } channel.send(message); if (logger.isDebugEnabled()) { logger.debug("Sent " + message + " to channel " + channel); } return true; } return true;
423
106
529
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/RemoteChunkingWorkerBuilder.java
RemoteChunkingWorkerBuilder
itemProcessor
class RemoteChunkingWorkerBuilder<I, O> { private static final String SERVICE_ACTIVATOR_METHOD_NAME = "handleChunk"; private ItemProcessor<I, O> itemProcessor; private ItemWriter<O> itemWriter; private MessageChannel inputChannel; private MessageChannel outputChannel; /** * Set the {@link ItemProcessor} t...
Assert.notNull(itemProcessor, "itemProcessor must not be null"); this.itemProcessor = itemProcessor; return this;
804
37
841
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/config/annotation/BatchIntegrationConfiguration.java
BatchIntegrationConfiguration
afterPropertiesSet
class BatchIntegrationConfiguration<I, O> implements InitializingBean { private final JobExplorer jobExplorer; private final JobRepository jobRepository; private final PlatformTransactionManager transactionManager; private RemoteChunkingManagerStepBuilderFactory remoteChunkingManagerStepBuilderFactory; privat...
this.remoteChunkingManagerStepBuilderFactory = new RemoteChunkingManagerStepBuilderFactory(this.jobRepository, this.transactionManager); this.remoteChunkingWorkerBuilder = new RemoteChunkingWorkerBuilder<>(); this.remotePartitioningManagerStepBuilderFactory = new RemotePartitioningManagerStepBuilderFactory( ...
385
130
515
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/BatchIntegrationNamespaceHandler.java
BatchIntegrationNamespaceHandler
init
class BatchIntegrationNamespaceHandler extends AbstractIntegrationNamespaceHandler { @Override public void init() {<FILL_FUNCTION_BODY>} }
this.registerBeanDefinitionParser("job-launching-gateway", new JobLaunchingGatewayParser()); RemoteChunkingManagerParser remoteChunkingManagerParser = new RemoteChunkingManagerParser(); this.registerBeanDefinitionParser("remote-chunking-manager", remoteChunkingManagerParser); RemoteChunkingWorkerParser remoteC...
40
130
170
<methods>public void <init>() ,public final org.springframework.beans.factory.config.BeanDefinition parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext) <variables>private final java.util.concurrent.atomic.AtomicBoolean initialized
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/JobLaunchingGatewayParser.java
JobLaunchingGatewayParser
parseHandler
class JobLaunchingGatewayParser extends AbstractConsumerEndpointParser { private static final Log logger = LogFactory.getLog(JobLaunchingGatewayParser.class); @Override protected String getInputChannelAttributeName() { return "request-channel"; } @Override protected BeanDefinitionBuilder parseHandler(Element...
final BeanDefinitionBuilder jobLaunchingGatewayBuilder = BeanDefinitionBuilder .genericBeanDefinition(JobLaunchingGateway.class); final String jobLauncher = element.getAttribute("job-launcher"); if (StringUtils.hasText(jobLauncher)) { jobLaunchingGatewayBuilder.addConstructorArgReference(jobLauncher); ...
105
280
385
<methods>public void <init>() <variables>protected static final java.lang.String EXPRESSION_ATTRIBUTE,protected static final java.lang.String METHOD_ATTRIBUTE,protected static final java.lang.String REF_ATTRIBUTE
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/RemoteChunkingManagerParser.java
RemoteChunkingManagerParser
parseInternal
class RemoteChunkingManagerParser extends AbstractBeanDefinitionParser { private static final String MESSAGE_TEMPLATE_ATTRIBUTE = "message-template"; private static final String STEP_ATTRIBUTE = "step"; private static final String REPLY_CHANNEL_ATTRIBUTE = "reply-channel"; private static final String MESSAGING_...
String id = element.getAttribute(ID_ATTRIBUTE); Assert.hasText(id, "The id attribute must be specified"); String messageTemplate = element.getAttribute(MESSAGE_TEMPLATE_ATTRIBUTE); Assert.hasText(messageTemplate, "The message-template attribute must be specified"); String step = element.getAttribute(STEP_A...
238
417
655
<methods>public void <init>() ,public final org.springframework.beans.factory.config.BeanDefinition parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext) <variables>public static final java.lang.String ID_ATTRIBUTE,public static final java.lang.String NAME_ATTRIBUTE
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/config/xml/RemoteChunkingWorkerParser.java
RemoteChunkingWorkerParser
parseInternal
class RemoteChunkingWorkerParser extends AbstractBeanDefinitionParser { private static final String INPUT_CHANNEL_ATTRIBUTE = "input-channel"; private static final String OUTPUT_CHANNEL_ATTRIBUTE = "output-channel"; private static final String ITEM_PROCESSOR_ATTRIBUTE = "item-processor"; private static final St...
String id = element.getAttribute(ID_ATTRIBUTE); Assert.hasText(id, "The id attribute must be specified"); String inputChannel = element.getAttribute(INPUT_CHANNEL_ATTRIBUTE); Assert.hasText(inputChannel, "The input-channel attribute must be specified"); String outputChannel = element.getAttribute(OUTPUT_CH...
576
490
1,066
<methods>public void <init>() ,public final org.springframework.beans.factory.config.BeanDefinition parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext) <variables>public static final java.lang.String ID_ATTRIBUTE,public static final java.lang.String NAME_ATTRIBUTE
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/launch/JobLaunchRequest.java
JobLaunchRequest
toString
class JobLaunchRequest { private final Job job; private final JobParameters jobParameters; /** * @param job job to be launched * @param jobParameters parameters to run the job with */ public JobLaunchRequest(Job job, JobParameters jobParameters) { super(); this.job = job; this.jobParameters = jobPara...
return "JobLaunchRequest: " + job.getName() + ", parameters=" + jobParameters;
193
27
220
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/launch/JobLaunchingGateway.java
JobLaunchingGateway
handleRequestMessage
class JobLaunchingGateway extends AbstractReplyProducingMessageHandler { private final JobLaunchingMessageHandler jobLaunchingMessageHandler; /** * Constructor taking a {@link JobLauncher} as parameter. * @param jobLauncher Must not be null. * */ public JobLaunchingGateway(JobLauncher jobLauncher) { Asse...
Assert.notNull(requestMessage, "The provided requestMessage must not be null."); final Object payload = requestMessage.getPayload(); Assert.isInstanceOf(JobLaunchRequest.class, payload, "The payload must be of type JobLaunchRequest."); final JobLaunchRequest jobLaunchRequest = (JobLaunchRequest) payload; ...
315
171
486
<methods>public void <init>() ,public org.springframework.integration.IntegrationPatternType getIntegrationPatternType() ,public void setAdviceChain(List<org.aopalliance.aop.Advice>) ,public void setBeanClassLoader(java.lang.ClassLoader) ,public void setRequiresReply(boolean) <variables>private final List<org.aopallian...
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/launch/JobLaunchingMessageHandler.java
JobLaunchingMessageHandler
launch
class JobLaunchingMessageHandler implements JobLaunchRequestHandler { private final JobLauncher jobLauncher; /** * @param jobLauncher {@link org.springframework.batch.core.launch.JobLauncher} used * to execute Spring Batch jobs */ public JobLaunchingMessageHandler(JobLauncher jobLauncher) { super(); this...
Job job = request.getJob(); JobParameters jobParameters = request.getJobParameters(); return jobLauncher.run(job, jobParameters);
143
43
186
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/partition/StepExecutionRequestHandler.java
StepExecutionRequestHandler
handle
class StepExecutionRequestHandler { private JobExplorer jobExplorer; private StepLocator stepLocator; /** * Used to locate a {@link Step} to execute for each request. * @param stepLocator a {@link StepLocator} */ public void setStepLocator(StepLocator stepLocator) { this.stepLocator = stepLocator; } /...
Long jobExecutionId = request.getJobExecutionId(); Long stepExecutionId = request.getStepExecutionId(); StepExecution stepExecution = jobExplorer.getStepExecution(jobExecutionId, stepExecutionId); if (stepExecution == null) { throw new NoSuchStepException("No StepExecution could be located for this request...
215
289
504
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-integration/src/main/java/org/springframework/batch/integration/step/DelegateStep.java
DelegateStep
afterPropertiesSet
class DelegateStep extends AbstractStep { private Step delegate; /** * @param delegate the delegate to set */ public void setDelegate(Step delegate) { this.delegate = delegate; } /** * Check mandatory properties (delegate). */ @Override public void afterPropertiesSet() throws Exception {<FILL_FUNCTI...
Assert.state(delegate != null, "A delegate Step must be provided"); super.afterPropertiesSet();
132
34
166
<methods>public void <init>() ,public void <init>(java.lang.String) ,public void afterPropertiesSet() throws java.lang.Exception,public final void execute(org.springframework.batch.core.StepExecution) throws org.springframework.batch.core.JobInterruptedException, org.springframework.batch.core.UnexpectedJobExecutionExc...
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/amqp/AmqpJobConfiguration.java
AmqpJobConfiguration
step
class AmqpJobConfiguration { @Bean public Job job(JobRepository jobRepository, Step step) { return new JobBuilder("amqp-config-job", jobRepository).start(step).build(); } @Bean public Step step(JobRepository jobRepository, JdbcTransactionManager transactionManager, RabbitTemplate rabbitInputTemplate, Rabbit...
return new StepBuilder("step", jobRepository).<String, String>chunk(1, transactionManager) .reader(amqpItemReader(rabbitInputTemplate)) .processor(new MessageProcessor()) .writer(amqpItemWriter(rabbitOutputTemplate)) .build();
343
74
417
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/amqp/AmqpMessageProducer.java
AmqpMessageProducer
main
class AmqpMessageProducer { private AmqpMessageProducer() { } private static final int SEND_MESSAGE_COUNT = 10; private static final String[] BEAN_CONFIG = { "classpath:org/springframework/batch/samples/amqp/job/rabbitmq-beans.xml" }; public static void main(String[] args) {<FILL_FUNCTION_BODY>} }
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(BEAN_CONFIG); AmqpTemplate amqpTemplate = applicationContext.getBean("inboundAmqpTemplate", RabbitTemplate.class); for (int i = 0; i < SEND_MESSAGE_COUNT; i++) { amqpTemplate.convertAndSend("foo message: " + i); } ((ConfigurableA...
111
116
227
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/amqp/MessageProcessor.java
MessageProcessor
process
class MessageProcessor implements ItemProcessor<String, String> { @Nullable @Override public String process(String message) throws Exception {<FILL_FUNCTION_BODY>} }
return "Message: \"" + message + "\" processed on: " + new Date();
46
24
70
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/chunking/WorkerConfiguration.java
WorkerConfiguration
itemProcessor
class WorkerConfiguration { @Value("${broker.url}") private String brokerUrl; @Autowired private RemoteChunkingWorkerBuilder<Integer, Integer> remoteChunkingWorkerBuilder; @Bean public ActiveMQConnectionFactory connectionFactory() throws JMSException { ActiveMQConnectionFactory connectionFactory = new Active...
return item -> { System.out.println("processing item " + item); return item; };
491
33
524
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/common/ColumnRangePartitioner.java
ColumnRangePartitioner
partition
class ColumnRangePartitioner implements Partitioner { private JdbcOperations jdbcTemplate; private String table; private String column; /** * The name of the SQL table the data are in. * @param table the name of the table */ public void setTable(String table) { this.table = table; } /** * The name...
int min = jdbcTemplate.queryForObject("SELECT MIN(" + column + ") from " + table, Integer.class); int max = jdbcTemplate.queryForObject("SELECT MAX(" + column + ") from " + table, Integer.class); int targetSize = (max - min) / gridSize + 1; Map<String, ExecutionContext> result = new HashMap<>(); int number ...
317
238
555
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/common/ErrorLogTasklet.java
ErrorLogTasklet
getSkipCount
class ErrorLogTasklet implements Tasklet, StepExecutionListener { private JdbcOperations jdbcTemplate; private String jobName; private StepExecution stepExecution; private String stepName; @Nullable @Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Except...
if (stepExecution == null || stepName == null) { return 0; } for (StepExecution execution : stepExecution.getJobExecution().getStepExecutions()) { if (execution.getStepName().equals(stepName)) { return execution.getSkipCount(); } } return 0;
380
85
465
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/common/OutputFileListener.java
OutputFileListener
createOutputNameFromInput
class OutputFileListener { private String outputKeyName = "outputFile"; private String inputKeyName = "fileName"; private String path = "file:./target/output/"; public void setPath(String path) { this.path = path; } public void setOutputKeyName(String outputKeyName) { this.outputKeyName = outputKeyName; ...
ExecutionContext executionContext = stepExecution.getExecutionContext(); String inputName = stepExecution.getStepName().replace(":", "-"); if (executionContext.containsKey(inputKeyName)) { inputName = executionContext.getString(inputKeyName); } if (!executionContext.containsKey(outputKeyName)) { execut...
159
118
277
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/common/SkipCheckingDecider.java
SkipCheckingDecider
decide
class SkipCheckingDecider implements JobExecutionDecider { @Override public FlowExecutionStatus decide(JobExecution jobExecution, @Nullable StepExecution stepExecution) {<FILL_FUNCTION_BODY>} }
if (!stepExecution.getExitStatus().getExitCode().equals(ExitStatus.FAILED.getExitCode()) && stepExecution.getSkipCount() > 0) { return new FlowExecutionStatus("COMPLETED WITH SKIPS"); } else { return new FlowExecutionStatus(ExitStatus.COMPLETED.getExitCode()); }
53
89
142
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/common/SkipCheckingListener.java
SkipCheckingListener
checkForSkips
class SkipCheckingListener { private static final Log logger = LogFactory.getLog(SkipCheckingListener.class); private static int processSkips; @AfterStep public ExitStatus checkForSkips(StepExecution stepExecution) {<FILL_FUNCTION_BODY>} /** * Convenience method for testing * @return the processSkips */ ...
if (!stepExecution.getExitStatus().getExitCode().equals(ExitStatus.FAILED.getExitCode()) && stepExecution.getSkipCount() > 0) { return new ExitStatus("COMPLETED WITH SKIPS"); } else { return null; }
281
75
356
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/common/StagingItemListener.java
StagingItemListener
afterRead
class StagingItemListener extends StepListenerSupport<Long, Long> implements InitializingBean { private JdbcOperations jdbcTemplate; public void setDataSource(DataSource dataSource) { jdbcTemplate = new JdbcTemplate(dataSource); } @Override public final void afterPropertiesSet() throws Exception { Assert.st...
int count = jdbcTemplate.update("UPDATE BATCH_STAGING SET PROCESSED=? WHERE ID=? AND PROCESSED=?", StagingItemWriter.DONE, id, StagingItemWriter.NEW); if (count != 1) { throw new OptimisticLockingFailureException("The staging record with ID=" + id + " was updated concurrently when trying to mark as com...
130
119
249
<methods>public non-sealed void <init>() <variables>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/common/StagingItemProcessor.java
StagingItemProcessor
afterPropertiesSet
class StagingItemProcessor<T> implements ItemProcessor<ProcessIndicatorItemWrapper<T>, T>, InitializingBean { private JdbcOperations jdbcTemplate; public void setJdbcTemplate(JdbcOperations jdbcTemplate) { this.jdbcTemplate = jdbcTemplate; } public void setDataSource(DataSource dataSource) { this.jdbcTemplat...
Assert.state(jdbcTemplate != null, "Either jdbcTemplate or dataSource must be set");
321
30
351
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/common/StagingItemReader.java
StagingItemReader
retrieveKeys
class StagingItemReader<T> implements ItemReader<ProcessIndicatorItemWrapper<T>>, StepExecutionListener, InitializingBean, DisposableBean { private static final Log logger = LogFactory.getLog(StagingItemReader.class); private StepExecution stepExecution; private final Lock lock = new ReentrantLock(); private ...
this.lock.lock(); try { return jdbcTemplate.query( "SELECT ID FROM BATCH_STAGING WHERE JOB_ID=? AND PROCESSED=? ORDER BY ID", (rs, rowNum) -> rs.getLong(1), stepExecution.getJobExecution().getJobId(), StagingItemWriter.NEW); } finally { this.lock.unlock(); }
671
121
792
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/common/StagingItemWriter.java
StagingItemWriter
write
class StagingItemWriter<T> extends JdbcDaoSupport implements StepExecutionListener, ItemWriter<T> { protected static final String NEW = "N"; protected static final String DONE = "Y"; private DataFieldMaxValueIncrementer incrementer; private StepExecution stepExecution; /** * Check mandatory properties. * ...
final ListIterator<? extends T> itemIterator = chunk.getItems().listIterator(); getJdbcTemplate().batchUpdate("INSERT into BATCH_STAGING (ID, JOB_ID, VALUE, PROCESSED) values (?,?,?,?)", new BatchPreparedStatementSetter() { @Override public int getBatchSize() { return chunk.size(); } ...
393
238
631
<methods>public void <init>() ,public final javax.sql.DataSource getDataSource() ,public final org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate() ,public final void setDataSource(javax.sql.DataSource) ,public final void setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) <variables>private org.springf...
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/person/Child.java
Child
equals
class Child { private String name; public void setName(String name) { this.name = name; } public String getName() { return name; } @Override public String toString() { return "Child [name=" + name + "]"; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime ...
if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Child other = (Child) obj; if (name == null) { if (other.name != null) { return false; } } else if (!name.equals(other.name)) { return false; } ret...
160
135
295
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/person/Person.java
Person
toString
class Person { private String title = ""; private String firstName = ""; private String last_name = ""; private int age = 0; private Address address = new Address(); private List<Child> children = new ArrayList<>(); public Person() { children.add(new Child()); children.add(new Child()); } /** * @...
return "Person [address=" + address + ", age=" + age + ", children=" + children + ", firstName=" + firstName + ", last_name=" + last_name + ", title=" + title + "]";
1,123
61
1,184
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/person/PersonService.java
PersonService
getData
class PersonService { private static final int GENERATION_LIMIT = 10; private int generatedCounter = 0; private int processedCounter = 0; public Person getData() {<FILL_FUNCTION_BODY>} /* * Badly designed method signature which accepts multiple implicitly related arguments * instead of a single Person arg...
if (generatedCounter >= GENERATION_LIMIT) { return null; } Person person = new Person(); Address address = new Address(); Child child = new Child(); List<Child> children = new ArrayList<>(1); children.add(child); person.setFirstName("John" + generatedCounter); person.setAge(20 + generatedCounte...
153
178
331
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/CompositeCustomerUpdateLineTokenizer.java
CompositeCustomerUpdateLineTokenizer
tokenize
class CompositeCustomerUpdateLineTokenizer implements StepExecutionListener, LineTokenizer { private LineTokenizer customerTokenizer; private LineTokenizer footerTokenizer; private StepExecution stepExecution; @Override public FieldSet tokenize(@Nullable String line) {<FILL_FUNCTION_BODY>} @Override public ...
if (line.charAt(0) == 'F') { // line starts with F, so the footer tokenizer should tokenize it. FieldSet fs = footerTokenizer.tokenize(line); long customerUpdateTotal = stepExecution.getReadCount(); long fileUpdateTotal = fs.readLong(1); if (customerUpdateTotal != fileUpdateTotal) { throw new Ill...
291
327
618
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/CustomerCredit.java
CustomerCredit
toString
class CustomerCredit { @Id private int id; private String name; private BigDecimal credit; public CustomerCredit() { } public CustomerCredit(int id, String name, BigDecimal credit) { this.id = id; this.name = name; this.credit = credit; } @Override public String toString() {<FILL_FUNCTION_BODY>} ...
return "CustomerCredit [id=" + id + ",name=" + name + ", credit=" + credit + "]";
367
34
401
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/CustomerDebit.java
CustomerDebit
hashCode
class CustomerDebit { private String name; private BigDecimal debit; public CustomerDebit() { } CustomerDebit(String name, BigDecimal debit) { this.name = name; this.debit = debit; } public BigDecimal getDebit() { return debit; } public void setDebit(BigDecimal debit) { this.debit = debit; } p...
final int prime = 31; int result = 1; result = prime * result + ((debit == null) ? 0 : debit.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); return result;
420
73
493
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/CustomerUpdate.java
CustomerUpdate
toString
class CustomerUpdate { private final CustomerOperation operation; private final String customerName; private final BigDecimal credit; public CustomerUpdate(CustomerOperation operation, String customerName, BigDecimal credit) { this.operation = operation; this.customerName = customerName; this.credit = cre...
return "Customer Update, name: [" + customerName + "], operation: [" + operation + "], credit: [" + credit + "]";
156
38
194
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/CustomerUpdateFieldSetMapper.java
CustomerUpdateFieldSetMapper
mapFieldSet
class CustomerUpdateFieldSetMapper implements FieldSetMapper<CustomerUpdate> { @Override public CustomerUpdate mapFieldSet(FieldSet fs) {<FILL_FUNCTION_BODY>} }
if (fs == null) { return null; } CustomerOperation operation = CustomerOperation.fromCode(fs.readChar(0)); String name = fs.readString(1); BigDecimal credit = fs.readBigDecimal(2); return new CustomerUpdate(operation, name, credit);
48
86
134
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/CustomerUpdateProcessor.java
CustomerUpdateProcessor
process
class CustomerUpdateProcessor implements ItemProcessor<CustomerUpdate, CustomerUpdate> { private CustomerDao customerDao; private InvalidCustomerLogger invalidCustomerLogger; @Nullable @Override public CustomerUpdate process(CustomerUpdate item) throws Exception {<FILL_FUNCTION_BODY>} public void setCustomerD...
if (item.getOperation() == DELETE) { // delete is not supported invalidCustomerLogger.log(item); return null; } CustomerCredit customerCredit = customerDao.getCustomerByName(item.getCustomerName()); if (item.getOperation() == ADD && customerCredit == null) { return item; } else if (item.getO...
133
263
396
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/CustomerUpdateWriter.java
CustomerUpdateWriter
write
class CustomerUpdateWriter implements ItemWriter<CustomerUpdate> { private CustomerDao customerDao; @Override public void write(Chunk<? extends CustomerUpdate> items) throws Exception {<FILL_FUNCTION_BODY>} public void setCustomerDao(CustomerDao customerDao) { this.customerDao = customerDao; } }
for (CustomerUpdate customerUpdate : items) { if (customerUpdate.getOperation() == CustomerOperation.ADD) { customerDao.insertCustomer(customerUpdate.getCustomerName(), customerUpdate.getCredit()); } else if (customerUpdate.getOperation() == CustomerOperation.UPDATE) { customerDao.updateCustomer(cus...
91
117
208
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/Trade.java
Trade
equals
class Trade implements Serializable { private String isin = ""; private long quantity = 0; private BigDecimal price = BigDecimal.ZERO; private String customer = ""; private Long id; private long version = 0; public Trade() { } public Trade(String isin, long quantity, BigDecimal price, String customer) ...
if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Trade other = (Trade) obj; if (customer == null) { if (other.customer != null) { return false; } } else if (!customer.equals(other.customer)) { return false...
636
286
922
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/CommonsLoggingInvalidCustomerLogger.java
CommonsLoggingInvalidCustomerLogger
log
class CommonsLoggingInvalidCustomerLogger implements InvalidCustomerLogger { protected static final Log LOG = LogFactory.getLog(CommandLineJobRunner.class); @Override public void log(CustomerUpdate customerUpdate) {<FILL_FUNCTION_BODY>} }
LOG.error("invalid customer encountered: [ " + customerUpdate + "]");
65
23
88
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/CustomerCreditFieldSetMapper.java
CustomerCreditFieldSetMapper
mapFieldSet
class CustomerCreditFieldSetMapper implements FieldSetMapper<CustomerCredit> { public static final int ID_COLUMN = 0; public static final int NAME_COLUMN = 1; public static final int CREDIT_COLUMN = 2; @Override public CustomerCredit mapFieldSet(FieldSet fieldSet) {<FILL_FUNCTION_BODY>} }
CustomerCredit trade = new CustomerCredit(); trade.setId(fieldSet.readInt(ID_COLUMN)); trade.setName(fieldSet.readString(NAME_COLUMN)); trade.setCredit(fieldSet.readBigDecimal(CREDIT_COLUMN)); return trade;
96
90
186
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/CustomerCreditRowMapper.java
CustomerCreditRowMapper
mapRow
class CustomerCreditRowMapper implements RowMapper<CustomerCredit> { public static final String ID_COLUMN = "id"; public static final String NAME_COLUMN = "name"; public static final String CREDIT_COLUMN = "credit"; @Override public CustomerCredit mapRow(ResultSet rs, int rowNum) throws SQLException {<FILL_FUN...
CustomerCredit customerCredit = new CustomerCredit(); customerCredit.setId(rs.getInt(ID_COLUMN)); customerCredit.setName(rs.getString(NAME_COLUMN)); customerCredit.setCredit(rs.getBigDecimal(CREDIT_COLUMN)); return customerCredit;
104
94
198
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/CustomerCreditUpdateWriter.java
CustomerCreditUpdateWriter
write
class CustomerCreditUpdateWriter implements ItemWriter<CustomerCredit> { private double creditFilter = 800; private CustomerCreditDao dao; @Override public void write(Chunk<? extends CustomerCredit> customerCredits) throws Exception {<FILL_FUNCTION_BODY>} public void setCreditFilter(double creditFilter) { th...
for (CustomerCredit customerCredit : customerCredits) { if (customerCredit.getCredit().doubleValue() > creditFilter) { dao.writeCredit(customerCredit); } }
134
59
193
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/CustomerDebitRowMapper.java
CustomerDebitRowMapper
mapRow
class CustomerDebitRowMapper implements RowMapper<CustomerDebit> { public static final String CUSTOMER_COLUMN = "customer"; public static final String PRICE_COLUMN = "price"; @Override public CustomerDebit mapRow(ResultSet rs, int ignoredRowNumber) throws SQLException {<FILL_FUNCTION_BODY>} }
CustomerDebit customerDebit = new CustomerDebit(); customerDebit.setName(rs.getString(CUSTOMER_COLUMN)); customerDebit.setDebit(rs.getBigDecimal(PRICE_COLUMN)); return customerDebit;
91
75
166
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/CustomerUpdateWriter.java
CustomerUpdateWriter
write
class CustomerUpdateWriter implements ItemWriter<Trade> { private CustomerDebitDao dao; @Override public void write(Chunk<? extends Trade> trades) {<FILL_FUNCTION_BODY>} public void setDao(CustomerDebitDao outputSource) { this.dao = outputSource; } }
for (Trade trade : trades) { CustomerDebit customerDebit = new CustomerDebit(); customerDebit.setName(trade.getCustomer()); customerDebit.setDebit(trade.getPrice()); dao.write(customerDebit); }
87
77
164
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/FlatFileCustomerCreditDao.java
FlatFileCustomerCreditDao
open
class FlatFileCustomerCreditDao implements CustomerCreditDao, DisposableBean { private ItemWriter<String> itemWriter; private String separator = "\t"; private volatile boolean opened = false; @Override public void writeCredit(CustomerCredit customerCredit) throws Exception { if (!opened) { open(new Execu...
if (itemWriter instanceof ItemStream) { ((ItemStream) itemWriter).open(executionContext); } opened = true;
275
40
315
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/GeneratingTradeItemReader.java
GeneratingTradeItemReader
read
class GeneratingTradeItemReader implements ItemReader<Trade> { private int limit = 1; private int counter = 0; @Nullable @Override public Trade read() throws Exception {<FILL_FUNCTION_BODY>} /** * @param limit number of items that will be generated (null returned on consecutive * calls). */ public void...
if (counter < limit) { counter++; return new Trade("isin" + counter, counter, new BigDecimal(counter), "customer" + counter); } return null;
159
53
212
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/HibernateAwareCustomerCreditItemWriter.java
HibernateAwareCustomerCreditItemWriter
afterPropertiesSet
class HibernateAwareCustomerCreditItemWriter implements ItemWriter<CustomerCredit>, InitializingBean { private CustomerCreditDao dao; private SessionFactory sessionFactory; @Override public void write(Chunk<? extends CustomerCredit> items) throws Exception { for (CustomerCredit credit : items) { dao.writeCr...
Assert.state(sessionFactory != null, "Hibernate SessionFactory is required"); Assert.state(dao != null, "Delegate DAO must be set");
244
47
291
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/HibernateCreditDao.java
HibernateCreditDao
writeCredit
class HibernateCreditDao implements CustomerCreditDao, RepeatListener { private int failOnFlush = -1; private final List<Throwable> errors = new ArrayList<>(); private SessionFactory sessionFactory; public void setSessionFactory(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } /** ...
if (customerCredit.getId() == failOnFlush) { // try to insert one with a duplicate ID CustomerCredit newCredit = new CustomerCredit(); newCredit.setId(customerCredit.getId()); newCredit.setName(customerCredit.getName()); newCredit.setCredit(customerCredit.getCredit()); sessionFactory.getCurrentSess...
371
139
510
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/ItemTrackingTradeItemWriter.java
ItemTrackingTradeItemWriter
write
class ItemTrackingTradeItemWriter implements ItemWriter<Trade> { private final List<Trade> items = new ArrayList<>(); private String writeFailureISIN; private JdbcOperations jdbcTemplate; public void setDataSource(DataSource dataSource) { jdbcTemplate = new JdbcTemplate(dataSource); } public void setWriteF...
List<Trade> newItems = new ArrayList<>(); for (Trade t : items) { if (t.getIsin().equals(this.writeFailureISIN)) { throw new IOException("write failed"); } newItems.add(t); if (jdbcTemplate != null) { jdbcTemplate.update("UPDATE TRADE set VERSION=? where ID=? and version=?", t.getVersion() +...
171
153
324
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/JdbcCustomerDao.java
JdbcCustomerDao
getCustomerByName
class JdbcCustomerDao extends JdbcDaoSupport implements CustomerDao { private static final String GET_CUSTOMER_BY_NAME = "SELECT ID, NAME, CREDIT from CUSTOMER where NAME = ?"; private static final String INSERT_CUSTOMER = "INSERT into CUSTOMER(ID, NAME, CREDIT) values(?,?,?)"; private static final String UPDATE_...
List<CustomerCredit> customers = getJdbcTemplate().query(GET_CUSTOMER_BY_NAME, (rs, rowNum) -> { CustomerCredit customer = new CustomerCredit(); customer.setName(rs.getString("NAME")); customer.setId(rs.getInt("ID")); customer.setCredit(rs.getBigDecimal("CREDIT")); return customer; }, name); if ...
303
153
456
<methods>public void <init>() ,public final javax.sql.DataSource getDataSource() ,public final org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate() ,public final void setDataSource(javax.sql.DataSource) ,public final void setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) <variables>private org.springf...
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/JdbcTradeDao.java
JdbcTradeDao
writeTrade
class JdbcTradeDao implements TradeDao { private final Log log = LogFactory.getLog(JdbcTradeDao.class); /** * template for inserting a row */ private static final String INSERT_TRADE_RECORD = "INSERT INTO TRADE (id, version, isin, quantity, price, customer) VALUES (?, 0, ?, ? ,?, ?)"; /** * handles the pro...
Long id = incrementer.nextLongValue(); if (log.isDebugEnabled()) { log.debug("Processing: " + trade); } jdbcTemplate.update(INSERT_TRADE_RECORD, id, trade.getIsin(), trade.getQuantity(), trade.getPrice(), trade.getCustomer());
267
91
358
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/TradeFieldSetMapper.java
TradeFieldSetMapper
mapFieldSet
class TradeFieldSetMapper implements FieldSetMapper<Trade> { public static final int ISIN_COLUMN = 0; public static final int QUANTITY_COLUMN = 1; public static final int PRICE_COLUMN = 2; public static final int CUSTOMER_COLUMN = 3; @Override public Trade mapFieldSet(FieldSet fieldSet) {<FILL_FUNCTION_BODY>...
Trade trade = new Trade(); trade.setIsin(fieldSet.readString(ISIN_COLUMN)); trade.setQuantity(fieldSet.readLong(QUANTITY_COLUMN)); trade.setPrice(fieldSet.readBigDecimal(PRICE_COLUMN)); trade.setCustomer(fieldSet.readString(CUSTOMER_COLUMN)); return trade;
110
115
225
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/TradeProcessor.java
TradeProcessor
process
class TradeProcessor implements ItemProcessor<Trade, Trade> { private int failure = -1; private int index = 0; private Trade failedItem = null; /** * Public setter for the index on which failure should occur. * @param failure the failure to set */ public void setValidationFailure(int failure) { this.fa...
if ((failedItem == null && index++ == failure) || (failedItem != null && failedItem.equals(item))) { failedItem = item; throw new ValidationException("Some bad data for " + failedItem); } return item;
127
67
194
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/TradeRowMapper.java
TradeRowMapper
mapRow
class TradeRowMapper implements RowMapper<Trade> { public static final int ISIN_COLUMN = 1; public static final int QUANTITY_COLUMN = 2; public static final int PRICE_COLUMN = 3; public static final int CUSTOMER_COLUMN = 4; public static final int ID_COLUMN = 5; public static final int VERSION_COLUMN = 6; ...
Trade trade = new Trade(rs.getLong(ID_COLUMN)); trade.setIsin(rs.getString(ISIN_COLUMN)); trade.setQuantity(rs.getLong(QUANTITY_COLUMN)); trade.setPrice(rs.getBigDecimal(PRICE_COLUMN)); trade.setCustomer(rs.getString(CUSTOMER_COLUMN)); trade.setVersion(rs.getInt(VERSION_COLUMN)); return trade;
144
140
284
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/TradeWriter.java
TradeWriter
write
class TradeWriter extends ItemStreamSupport implements ItemWriter<Trade> { private static final Log log = LogFactory.getLog(TradeWriter.class); public static final String TOTAL_AMOUNT_KEY = "TOTAL_AMOUNT"; private TradeDao dao; private List<String> failingCustomers = new ArrayList<>(); private BigDecimal tota...
for (Trade trade : trades) { log.debug(trade); dao.writeTrade(trade); Assert.notNull(trade.getPrice(), "price must not be null"); // There must be a // price to total if (this.failingCustomers.contains(trade.getCustomer())) { throw new WriteFailedException("Something unexpected...
455
117
572
<methods>public non-sealed void <init>() ,public void close() ,public java.lang.String getExecutionContextKey(java.lang.String) ,public java.lang.String getName() ,public void open(org.springframework.batch.item.ExecutionContext) ,public void setName(java.lang.String) ,public void update(org.springframework.batch.item....
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/domain/trade/internal/validator/TradeValidator.java
TradeValidator
validate
class TradeValidator implements Validator { @Override public boolean supports(Class<?> clazz) { return clazz.equals(Trade.class); } @Override public void validate(Object target, Errors errors) {<FILL_FUNCTION_BODY>} }
Trade trade = (Trade) target; if (trade.getIsin().length() >= 13) { errors.rejectValue("isin", "isin_length"); }
72
56
128
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/delimited/DelimitedJobConfiguration.java
DelimitedJobConfiguration
itemReader
class DelimitedJobConfiguration { @Bean @StepScope public FlatFileItemReader<CustomerCredit> itemReader(@Value("#{jobParameters[inputFile]}") Resource resource) {<FILL_FUNCTION_BODY>} @Bean @StepScope public FlatFileItemWriter<CustomerCredit> itemWriter( @Value("#{jobParameters[outputFile]}") WritableResourc...
return new FlatFileItemReaderBuilder<CustomerCredit>().name("itemReader") .resource(resource) .delimited() .names("name", "credit") .targetType(CustomerCredit.class) .build();
286
65
351
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/fixed/FixedLengthJobConfiguration.java
FixedLengthJobConfiguration
itemWriter
class FixedLengthJobConfiguration { @Bean @StepScope public FlatFileItemReader<CustomerCredit> itemReader(@Value("#{jobParameters[inputFile]}") Resource resource) { return new FlatFileItemReaderBuilder<CustomerCredit>().name("itemReader") .resource(resource) .fixedLength() .columns(new Range(1, 9), new R...
return new FlatFileItemWriterBuilder<CustomerCredit>().name("itemWriter") .resource(resource) .formatted() .format("%-9s%-2.0f") .names("name", "credit") .build();
319
67
386
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/json/JsonJobConfiguration.java
JsonJobConfiguration
itemWriter
class JsonJobConfiguration { @Bean @StepScope public JsonItemReader<Trade> itemReader(@Value("#{jobParameters[inputFile]}") Resource resource) { return new JsonItemReaderBuilder<Trade>().name("tradesJsonItemReader") .resource(resource) .jsonObjectReader(new GsonJsonObjectReader<>(Trade.class)) .build(); ...
return new JsonFileItemWriterBuilder<Trade>().resource(resource) .lineSeparator("\n") .jsonObjectMarshaller(new JacksonJsonObjectMarshaller<>()) .name("tradesJsonFileItemWriter") .shouldDeleteIfExists(true) .build();
281
75
356
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/multiline/MultiLineJobConfiguration.java
MultiLineJobConfiguration
itemReader
class MultiLineJobConfiguration { @Bean @StepScope public MultiLineTradeItemReader itemReader(@Value("#{jobParameters[inputFile]}") Resource resource) {<FILL_FUNCTION_BODY>} @Bean @StepScope public MultiLineTradeItemWriter itemWriter(@Value("#{jobParameters[outputFile]}") WritableResource resource) { FlatFile...
FlatFileItemReader<FieldSet> delegate = new FlatFileItemReaderBuilder<FieldSet>().name("delegateItemReader") .resource(resource) .lineTokenizer(new DelimitedLineTokenizer()) .fieldSetMapper(new PassThroughFieldSetMapper()) .build(); MultiLineTradeItemReader reader = new MultiLineTradeItemReader(); re...
301
113
414
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/multiline/MultiLineTradeItemReader.java
MultiLineTradeItemReader
read
class MultiLineTradeItemReader implements ItemReader<Trade>, ItemStream { private FlatFileItemReader<FieldSet> delegate; /** * @see org.springframework.batch.item.ItemReader#read() */ @Nullable @Override public Trade read() throws Exception {<FILL_FUNCTION_BODY>} public void setDelegate(FlatFileItemReader<...
Trade t = null; for (FieldSet line; (line = this.delegate.read()) != null;) { String prefix = line.readString(0); switch (prefix) { case "BEGIN" -> t = new Trade(); // Record must start with 'BEGIN' case "INFO" -> { Assert.notNull(t, "No 'BEGIN' was found."); t.setIsin(line.readString(1));...
210
253
463
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/multiline/MultiLineTradeItemWriter.java
MultiLineTradeItemWriter
write
class MultiLineTradeItemWriter implements ItemWriter<Trade>, ItemStream { private FlatFileItemWriter<String> delegate; @Override public void write(Chunk<? extends Trade> items) throws Exception {<FILL_FUNCTION_BODY>} public void setDelegate(FlatFileItemWriter<String> delegate) { this.delegate = delegate; } ...
Chunk<String> lines = new Chunk<>(); for (Trade t : items) { lines.add("BEGIN"); lines.add("INFO," + t.getIsin() + "," + t.getCustomer()); lines.add("AMNT," + t.getQuantity() + "," + t.getPrice()); lines.add("END"); } this.delegate.write(lines);
191
115
306
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/multiline/Trade.java
Trade
hashCode
class Trade implements Serializable { private String isin = ""; private long quantity = 0; private BigDecimal price = BigDecimal.ZERO; private String customer = ""; private Long id; private long version = 0; public Trade() { } public Trade(String isin, long quantity, BigDecimal price, String customer) ...
final int prime = 31; int result = 1; result = prime * result + ((customer == null) ? 0 : customer.hashCode()); result = prime * result + ((isin == null) ? 0 : isin.hashCode()); result = prime * result + ((price == null) ? 0 : price.hashCode()); result = prime * result + (int) (quantity ^ (quantity >>> 32)...
778
144
922
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/multilineaggregate/AggregateItemFieldSetMapper.java
AggregateItemFieldSetMapper
mapFieldSet
class AggregateItemFieldSetMapper<T> implements FieldSetMapper<AggregateItem<T>>, InitializingBean { private FieldSetMapper<T> delegate; private String end = "END"; private String begin = "BEGIN"; /** * Public setter for the delegate. * @param delegate the delegate to set */ public void setDelegate(Field...
if (fieldSet.readString(0).equals(begin)) { return AggregateItem.getHeader(); } if (fieldSet.readString(0).equals(end)) { return AggregateItem.getFooter(); } return new AggregateItem<>(delegate.mapFieldSet(fieldSet));
497
90
587
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/multilineaggregate/AggregateItemReader.java
AggregateItemReader
process
class AggregateItemReader<T> implements ItemReader<List<T>> { private static final Log LOG = LogFactory.getLog(AggregateItemReader.class); private ItemReader<AggregateItem<T>> itemReader; /** * Get the next list of records. * * @see org.springframework.batch.item.ItemReader#read() */ @Nullable @Override...
// finish processing if we hit the end of file if (value == null) { LOG.debug("Exhausted ItemReader"); holder.setExhausted(true); return false; } // start a new collection if (value.isHeader()) { LOG.debug("Start of new record detected"); return true; } // mark we are finished with curre...
410
195
605
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/multirecordtype/DelegatingTradeLineAggregator.java
DelegatingTradeLineAggregator
aggregate
class DelegatingTradeLineAggregator implements LineAggregator<Object> { private LineAggregator<Trade> tradeLineAggregator; private LineAggregator<CustomerCredit> customerLineAggregator; @Override public String aggregate(Object item) {<FILL_FUNCTION_BODY>} public void setTradeLineAggregator(LineAggregator<Trade...
if (item instanceof Trade) { return this.tradeLineAggregator.aggregate((Trade) item); } else if (item instanceof CustomerCredit) { return this.customerLineAggregator.aggregate((CustomerCredit) item); } else { throw new RuntimeException(); }
158
85
243
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/multirecordtype/MultiRecordTypeJobConfiguration.java
MultiRecordTypeJobConfiguration
tradeLineAggregator
class MultiRecordTypeJobConfiguration { @Bean @StepScope public FlatFileItemReader itemReader(PatternMatchingCompositeLineMapper lineMapper, @Value("#{jobParameters[inputFile]}") Resource resource) { return new FlatFileItemReaderBuilder().name("itemReader").resource(resource).lineMapper(lineMapper).build(); }...
FormatterLineAggregator<Trade> formatterLineAggregator = new FormatterLineAggregator<>(); BeanWrapperFieldExtractor<Trade> fieldExtractor = new BeanWrapperFieldExtractor<>(); fieldExtractor.setNames(new String[] { "isin", "quantity", "price", "customer" }); formatterLineAggregator.setFieldExtractor(fieldExtrac...
941
141
1,082
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/multiresource/MultiResourceJobConfiguration.java
MultiResourceJobConfiguration
job
class MultiResourceJobConfiguration { @Bean @StepScope public MultiResourceItemReader<CustomerCredit> itemReader( @Value("#{jobParameters[inputFiles]}") Resource[] resources) { return new MultiResourceItemReaderBuilder<CustomerCredit>().name("itemReader") .resources(resources) .delegate(delegateReader())...
return new JobBuilder("ioSampleJob", jobRepository) .start(new StepBuilder("step1", jobRepository).<CustomerCredit, CustomerCredit>chunk(2, transactionManager) .reader(itemReader) .processor(new CustomerCreditIncreaseProcessor()) .writer(itemWriter) .build()) .build();
398
89
487
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/Address.java
Address
toString
class Address { public static final String LINE_ID_BILLING_ADDR = "BAD"; public static final String LINE_ID_SHIPPING_ADDR = "SAD"; private String addressee; private String addrLine1; private String addrLine2; private String city; private String zipCode; private String state; private String country; ...
return "Address [addressee=" + addressee + ", city=" + city + ", country=" + country + ", state=" + state + ", zipCode=" + zipCode + "]";
791
54
845
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/BillingInfo.java
BillingInfo
equals
class BillingInfo { public static final String LINE_ID_BILLING_INFO = "BIN"; private String paymentId; private String paymentDesc; public String getPaymentDesc() { return paymentDesc; } public void setPaymentDesc(String paymentDesc) { this.paymentDesc = paymentDesc; } public String getPaymentId() { ...
if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } BillingInfo other = (BillingInfo) obj; if (paymentDesc == null) { if (other.paymentDesc != null) { return false; } } else if (!paymentDesc.equals(other.payment...
287
205
492
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/Customer.java
Customer
equals
class Customer { public static final String LINE_ID_BUSINESS_CUST = "BCU"; public static final String LINE_ID_NON_BUSINESS_CUST = "NCU"; private boolean businessCustomer; private boolean registered; private long registrationId; // non-business customer private String firstName; private String lastName; ...
if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Customer other = (Customer) obj; if (businessCustomer != other.businessCustomer) { return false; } if (companyName == null) { if (other.companyName != null) { ...
771
398
1,169
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/LineItem.java
LineItem
toString
class LineItem { public static final String LINE_ID_ITEM = "LIT"; private long itemId; private BigDecimal price; private BigDecimal discountPerc; private BigDecimal discountAmount; private BigDecimal shippingPrice; private BigDecimal handlingPrice; private int quantity; private BigDecimal totalPrice; ...
return "LineItem [price=" + price + ", quantity=" + quantity + ", totalPrice=" + totalPrice + "]";
697
35
732
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/Order.java
Order
hashCode
class Order { public static final String LINE_ID_HEADER = "HEA"; public static final String LINE_ID_FOOTER = "FOT"; // header private long orderId; private Date orderDate; // footer private int totalLines; private int totalItems; private BigDecimal totalPrice; private Customer customer; private Addr...
final int prime = 31; int result = 1; result = prime * result + ((billing == null) ? 0 : billing.hashCode()); result = prime * result + ((billingAddress == null) ? 0 : billingAddress.hashCode()); result = prime * result + ((customer == null) ? 0 : customer.hashCode()); result = prime * result + ((lineItems...
1,336
275
1,611
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/ShippingInfo.java
ShippingInfo
equals
class ShippingInfo { public static final String LINE_ID_SHIPPING_INFO = "SIN"; private String shipperId; private String shippingTypeId; private String shippingInfo; public String getShipperId() { return shipperId; } public void setShipperId(String shipperId) { this.shipperId = shipperId; } public St...
if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } ShippingInfo other = (ShippingInfo) obj; if (shipperId == null) { if (other.shipperId != null) { return false; } } else if (!shipperId.equals(other.shipperId))...
343
273
616
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/internal/OrderItemReader.java
OrderItemReader
process
class OrderItemReader implements ItemReader<Order> { private static final Log log = LogFactory.getLog(OrderItemReader.class); private Order order; private boolean recordFinished; private FieldSetMapper<Order> headerMapper; private FieldSetMapper<Customer> customerMapper; private FieldSetMapper<Address> addr...
// finish processing if we hit the end of file if (fieldSet == null) { log.debug("FINISHED"); recordFinished = true; order = null; return; } String lineId = fieldSet.readString(0); switch (lineId) { case Order.LINE_ID_HEADER -> { log.debug("STARTING NEW RECORD"); order = headerMapper...
547
838
1,385
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/internal/OrderLineAggregator.java
OrderLineAggregator
aggregate
class OrderLineAggregator implements LineAggregator<Order> { private static final String LINE_SEPARATOR = System.getProperty("line.separator"); private Map<String, LineAggregator<Object>> aggregators; @Override public String aggregate(Order order) {<FILL_FUNCTION_BODY>} /** * Set aggregators for all types of...
StringBuilder result = new StringBuilder(); result.append(aggregators.get("header").aggregate(order)).append(LINE_SEPARATOR); result.append(aggregators.get("customer").aggregate(order)).append(LINE_SEPARATOR); result.append(aggregators.get("address").aggregate(order)).append(LINE_SEPARATOR); result.append(a...
160
211
371
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/internal/extractor/AddressFieldExtractor.java
AddressFieldExtractor
extract
class AddressFieldExtractor implements FieldExtractor<Order> { @Override public Object[] extract(Order order) {<FILL_FUNCTION_BODY>} }
Address address = order.getBillingAddress(); return new Object[] { "ADDRESS:", address.getAddrLine1(), address.getCity(), address.getZipCode() };
43
48
91
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/internal/extractor/BillingInfoFieldExtractor.java
BillingInfoFieldExtractor
extract
class BillingInfoFieldExtractor implements FieldExtractor<Order> { @Override public Object[] extract(Order order) {<FILL_FUNCTION_BODY>} }
BillingInfo billingInfo = order.getBilling(); return new Object[] { "BILLING:", billingInfo.getPaymentId(), billingInfo.getPaymentDesc() };
45
51
96
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/internal/extractor/CustomerFieldExtractor.java
CustomerFieldExtractor
extract
class CustomerFieldExtractor implements FieldExtractor<Order> { @Override public Object[] extract(Order order) {<FILL_FUNCTION_BODY>} private String emptyIfNull(String s) { return s != null ? s : ""; } }
Customer customer = order.getCustomer(); return new Object[] { "CUSTOMER:", customer.getRegistrationId(), emptyIfNull(customer.getFirstName()), emptyIfNull(customer.getMiddleName()), emptyIfNull(customer.getLastName()) };
68
70
138
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/internal/mapper/AddressFieldSetMapper.java
AddressFieldSetMapper
mapFieldSet
class AddressFieldSetMapper implements FieldSetMapper<Address> { public static final String ADDRESSEE_COLUMN = "ADDRESSEE"; public static final String ADDRESS_LINE1_COLUMN = "ADDR_LINE1"; public static final String ADDRESS_LINE2_COLUMN = "ADDR_LINE2"; public static final String CITY_COLUMN = "CITY"; public st...
Address address = new Address(); address.setAddressee(fieldSet.readString(ADDRESSEE_COLUMN)); address.setAddrLine1(fieldSet.readString(ADDRESS_LINE1_COLUMN)); address.setAddrLine2(fieldSet.readString(ADDRESS_LINE2_COLUMN)); address.setCity(fieldSet.readString(CITY_COLUMN)); address.setZipCode(fieldSet.rea...
184
183
367
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/internal/mapper/BillingFieldSetMapper.java
BillingFieldSetMapper
mapFieldSet
class BillingFieldSetMapper implements FieldSetMapper<BillingInfo> { public static final String PAYMENT_TYPE_ID_COLUMN = "PAYMENT_TYPE_ID"; public static final String PAYMENT_DESC_COLUMN = "PAYMENT_DESC"; @Override public BillingInfo mapFieldSet(FieldSet fieldSet) {<FILL_FUNCTION_BODY>} }
BillingInfo info = new BillingInfo(); info.setPaymentId(fieldSet.readString(PAYMENT_TYPE_ID_COLUMN)); info.setPaymentDesc(fieldSet.readString(PAYMENT_DESC_COLUMN)); return info;
103
78
181
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/internal/mapper/CustomerFieldSetMapper.java
CustomerFieldSetMapper
mapFieldSet
class CustomerFieldSetMapper implements FieldSetMapper<Customer> { public static final String LINE_ID_COLUMN = "LINE_ID"; public static final String COMPANY_NAME_COLUMN = "COMPANY_NAME"; public static final String LAST_NAME_COLUMN = "LAST_NAME"; public static final String FIRST_NAME_COLUMN = "FIRST_NAME"; pub...
Customer customer = new Customer(); if (Customer.LINE_ID_BUSINESS_CUST.equals(fieldSet.readString(LINE_ID_COLUMN))) { customer.setCompanyName(fieldSet.readString(COMPANY_NAME_COLUMN)); // business customer must be always registered customer.setRegistered(true); } if (Customer.LINE_ID_NON_BUSINESS_CU...
230
306
536
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/internal/mapper/HeaderFieldSetMapper.java
HeaderFieldSetMapper
mapFieldSet
class HeaderFieldSetMapper implements FieldSetMapper<Order> { public static final String ORDER_ID_COLUMN = "ORDER_ID"; public static final String ORDER_DATE_COLUMN = "ORDER_DATE"; @Override public Order mapFieldSet(FieldSet fieldSet) {<FILL_FUNCTION_BODY>} }
Order order = new Order(); order.setOrderId(fieldSet.readLong(ORDER_ID_COLUMN)); order.setOrderDate(fieldSet.readDate(ORDER_DATE_COLUMN)); return order;
85
64
149
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/internal/mapper/OrderItemFieldSetMapper.java
OrderItemFieldSetMapper
mapFieldSet
class OrderItemFieldSetMapper implements FieldSetMapper<LineItem> { public static final String TOTAL_PRICE_COLUMN = "TOTAL_PRICE"; public static final String QUANTITY_COLUMN = "QUANTITY"; public static final String HANDLING_PRICE_COLUMN = "HANDLING_PRICE"; public static final String SHIPPING_PRICE_COLUMN = "SHI...
LineItem item = new LineItem(); item.setItemId(fieldSet.readLong(ITEM_ID_COLUMN)); item.setPrice(fieldSet.readBigDecimal(PRICE_COLUMN)); item.setDiscountPerc(fieldSet.readBigDecimal(DISCOUNT_PERC_COLUMN)); item.setDiscountAmount(fieldSet.readBigDecimal(DISCOUNT_AMOUNT_COLUMN)); item.setShippingPrice(field...
234
238
472
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/internal/mapper/ShippingFieldSetMapper.java
ShippingFieldSetMapper
mapFieldSet
class ShippingFieldSetMapper implements FieldSetMapper<ShippingInfo> { public static final String ADDITIONAL_SHIPPING_INFO_COLUMN = "ADDITIONAL_SHIPPING_INFO"; public static final String SHIPPING_TYPE_ID_COLUMN = "SHIPPING_TYPE_ID"; public static final String SHIPPER_ID_COLUMN = "SHIPPER_ID"; @Override public ...
ShippingInfo info = new ShippingInfo(); info.setShipperId(fieldSet.readString(SHIPPER_ID_COLUMN)); info.setShippingTypeId(fieldSet.readString(SHIPPING_TYPE_ID_COLUMN)); info.setShippingInfo(fieldSet.readString(ADDITIONAL_SHIPPING_INFO_COLUMN)); return info;
135
113
248
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/patternmatching/internal/xml/Customer.java
Customer
toString
class Customer { private String name; private String address; private int age; private int moo; private int poo; public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public int getAge() { return age; } public void setAge(int age) { ...
return "Customer [address=" + address + ", age=" + age + ", name=" + name + "]";
256
32
288
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/file/xml/XmlJobConfiguration.java
XmlJobConfiguration
customerCreditMarshaller
class XmlJobConfiguration { @Bean public XStreamMarshaller customerCreditMarshaller() {<FILL_FUNCTION_BODY>} @Bean @StepScope public StaxEventItemReader<CustomerCredit> itemReader(@Value("#{jobParameters[inputFile]}") Resource resource) { return new StaxEventItemReaderBuilder<CustomerCredit>().name("itemReader...
XStreamMarshaller marshaller = new XStreamMarshaller(); marshaller .setAliases(Map.of("customer", CustomerCredit.class, "credit", BigDecimal.class, "name", String.class)); marshaller.setTypePermissions(new ExplicitTypePermission(new Class[] { CustomerCredit.class })); return marshaller;
382
100
482
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/football/FootballJobConfiguration.java
FootballJobConfiguration
playerFileItemReader
class FootballJobConfiguration { // step 1 configuration @Bean public FlatFileItemReader<Player> playerFileItemReader() {<FILL_FUNCTION_BODY>} @Bean public PlayerItemWriter playerWriter(DataSource dataSource) { PlayerItemWriter playerItemWriter = new PlayerItemWriter(); JdbcPlayerDao playerDao = new JdbcPla...
return new FlatFileItemReaderBuilder<Player>().name("playerFileItemReader") .resource(new ClassPathResource("org/springframework/batch/samples/football/data/player-small1.csv")) .delimited() .names("ID", "lastName", "firstName", "position", "birthYear", "debutYear") .fieldSetMapper(new PlayerFieldSetMapp...
1,098
107
1,205
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/football/Game.java
Game
equals
class Game implements Serializable { private String id; private int year; private String team; private int week; private String opponent; private int completes; private int attempts; private int passingYards; private int passingTd; private int interceptions; private int rushes; private int rushY...
if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Game other = (Game) obj; if (id == null) { if (other.id != null) { return false; } } else if (!id.equals(other.id)) { return false; } return true;
1,326
131
1,457
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/football/Player.java
Player
toString
class Player implements Serializable { private String id; private String lastName; private String firstName; private String position; private int birthYear; private int debutYear; @Override public String toString() {<FILL_FUNCTION_BODY>} public String getId() { return id; } public String getLastNa...
return "PLAYER:id=" + id + ",Last Name=" + lastName + ",First Name=" + firstName + ",Position=" + position + ",Birth Year=" + birthYear + ",DebutYear=" + debutYear;
319
65
384
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/football/PlayerSummary.java
PlayerSummary
toString
class PlayerSummary { private String id; private int year; private int completes; private int attempts; private int passingYards; private int passingTd; private int interceptions; private int rushes; private int rushYards; private int receptions; private int receptionYards; private int totalTd; ...
return "Player Summary: ID=" + id + " Year=" + year + "[" + completes + ";" + attempts + ";" + passingYards + ";" + passingTd + ";" + interceptions + ";" + rushes + ";" + rushYards + ";" + receptions + ";" + receptionYards + ";" + totalTd;
850
90
940
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/football/internal/GameFieldSetMapper.java
GameFieldSetMapper
mapFieldSet
class GameFieldSetMapper implements FieldSetMapper<Game> { @Override public Game mapFieldSet(FieldSet fs) {<FILL_FUNCTION_BODY>} }
if (fs == null) { return null; } Game game = new Game(); game.setId(fs.readString("id")); game.setYear(fs.readInt("year")); game.setTeam(fs.readString("team")); game.setWeek(fs.readInt("week")); game.setOpponent(fs.readString("opponent")); game.setCompletes(fs.readInt("completes")); game.setAt...
45
307
352
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/football/internal/JdbcGameDao.java
JdbcGameDao
write
class JdbcGameDao extends JdbcDaoSupport implements ItemWriter<Game> { private SimpleJdbcInsert insertGame; @Override protected void initDao() throws Exception { super.initDao(); insertGame = new SimpleJdbcInsert(getDataSource()).withTableName("GAMES") .usingColumns("player_id", "year_no", "team", "week", "...
for (Game game : games) { SqlParameterSource values = new MapSqlParameterSource().addValue("player_id", game.getId()) .addValue("year_no", game.getYear()) .addValue("team", game.getTeam()) .addValue("week", game.getWeek()) .addValue("opponent", game.getOpponent()) .addValue("completes", game...
194
285
479
<methods>public void <init>() ,public final javax.sql.DataSource getDataSource() ,public final org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate() ,public final void setDataSource(javax.sql.DataSource) ,public final void setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) <variables>private org.springf...
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/football/internal/JdbcPlayerSummaryDao.java
JdbcPlayerSummaryDao
write
class JdbcPlayerSummaryDao implements ItemWriter<PlayerSummary> { private static final String INSERT_SUMMARY = "INSERT into PLAYER_SUMMARY(ID, YEAR_NO, COMPLETES, ATTEMPTS, PASSING_YARDS, PASSING_TD, " + "INTERCEPTIONS, RUSHES, RUSH_YARDS, RECEPTIONS, RECEPTIONS_YARDS, TOTAL_TD) " + "values(:id, :year, :complet...
for (PlayerSummary summary : summaries) { MapSqlParameterSource args = new MapSqlParameterSource().addValue("id", summary.getId()) .addValue("year", summary.getYear()) .addValue("completes", summary.getCompletes()) .addValue("attempts", summary.getAttempts()) .addValue("passingYards", summary.ge...
268
247
515
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/football/internal/PlayerFieldSetMapper.java
PlayerFieldSetMapper
mapFieldSet
class PlayerFieldSetMapper implements FieldSetMapper<Player> { @Override public Player mapFieldSet(FieldSet fs) {<FILL_FUNCTION_BODY>} }
if (fs == null) { return null; } Player player = new Player(); player.setId(fs.readString("ID")); player.setLastName(fs.readString("lastName")); player.setFirstName(fs.readString("firstName")); player.setPosition(fs.readString("position")); player.setDebutYear(fs.readInt("debutYear")); player.se...
45
139
184
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/football/internal/PlayerSummaryMapper.java
PlayerSummaryMapper
mapRow
class PlayerSummaryMapper implements RowMapper<PlayerSummary> { @Override public PlayerSummary mapRow(ResultSet rs, int rowNum) throws SQLException {<FILL_FUNCTION_BODY>} }
PlayerSummary summary = new PlayerSummary(); summary.setId(rs.getString(1)); summary.setYear(rs.getInt(2)); summary.setCompletes(rs.getInt(3)); summary.setAttempts(rs.getInt(4)); summary.setPassingYards(rs.getInt(5)); summary.setPassingTd(rs.getInt(6)); summary.setInterceptions(rs.getInt(7)); summa...
52
224
276
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/football/internal/PlayerSummaryRowMapper.java
PlayerSummaryRowMapper
mapRow
class PlayerSummaryRowMapper implements RowMapper<PlayerSummary> { @Override public PlayerSummary mapRow(ResultSet rs, int rowNum) throws SQLException {<FILL_FUNCTION_BODY>} }
PlayerSummary summary = new PlayerSummary(); summary.setId(rs.getString(1)); summary.setYear(rs.getInt(2)); summary.setCompletes(rs.getInt(3)); summary.setAttempts(rs.getInt(4)); summary.setPassingYards(rs.getInt(5)); summary.setPassingTd(rs.getInt(6)); summary.setInterceptions(rs.getInt(7)); summa...
53
224
277
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/helloworld/HelloWorldJobConfiguration.java
HelloWorldJobConfiguration
step
class HelloWorldJobConfiguration { @Bean public Step step(JobRepository jobRepository, JdbcTransactionManager transactionManager) {<FILL_FUNCTION_BODY>} @Bean public Job job(JobRepository jobRepository, Step step) { return new JobBuilder("job", jobRepository).start(step).build(); } }
return new StepBuilder("step", jobRepository).tasklet((contribution, chunkContext) -> { System.out.println("Hello world!"); return RepeatStatus.FINISHED; }, transactionManager).build();
83
60
143
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/jdbc/JdbcReaderBatchWriterSampleJob.java
JdbcReaderBatchWriterSampleJob
itemWriter
class JdbcReaderBatchWriterSampleJob { @Bean public JdbcBatchItemWriter<CustomerCredit> itemWriter(DataSource dataSource) {<FILL_FUNCTION_BODY>} @Bean public Job job(JobRepository jobRepository, JdbcTransactionManager transactionManager, ItemReader<CustomerCredit> itemReader, JdbcBatchItemWriter<CustomerCredit...
String sql = "UPDATE CUSTOMER set credit = :credit where id = :id"; return new JdbcBatchItemWriterBuilder<CustomerCredit>().dataSource(dataSource) .sql(sql) .itemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<>()) .assertUpdates(true) .build();
186
89
275
<no_super_class>
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/jdbc/cursor/JdbcCursorReaderBatchWriterSampleJob.java
JdbcCursorReaderBatchWriterSampleJob
itemReader
class JdbcCursorReaderBatchWriterSampleJob extends JdbcReaderBatchWriterSampleJob { @Bean public JdbcCursorItemReader<CustomerCredit> itemReader(DataSource dataSource) {<FILL_FUNCTION_BODY>} }
String sql = "select ID, NAME, CREDIT from CUSTOMER"; return new JdbcCursorItemReaderBuilder<CustomerCredit>().name("customerReader") .dataSource(dataSource) .sql(sql) .rowMapper(new CustomerCreditRowMapper()) .build();
59
78
137
<methods>public non-sealed void <init>() ,public JdbcBatchItemWriter<org.springframework.batch.samples.domain.trade.CustomerCredit> itemWriter(javax.sql.DataSource) ,public org.springframework.batch.core.Job job(org.springframework.batch.core.repository.JobRepository, org.springframework.jdbc.support.JdbcTransactionMan...
spring-projects_spring-batch
spring-batch/spring-batch-samples/src/main/java/org/springframework/batch/samples/jdbc/paging/JdbcPagingReaderBatchWriterSampleJob.java
JdbcPagingReaderBatchWriterSampleJob
itemReader
class JdbcPagingReaderBatchWriterSampleJob extends JdbcReaderBatchWriterSampleJob { @Bean @StepScope public JdbcPagingItemReader<CustomerCredit> itemReader(DataSource dataSource, @Value("#{jobParameters['credit']}") Double credit) {<FILL_FUNCTION_BODY>} }
Map<String, Object> parameterValues = new HashMap<>(); parameterValues.put("statusCode", "PE"); parameterValues.put("credit", credit); parameterValues.put("type", "COLLECTION"); return new JdbcPagingItemReaderBuilder<CustomerCredit>().name("customerReader") .dataSource(dataSource) .selectClause("selec...
82
193
275
<methods>public non-sealed void <init>() ,public JdbcBatchItemWriter<org.springframework.batch.samples.domain.trade.CustomerCredit> itemWriter(javax.sql.DataSource) ,public org.springframework.batch.core.Job job(org.springframework.batch.core.repository.JobRepository, org.springframework.jdbc.support.JdbcTransactionMan...