Search in sources :

Example 1 with TSchedules

use of org.wso2.carbon.bpel.config.TSchedules in project carbon-business-process by wso2.

the class BPELServerConfiguration method getSystemCleanupCronJobs.

public List<ProcessConf.CronJob> getSystemCleanupCronJobs() {
    List<ProcessConf.CronJob> jobs = new ArrayList<ProcessConf.CronJob>();
    TSchedules schedules = bpsConfigDocument.getWSO2BPS().getSchedules();
    if (schedules != null && schedules.getScheduleArray() != null && schedules.getScheduleArray().length > 0) {
        for (TSchedule schedule : schedules.getScheduleArray()) {
            ProcessConf.CronJob job = new ProcessConf.CronJob();
            try {
                job.setCronExpression(new CronExpression(schedule.getWhen()));
                for (final TCleanup aCleanup : schedule.getCleanupArray()) {
                    ProcessConf.CleanupInfo cleanupInfo = new ProcessConf.CleanupInfo();
                    assert !(aCleanup.getFilterArray().length == 0);
                    cleanupInfo.setFilters(Arrays.asList(aCleanup.getFilterArray()));
                    processACleanup(cleanupInfo.getCategories(), Arrays.asList(aCleanup.getCategoryArray()));
                    Scheduler.JobDetails runnableDetails = new Scheduler.JobDetails();
                    runnableDetails.getDetailsExt().put(BPELConstants.ODE_DETAILS_EXT_CLEAN_UP_INFO, cleanupInfo);
                    runnableDetails.getDetailsExt().put(BPELConstants.ODE_DETAILS_EXT_TRANSACTION_SIZE, 10);
                    job.getRunnableDetailList().add(runnableDetails);
                    log.info("SYSTEM CRON configuration added a runtime data cleanup: " + runnableDetails);
                }
                jobs.add(job);
            } catch (ParseException e) {
                log.error("Exception during parsing the schedule cron expression: " + schedule.getWhen() + ", skipped the scheduled job.");
            }
        }
    }
    return jobs;
}
Also used : Scheduler(org.apache.ode.bpel.iapi.Scheduler) ProcessConf(org.apache.ode.bpel.iapi.ProcessConf) ArrayList(java.util.ArrayList) CronExpression(org.apache.ode.utils.CronExpression) ParseException(java.text.ParseException) TCleanup(org.wso2.carbon.bpel.config.TCleanup) TSchedules(org.wso2.carbon.bpel.config.TSchedules) TSchedule(org.wso2.carbon.bpel.config.TSchedule)

Aggregations

ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 ProcessConf (org.apache.ode.bpel.iapi.ProcessConf)1 Scheduler (org.apache.ode.bpel.iapi.Scheduler)1 CronExpression (org.apache.ode.utils.CronExpression)1 TCleanup (org.wso2.carbon.bpel.config.TCleanup)1 TSchedule (org.wso2.carbon.bpel.config.TSchedule)1 TSchedules (org.wso2.carbon.bpel.config.TSchedules)1