taskTO.setNextExec(trigger.getNextFireTime());
}
}
public TaskTO getTaskTO(final Task task, final TaskUtil taskUtil) {
TaskTO taskTO = taskUtil.newTaskTO();
BeanUtils.copyProperties(task, taskTO, IGNORE_TASK_PROPERTIES);
TaskExec latestExec = taskExecDAO.findLatestStarted(task);
taskTO.setLatestExecStatus(latestExec == null
? ""
: latestExec.getStatus());
taskTO.setStartDate(latestExec == null
? null
: latestExec.getStartDate());
taskTO.setEndDate(latestExec == null
? null
: latestExec.getEndDate());
for (TaskExec execution : task.getExecs()) {
taskTO.addExecution(getTaskExecTO(execution));
}
switch (taskUtil) {
case PROPAGATION:
if (!(task instanceof PropagationTask)) {
throw new ClassCastException("taskUtil is type Propagation but task is not PropagationTask: "
+ task.getClass().getName());
}
((PropagationTaskTO) taskTO).setResource(((PropagationTask) task).getResource().getName());
break;
case SCHED:
if (!(task instanceof SchedTask)) {
throw new ClassCastException("taskUtil is type Sched but task is not SchedTask: "
+ task.getClass().getName());
}
setExecTime((SchedTaskTO) taskTO, task);
((SchedTaskTO) taskTO).setName(((SchedTask) task).getName());
((SchedTaskTO) taskTO).setDescription(((SchedTask) task).getDescription());
break;
case SYNC:
if (!(task instanceof SyncTask)) {
throw new ClassCastException("taskUtil is type Sync but task is not SyncTask: "
+ task.getClass().getName());
}
setExecTime((SchedTaskTO) taskTO, task);
((SyncTaskTO) taskTO).setName(((SyncTask) task).getName());
((SyncTaskTO) taskTO).setDescription(((SyncTask) task).getDescription());
((SyncTaskTO) taskTO).setResource(((SyncTask) task).getResource().getName());
break;
case NOTIFICATION:
if (((NotificationTask) task).isExecuted() && StringUtils.isBlank(taskTO.getLatestExecStatus())) {
taskTO.setLatestExecStatus("[EXECUTED]");
}
break;
default:
}