protected String getActivityIdExceptionMessage(VariableScope variableScope) { String activityId = null; String definitionIdMessage = ""; if (variableScope instanceof DelegateExecution) { activityId = ((DelegateExecution) variableScope).getCurrentActivityId(); definitionIdMessage = " in the process definition with id '" + ((DelegateExecution) variableScope).getProcessDefinitionId() + "'"; } else if (variableScope instanceof TaskEntity) { TaskEntity task = (TaskEntity) variableScope; if (task.getExecution() != null) { activityId = task.getExecution().getActivityId(); definitionIdMessage = " in the process definition with id '" + task.getProcessDefinitionId() + "'"; } if (task.getCaseExecution() != null) { activityId = task.getCaseExecution().getActivityId(); definitionIdMessage = " in the case definition with id '" + task.getCaseDefinitionId() + "'"; } } else if (variableScope instanceof DelegateCaseExecution) { activityId = ((DelegateCaseExecution) variableScope).getActivityId(); definitionIdMessage = " in the case definition with id '" + ((DelegateCaseExecution) variableScope).getCaseDefinitionId() + "'"; } if (activityId == null) { return ""; } else { return " while executing activity '" + activityId + "'" + definitionIdMessage; } }
protected String getActivityIdExceptionMessage(VariableScope variableScope) { String activityId = null; String definitionIdMessage = ""; if (variableScope instanceof DelegateExecution) { activityId = ((DelegateExecution) variableScope).getCurrentActivityId(); definitionIdMessage = " in the process definition with id '" + ((DelegateExecution) variableScope).getProcessDefinitionId() + "'"; } else if (variableScope instanceof TaskEntity) { TaskEntity task = (TaskEntity) variableScope; if (task.getExecution() != null) { activityId = task.getExecution().getActivityId(); definitionIdMessage = " in the process definition with id '" + task.getProcessDefinitionId() + "'"; } if (task.getCaseExecution() != null) { activityId = task.getCaseExecution().getActivityId(); definitionIdMessage = " in the case definition with id '" + task.getCaseDefinitionId() + "'"; } } else if (variableScope instanceof DelegateCaseExecution) { activityId = ((DelegateCaseExecution) variableScope).getActivityId(); definitionIdMessage = " in the case definition with id '" + ((DelegateCaseExecution) variableScope).getCaseDefinitionId() + "'"; } if (activityId == null) { return ""; } else { return " while executing activity '" + activityId + "'" + definitionIdMessage; } }
@Test public void providerCalledWithSuperProcessInstance() { ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider(); TestTenantIdProvider.delegate = tenantIdProvider; testRule.deploy(Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().done(), Bpmn.createExecutableProcess("superProcess").startEvent().callActivity().calledElement(PROCESS_DEFINITION_KEY).done()); ProcessDefinition superProcessDefinition = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("superProcess").singleResult(); // if a process instance is started engineRule.getRuntimeService().startProcessInstanceByKey("superProcess"); // then the tenant id provider is passed in the process definition DelegateExecution superExecution = tenantIdProvider.parameters.get(1).getSuperExecution(); assertThat(superExecution, is(notNullValue())); assertThat(superExecution.getProcessDefinitionId(), is(superProcessDefinition.getId())); }
@Override void setValueIntoDictionary(Dictionary<String, String> dictionary, DelegateExecution execution) { dictionary.put(this.getPropertyKey(), execution.getProcessDefinitionId()); }
public static DelegateEvent fromExecution(DelegateExecution delegateExecution) { DelegateEvent event = new DelegateEvent(); event.activityInstanceId = delegateExecution.getActivityInstanceId(); event.businessKey = delegateExecution.getBusinessKey(); event.currentActivityId = delegateExecution.getCurrentActivityId(); event.currentActivityName = delegateExecution.getCurrentActivityName(); event.currentTransitionId = delegateExecution.getCurrentTransitionId(); event.eventName = delegateExecution.getEventName(); event.id = delegateExecution.getId(); event.parentActivityInstanceId = delegateExecution.getParentActivityInstanceId(); event.parentId = delegateExecution.getParentId(); event.processBusinessKey = delegateExecution.getProcessBusinessKey(); event.processDefinitionId = delegateExecution.getProcessDefinitionId(); event.processInstanceId = delegateExecution.getProcessInstanceId(); event.tenantId = delegateExecution.getTenantId(); event.variableScopeKey = delegateExecution.getVariableScopeKey(); return event; }
public static String from(DelegateExecution execution) { return new Adapter(Context.bpmn, execution.getProcessEngineServices().getRepositoryService(), execution.getProcessDefinitionId()).get(); }
private CoveredFlowNode createCoveredFlowNode(DelegateExecution execution) { // Get the process definition in order to obtain the key final RepositoryService repositoryService = execution.getProcessEngineServices().getRepositoryService(); final ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId( execution.getProcessDefinitionId()).singleResult(); final String currentActivityId = execution.getCurrentActivityId(); final CoveredFlowNode coveredFlowNode = new CoveredFlowNode(processDefinition.getKey(), currentActivityId); return coveredFlowNode; }
@Override public void notify(DelegateExecution execution) throws Exception { if (coverageTestRunState == null) { logger.warning("Coverage execution listener in use but no coverage run state assigned!"); return; } final RepositoryService repositoryService = execution.getProcessEngineServices().getRepositoryService(); // Get the process definition in order to obtain the key final ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId( execution.getProcessDefinitionId()).singleResult(); final String transitionId = execution.getCurrentTransitionId(); // Record sequence flow coverage final CoveredSequenceFlow coveredSequenceFlow = new CoveredSequenceFlow(processDefinition.getKey(), transitionId); coverageTestRunState.addCoveredElement(coveredSequenceFlow); // Record possible event coverage handleEvent(transitionId, processDefinition, repositoryService); }
protected String getActivityIdExceptionMessage(VariableScope variableScope) { String activityId = null; String definitionIdMessage = ""; if (variableScope instanceof DelegateExecution) { activityId = ((DelegateExecution) variableScope).getCurrentActivityId(); definitionIdMessage = " in the process definition with id '" + ((DelegateExecution) variableScope).getProcessDefinitionId() + "'"; } else if (variableScope instanceof TaskEntity) { TaskEntity task = (TaskEntity) variableScope; if (task.getExecution() != null) { activityId = task.getExecution().getActivityId(); definitionIdMessage = " in the process definition with id '" + task.getProcessDefinitionId() + "'"; } if (task.getCaseExecution() != null) { activityId = task.getCaseExecution().getActivityId(); definitionIdMessage = " in the case definition with id '" + task.getCaseDefinitionId() + "'"; } } else if (variableScope instanceof DelegateCaseExecution) { activityId = ((DelegateCaseExecution) variableScope).getActivityId(); definitionIdMessage = " in the case definition with id '" + ((DelegateCaseExecution) variableScope).getCaseDefinitionId() + "'"; } if (activityId == null) { return ""; } else { return " while executing activity '" + activityId + "'" + definitionIdMessage; } }
@Test public void providerCalledWithSuperProcessInstance() { ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider(); TestTenantIdProvider.delegate = tenantIdProvider; testRule.deploy(Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().done(), Bpmn.createExecutableProcess("superProcess").startEvent().callActivity().calledElement(PROCESS_DEFINITION_KEY).done()); ProcessDefinition superProcessDefinition = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("superProcess").singleResult(); // if a process instance is started engineRule.getRuntimeService().startProcessInstanceByKey("superProcess"); // then the tenant id provider is passed in the process definition DelegateExecution superExecution = tenantIdProvider.parameters.get(1).getSuperExecution(); assertThat(superExecution, is(notNullValue())); assertThat(superExecution.getProcessDefinitionId(), is(superProcessDefinition.getId())); }
public static DelegateEvent fromExecution(DelegateExecution delegateExecution) { DelegateEvent event = new DelegateEvent(); event.activityInstanceId = delegateExecution.getActivityInstanceId(); event.businessKey = delegateExecution.getBusinessKey(); event.currentActivityId = delegateExecution.getCurrentActivityId(); event.currentActivityName = delegateExecution.getCurrentActivityName(); event.currentTransitionId = delegateExecution.getCurrentTransitionId(); event.eventName = delegateExecution.getEventName(); event.id = delegateExecution.getId(); event.parentActivityInstanceId = delegateExecution.getParentActivityInstanceId(); event.parentId = delegateExecution.getParentId(); event.processBusinessKey = delegateExecution.getProcessBusinessKey(); event.processDefinitionId = delegateExecution.getProcessDefinitionId(); event.processInstanceId = delegateExecution.getProcessInstanceId(); event.tenantId = delegateExecution.getTenantId(); event.variableScopeKey = delegateExecution.getVariableScopeKey(); return event; }