use of org.jaffa.modules.scheduler.components.taskfinder.dto.TaskFinderOutDto in project jaffa-framework by jaffa-projects.
the class TaskFinderTx method find.
/**
* Searches for Task objects.
* @param taskType taskType of tasks that should be returned.
* @throws FrameworkException in case any internal error occurs.
* @throws ApplicationExceptions Indicates application error(s).
* @return The search results.
*/
public TaskFinderOutDto find(String taskType) throws FrameworkException, ApplicationExceptions {
UOW uow = null;
try {
if (log.isDebugEnabled())
log.debug("Retrieving all scheduled tasks");
uow = new UOW();
SchedulerHelper sh = SchedulerHelperFactory.instance();
TaskFinderOutDto output = new TaskFinderOutDto();
output.setSchedulerStatus(sh.getSchedulerStatus());
if (output.getSchedulerStatus() == SchedulerHelper.SchedulerStatusEnumeration.STOPPED) {
if (log.isDebugEnabled())
log.debug("The Scheduler has been shutdown. The Task list cannot be obtained");
} else {
ScheduledTask[] tasks = null;
if (SecurityManager.checkFunctionAccess("Jaffa.Scheduler.Task.InquiryAll"))
tasks = sh.getTasks(null, taskType != null ? taskType : null);
else
tasks = sh.getTasks(org.jaffa.security.SecurityManager.getPrincipal().getName(), taskType != null ? taskType : null);
if (tasks != null) {
Collection<TaskFinderOutRowDto> rows = new LinkedList<TaskFinderOutRowDto>();
for (ScheduledTask task : tasks) {
if (SchedulerBrowser.hasBrowseTaskAccess(task)) {
TaskFinderOutRowDto row = new TaskFinderOutRowDto(task);
if (row.getFailedTaskCount() != null && row.getFailedTaskCount() > 0)
row.setLastError(findLastError(uow, task.getScheduledTaskId()));
row.setHasAdminTaskAccess(SchedulerBrowser.hasAdminTaskAccess(task.getTaskType()));
rows.add(row);
}
}
output.setRows(rows.toArray(new TaskFinderOutRowDto[rows.size()]));
}
}
if (log.isDebugEnabled())
log.debug("Output: " + output);
return output;
} catch (Exception e) {
throw ExceptionHelper.throwAFR(e);
} finally {
if (uow != null)
uow.rollback();
}
}
use of org.jaffa.modules.scheduler.components.taskfinder.dto.TaskFinderOutDto in project jaffa-framework by jaffa-projects.
the class TaskFinderForm method populateRows.
/**
* This will populate the input GridModel with the data in the finderOutDto of the Component.
* @param rows The GridModel object to populate.
*/
public void populateRows(GridModel rows) {
rows.clearRows();
TaskFinderOutDto finderOutDto = ((TaskFinderComponent) getComponent()).getFinderOutDto();
if (finderOutDto != null && finderOutDto.getRows() != null) {
for (TaskFinderOutRowDto rowDto : finderOutDto.getRows()) {
GridModelRow row = rows.newRow();
row.addElement("scheduledTaskId", rowDto.getScheduledTaskId());
row.addElement("taskType", rowDto.getTaskType());
row.addElement("description", rowDto.getDescription());
row.addElement("runAs", rowDto.getRunAs());
row.addElement("startOn", rowDto.getStartOn());
row.addElement("endOn", rowDto.getEndOn());
row.addElement("recurrence", rowDto.getRecurrence());
row.addElement("misfireRecovery", rowDto.getMisfireRecovery());
row.addElement("businessObject", rowDto.getBusinessObject());
row.addElement("createdOn", rowDto.getCreatedOn());
row.addElement("createdBy", rowDto.getCreatedBy());
row.addElement("lastChangedOn", rowDto.getLastChangedOn());
row.addElement("lastChangedBy", rowDto.getLastChangedBy());
row.addElement("nextDue", rowDto.getNextDue());
row.addElement("lastRunOn", rowDto.getLastRunOn());
row.addElement("status", rowDto.getStatus());
row.addElement("lastError", rowDto.getLastError());
row.addElement("failedTaskCount", rowDto.getFailedTaskCount());
row.addElement("hasAdminTaskAccess", rowDto.getHasAdminTaskAccess());
}
}
}
Aggregations