use of org.activiti.engine.RuntimeService in project Activiti by Activiti.
the class MuleHttpTest method http.
@Test
public void http() throws Exception {
Assert.assertTrue(muleContext.isStarted());
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
Deployment deployment = processEngine.getRepositoryService().createDeployment().addClasspathResource("org/activiti/mule/testHttp.bpmn20.xml").deploy();
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
Assert.assertFalse(processInstance.isEnded());
Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
Assert.assertEquals(20, result);
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
processEngine.getRepositoryService().deleteDeployment(deployment.getId());
assertAndEnsureCleanDb(processEngine);
ProcessEngines.destroy();
}
use of org.activiti.engine.RuntimeService in project midpoint by Evolveum.
the class ProcessInstanceManager method cleanupActivitiProcesses.
public void cleanupActivitiProcesses(OperationResult result) throws SchemaException {
RuntimeService runtimeService = activitiEngine.getRuntimeService();
TaskService taskService = activitiEngine.getTaskService();
LOGGER.info("Starting cleanup of Activiti processes");
Collection<String> processInstancesToKeep = getProcessInstancesToKeep(result);
LOGGER.info("Process instances to keep: {}", processInstancesToKeep);
List<ProcessInstance> instances = runtimeService.createProcessInstanceQuery().list();
LOGGER.info("Existing process instances in Activiti: {}", instances.size());
int ok = 0, fail = 0;
for (ProcessInstance instance : instances) {
String instanceId = instance.getId();
if (processInstancesToKeep.contains(instanceId)) {
continue;
}
LOGGER.debug("Deleting process instance {}", instance);
try {
runtimeService.setVariable(instanceId, CommonProcessVariableNames.VARIABLE_PROCESS_INSTANCE_IS_STOPPING, Boolean.TRUE);
runtimeService.deleteProcessInstance(instanceId, "Deleted as part of activiti processes cleanup");
ok++;
} catch (Throwable t) {
LOGGER.info("Couldn't delete process instance {}, retrying with explicit deletion of some variables for its tasks", instanceId);
List<org.activiti.engine.task.Task> tasks = taskService.createTaskQuery().processInstanceId(instanceId).list();
LOGGER.debug("Tasks: {}", tasks);
for (org.activiti.engine.task.Task task : tasks) {
taskService.removeVariables(task.getId(), Arrays.asList("approvalSchema", "level"));
}
try {
runtimeService.deleteProcessInstance(instanceId, "Deleted as part of activiti processes cleanup");
ok++;
} catch (Throwable t2) {
result.createSubresult(ProcessInstanceManager.class.getName() + ".cleanupActivitiProcess").recordPartialError("Couldn't delete Activiti process instance " + instanceId + ": " + t2.getMessage(), t2);
fail++;
}
}
}
String message = "Successfully deleted " + ok + " instances; failed " + fail + " times";
LOGGER.info(message);
result.recordStatus(fail > 0 ? OperationResultStatus.PARTIAL_ERROR : OperationResultStatus.SUCCESS, message);
}
use of org.activiti.engine.RuntimeService in project midpoint by Evolveum.
the class DumpVariables method execute.
public void execute(DelegateExecution execution) {
if (LOGGER.isTraceEnabled()) {
RuntimeService runtimeService = execution.getEngineServices().getRuntimeService();
Set<String> variablesSeen = new HashSet<>();
LOGGER.trace("--------------------------------- DumpVariables: " + execution.getCurrentActivityId());
// LOGGER.trace("All variables for execution id={}, parent id={}", execution.getId(), execution.getParentId());
// execution.getVariableInstances().forEach((n, v) -> LOGGER.trace(" - {} = {} (in {})", n, v.getValue(), v.getExecutionId()));
LOGGER.trace("Execution hierarchy for id={}", execution.getId());
LOGGER.trace("------------------------------------");
dumpExecutionVariables(execution.getId(), execution, null, variablesSeen, runtimeService);
Collection<String> disjunction = CollectionUtils.disjunction(variablesSeen, execution.getVariableNames());
if (!disjunction.isEmpty()) {
LOGGER.trace("*** Variables not found in execution tree or 'execution.getVariableNames()': {}", disjunction);
}
LOGGER.trace("--------------------------------- DumpVariables: " + execution.getCurrentActivityId() + " END ------------");
}
}
use of org.activiti.engine.RuntimeService in project bamboobsc by billchen198318.
the class TestBPMN001 method startProcess.
@Test
public void startProcess() throws Exception {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("confirmPublish", "N");
String processId = "Employee360DegreeFeedbackProjectPublishProcess";
RuntimeService runtimeService = (RuntimeService) AppContext.getBean("runtimeService");
ProcessInstance process = runtimeService.startProcessInstanceByKey(processId, paramMap);
System.out.println("DeploymentId: " + process.getDeploymentId());
System.out.println("ActivityId: " + process.getActivityId());
System.out.println("Name: " + process.getName());
System.out.println("ProcessDefinitionId: " + process.getProcessDefinitionId());
System.out.println("ProcessDefinitionKey: " + process.getProcessDefinitionKey());
System.out.println("ProcessDefinitionName: " + process.getProcessDefinitionName());
System.out.println("BusinessKey: " + process.getBusinessKey());
}
Aggregations