use of eu.bcvsolutions.idm.core.scheduler.api.dto.SimpleTaskTrigger in project CzechIdMng by bcvsolutions.
the class BaseScheduledTaskInitializer method getTrigger.
/**
* Method return {@link AbstractTaskTrigger} from
* {@link IdmScheduledTaskTriggerType}
*
* @param triggerType
* @return
* @throws ClassNotFoundException
*/
protected AbstractTaskTrigger getTrigger(IdmScheduledTaskTriggerType triggerType) throws ClassNotFoundException {
@SuppressWarnings("unchecked") Class<AbstractTaskTrigger> triggerClass = (Class<AbstractTaskTrigger>) Class.forName(triggerType.getType());
if (triggerClass.isAssignableFrom(SimpleTaskTrigger.class)) {
SimpleTaskTrigger simpleTrigger = new SimpleTaskTrigger();
simpleTrigger = (SimpleTaskTrigger) setTriggerDefaultValues(simpleTrigger, triggerType);
simpleTrigger.setFireTime(Instant.ofEpochMilli(triggerType.getFireTime()).atZone(ZoneId.systemDefault()));
return simpleTrigger;
} else if (triggerClass.isAssignableFrom(CronTaskTrigger.class)) {
CronTaskTrigger cronTrigger = new CronTaskTrigger();
cronTrigger = (CronTaskTrigger) setTriggerDefaultValues(cronTrigger, triggerType);
cronTrigger.setCron(triggerType.getCron());
return cronTrigger;
} else {
LOG.error("Trigger type: [{}] is not implemented, please override method getTrigger from AbstractScheduledTaskInitializer. " + "This trigger will be skipped.", triggerType.getType());
return null;
}
}
Aggregations