Search in sources :

Example 11 with SimpleTaskTrigger

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;
    }
}
Also used : AbstractTaskTrigger(eu.bcvsolutions.idm.core.scheduler.api.dto.AbstractTaskTrigger) CronTaskTrigger(eu.bcvsolutions.idm.core.scheduler.api.dto.CronTaskTrigger) SimpleTaskTrigger(eu.bcvsolutions.idm.core.scheduler.api.dto.SimpleTaskTrigger)

Aggregations

SimpleTaskTrigger (eu.bcvsolutions.idm.core.scheduler.api.dto.SimpleTaskTrigger)11 CronTaskTrigger (eu.bcvsolutions.idm.core.scheduler.api.dto.CronTaskTrigger)7 AbstractTaskTrigger (eu.bcvsolutions.idm.core.scheduler.api.dto.AbstractTaskTrigger)6 Task (eu.bcvsolutions.idm.core.scheduler.api.dto.Task)6 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)4 Test (org.junit.Test)4 DependentTaskTrigger (eu.bcvsolutions.idm.core.scheduler.api.dto.DependentTaskTrigger)3 IdmLongRunningTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto)2 DryRunNotSupportedException (eu.bcvsolutions.idm.core.scheduler.api.exception.DryRunNotSupportedException)2 IdmDependentTaskTrigger (eu.bcvsolutions.idm.core.scheduler.entity.IdmDependentTaskTrigger)2 SchedulerException (eu.bcvsolutions.idm.core.scheduler.exception.SchedulerException)2 DateTime (org.joda.time.DateTime)2 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)1 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)1 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)1 EventResult (eu.bcvsolutions.idm.core.api.event.EventResult)1 CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)1 ConfigurationService (eu.bcvsolutions.idm.core.api.service.ConfigurationService)1 IdmIdentityService (eu.bcvsolutions.idm.core.api.service.IdmIdentityService)1