public static Trigger convertTriggerFromNativeObject(org.quartz.Trigger quartzTrigger) { Trigger spagobiTrigger; spagobiTrigger = new Trigger(); spagobiTrigger.setName(quartzTrigger.getName()); spagobiTrigger.setGroupName(quartzTrigger.getGroup()); spagobiTrigger.setDescription(quartzTrigger.getDescription()); // spagobiTrigger.setCalendarName( quartzTrigger.getCalendarName() ); Assert.assertTrue( quartzTrigger.getCalendarName() == null, "quartz trigger calendar name is not null: " + quartzTrigger.getCalendarName()); spagobiTrigger.setStartTime(quartzTrigger.getStartTime()); spagobiTrigger.setEndTime(quartzTrigger.getEndTime()); // triggers that run immediately have a generated name that starts with schedule_uuid_ (see // TriggerXMLDeserializer) // It would be better anyway to relay on a specific property to recognize if a trigger is // thinked to run immediately spagobiTrigger.setRunImmediately(spagobiTrigger.getName().startsWith("schedule_uuid_")); if (quartzTrigger instanceof org.quartz.CronTrigger) { org.quartz.CronTrigger quartzCronTrigger = (org.quartz.CronTrigger) quartzTrigger; // dirty trick String expression = (String) quartzCronTrigger.getJobDataMap().get(SPAGOBI_CRON_EXPRESSION); if (expression != null) { quartzCronTrigger.getJobDataMap().remove(SPAGOBI_CRON_EXPRESSION); } else { // for back compatibility expression = (String) quartzCronTrigger.getJobDataMap().get(SPAGOBI_CRON_EXPRESSION_DEPRECATED); quartzCronTrigger.getJobDataMap().remove(SPAGOBI_CRON_EXPRESSION_DEPRECATED); } spagobiTrigger.setCronExpression(new CronExpression(expression)); } Job job = new Job(); job.setName(quartzTrigger.getJobName()); job.setGroupName(quartzTrigger.getJobGroup()); job.setVolatile(quartzTrigger.isVolatile()); Map<String, String> parameters = convertParametersFromNativeObject(quartzTrigger.getJobDataMap()); job.addParameters(parameters); spagobiTrigger.setJob(job); return spagobiTrigger; }
public static Job convertJobFromNativeObject(org.quartz.JobDetail quartzJob) { Job spagobiJob; spagobiJob = new Job(); spagobiJob.setName(quartzJob.getName()); spagobiJob.setGroupName(quartzJob.getGroup()); spagobiJob.setDescription(quartzJob.getDescription()); spagobiJob.setJobClass(quartzJob.getJobClass()); spagobiJob.setDurable(quartzJob.isDurable()); spagobiJob.setRequestsRecovery(quartzJob.requestsRecovery()); spagobiJob.setVolatile(quartzJob.isVolatile()); Map<String, String> parameters = convertParametersFromNativeObject(quartzJob.getJobDataMap()); spagobiJob.addParameters(parameters); return spagobiJob; }