List of usage examples for org.springframework.batch.item ExecutionContext containsKey
public boolean containsKey(String key)
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 {/*w ww . j av a2 s . co 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 www . j a v a 2 s . c o m this.totalPrice = BigDecimal.ZERO; } }
From source file:batch.OutputFileListener.java
@BeforeStep public void createOutputNameFromInput(StepExecution stepExecution) { ExecutionContext executionContext = stepExecution.getExecutionContext(); String inputName = stepExecution.getStepName().replace(":", "-"); if (executionContext.containsKey(inputKeyName)) { inputName = executionContext.getString(inputKeyName); }/* w w w . j a v a 2 s . c o m*/ if (!executionContext.containsKey(outputKeyName)) { executionContext.putString(outputKeyName, path + FilenameUtils.getBaseName(inputName) + ".csv"); } }
From source file:mpg.biochem.de.interbase.batch.OutputFileListener.java
@BeforeStep public void createOutputNameFromInput(StepExecution stepExecution) { ExecutionContext executionContext = stepExecution.getExecutionContext(); String inputName = stepExecution.getStepName().replace(":", "-"); if (executionContext.containsKey(inputKeyName)) { inputName = executionContext.getString(inputKeyName); }/*ww w . j ava2 s. com*/ if (!executionContext.containsKey(outputKeyName)) { executionContext.putString(outputKeyName, path + FilenameUtils.getBaseName(inputName) + ".mapped.tab"); } }
From source file:com.cat.ic.listener.impl.OutputFileListenerMVNO.java
@BeforeStep public void createOutputNameFromInput(StepExecution stepExecution) { ExecutionContext executionContext = stepExecution.getExecutionContext(); String inputName = stepExecution.getStepName().replace(":", "-"); if (executionContext.containsKey(inputKeyName)) { inputName = executionContext.getString(inputKeyName); }//from ww w . ja v a 2s.c o m if (!executionContext.containsKey(outputKeyName)) { executionContext.putString(outputKeyName, path + FilenameUtils.getName(inputName) + ".mvno"); } log.info("[" + executionContext.getString(outputKeyName) + "]"); }
From source file:egovframework.rte.bat.core.listener.EgovOutputFileListener.java
/** * stepExecutionContext? inputKeyName ? ? outputKeyName? put * //from w w w. j av a2s . c o m * @param stepExecution */ @BeforeStep public void createOutputNameFromInput(StepExecution stepExecution) { ExecutionContext executionContext = stepExecution.getExecutionContext(); String inputName = stepExecution.getStepName().replace(":", "-"); if (executionContext.containsKey(inputKeyName)) { inputName = executionContext.getString(inputKeyName); } if (!executionContext.containsKey(outputKeyName)) { executionContext.putString(outputKeyName, path + FilenameUtils.getBaseName(inputName) + ".csv"); } }
From source file:batch.demo.job.MultiThreadedFlatFileItemReader.java
@Override public void open(ExecutionContext executionContext) throws ItemStreamException { if (isSaveState()) { Assert.notNull(executionContext, "ExecutionContext must not be null"); if (executionContext.containsKey(getExecutionContextUserSupport().getKey(START_AT_KEY))) { startAt = executionContext.getLong(getExecutionContextUserSupport().getKey(START_AT_KEY)); }/* w w w. j a v a 2 s.co m*/ } // replace the DefaultBufferedReaderFactory with an implementation that seeks to the start before reading setBufferedReaderFactory(new BufferedFileReaderFactory(this.startAt)); super.open(executionContext); }
From source file:es.fcs.batch.integration.chunk.MyChunkMessageChannelItemWriter.java
public void open(ExecutionContext executionContext) throws ItemStreamException { if (executionContext.containsKey(EXPECTED)) { localState.open(executionContext.getInt(EXPECTED), executionContext.getInt(ACTUAL)); if (!waitForResults()) { throw new ItemStreamException("Timed out waiting for back log on open"); }/*from w ww . j av a2 s . c o m*/ } }
From source file:org.opensourcebank.batch.reader.HazelcastMapItemReader.java
public void open(ExecutionContext executionContext) throws ItemStreamException { // staring Hazelcast to have this node join the cluster // and getting a reference to an items map itemMap = Hazelcast.getMap(mapName); // possibly restarted, but all items were completed / evicted by another node // or just a wrong map name if (itemMap.size() == 0) { logger.warn("Map [ " + mapName + " ] is empty, no items to read"); }/*from w ww.j a v a 2 s. c o m*/ // is this step restarted? if (executionContext.containsKey(CURRENT_ITEM_ID)) { currentItemId = new Long(executionContext.getLong(CURRENT_ITEM_ID)).intValue(); } else { currentItemId = fromId; } }
From source file:me.andpay.ti.spring.batch.FlatFileItemWriter.java
private void doOpen(ExecutionContext executionContext) throws ItemStreamException { OutputState outputState = getOutputState(); if (executionContext.containsKey(getKey(RESTART_DATA_NAME))) { outputState.restoreFrom(executionContext); }/*from w w w . j av a 2s . c o m*/ try { outputState.initializeBufferedWriter(); } catch (IOException ioe) { throw new ItemStreamException("Failed to initialize writer", ioe); } if (outputState.lastMarkedByteOffsetPosition == 0 && !outputState.appending) { if (headerCallback != null) { try { headerCallback.writeHeader(outputState.outputBufferedWriter); outputState.write(lineSeparator); } catch (IOException e) { throw new ItemStreamException("Could not write headers. The file may be corrupt.", e); } } } }