Search in sources :

Example 6 with JobsService

use of io.automatiko.engine.api.jobs.JobsService in project automatiko-engine by automatiko-io.

the class StateBasedNodeInstance method cancelSlaTimer.

private void cancelSlaTimer() {
    if (this.slaTimerId != null && !this.slaTimerId.trim().isEmpty()) {
        JobsService jobService = getProcessInstance().getProcessRuntime().getJobsService();
        jobService.cancelJob(this.slaTimerId);
        logger.debug("SLA Timer {} has been canceled", this.slaTimerId);
    }
}
Also used : JobsService(io.automatiko.engine.api.jobs.JobsService)

Example 7 with JobsService

use of io.automatiko.engine.api.jobs.JobsService in project automatiko-engine by automatiko-io.

the class StateBasedNodeInstance method internalTrigger.

@Override
public void internalTrigger(NodeInstance from, String type) {
    super.internalTrigger(from, type);
    // if node instance was cancelled, abort
    if (getNodeInstanceContainer().getNodeInstance(getId()) == null) {
        return;
    }
    addCompletionListeners();
    // activate timers
    Map<Timer, ProcessAction> timers = getEventBasedNode().getTimers();
    if (timers != null) {
        addTimerListener();
        timerInstances = new ArrayList<>(timers.size());
        JobsService jobService = getProcessInstance().getProcessRuntime().getJobsService();
        for (Timer timer : timers.keySet()) {
            ExpirationTime expirationTime = createTimerInstance(timer);
            String jobId = jobService.scheduleProcessInstanceJob(ProcessInstanceJobDescription.of(timer.getId(), expirationTime, getProcessInstanceIdWithParent(), getProcessInstance().getRootProcessInstanceId(), getProcessInstance().getProcessId(), getProcessInstance().getProcess().getVersion(), getProcessInstance().getRootProcessId()));
            timerInstances.add(jobId);
        }
    }
    ((WorkflowProcessInstanceImpl) getProcessInstance()).addActivatingNodeId((String) getNode().getMetaData().get("UniqueId"));
    if (getExtendedNode().hasCondition()) {
        ProcessContext context = new ProcessContext(getProcessInstance().getProcessRuntime());
        context.setProcessInstance(getProcessInstance());
        if (getExtendedNode().getMetaData("ConditionEventType") != null && getExtendedNode().isMet(context)) {
            getProcessInstance().signalEvent((String) getExtendedNode().getMetaData("ConditionEventType"), null);
        } else {
            getProcessInstance().addEventListener("variableChanged", this, false);
        }
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) Timer(io.automatiko.engine.workflow.base.core.timer.Timer) JobsService(io.automatiko.engine.api.jobs.JobsService) WorkflowProcessInstanceImpl(io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl) ExactExpirationTime(io.automatiko.engine.api.jobs.ExactExpirationTime) ExpirationTime(io.automatiko.engine.api.jobs.ExpirationTime) DurationExpirationTime(io.automatiko.engine.api.jobs.DurationExpirationTime) CronExpirationTime(io.automatiko.engine.workflow.base.core.timer.CronExpirationTime) ProcessContext(io.automatiko.engine.workflow.base.core.context.ProcessContext)

Aggregations

JobsService (io.automatiko.engine.api.jobs.JobsService)7 ExpirationTime (io.automatiko.engine.api.jobs.ExpirationTime)3 DurationExpirationTime (io.automatiko.engine.api.jobs.DurationExpirationTime)2 ProcessContext (io.automatiko.engine.workflow.base.core.context.ProcessContext)2 Timer (io.automatiko.engine.workflow.base.core.timer.Timer)2 NodeInstanceImpl (io.automatiko.engine.workflow.process.instance.impl.NodeInstanceImpl)2 WorkflowProcessInstanceImpl (io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl)2 Model (io.automatiko.engine.api.Model)1 ExactExpirationTime (io.automatiko.engine.api.jobs.ExactExpirationTime)1 WorkflowProcessInstance (io.automatiko.engine.api.runtime.process.WorkflowProcessInstance)1 ExportedProcessInstance (io.automatiko.engine.api.workflow.ExportedProcessInstance)1 ProcessInstance (io.automatiko.engine.api.workflow.ProcessInstance)1 AbstractProcess (io.automatiko.engine.workflow.AbstractProcess)1 AbstractProcessInstance (io.automatiko.engine.workflow.AbstractProcessInstance)1 StringExportedProcessInstance (io.automatiko.engine.workflow.StringExportedProcessInstance)1 ActionExceptionHandler (io.automatiko.engine.workflow.base.core.context.exception.ActionExceptionHandler)1 CronExpirationTime (io.automatiko.engine.workflow.base.core.timer.CronExpirationTime)1 ContextInstanceContainer (io.automatiko.engine.workflow.base.instance.ContextInstanceContainer)1 ProcessInstance (io.automatiko.engine.workflow.base.instance.ProcessInstance)1 Action (io.automatiko.engine.workflow.base.instance.impl.Action)1