use of org.jbpm.services.api.model.DeployedUnit in project jbpm by kiegroup.
the class ProcessServiceImpl method signalEvent.
@Override
public void signalEvent(String deploymentId, String signalName, Object event) {
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if (deployedUnit == null) {
throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
}
RuntimeManager manager = deployedUnit.getRuntimeManager();
event = process(event, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
manager.signalEvent(signalName, event);
}
use of org.jbpm.services.api.model.DeployedUnit in project jbpm by kiegroup.
the class ProcessServiceImpl method startProcess.
@Override
public Long startProcess(String deploymentId, String processId, CorrelationKey correlationKey, Map<String, Object> params) {
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if (deployedUnit == null) {
throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
}
if (!deployedUnit.isActive()) {
throw new DeploymentNotFoundException("Deployments " + deploymentId + " is not active");
}
RuntimeManager manager = deployedUnit.getRuntimeManager();
params = process(params, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
RuntimeEngine engine = manager.getRuntimeEngine(getContext(params));
KieSession ksession = engine.getKieSession();
ProcessInstance pi;
try {
pi = ((CorrelationAwareProcessRuntime) ksession).startProcess(processId, correlationKey, params);
return pi.getId();
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.jbpm.services.api.model.DeployedUnit in project jbpm by kiegroup.
the class KModuleDeploymentService method activate.
@Override
public void activate(String deploymentId) {
DeployedUnit deployed = getDeployedUnit(deploymentId);
if (deployed != null) {
((DeployedUnitImpl) deployed).setActive(true);
((InternalRuntimeManager) deployed.getRuntimeManager()).activate();
notifyOnActivate(deployed.getDeploymentUnit(), deployed);
}
}
use of org.jbpm.services.api.model.DeployedUnit in project jbpm by kiegroup.
the class ProcessServiceImpl method completeWorkItem.
@Override
public void completeWorkItem(String deploymentId, Long processInstanceId, Long id, Map<String, Object> results) {
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if (deployedUnit == null) {
throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
}
RuntimeManager manager = deployedUnit.getRuntimeManager();
results = process(results, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
try {
KieSession ksession = engine.getKieSession();
WorkItem workItem = ((WorkItemManager) ksession.getWorkItemManager()).getWorkItem(id);
if (workItem == null) {
throw new WorkItemNotFoundException("Work item with id " + id + " was not found");
}
ksession.getWorkItemManager().completeWorkItem(id, results);
} catch (SessionNotFoundException e) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found", e);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.jbpm.services.api.model.DeployedUnit in project jbpm by kiegroup.
the class ProcessServiceImpl method getAvailableSignals.
@Override
public Collection<String> getAvailableSignals(String deploymentId, Long processInstanceId) {
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if (deployedUnit == null) {
throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
}
RuntimeManager manager = deployedUnit.getRuntimeManager();
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
try {
KieSession ksession = engine.getKieSession();
ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
Collection<String> activeSignals = new ArrayList<>();
if (processInstance != null) {
((ProcessInstanceImpl) processInstance).setProcess(ksession.getKieBase().getProcess(processInstance.getProcessId()));
Collection<NodeInstance> activeNodes = ((WorkflowProcessInstance) processInstance).getNodeInstances();
Collection<String> activeBoundaryNodesSignals = getActiveBoundaryNodesSignals(processInstance, activeNodes);
activeSignals.addAll(collectActiveSignals(activeNodes));
activeSignals.addAll(activeBoundaryNodesSignals);
}
return activeSignals;
} catch (SessionNotFoundException e) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found", e);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
Aggregations