diff options
author | 2017-09-07 08:52:41 -0400 | |
---|---|---|
committer | 2017-09-07 08:54:52 -0400 | |
commit | 8cd208ebaa33627daf05d8ffff7b28e53a7067d0 (patch) | |
tree | 0b07ec3c6305c46f34eae69d8fb6fa824aaae256 /ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java | |
parent | b52d4cebc430a083ec1e6881c4f01dfe709ac726 (diff) |
Adjust code for Sonar issues
Made non-functional updates to address static code analysis issues.
Update license header with simple double-quote characters.
Issue: PORTAL-72, PORTAL-90
Change-Id: Ic2c330daea07d721f0e6b350ebf03da97073f7ce
Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java')
-rw-r--r-- | ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java | 93 |
1 files changed, 38 insertions, 55 deletions
diff --git a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java index 73da941c..b7a21a4e 100644 --- a/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java +++ b/ecomp-sdk/epsdk-workflow/src/main/java/org/onap/portalsdk/workflow/services/WorkflowScheduleServiceImpl.java @@ -6,7 +6,7 @@ * =================================================================== * * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the “License”); + * under the Apache License, Version 2.0 (the "License"); * you may not use this software except in compliance with the License. * You may obtain a copy of the License at * @@ -19,7 +19,7 @@ * limitations under the License. * * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at * @@ -56,63 +56,56 @@ import org.springframework.scheduling.quartz.SchedulerFactoryBean; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; - - @Service("workflowScheduleService") @Transactional -public class WorkflowScheduleServiceImpl implements WorkflowScheduleService{ - +public class WorkflowScheduleServiceImpl implements WorkflowScheduleService { + private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WorkflowScheduleServiceImpl.class); - + @Autowired - private DataAccessService dataAccessService; - + private DataAccessService dataAccessService; + @Autowired private WorkFlowScheduleRegistry workflowRegistry; - + @Autowired private ApplicationContext appContext; - + @Override public List<WorkflowSchedule> findAll() { - - /* List<WorkflowSchedule> allworkflows = getDataAccessService().getList(WorkflowSchedule.class, null); - for (WorkflowSchedule ws : allworkflows) { - - System.out.println("Key:"+ws.getWorkflowKey()+" "+"CronDetails:"+ws.getStartdatetimecron()); - } */ @SuppressWarnings("unchecked") List<WorkflowSchedule> list = getDataAccessService().getList(WorkflowSchedule.class, null); return list; } - - - public void saveWorkflowSchedule(WorkflowSchedule ws){ - + + @Override + public void saveWorkflowSchedule(WorkflowSchedule ws) { getDataAccessService().saveDomainObject(ws, null); - logger.info(EELFLoggerDelegate.debugLogger, ("Workflow Scheduled " + ws.getId() + " " + ws.getEndDateTime())); - triggerWorkflowScheduling((SchedulerFactoryBean)appContext.getBean(SchedulerFactoryBean.class),ws); - + logger.info(EELFLoggerDelegate.debugLogger, "Workflow Scheduled " + ws.getId() + " " + ws.getEndDateTime()); + triggerWorkflowScheduling((SchedulerFactoryBean) appContext.getBean(SchedulerFactoryBean.class), ws); } - + + @Override public void triggerWorkflowScheduling(SchedulerFactoryBean schedulerBean, WorkflowSchedule ws) { - try { - final CronTriggerFactoryBean triggerBean = workflowRegistry.setUpTrigger(ws.getId(), ws.getServerUrl(), ws.getWorkflowKey(),ws.getArguments(),ws.getCronDetails(), ws.getStartDateTime(),ws.getEndDateTime()); - schedulerBean.getScheduler().scheduleJob((JobDetail)triggerBean.getJobDataMap().get("jobDetail"),triggerBean.getObject()); + final CronTriggerFactoryBean triggerBean = workflowRegistry.setUpTrigger(ws.getId(), ws.getServerUrl(), + ws.getWorkflowKey(), ws.getArguments(), ws.getCronDetails(), ws.getStartDateTime(), + ws.getEndDateTime()); + schedulerBean.getScheduler().scheduleJob((JobDetail) triggerBean.getJobDataMap().get("jobDetail"), + triggerBean.getObject()); } catch (Exception e) { - logger.debug(EELFLoggerDelegate.debugLogger, ("Error scheduling work flow with Id" + ws.getId() + e.getMessage())); + logger.error(EELFLoggerDelegate.errorLogger, "Error scheduling work flow with Id" + ws.getId(), e); } - } - + + @Override public List<Trigger> triggerWorkflowScheduling() { - - Date date = new Date(); - List<Trigger> triggers = new ArrayList<Trigger>(); - - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + Date date = new Date(); + List<Trigger> triggers = new ArrayList<>(); + + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); if (getDataAccessService() != null) { @SuppressWarnings("unchecked") @@ -120,42 +113,32 @@ public class WorkflowScheduleServiceImpl implements WorkflowScheduleService{ .executeQuery("From WorkflowSchedule where endDateTime > '" + dateFormat.format(date) + "'", null); for (WorkflowSchedule ws : allWorkflows) { - logger.info(EELFLoggerDelegate.debugLogger, ("Workflow Scheduled " + ws.getId() + "/ End Time: " + ws.getEndDateTime())); - + logger.info(EELFLoggerDelegate.debugLogger, + "Workflow Scheduled " + ws.getId() + "/ End Time: " + ws.getEndDateTime()); try { - - final CronTriggerFactoryBean triggerBean = workflowRegistry.setUpTrigger(ws.getId(), ws.getServerUrl(), ws.getWorkflowKey(),ws.getArguments(), ws.getCronDetails(), ws.getStartDateTime(),ws.getEndDateTime()); - + final CronTriggerFactoryBean triggerBean = workflowRegistry.setUpTrigger(ws.getId(), + ws.getServerUrl(), ws.getWorkflowKey(), ws.getArguments(), ws.getCronDetails(), + ws.getStartDateTime(), ws.getEndDateTime()); triggers.add(triggerBean.getObject()); - - //schedulerBean.getScheduler().scheduleJob(trigger); - - } catch (Exception e) { - logger.debug(EELFLoggerDelegate.debugLogger, ("Error scheduling work flow with Id" + ws.getId() + e.getMessage())); + logger.error(EELFLoggerDelegate.errorLogger, "Error scheduling work flow with Id" + ws.getId(), e); } - - } } - + return triggers; } - - + public DataAccessService getDataAccessService() { return dataAccessService; } - public void setDataAccessService(DataAccessService dataAccessService) { this.dataAccessService = dataAccessService; } @Override public WorkflowSchedule getWorkflowScheduleByKey(Long key) { - return (WorkflowSchedule)(getDataAccessService().getDomainObject(WorkflowSchedule.class, key, null)); + return (WorkflowSchedule) (getDataAccessService().getDomainObject(WorkflowSchedule.class, key, null)); } } - - |