List of usage examples for org.springframework.batch.core JobParameters getString
@Nullable
public String getString(String key)
From source file:org.duracloud.snapshot.service.impl.RestoreJobParameterMarshaller.java
public static String unmarshal(JobParameters parameters) { return parameters.getString(SnapshotServiceConstants.SPRING_BATCH_UNIQUE_ID); }
From source file:biz.c24.io.spring.batch.writer.C24ItemWriterTests.java
/** * Mock up the necessary job parameters/*from www . j ava2 s . c o m*/ * * @param outputFileName The filename we want the ItemWriter to write to */ private StepExecution getStepExecution(String outputFileName) throws IOException { JobParameters jobParams = mock(JobParameters.class); when(jobParams.getString("output.file")).thenReturn(outputFileName); StepExecution stepExecution = mock(StepExecution.class); when(stepExecution.getJobParameters()).thenReturn(jobParams); return stepExecution; }
From source file:uk.ac.ebi.intact.editor.controller.dbmanager.ImportJobController.java
public String extractJobId(JobExecution execution) { if (execution != null) { JobParameters param = execution.getJobParameters(); if (param != null) { return param.getString("MIJobId"); }// w w w. j a va 2 s .c o m } return null; }
From source file:uk.ac.ebi.intact.editor.controller.dbmanager.ImportJobController.java
public void acceptImport(ActionEvent evt) { if (!evt.getComponent().getChildren().isEmpty()) { UIParameter param = (UIParameter) evt.getComponent().getChildren().iterator().next(); long executionId = (Long) param.getValue(); JobExecution execution = getJobExplorer().getJobExecution(executionId); if (execution != null) { JobParameters params = execution.getJobParameters(); if (params != null) { String jobId = params.getString("MIJobId"); try { getDbImportService().acceptImport(jobId); getBatchJobService().deleteJob(executionId); addInfoMessage("Job accepted, import annotations removed", "Execution ID: " + executionId); } catch (Throwable e) { addErrorMessage("Cannot accept job import " + e.getMessage(), "Execution ID: " + executionId); }/*from w ww .j ava 2s .c o m*/ } } } }
From source file:uk.ac.ebi.intact.editor.controller.dbmanager.ImportJobController.java
public void discardImport(ActionEvent evt) { if (!evt.getComponent().getChildren().isEmpty()) { UIParameter param = (UIParameter) evt.getComponent().getChildren().iterator().next(); long executionId = (Long) param.getValue(); JobExecution execution = getJobExplorer().getJobExecution(executionId); if (execution != null) { JobParameters params = execution.getJobParameters(); if (params != null) { String jobId = params.getString("MIJobId"); try { getDbImportService().deleteImportedFeatures(jobId); getDbImportService().deleteImportedParticipants(jobId); getDbImportService().deleteImportedInteractions(jobId); getDbImportService().deleteImportedExperiments(jobId); getDbImportService().deleteImportedPublications(jobId); getDbImportService().deleteImportedOrganisms(jobId); getDbImportService().deleteImportedSources(jobId); getDbImportService().deleteImportedCvs(jobId); getBatchJobService().deleteJob(executionId); addInfoMessage("Job cleared, import objects deleted", "Execution ID: " + executionId); } catch (Throwable e) { addErrorMessage("Cannot clear job import " + e.getMessage(), "Execution ID: " + executionId + ", " + ExceptionUtils.getFullStackTrace(e)); }//from www .j ava2s. com String errorFileName = params.getString("error.file"); String fileName = params.getString("input.file"); File file = new File(fileName); if (file.exists()) { file.delete(); } File errorFile = new File(errorFileName); if (errorFile.exists()) { errorFile.delete(); } } } } }
From source file:uk.ac.ebi.intact.editor.controller.dbmanager.ImportJobController.java
public void stopAndDiscardImport(ActionEvent evt) { if (!evt.getComponent().getChildren().isEmpty()) { UIParameter param = (UIParameter) evt.getComponent().getChildren().iterator().next(); long executionId = (Long) param.getValue(); try {//from w ww. j a v a2 s. com getPsiMIJobManager().getJobOperator().stop(executionId); addInfoMessage("Job stopped", "Execution ID: " + executionId); } catch (NoSuchJobExecutionException e) { addErrorMessage("Job does not exist: " + e.getMessage(), "Execution ID: " + executionId); e.printStackTrace(); } catch (JobExecutionNotRunningException e) { addErrorMessage("Job is not running anymore: " + e.getMessage(), "Execution ID: " + executionId); e.printStackTrace(); } JobExecution execution = getJobExplorer().getJobExecution(executionId); if (execution != null) { JobParameters params = execution.getJobParameters(); if (params != null) { String jobId = params.getString("MIJobId"); try { getDbImportService().deleteImportedFeatures(jobId); getDbImportService().deleteImportedParticipants(jobId); getDbImportService().deleteImportedInteractions(jobId); getDbImportService().deleteImportedExperiments(jobId); getDbImportService().deleteImportedPublications(jobId); getDbImportService().deleteImportedOrganisms(jobId); getDbImportService().deleteImportedSources(jobId); getDbImportService().deleteImportedCvs(jobId); getBatchJobService().deleteJob(executionId); addInfoMessage("Job cleared, import objects deleted", "Execution ID: " + executionId); } catch (Throwable e) { addErrorMessage("Cannot clear job import " + e.getMessage(), "Execution ID: " + executionId + ", " + ExceptionUtils.getFullStackTrace(e)); } String errorFileName = params.getString("error.file"); String fileName = params.getString("input.file"); File file = new File(fileName); if (file.exists()) { file.delete(); } File errorFile = new File(errorFileName); if (errorFile.exists()) { errorFile.delete(); } } } } }
From source file:org.springframework.xd.dirt.plugins.job.JobLaunchRequestTransformer.java
@Transformer public JobLaunchRequest toJobLaunchRequest(Message<?> message) { Job job;//w w w. j a v a 2s . co m try { job = jobRegistry.getJob(jobName); } catch (NoSuchJobException e) { throw new IllegalArgumentException("The job " + jobName + " doesn't exist. Is it deployed?"); } final Object payload = message.getPayload(); JobParameters jobParameters; if (logger.isDebugEnabled()) { logger.debug(String.format( "JobParameters are provided as '%s'. " + "Convertering to Spring Batch JobParameters...", payload.getClass().getSimpleName())); } if (payload instanceof File) { jobParameters = jobParametersConverter.getJobParametersForFile((File) message.getPayload()); } else if (payload instanceof String) { jobParameters = jobParametersConverter.getJobParametersForJsonString((String) payload); } else if (payload instanceof Properties) { jobParameters = jobParametersConverter.getJobParameters((Properties) payload); } else if (payload instanceof Map<?, ?>) { jobParameters = jobParametersConverter.getJobParametersForMap((Map) payload); } else if (payload instanceof Tuple) { final Tuple tuple = (Tuple) payload; final List<Object> tupleValues = tuple.getValues(); final Map<String, Object> map = new LinkedHashMap<String, Object>(tupleValues.size()); for (int i = 0; i < tupleValues.size(); i++) { map.put(tuple.getFieldNames().get(i), tupleValues.get(i)); } jobParameters = jobParametersConverter.getJobParametersForMap(map); } else { throw new IllegalArgumentException( "This transformer does not support payloads of type " + payload.getClass().getSimpleName()); } final boolean isRestart = Boolean .valueOf(jobParameters.getString(ExpandedJobParametersConverter.IS_RESTART_JOB_PARAMETER_KEY)); if (job.getJobParametersIncrementer() != null && !isRestart) { jobParameters = job.getJobParametersIncrementer().getNext(jobParameters); } jobParameters = jobParametersConverter.removeRestartParameterIfExists(jobParameters); return new JobLaunchRequest(job, jobParameters); }