Search in sources :

Example 6 with Line

use of org.baeldung.taskletsvschunks.model.Line in project tutorials by eugenp.

the class LinesWriter method beforeStep.

@Override
public void beforeStep(StepExecution stepExecution) {
    ExecutionContext executionContext = stepExecution.getJobExecution().getExecutionContext();
    this.lines = (List<Line>) executionContext.get("lines");
    fu = new FileUtils("output.csv");
    logger.debug("Lines Writer initialized.");
}
Also used : Line(org.baeldung.taskletsvschunks.model.Line) ExecutionContext(org.springframework.batch.item.ExecutionContext) FileUtils(org.baeldung.taskletsvschunks.utils.FileUtils)

Example 7 with Line

use of org.baeldung.taskletsvschunks.model.Line in project tutorials by eugenp.

the class LinesWriter method execute.

@Override
public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {
    for (Line line : lines) {
        fu.writeLine(line);
        logger.debug("Wrote line " + line.toString());
    }
    return RepeatStatus.FINISHED;
}
Also used : Line(org.baeldung.taskletsvschunks.model.Line)

Aggregations

Line (org.baeldung.taskletsvschunks.model.Line)7 FileUtils (org.baeldung.taskletsvschunks.utils.FileUtils)2 ExecutionContext (org.springframework.batch.item.ExecutionContext)2