public void notify(DelegateExecution execution) throws Exception { Integer counter = (Integer) execution.getVariable("executionListenerCounter"); if (counter == null) { counter = 0; } execution.setVariable("subExecutionListenerCounter", ++counter); }
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 void execute(DelegateExecution execution) throws Exception { activityInstance = execution.getProcessEngineServices() .getRuntimeService() .getActivityInstance(execution.getProcessInstanceId()); }
public CdiBusinessProcessEvent(String activityId, String transitionName, ProcessDefinition processDefinition, DelegateExecution execution, BusinessProcessEventType type, Date timeStamp) { this.activityId = activityId; this.transitionName = transitionName; this.processInstanceId = execution.getProcessInstanceId(); this.executionId = execution.getId(); this.type = type; this.timeStamp = timeStamp; this.processDefinition = processDefinition; this.delegateTask = null; }
public void notify(DelegateExecution execution) throws Exception { execution.setVariable("variableSetInExecutionListener", "secondValue"); execution.setVariable("eventNameReceived", execution.getEventName()); } }
protected BusinessProcessEvent createEvent(DelegateExecution execution) { ProcessDefinition processDefinition = Context.getExecutionContext().getProcessDefinition(); // map type String eventName = execution.getEventName(); BusinessProcessEventType type = null; if(ExecutionListener.EVENTNAME_START.equals(eventName)) { type = BusinessProcessEventType.START_ACTIVITY; } else if(ExecutionListener.EVENTNAME_END.equals(eventName)) { type = BusinessProcessEventType.END_ACTIVITY; } else if(ExecutionListener.EVENTNAME_TAKE.equals(eventName)) { type = BusinessProcessEventType.TAKE; } return new CdiBusinessProcessEvent(execution.getCurrentActivityId(), execution.getCurrentTransitionId(), processDefinition, execution, type, ClockUtil.getCurrentTime()); }
@Override public void execute(DelegateExecution execution) throws Exception { Boolean fail = (Boolean) execution.getVariable("fail"); if (fail == null || fail == true) { throw new ProcessEngineException(EXCEPTION_MESSAGE); } }
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; } }
public void notify(DelegateExecution execution) throws Exception { int listenerInvocationCount = 0; if(execution.hasVariable(LISTENER_INVOCATION_COUNT)) { listenerInvocationCount = (Integer) execution.getVariable(LISTENER_INVOCATION_COUNT); } listenerInvocationCount += 1; execution.setVariable(LISTENER_INVOCATION_COUNT, listenerInvocationCount); } };
public void execute(DelegateExecution execution) throws Exception { if (execution.getVariable("listVar") != null) { execution.removeVariable("listVar"); execution.setVariable("listVar", "stringValue"); } else if (execution.getVariable("foo") != null) { execution.removeVariable("foo"); execution.setVariable("foo", "secondValue"); } } }
@Override public void execute(DelegateExecution execution) throws Exception { RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService(); TaskService taskService = execution.getProcessEngineServices().getTaskService(); String instanceToDelete = (String) execution.getVariable("instanceToComplete"); Task taskToTrigger = taskService.createTaskQuery().processInstanceId(instanceToDelete).singleResult(); taskService.complete(taskToTrigger.getId()); ActivityInstance activityInstance = runtimeService.getActivityInstance(instanceToDelete); execution.setVariable("activityInstanceNull", activityInstance == null); }
/** * Checks, if a variable with specified name is set (global and local). * * @param execution * process execution. * @param variableName * name of the variable to check. */ public static void checkIsSet(final DelegateExecution execution, final String variableName) { Preconditions.checkArgument(variableName != null, "Variable name must be not null"); final Object variableLocal = execution.getVariableLocal(variableName); final Object variable = execution.getVariable(variableName); Preconditions.checkState((variableLocal != null) || (variable != null), String.format("Condition of task '%s' is violated: Variable '%s' is not set.", new Object[] { execution.getCurrentActivityId(), variableName })); }
public void notify(DelegateExecution execution) throws Exception { ExecutionEntity executionCasted = ((ExecutionEntity)execution); String parameterValue = null; if (parameter != null) { parameterValue = (String)parameter.getValue(execution); } String activityName = null; if (executionCasted.getActivity() != null) { activityName = executionCasted.getActivity().getProperties().get(new PropertyKey<String>("name")); } recordedEvents.add( new RecordedEvent( executionCasted.getActivityId(), activityName, execution.getEventName(), parameterValue, execution.getActivityInstanceId(), execution.getCurrentTransitionId(), execution.isCanceled(), execution.getId())); }
/** * Checks, if a global variable with specified name is set. * * @param execution * process execution. * @param variableName * name of the variable to check. */ public static void checkIsSetGlobal(final DelegateExecution execution, final String variableName) { Preconditions.checkArgument(variableName != null, VARIABLE_SKIP_GUARDS); final Object variable = execution.getVariable(variableName); Preconditions.checkState(variable != null, String.format("Condition of task '%s' is violated: Global variable '%s' is not set.", new Object[] { execution.getCurrentActivityId(), variableName })); } }
public void notify(DelegateExecution execution) throws Exception { String counterKey = execution.getCurrentActivityId() + "-" +execution.getEventName(); collectedEvents.add(counterKey); }
@Override public void notify(DelegateExecution execution) throws Exception { System.out.println("Hello world. There was an event '" + execution.getEventName() + "'! It came from activity '"+execution.getCurrentActivityId()+"' for process instance '" + execution.getProcessInstanceId() + "'"); }
public void notify(DelegateExecution execution) throws Exception { execution.setVariable("variableSetInExecutionListener", "firstValue"); execution.setVariable("eventNameReceived", execution.getEventName()); execution.setVariable("businessKeyInExecution", execution.getProcessBusinessKey()); } }
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; }
public void execute(DelegateExecution execution) throws Exception { List<String> list = (List<String>) execution.getVariable("listVar"); execution.removeVariable("listVar"); // implicitly update the previous list, should update the variable value list.add(NEW_ELEMENT); }
public void execute(DelegateExecution execution) throws Exception { assertCanAccessServices(execution.getProcessEngineServices()); } }