use of org.jbpm.services.api.ProcessDefinitionNotFoundException in project jbpm by kiegroup.
the class AddDynamicProcessCommand method execute.
@Override
public Long execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
if (processInstance == null) {
throw new ProcessInstanceNotFoundException("No process instance found with id " + processInstanceId);
}
try {
CaseFileInstance caseFile = getCaseFile(ksession, caseId);
FactHandle factHandle = ksession.getFactHandle(caseFile);
CaseEventSupport caseEventSupport = getCaseEventSupport(context);
caseEventSupport.fireBeforeDynamicProcessAdded(caseId, caseFile, processInstanceId, processId, parameters);
long subProcessInstanceId = DynamicUtils.addDynamicSubProcess(processInstance, ksession, processId, parameters);
ksession.update(factHandle, caseFile);
triggerRules(ksession);
caseEventSupport.fireAfterDynamicProcessAdded(caseId, caseFile, processInstanceId, processId, parameters, subProcessInstanceId);
return subProcessInstanceId;
} catch (IllegalArgumentException e) {
throw new ProcessDefinitionNotFoundException(e.getMessage());
}
}
use of org.jbpm.services.api.ProcessDefinitionNotFoundException in project jbpm by kiegroup.
the class AddDynamicProcessToStageCommand method execute.
@Override
public Long execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
if (processInstance == null) {
throw new ProcessInstanceNotFoundException("No process instance found with id " + processInstanceId);
}
DynamicNodeInstance dynamicContext = (DynamicNodeInstance) ((WorkflowProcessInstanceImpl) processInstance).getNodeInstances(true).stream().filter(ni -> (ni instanceof DynamicNodeInstance) && stageId.equals(ni.getNode().getMetaData().get("UniqueId"))).findFirst().orElse(null);
if (dynamicContext == null) {
throw new StageNotFoundException("No stage found with id " + stageId);
}
try {
CaseFileInstance caseFile = getCaseFile(ksession, caseId);
CaseEventSupport caseEventSupport = getCaseEventSupport(context);
caseEventSupport.fireBeforeDynamicProcessAdded(caseId, caseFile, processInstanceId, processId, parameters);
long subProcessInstanceId = DynamicUtils.addDynamicSubProcess(dynamicContext, ksession, processId, parameters);
if (subProcessInstanceId < 0) {
throw new ProcessDefinitionNotFoundException("No process definition found with id: " + processId);
}
caseEventSupport.fireAfterDynamicProcessAdded(caseId, caseFile, processInstanceId, processId, parameters, subProcessInstanceId);
return subProcessInstanceId;
} catch (IllegalArgumentException e) {
throw new ProcessDefinitionNotFoundException(e.getMessage());
}
}
Aggregations