List of usage examples for org.springframework.batch.item ExecutionContext get
@Nullable
public Object get(String key)
From source file:org.obiba.onyx.core.domain.statistics.AppointmentUpdateLog.java
/** * Adds {@link AppointmentUpdateLog}s with the level {@link AppointmentUpdateLog.Level}=ERROR to the Spring Batch * {@link ExecutionContext}. {@code AppointmentUpdateLog}s that are not of the ERROR level will be ignored. * @param context Spring Batch ExecutionContext. * @param appointmentUpdateLog A single appointment update log entry. *//*from w ww. j a va 2 s . com*/ @SuppressWarnings("unchecked") public static void addErrorLog(ExecutionContext context, AppointmentUpdateLog appointmentUpdateLog) { if (context == null) return; if (context.get("logList") == null) context.put("logList", new ArrayList<AppointmentUpdateLog>()); if (appointmentUpdateLog != null && appointmentUpdateLog.getLevel() == Level.ERROR) { ((ArrayList<AppointmentUpdateLog>) context.get("logList")).add(appointmentUpdateLog); } }
From source file:org.cbio.portal.pipelines.foundation.CnaStepListener.java
@Override public void beforeStep(StepExecution stepExecution) { // add map of case id to case data to execution context ExecutionContext executionContext = stepExecution.getJobExecution().getExecutionContext(); Map<String, CaseType> fmiCaseTypeMap = (Map<String, CaseType>) executionContext.get("fmiCaseTypeMap"); stepExecution.getExecutionContext().put("fmiCaseTypeMap", fmiCaseTypeMap); }
From source file:org.cbio.portal.pipelines.foundation.FoundationStepListener.java
@Override public void beforeStep(StepExecution stepExecution) { // add Foundation case list to step execution context ExecutionContext executionContext = stepExecution.getJobExecution().getExecutionContext(); Map<String, CaseType> fmiCaseTypeMap = (Map<String, CaseType>) executionContext.get("fmiCaseTypeMap"); stepExecution.getExecutionContext().put("fmiCaseList", new ArrayList(fmiCaseTypeMap.values())); }
From source file:org.cbio.portal.pipelines.foundation.CnaDataReader.java
@Override public void open(ExecutionContext executionContext) throws ItemStreamException { Map<String, CaseType> fmiCaseTypeMap = (Map<String, CaseType>) executionContext.get("fmiCaseTypeMap"); this.foundationCnaRowData = generateCnaRowData(fmiCaseTypeMap); }
From source file:org.openmrs.module.bahmniexports.example.domain.trade.internal.TradeWriter.java
@Override public void open(ExecutionContext executionContext) { if (executionContext.containsKey(TOTAL_AMOUNT_KEY)) { this.totalPrice = (BigDecimal) executionContext.get(TOTAL_AMOUNT_KEY); } else {//from w ww . j av a2 s. c o m // // Fresh run. Disregard old state. // this.totalPrice = BigDecimal.ZERO; } }
From source file:lcn.module.batch.web.guide.service.TradeWriter.java
@Override public void open(ExecutionContext executionContext) throws ItemStreamException { if (executionContext.containsKey(TOTAL_AMOUNT_KEY)) { this.totalPrice = (BigDecimal) executionContext.get(TOTAL_AMOUNT_KEY); } else {//from ww w.j av a 2s. c om this.totalPrice = BigDecimal.ZERO; } }
From source file:org.jasig.ssp.util.importer.job.csv.RawItemCsvWriter.java
@Override public void open(ExecutionContext executionContext) { RawItemFlatFileHeaderCallback headerCallBack = new RawItemFlatFileHeaderCallback(); String[] columnNames = (String[]) executionContext.get("COLUMNS_NAMES_KEY"); headerCallBack.setColumnNames(columnNames); headerCallBack.setDelimiter(delimiter); super.setHeaderCallback(headerCallBack); RawItemLineAggregator aggregator = new RawItemLineAggregator(); aggregator.setColumnNames(columnNames); aggregator.setDelimiter(delimiter);/*from w w w . j a v a 2s. c om*/ super.setLineAggregator((LineAggregator<RawItem>) aggregator); super.open(executionContext); }
From source file:org.cbio.portal.pipelines.foundation.FoundationReader.java
@Override public void open(ExecutionContext executionContext) throws ItemStreamException { // retrieve list of foundation cases from execution context List<CaseType> foundationCaseListExecution = (List<CaseType>) executionContext.get("fmiCaseList"); if (foundationCaseListExecution.isEmpty() || foundationCaseListExecution == null) { LOG.error("Error retrieving Foundation case list from execution context."); } else {// ww w . j a v a2s .c om this.foundationCaseList = new ArrayList(foundationCaseListExecution); } }
From source file:org.cbio.portal.pipelines.foundation.CnaDataWriter.java
@Override public void open(ExecutionContext executionContext) throws ItemStreamException { // retrieve list of foundation cases from execution context final Map<String, CaseType> fmiCaseTypeMap = (Map<String, CaseType>) executionContext.get("fmiCaseTypeMap"); String stagingFile = outputDirectory + "data_CNA.txt"; PassThroughLineAggregator aggr = new PassThroughLineAggregator(); flatFileItemWriter.setLineAggregator(aggr); flatFileItemWriter.setHeaderCallback(new FlatFileHeaderCallback() { @Override/*from w w w .j a v a2 s .c om*/ public void writeHeader(Writer writer) throws IOException { writer.write(getHeader(fmiCaseTypeMap.keySet())); } }); flatFileItemWriter.setResource(new FileSystemResource(stagingFile)); flatFileItemWriter.open(executionContext); }
From source file:org.cbio.portal.pipelines.foundation.MutationDataWriter.java
@Override public void open(ExecutionContext executionContext) throws ItemStreamException { // retrieve list of foundation cases from execution context final List<CaseType> fmiCaseList = (List<CaseType>) executionContext.get("fmiCaseList"); String stagingFile = outputDirectory + "data_mutations_extended.txt"; PassThroughLineAggregator aggr = new PassThroughLineAggregator(); flatFileItemWriter.setLineAggregator(aggr); flatFileItemWriter.setHeaderCallback(new FlatFileHeaderCallback() { @Override/*from w ww.j a v a2 s.co m*/ public void writeHeader(Writer writer) throws IOException { writer.write(getHeader(fmiCaseList)); } }); flatFileItemWriter.setResource(new FileSystemResource(stagingFile)); flatFileItemWriter.open(executionContext); }