use of org.kie.kogito.internal.process.runtime.KogitoNodeInstance in project kogito-runtimes by kiegroup.
the class KogitoProcessEventSupportImpl method fireAfterNodeLeft.
@Override
public void fireAfterNodeLeft(final KogitoNodeInstance nodeInstance, KieRuntime kruntime) {
final ProcessNodeLeftEvent event = new KogitoProcessNodeLeftEventImpl(nodeInstance, kruntime);
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, e -> {
if (hasListeners()) {
notifyAllListeners(event, (l, e1) -> l.afterNodeLeft(e1));
}
}));
}
use of org.kie.kogito.internal.process.runtime.KogitoNodeInstance in project kogito-runtimes by kiegroup.
the class KogitoProcessEventSupportImpl method fireAfterNodeTriggered.
@Override
public void fireAfterNodeTriggered(final KogitoNodeInstance nodeInstance, KieRuntime kruntime) {
final ProcessNodeTriggeredEvent event = new KogitoProcessNodeTriggeredEventImpl(nodeInstance, kruntime);
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, e -> {
if (hasListeners()) {
notifyAllListeners(event, (l, e1) -> l.afterNodeTriggered(e1));
}
}));
}
use of org.kie.kogito.internal.process.runtime.KogitoNodeInstance in project kogito-runtimes by kiegroup.
the class KogitoProcessEventSupportImpl method fireBeforeNodeLeft.
@Override
public void fireBeforeNodeLeft(final KogitoNodeInstance nodeInstance, KieRuntime kruntime) {
final ProcessNodeLeftEvent event = new KogitoProcessNodeLeftEventImpl(nodeInstance, kruntime);
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, e -> {
if (hasListeners()) {
notifyAllListeners(event, (l, e1) -> l.beforeNodeLeft(e1));
}
}));
}
use of org.kie.kogito.internal.process.runtime.KogitoNodeInstance in project kogito-runtimes by kiegroup.
the class AsyncEventNodeInstance method internalTrigger.
@Override
public void internalTrigger(KogitoNodeInstance from, String type) {
addEventListeners();
addAsyncStatus();
final InternalProcessRuntime processRuntime = (InternalProcessRuntime) getProcessInstance().getKnowledgeRuntime().getProcessRuntime();
// Deffer the timer scheduling to the end of current UnitOfWork execution chain
processRuntime.getUnitOfWorkManager().currentUnitOfWork().intercept(new BaseWorkUnit<>(this, instance -> {
ExpirationTime expirationTime = ExactExpirationTime.of(ZonedDateTime.now().plus(1, ChronoUnit.MILLIS));
ProcessInstanceJobDescription jobDescription = ProcessInstanceJobDescription.of(new AsyncJobId(instance.getStringId()), expirationTime, instance.getProcessInstance().getStringId(), instance.getProcessInstance().getRootProcessInstanceId(), instance.getProcessInstance().getProcessId(), instance.getProcessInstance().getRootProcessId(), Optional.ofNullable(from).map(KogitoNodeInstance::getStringId).orElse(null));
JobsService jobService = processRuntime.getJobsService();
String jobId = jobService.scheduleProcessInstanceJob(jobDescription);
setJobId(jobId);
}, i -> {
}, WorkUnit.LOW_PRIORITY));
}
use of org.kie.kogito.internal.process.runtime.KogitoNodeInstance in project kogito-runtimes by kiegroup.
the class NodeInstanceImpl method trigger.
@Override
public final void trigger(KogitoNodeInstance from, String type) {
boolean hidden = false;
if (getNode().getMetaData().get(HIDDEN) != null) {
hidden = true;
}
if (from != null) {
int level = ((org.jbpm.workflow.instance.NodeInstance) from).getLevel();
((org.jbpm.workflow.instance.NodeInstanceContainer) getNodeInstanceContainer()).setCurrentLevel(level);
Collection<Connection> incoming = getNode().getIncomingConnections(type);
for (Connection conn : incoming) {
if (conn.getFrom().getId() == from.getNodeId()) {
this.metaData.put(INCOMING_CONNECTION, conn.getMetaData().get(UNIQUE_ID));
break;
}
}
}
if (dynamicParameters != null) {
for (Entry<String, Object> entry : dynamicParameters.entrySet()) {
setVariable(entry.getKey(), entry.getValue());
}
}
configureSla();
InternalKnowledgeRuntime kruntime = getProcessInstance().getKnowledgeRuntime();
if (!hidden) {
((InternalProcessRuntime) kruntime.getProcessRuntime()).getProcessEventSupport().fireBeforeNodeTriggered(this, kruntime);
}
try {
internalTrigger(from, type);
} catch (Exception e) {
logger.debug("Node instance causing process instance error in id {}", this.getStringId(), e);
captureError(e);
// stop after capturing error
return;
}
if (!hidden) {
((InternalProcessRuntime) kruntime.getProcessRuntime()).getProcessEventSupport().fireAfterNodeTriggered(this, kruntime);
}
}
Aggregations