use of org.jbpm.process.instance.InternalProcessRuntime in project jbpm by kiegroup.
the class VariableScopeInstance method setVariable.
public void setVariable(String name, Object value) {
if (name == null) {
throw new IllegalArgumentException("The name of a variable may not be null!");
}
Object oldValue = variables.get(name);
if (oldValue == null) {
if (value == null) {
return;
}
}
ProcessEventSupport processEventSupport = ((InternalProcessRuntime) getProcessInstance().getKnowledgeRuntime().getProcessRuntime()).getProcessEventSupport();
processEventSupport.fireBeforeVariableChanged((variableIdPrefix == null ? "" : variableIdPrefix + ":") + name, (variableInstanceIdPrefix == null ? "" : variableInstanceIdPrefix + ":") + name, oldValue, value, getProcessInstance(), getProcessInstance().getKnowledgeRuntime());
internalSetVariable(name, value);
processEventSupport.fireAfterVariableChanged((variableIdPrefix == null ? "" : variableIdPrefix + ":") + name, (variableInstanceIdPrefix == null ? "" : variableInstanceIdPrefix + ":") + name, oldValue, value, getProcessInstance(), getProcessInstance().getKnowledgeRuntime());
}
use of org.jbpm.process.instance.InternalProcessRuntime in project jbpm by kiegroup.
the class StateBasedNodeInstance method handleSLAViolation.
protected void handleSLAViolation() {
if (slaCompliance == ProcessInstance.SLA_PENDING) {
InternalProcessRuntime processRuntime = ((InternalProcessRuntime) getProcessInstance().getKnowledgeRuntime().getProcessRuntime());
processRuntime.getProcessEventSupport().fireBeforeSLAViolated(getProcessInstance(), this, getProcessInstance().getKnowledgeRuntime());
logger.debug("SLA violated on node instance {}", getId());
this.slaCompliance = ProcessInstance.SLA_VIOLATED;
this.slaTimerId = -1;
processRuntime.getProcessEventSupport().fireAfterSLAViolated(getProcessInstance(), this, getProcessInstance().getKnowledgeRuntime());
}
}
use of org.jbpm.process.instance.InternalProcessRuntime in project jbpm by kiegroup.
the class StateBasedNodeInstance method cancelSlaTimer.
private void cancelSlaTimer() {
if (this.slaTimerId > -1) {
TimerManager timerManager = ((InternalProcessRuntime) getProcessInstance().getKnowledgeRuntime().getProcessRuntime()).getTimerManager();
timerManager.cancelTimer(this.slaTimerId);
logger.debug("SLA Timer {} has been canceled", this.slaTimerId);
}
}
use of org.jbpm.process.instance.InternalProcessRuntime in project jbpm by kiegroup.
the class DynamicUtils method executeWorkItem.
private static void executeWorkItem(StatefulKnowledgeSessionImpl ksession, WorkItemImpl workItem, WorkItemNodeInstance workItemNodeInstance) {
ProcessEventSupport eventSupport = ((InternalProcessRuntime) ksession.getProcessRuntime()).getProcessEventSupport();
eventSupport.fireBeforeNodeTriggered(workItemNodeInstance, ksession);
((WorkItemManager) ksession.getWorkItemManager()).internalExecuteWorkItem(workItem);
workItemNodeInstance.internalSetWorkItemId(workItem.getId());
eventSupport.fireAfterNodeTriggered(workItemNodeInstance, ksession);
}
use of org.jbpm.process.instance.InternalProcessRuntime in project jbpm by kiegroup.
the class DynamicUtils method executeSubProcess.
private static long executeSubProcess(StatefulKnowledgeSessionImpl ksession, String processId, Map<String, Object> parameters, ProcessInstance processInstance, SubProcessNodeInstance subProcessNodeInstance) {
Process process = ksession.getKieBase().getProcess(processId);
if (process == null) {
logger.error("Could not find process {}", processId);
throw new IllegalArgumentException("No process definition found with id: " + processId);
} else {
ProcessEventSupport eventSupport = ((InternalProcessRuntime) ((InternalKnowledgeRuntime) ksession).getProcessRuntime()).getProcessEventSupport();
eventSupport.fireBeforeNodeTriggered(subProcessNodeInstance, ksession);
ProcessInstance subProcessInstance = null;
if (((WorkflowProcessInstanceImpl) processInstance).getCorrelationKey() != null) {
List<String> businessKeys = new ArrayList<String>();
businessKeys.add(((WorkflowProcessInstanceImpl) processInstance).getCorrelationKey());
businessKeys.add(processId);
businessKeys.add(String.valueOf(System.currentTimeMillis()));
CorrelationKeyFactory correlationKeyFactory = KieInternalServices.Factory.get().newCorrelationKeyFactory();
CorrelationKey subProcessCorrelationKey = correlationKeyFactory.newCorrelationKey(businessKeys);
subProcessInstance = (ProcessInstance) ((CorrelationAwareProcessRuntime) ksession).createProcessInstance(processId, subProcessCorrelationKey, parameters);
} else {
subProcessInstance = (ProcessInstance) ksession.createProcessInstance(processId, parameters);
}
((ProcessInstanceImpl) subProcessInstance).setMetaData("ParentProcessInstanceId", processInstance.getId());
((ProcessInstanceImpl) subProcessInstance).setParentProcessInstanceId(processInstance.getId());
subProcessInstance = (ProcessInstance) ksession.startProcessInstance(subProcessInstance.getId());
subProcessNodeInstance.internalSetProcessInstanceId(subProcessInstance.getId());
eventSupport.fireAfterNodeTriggered(subProcessNodeInstance, ksession);
if (subProcessInstance.getState() == ProcessInstance.STATE_COMPLETED) {
subProcessNodeInstance.triggerCompleted();
} else {
subProcessNodeInstance.addEventListeners();
}
return subProcessInstance.getId();
}
}
Aggregations