Java Code Examples for org.activiti.bpmn.model.SequenceFlow#getSourceRef()

The following examples show how to use org.activiti.bpmn.model.SequenceFlow#getSourceRef() . 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: ExecutionTreeNode.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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 2
Source File: SequenceflowValidator.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@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");
      }
    }
  }
}