Java Code Examples for org.activiti.bpmn.model.SequenceFlow#getTargetRef()
The following examples show how to use
org.activiti.bpmn.model.SequenceFlow#getTargetRef() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DisplayJsonClientResource.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected List<String> gatherCompletedFlows(List<String> completedActivityInstances, List<String> currentActivityinstances, BpmnModel pojoModel) { List<String> completedFlows = new ArrayList<String>(); List<String> activities = new ArrayList<String>(completedActivityInstances); activities.addAll(currentActivityinstances); // TODO: not a robust way of checking when parallel paths are active, should be revisited // Go over all activities and check if it's possible to match any outgoing paths against the activities for (FlowElement activity : pojoModel.getMainProcess().getFlowElements()) { if(activity instanceof FlowNode) { int index = activities.indexOf(activity.getId()); if (index >= 0 && index + 1 < activities.size()) { List<SequenceFlow> outgoingFlows = ((FlowNode) activity).getOutgoingFlows(); for (SequenceFlow flow : outgoingFlows) { String destinationFlowId = flow.getTargetRef(); if (destinationFlowId.equals(activities.get(index + 1))) { completedFlows.add(flow.getId()); } } } } } return completedFlows; }
Example 2
Source File: RuntimeDisplayJsonClientResource.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected List<String> gatherCompletedFlows(Set<String> completedActivityInstances, Set<String> currentActivityinstances, BpmnModel pojoModel) { List<String> completedFlows = new ArrayList<String>(); List<String> activities = new ArrayList<String>(completedActivityInstances); activities.addAll(currentActivityinstances); // TODO: not a robust way of checking when parallel paths are active, should be revisited // Go over all activities and check if it's possible to match any outgoing paths against the activities for (FlowElement activity : pojoModel.getMainProcess().getFlowElements()) { if (activity instanceof FlowNode) { int index = activities.indexOf(activity.getId()); if (index >= 0 && index + 1 < activities.size()) { List<SequenceFlow> outgoingFlows = ((FlowNode) activity).getOutgoingFlows(); for (SequenceFlow flow : outgoingFlows) { String destinationFlowId = flow.getTargetRef(); if (destinationFlowId.equals(activities.get(index + 1))) { completedFlows.add(flow.getId()); } } } } } return completedFlows; }
Example 3
Source File: JobDefinitionServiceImpl.java From herd with Apache License 2.0 | 6 votes |
/** * Asserts that the first asyncable task in the given model is indeed asynchronous. Only asserts when the configuration is set to true. * * @param bpmnModel The BPMN model */ private void assertFirstTaskIsAsync(BpmnModel bpmnModel) { if (Boolean.TRUE.equals(configurationHelper.getProperty(ConfigurationValue.ACTIVITI_JOB_DEFINITION_ASSERT_ASYNC, Boolean.class))) { Process process = bpmnModel.getMainProcess(); for (StartEvent startEvent : process.findFlowElementsOfType(StartEvent.class)) { for (SequenceFlow sequenceFlow : startEvent.getOutgoingFlows()) { String targetRef = sequenceFlow.getTargetRef(); FlowElement targetFlowElement = process.getFlowElement(targetRef); if (targetFlowElement instanceof Activity) { Assert.isTrue(((Activity) targetFlowElement).isAsynchronous(), "Element with id \"" + targetRef + "\" must be set to activiti:async=true. All tasks which start the workflow must be asynchronous to prevent certain undesired " + "transactional behavior, such as records of workflow not being saved on errors. Please refer to Activiti and herd documentations " + "for details."); } } } } }
Example 4
Source File: ExecutionTreeNode.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected String getCurrentFlowElementId() { FlowElement flowElement = getExecutionEntity().getCurrentFlowElement(); if (flowElement instanceof SequenceFlow) { SequenceFlow sequenceFlow = (SequenceFlow) flowElement; return sequenceFlow.getSourceRef() + " -> " + sequenceFlow.getTargetRef(); } else if (flowElement != null) { return flowElement.getId() + " (" + flowElement.getClass().getSimpleName(); } else { return ""; } }
Example 5
Source File: SequenceflowValidator.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) { List<SequenceFlow> sequenceFlows = process.findFlowElementsOfType(SequenceFlow.class); for (SequenceFlow sequenceFlow : sequenceFlows) { String sourceRef = sequenceFlow.getSourceRef(); String targetRef = sequenceFlow.getTargetRef(); if (StringUtils.isEmpty(sourceRef)) { addError(errors, Problems.SEQ_FLOW_INVALID_SRC, process, sequenceFlow, "Invalid source for sequenceflow"); } if (StringUtils.isEmpty(targetRef)) { addError(errors, Problems.SEQ_FLOW_INVALID_TARGET, process, sequenceFlow, "Invalid target for sequenceflow"); } // Implicit check: sequence flow cannot cross (sub) process // boundaries, hence we check the parent and not the process // (could be subprocess for example) FlowElement source = process.getFlowElement(sourceRef, true); FlowElement target = process.getFlowElement(targetRef, true); // Src and target validation if (source == null) { addError(errors, Problems.SEQ_FLOW_INVALID_SRC, process, sequenceFlow, "Invalid source for sequenceflow"); } if (target == null) { addError(errors, Problems.SEQ_FLOW_INVALID_TARGET, process, sequenceFlow, "Invalid target for sequenceflow"); } if (source != null && target != null) { FlowElementsContainer sourceContainer = process.getFlowElementsContainer(source.getId()); FlowElementsContainer targetContainer = process.getFlowElementsContainer(target.getId()); if (sourceContainer == null) { addError(errors, Problems.SEQ_FLOW_INVALID_SRC, process, sequenceFlow, "Invalid source for sequenceflow"); } if (targetContainer == null) { addError(errors, Problems.SEQ_FLOW_INVALID_TARGET, process, sequenceFlow, "Invalid target for sequenceflow"); } if (sourceContainer != null && targetContainer != null && sourceContainer.equals(targetContainer) == false) { addError(errors, Problems.SEQ_FLOW_INVALID_TARGET, process, sequenceFlow, "Invalid target for sequenceflow, the target isn't defined in the same scope as the source"); } } } }