use of org.jbpm.services.api.model.DeployedUnit in project jbpm by kiegroup.
the class KModuleDeploymentService method deactivate.
@Override
public void deactivate(String deploymentId) {
DeployedUnit deployed = getDeployedUnit(deploymentId);
if (deployed != null && deployed.isActive()) {
((DeployedUnitImpl) deployed).setActive(false);
((InternalRuntimeManager) deployed.getRuntimeManager()).deactivate();
notifyOnDeactivate(deployed.getDeploymentUnit(), deployed);
}
}
use of org.jbpm.services.api.model.DeployedUnit in project jbpm by kiegroup.
the class ProcessServiceImpl method abortProcessInstance.
@Override
public void abortProcessInstance(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();
ksession.abortProcessInstance(processInstanceId);
} catch (SessionNotFoundException e) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found", e);
} catch (IllegalArgumentException 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 execute.
@Override
public <T> T execute(String deploymentId, Command<T> command) {
Long processInstanceId = CommonUtils.getProcessInstanceId(command);
logger.debug("Executing command {} with process instance id {} as contextual data", command, processInstanceId);
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if (deployedUnit == null) {
throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
}
disallowWhenNotActive(deployedUnit, command);
RuntimeManager manager = deployedUnit.getRuntimeManager();
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
try {
KieSession ksession = engine.getKieSession();
return ksession.execute(command);
} 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 getProcessInstanceVariables.
@Override
public Map<String, Object> getProcessInstanceVariables(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();
WorkflowProcessInstanceImpl pi = (WorkflowProcessInstanceImpl) ksession.getProcessInstance(processInstanceId, true);
Map<String, Object> variables = pi.getVariables();
for (Object variable : variables.values()) {
if (variable instanceof LazyLoaded<?>) {
((LazyLoaded<?>) variable).load();
}
}
return variables;
} 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 execute.
@Override
public <T> T execute(String deploymentId, Context<?> context, Command<T> command) {
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if (deployedUnit == null) {
throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
}
disallowWhenNotActive(deployedUnit, command);
RuntimeManager manager = deployedUnit.getRuntimeManager();
RuntimeEngine engine = manager.getRuntimeEngine(context);
try {
KieSession ksession = engine.getKieSession();
return ksession.execute(command);
} catch (SessionNotFoundException e) {
throw new ProcessInstanceNotFoundException("Process instance with context id " + context.getContextId() + " was not found", e);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
Aggregations