Search in sources :

Example 1 with BatchjobsDto

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;
}
Also used : CronTrigger(org.quartz.CronTrigger) Scheduler(org.quartz.Scheduler) MifosScheduler(org.mifos.framework.components.batchjobs.MifosScheduler) ArrayList(java.util.ArrayList) BatchjobsDto(org.mifos.application.admin.servicefacade.BatchjobsDto) MifosScheduler(org.mifos.framework.components.batchjobs.MifosScheduler) Date(java.util.Date) JobDetail(org.quartz.JobDetail) Trigger(org.quartz.Trigger) SimpleTrigger(org.quartz.SimpleTrigger) CronTrigger(org.quartz.CronTrigger) SimpleTrigger(org.quartz.SimpleTrigger)

Example 2 with BatchjobsDto

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;
}
Also used : ServletContext(javax.servlet.ServletContext) BatchjobsDto(org.mifos.application.admin.servicefacade.BatchjobsDto) Date(java.util.Date) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ReflectionException(org.mifos.reports.pentaho.util.ReflectionException) ReportProcessingException(org.pentaho.reporting.engine.classic.core.ReportProcessingException) IOException(java.io.IOException) AccessDeniedException(org.springframework.security.access.AccessDeniedException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 3 with BatchjobsDto

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;
}
Also used : HashMap(java.util.HashMap) BatchjobsSchedulerDto(org.mifos.application.admin.servicefacade.BatchjobsSchedulerDto) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) ServletContext(javax.servlet.ServletContext) BatchjobsDto(org.mifos.application.admin.servicefacade.BatchjobsDto) AccessDeniedException(org.springframework.security.access.AccessDeniedException) Date(java.util.Date)

Example 4 with BatchjobsDto

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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) ServletContext(javax.servlet.ServletContext) BatchjobsDto(org.mifos.application.admin.servicefacade.BatchjobsDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

BatchjobsDto (org.mifos.application.admin.servicefacade.BatchjobsDto)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 ServletContext (javax.servlet.ServletContext)3 HashMap (java.util.HashMap)2 AccessDeniedException (org.springframework.security.access.AccessDeniedException)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 IOException (java.io.IOException)1 BatchjobsSchedulerDto (org.mifos.application.admin.servicefacade.BatchjobsSchedulerDto)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 MifosScheduler (org.mifos.framework.components.batchjobs.MifosScheduler)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1 ReflectionException (org.mifos.reports.pentaho.util.ReflectionException)1 ReportProcessingException (org.pentaho.reporting.engine.classic.core.ReportProcessingException)1 CronTrigger (org.quartz.CronTrigger)1 JobDetail (org.quartz.JobDetail)1 Scheduler (org.quartz.Scheduler)1 SimpleTrigger (org.quartz.SimpleTrigger)1 Trigger (org.quartz.Trigger)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1