Source:
public void execute(final JobExecutionContext jobContext) throws JobExecutionException { SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this); LOGGER.info("********* Starting the Add 2015 V19 Upload Template job. *********"); try { List<UploadTemplateVersionDTO> allTemplates = uploadTemplateDao.findAll(); Optional<UploadTemplateVersionDTO> existingTemplate = allTemplates.stream() .filter(currTemplate -> currTemplate.getName().equals(UploadTemplateVersion.EDITION_2015_VERSION_5.getName())) .findFirst(); if (existingTemplate.isPresent()) { LOGGER.info("Template " + UploadTemplateVersion.EDITION_2015_VERSION_5.getName() + " exists and will be updated."); UploadTemplateVersionDTO newUploadTemplate = new UploadTemplateVersionDTO(); newUploadTemplate.setAvailableAsOf(new Date()); newUploadTemplate.setDeprecated(Boolean.FALSE); newUploadTemplate.setHeaderCsv(CSV_HEADER); newUploadTemplate.setName(UploadTemplateVersion.EDITION_2015_VERSION_5.getName()); insertableUploadTemplateDao.update(newUploadTemplate); LOGGER.info("Updated " + UploadTemplateVersion.EDITION_2015_VERSION_5.getName() + " template."); } else { LOGGER.info("Template " + UploadTemplateVersion.EDITION_2015_VERSION_5.getName() + " does not exist and will be added."); UploadTemplateVersionDTO newUploadTemplate = new UploadTemplateVersionDTO(); newUploadTemplate.setAvailableAsOf(new Date()); newUploadTemplate.setDeprecated(Boolean.FALSE); newUploadTemplate.setHeaderCsv(CSV_HEADER); newUploadTemplate.setName(UploadTemplateVersion.EDITION_2015_VERSION_5.getName()); insertableUploadTemplateDao.create(newUploadTemplate); LOGGER.info("Created " + UploadTemplateVersion.EDITION_2015_VERSION_5.getName() + " template."); } } catch (final Exception e) { LOGGER.error(e); } finally { CacheManager.getInstance().clearAll(); } LOGGER.info("********* Completed the Add 2015 V19 Upload Template job. *********"); }

Target:
public void execute(final JobExecutionContext jobContext) throws JobExecutionException { SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this); LOGGER.info("********* Starting the Add 2015 V19 Upload Template job. *********"); try { List<UploadTemplateVersionDTO> allTemplates = uploadTemplateDao.findAll(); Optional<UploadTemplateVersionDTO> existingTemplate = allTemplates.stream() .filter(currTemplate -> currTemplate.getName().equals(UploadTemplateVersion.EDITION_2015_VERSION_5.getName())) .findFirst(); UploadTemplateVersionDTO newUploadTemplate = new UploadTemplateVersionDTO(); newUploadTemplate.setAvailableAsOf(new Date()); newUploadTemplate.setDeprecated(Boolean.FALSE); newUploadTemplate.setHeaderCsv(CSV_HEADER); newUploadTemplate.setName(UploadTemplateVersion.EDITION_2015_VERSION_5.getName()); if (existingTemplate.isPresent()) { LOGGER.info("Template " + UploadTemplateVersion.EDITION_2015_VERSION_5.getName() + " exists and will be updated."); insertableUploadTemplateDao.update(newUploadTemplate); LOGGER.info("Updated " + UploadTemplateVersion.EDITION_2015_VERSION_5.getName() + " template."); } else { LOGGER.info("Template " + UploadTemplateVersion.EDITION_2015_VERSION_5.getName() + " does not exist and will be added."); insertableUploadTemplateDao.create(newUploadTemplate); LOGGER.info("Created " + UploadTemplateVersion.EDITION_2015_VERSION_5.getName() + " template."); } } catch (final Exception e) { LOGGER.error(e); } finally { CacheManager.getInstance().clearAll(); } LOGGER.info("********* Completed the Add 2015 V19 Upload Template job. *********"); }