use of org.mifos.framework.components.batchjobs.MifosScheduler 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.framework.components.batchjobs.MifosScheduler in project head by mifos.
the class BatchjobsServiceFacadeWebTier method getBatchjobsScheduler.
@Override
public BatchjobsSchedulerDto getBatchjobsScheduler(ServletContext context) throws SchedulerException {
MifosScheduler mifosScheduler = (MifosScheduler) context.getAttribute(MifosScheduler.class.getName());
Scheduler scheduler = mifosScheduler.getScheduler();
BatchjobsSchedulerDto batchjobsScheduler = new BatchjobsSchedulerDto(!scheduler.isInStandbyMode());
return batchjobsScheduler;
}
use of org.mifos.framework.components.batchjobs.MifosScheduler in project head by mifos.
the class StandardTestingService method runAllBatchJobs.
@Override
public void runAllBatchJobs(final ServletContext ctx) {
logger.info("running all batch jobs");
MifosScheduler mifosScheduler = (MifosScheduler) ctx.getAttribute(MifosScheduler.class.getName());
try {
mifosScheduler.runAllTasks();
} catch (TaskSystemException se) {
throw new MifosRuntimeException("Scheduler's inner exception while running all batch jobs!", se);
}
}
use of org.mifos.framework.components.batchjobs.MifosScheduler in project head by mifos.
the class LoanArrearsTaskIntegrationTest method getMifosScheduler.
private MifosScheduler getMifosScheduler(String taskConfigurationPath) throws TaskSystemException, IOException, FileNotFoundException {
ConfigurationLocator mockConfigurationLocator = createMock(ConfigurationLocator.class);
expect(mockConfigurationLocator.getResource(SchedulerConstants.CONFIGURATION_FILE_NAME)).andReturn(MifosResourceUtil.getClassPathResourceAsResource(taskConfigurationPath));
expectLastCall().times(2);
replay(mockConfigurationLocator);
MifosScheduler mifosScheduler = new MifosScheduler();
mifosScheduler.setConfigurationLocator(mockConfigurationLocator);
mifosScheduler.initialize();
return mifosScheduler;
}
use of org.mifos.framework.components.batchjobs.MifosScheduler in project head by mifos.
the class LoanArrearsAndPortfolioAtRiskIntegrationTest method getMifosScheduler.
private MifosScheduler getMifosScheduler(String taskConfigurationPath) throws TaskSystemException, IOException, FileNotFoundException {
ConfigurationLocator mockConfigurationLocator = createMock(ConfigurationLocator.class);
expect(mockConfigurationLocator.getResource(SchedulerConstants.CONFIGURATION_FILE_NAME)).andReturn(MifosResourceUtil.getClassPathResourceAsResource(taskConfigurationPath));
expectLastCall().times(2);
replay(mockConfigurationLocator);
MifosScheduler mifosScheduler = new MifosScheduler();
mifosScheduler.setConfigurationLocator(mockConfigurationLocator);
mifosScheduler.initialize();
return mifosScheduler;
}
Aggregations