use of org.mifos.application.admin.servicefacade.BatchjobsDto in project head by mifos.
the class BatchjobsServiceFacadeWebTier method getBatchjobs.
@Override
public List<BatchjobsDto> getBatchjobs(ServletContext context) throws TaskSystemException, FileNotFoundException, IOException, SchedulerException {
List<BatchjobsDto> batchjobs = new ArrayList<BatchjobsDto>();
MifosScheduler mifosScheduler = (MifosScheduler) context.getAttribute(MifosScheduler.class.getName());
Scheduler scheduler = mifosScheduler.getScheduler();
for (String groupName : scheduler.getJobGroupNames()) {
for (String jobName : scheduler.getJobNames(groupName)) {
Trigger[] triggers = scheduler.getTriggersOfJob(jobName, groupName);
Trigger trigger = triggers.length > 0 ? triggers[0] : null;
JobDetail jobDetail = scheduler.getJobDetail(jobName, groupName);
if (trigger != null && jobDetail != null) {
Date nextFire = trigger.getNextFireTime() != null ? trigger.getNextFireTime() : new Date(0);
Date lastFire = mifosScheduler.getJobsPreviousRunTime(jobName);
Date lastSuccessfulRun = mifosScheduler.getJobsLastSuccessfulRunTime(jobName);
int priority = trigger.getPriority();
String frequency = "";
String taskType = "";
if (trigger instanceof CronTrigger) {
frequency = ((CronTrigger) trigger).getCronExpression();
taskType = CRON_TRIGGER;
}
if (trigger instanceof SimpleTrigger) {
frequency = Long.toString(((SimpleTrigger) trigger).getRepeatInterval());
taskType = SIMPLE_TRIGGER;
}
String previousRunStatus = mifosScheduler.getJobsPreviousRunStatus(jobName);
int triggerState = scheduler.getTriggerState(trigger.getName(), groupName);
String failDescription = mifosScheduler.getJobFailDescription(jobName);
batchjobs.add(new BatchjobsDto(jobName, frequency, taskType, priority, previousRunStatus, lastFire, lastSuccessfulRun, nextFire, triggerState, failDescription));
}
}
}
return batchjobs;
}
use of org.mifos.application.admin.servicefacade.BatchjobsDto in project head by mifos.
the class PentahoReportsServiceImpl method getEtlLastUpdateDate.
@Override
@PreAuthorize("isFullyAuthenticated()")
public Date getEtlLastUpdateDate(HttpServletRequest request) {
ServletContext context = request.getSession().getServletContext();
Date lastSucessfulRunEtl = null;
try {
List<BatchjobsDto> batchjobs = batchjobsServiceFacade.getBatchjobs(context);
for (BatchjobsDto batchjob : batchjobs) {
if (batchjob.getName().equals("ETLReportDWTaskJob")) {
lastSucessfulRunEtl = batchjob.getLastSuccessfulRun();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return lastSucessfulRunEtl;
}
use of org.mifos.application.admin.servicefacade.BatchjobsDto in project head by mifos.
the class BatchjobsController method produceModelAndView.
private ModelAndView produceModelAndView(HttpServletRequest request, List<String> errorMessages) {
ServletContext context = request.getSession().getServletContext();
List<BatchjobsDto> batchjobs;
BatchjobsSchedulerDto batchjobsScheduler;
try {
batchjobs = batchjobsServiceFacade.getBatchjobs(context);
} catch (Exception tse) {
errorMessages.add("Error when retrieving batch jobs information: " + tse.getMessage());
batchjobs = new ArrayList<BatchjobsDto>();
}
try {
batchjobsScheduler = batchjobsServiceFacade.getBatchjobsScheduler(context);
} catch (Exception tse) {
errorMessages.add("Error when retrieving batch jobs information: " + tse.getMessage());
batchjobsScheduler = new BatchjobsSchedulerDto(false);
}
Map<String, Object> model = new HashMap<String, Object>();
model.put("request", request);
model.put("batchjobs", batchjobs);
if (batchjobsScheduler == null) {
model.put("scheduler", "");
} else {
model.put("scheduler", batchjobsScheduler.isStatus());
}
model.put("date0", new Date(0));
model.put("executedTasks", rawJobList);
if (rawJobList.length > 0) {
rawJobList = new String[0];
}
Map<String, Object> status = new HashMap<String, Object>();
status.put("errorMessages", errorMessages);
ModelAndView modelAndView = new ModelAndView("batchjobs", "model", model);
modelAndView.addObject("status", status);
return modelAndView;
}
use of org.mifos.application.admin.servicefacade.BatchjobsDto in project head by mifos.
the class BatchjobsDetailsController method processFormSubmit.
@RequestMapping(method = RequestMethod.GET)
public ModelAndView processFormSubmit(HttpServletRequest request) {
Map<String, Object> model = new HashMap<String, Object>();
List<String> errorMessages = new ArrayList<String>();
ServletContext context = request.getSession().getServletContext();
List<BatchjobsDto> batchjobs;
try {
batchjobs = batchjobsServiceFacade.getBatchjobs(context);
} catch (Exception tse) {
errorMessages.add("Error when retrieving batch jobs information: " + tse.getMessage());
batchjobs = new ArrayList<BatchjobsDto>();
}
model.put("batchjobs", batchjobs);
String[] jobFailNames = request.getParameterValues("jobFailName");
if (jobFailNames != null && jobFailNames.length > 0) {
model.put("jobFailName", jobFailNames[0]);
} else {
model.put("jobFailName", "");
}
Map<String, Object> status = new HashMap<String, Object>();
status.put("errorMessages", errorMessages);
ModelAndView modelAndView = new ModelAndView("batchjobsdetails", "model", model);
modelAndView.addObject("status", status);
return modelAndView;
}
Aggregations