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());
}
use of org.activiti.engine.RuntimeService in project crnk-framework by crnk-project.
the class ApprovalManagerTest method setup.
@Before
public void setup() {
runtimeService = Mockito.mock(RuntimeService.class);
TaskService taskService = Mockito.mock(TaskService.class);
repositoryFacade = Mockito.mock(ResourceRepositoryV2.class);
ApprovalMapper approvalMapper = new ApprovalMapper();
ActivitiResourceMapper resourceMapper = new ActivitiResourceMapper(new TypeParser(), new DefaultDateTimeMapper());
ResourceInformation information = Mockito.mock(ResourceInformation.class);
registryEntry = Mockito.mock(RegistryEntry.class);
ResourceRegistry resourceRegistry = Mockito.mock(ResourceRegistry.class);
Mockito.when(registryEntry.getResourceInformation()).thenReturn(information);
Mockito.when(registryEntry.getResourceRepositoryFacade()).thenReturn(repositoryFacade);
Mockito.when(information.getResourceType()).thenReturn("schedule");
Mockito.when(information.getId(Mockito.any())).thenReturn(mockId);
Mockito.when(resourceRegistry.getEntry(Mockito.any(Class.class))).thenReturn(registryEntry);
Mockito.when(resourceRegistry.getEntry(Mockito.any(String.class))).thenReturn(registryEntry);
ModuleRegistry moduleRegistry = Mockito.mock(ModuleRegistry.class);
Mockito.when(moduleRegistry.getResourceRegistry()).thenReturn(resourceRegistry);
originalResource = new Schedule();
originalResource.setId(mockId);
originalResource.setName("Jane");
Mockito.when(repositoryFacade.findOne(Mockito.any(Long.class), Mockito.any(QuerySpec.class))).thenReturn(originalResource);
manager = new ApprovalManager();
manager.init(runtimeService, taskService, resourceMapper, approvalMapper, moduleRegistry);
}
Aggregations