Java Code Examples for org.activiti.bpmn.model.FlowElement#getId()

The following examples show how to use org.activiti.bpmn.model.FlowElement#getId() . 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: ExecutionEntity.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void setCurrentFlowElement(FlowElement currentFlowElement) {
  this.currentFlowElement = currentFlowElement;
  if (currentFlowElement != null) {
    this.activityId = currentFlowElement.getId();
  } else {
    this.activityId = null;
  }
}
 
Example 2
Source File: AbstractBpmnParseHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected String getPrecedingEventBasedGateway(BpmnParse bpmnParse, IntermediateCatchEvent event) {
  String eventBasedGatewayId = null;
  for (SequenceFlow sequenceFlow : event.getIncomingFlows()) {
    FlowElement sourceElement = bpmnParse.getBpmnModel().getFlowElement(sequenceFlow.getSourceRef());
    if (sourceElement instanceof EventGateway) {
      eventBasedGatewayId = sourceElement.getId();
      break;
    }
  }
  return eventBasedGatewayId;
}
 
Example 3
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 4
Source File: ExecutionEntityImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void setCurrentFlowElement(FlowElement currentFlowElement) {
  this.currentFlowElement = currentFlowElement;
  if (currentFlowElement != null) {
    this.activityId = currentFlowElement.getId();
  } else {
    this.activityId = null;
  }
}
 
Example 5
Source File: AbstractBpmnParseHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected String getPrecedingEventBasedGateway(BpmnParse bpmnParse, IntermediateCatchEvent event) {
  String eventBasedGatewayId = null;
  for (SequenceFlow sequenceFlow : event.getIncomingFlows()) {
    FlowElement sourceElement = bpmnParse.getBpmnModel().getFlowElement(sequenceFlow.getSourceRef());
    if (sourceElement instanceof EventGateway) {
      eventBasedGatewayId = sourceElement.getId();
      break;
    }
  }
  return eventBasedGatewayId;
}
 
Example 6
Source File: SubprocessXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private List<BpmnModel> parseSubModels(FlowElement subElement, Map<String, GraphicInfo> locations, 
                                       Map<String, List<GraphicInfo>> flowLocations, Map<String, GraphicInfo> labelLocations) {
  List<BpmnModel> subModels = new ArrayList<BpmnModel>();
  BpmnModel subModel = new BpmnModel();
  String elementId = null;

  // find nested subprocess models
  Collection<FlowElement> subFlowElements = ((SubProcess)subElement).getFlowElements();
  // set main process in submodel to subprocess
  Process newMainProcess = new Process();
  newMainProcess.setId(subElement.getId());
  newMainProcess.getFlowElements().addAll(subFlowElements);
  newMainProcess.getArtifacts().addAll(((SubProcess)subElement).getArtifacts());
  subModel.addProcess(newMainProcess);

  for (FlowElement element : subFlowElements) {
    elementId = element.getId();
    if (element instanceof SubProcess) {
      subModels.addAll(parseSubModels(element, locations, flowLocations, labelLocations));
    }
    
    if (element instanceof SequenceFlow && null != flowLocations.get(elementId)) {
      // must be an edge
      subModel.getFlowLocationMap().put(elementId, flowLocations.get(elementId));
    } else {
      // do not include data objects because they do not have a corresponding shape in the BPMNDI data
      if (!(element instanceof DataObject) && null != locations.get(elementId)) {
        // must be a shape
        subModel.getLocationMap().put(elementId, locations.get(elementId));
      }
    }
    // also check for any labels
    if (null != labelLocations.get(elementId)) {
      subModel.getLabelLocationMap().put(elementId, labelLocations.get(elementId));
    }
  }
  subModels.add(subModel);

  return subModels;
}
 
Example 7
Source File: BpmnDeployer.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected boolean localizeFlowElements(Collection<FlowElement> flowElements, ObjectNode infoNode) {
  boolean localizationValuesChanged = false;
  
  if (flowElements == null) return localizationValuesChanged;
  
  CommandContext commandContext = Context.getCommandContext();
  DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration().getDynamicBpmnService();
  
  for (FlowElement flowElement : flowElements) {
    if (flowElement instanceof UserTask || flowElement instanceof SubProcess) {
      List<ExtensionElement> localizationElements = flowElement.getExtensionElements().get("localization");
      if (localizationElements != null) {
        for (ExtensionElement localizationElement : localizationElements) {
          if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix())) {
            String locale = localizationElement.getAttributeValue(null, "locale");
            String name = localizationElement.getAttributeValue(null, "name");
            String documentation = null;
            List<ExtensionElement> documentationElements = localizationElement.getChildElements().get("documentation");
            if (documentationElements != null) {
              for (ExtensionElement documentationElement : documentationElements) {
                documentation = StringUtils.trimToNull(documentationElement.getElementText());
                break;
              }
            }

            String flowElementId = flowElement.getId();
            if (isEqualToCurrentLocalizationValue(locale, flowElementId, "name", name, infoNode) == false) {
              dynamicBpmnService.changeLocalizationName(locale, flowElementId, name, infoNode);
              localizationValuesChanged = true;
            }
            
            if (documentation != null && isEqualToCurrentLocalizationValue(locale, flowElementId, "description", documentation, infoNode) == false) {
              dynamicBpmnService.changeLocalizationDescription(locale, flowElementId, documentation, infoNode);
              localizationValuesChanged = true;
            }
            
            break;
          }
        }
      }
      
      if (flowElement instanceof SubProcess) {
        SubProcess subprocess = (SubProcess) flowElement;
        boolean isFlowElementLocalizationChanged = localizeFlowElements(subprocess.getFlowElements(), infoNode);
        boolean isDataObjectLocalizationChanged = localizeDataObjectElements(subprocess.getDataObjects(), infoNode);
        if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) {
          localizationValuesChanged = true;
        }
      }
    }
  }
  
  return localizationValuesChanged;
}
 
Example 8
Source File: BpmnDeployer.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected boolean localizeFlowElements(Collection<FlowElement> flowElements, ObjectNode infoNode) {
  boolean localizationValuesChanged = false;
  
  if (flowElements == null) return localizationValuesChanged;
  
  CommandContext commandContext = Context.getCommandContext();
  DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration().getDynamicBpmnService();
  
  for (FlowElement flowElement : flowElements) {
    if (flowElement instanceof UserTask || flowElement instanceof SubProcess) {
      List<ExtensionElement> localizationElements = flowElement.getExtensionElements().get("localization");
      if (localizationElements != null) {
        for (ExtensionElement localizationElement : localizationElements) {
          if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix())) {
            String locale = localizationElement.getAttributeValue(null, "locale");
            String name = localizationElement.getAttributeValue(null, "name");
            String documentation = null;
            List<ExtensionElement> documentationElements = localizationElement.getChildElements().get("documentation");
            if (documentationElements != null) {
              for (ExtensionElement documentationElement : documentationElements) {
                documentation = StringUtils.trimToNull(documentationElement.getElementText());
                break;
              }
            }

            String flowElementId = flowElement.getId();
            if (isEqualToCurrentLocalizationValue(locale, flowElementId, "name", name, infoNode) == false) {
              dynamicBpmnService.changeLocalizationName(locale, flowElementId, name, infoNode);
              localizationValuesChanged = true;
            }
            
            if (documentation != null && isEqualToCurrentLocalizationValue(locale, flowElementId, "description", documentation, infoNode) == false) {
              dynamicBpmnService.changeLocalizationDescription(locale, flowElementId, documentation, infoNode);
              localizationValuesChanged = true;
            }
            
            break;
          }
        }
      }
      
      if (flowElement instanceof SubProcess) {
        SubProcess subprocess = (SubProcess) flowElement;
        boolean isFlowElementLocalizationChanged = localizeFlowElements(subprocess.getFlowElements(), infoNode);
        boolean isDataObjectLocalizationChanged = localizeDataObjectElements(subprocess.getDataObjects(), infoNode);
        if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) {
          localizationValuesChanged = true;
        }
      }
    }
  }
  
  return localizationValuesChanged;
}
 
Example 9
Source File: CdiEventSupportBpmnParseHandler.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected void addStartEventListener(FlowElement flowElement) {
  CdiExecutionListener listener = new CdiExecutionListener(flowElement.getId(), BusinessProcessEventType.START_ACTIVITY);
  addActivitiListenerToElement(flowElement, ExecutionListener.EVENTNAME_START, listener);
}
 
Example 10
Source File: CdiEventSupportBpmnParseHandler.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected void addEndEventListener(FlowElement flowElement) {
  CdiExecutionListener listener = new CdiExecutionListener(flowElement.getId(), BusinessProcessEventType.END_ACTIVITY);
  addActivitiListenerToElement(flowElement, ExecutionListener.EVENTNAME_END, listener);
}
 
Example 11
Source File: SubprocessXMLConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected List<BpmnModel> parseSubModels(BpmnModel model) {
  List<BpmnModel> subModels = new ArrayList<BpmnModel>();

  // find all subprocesses
  Collection<FlowElement> flowElements = model.getMainProcess().getFlowElements();
  Map<String, GraphicInfo> locations = new HashMap<String, GraphicInfo>();
  Map<String, List<GraphicInfo>> flowLocations = new HashMap<String, List<GraphicInfo>>();
  Map<String, GraphicInfo> labelLocations = new HashMap<String, GraphicInfo>();

  locations.putAll(model.getLocationMap());
  flowLocations.putAll(model.getFlowLocationMap());
  labelLocations.putAll(model.getLabelLocationMap());

  // include main process as separate model
  BpmnModel mainModel = new BpmnModel();
  // set main process in submodel to subprocess
  mainModel.addProcess(model.getMainProcess());

  String elementId = null;
  for (FlowElement element : flowElements) {
    elementId = element.getId();
    if (element instanceof SubProcess) {
      subModels.addAll(parseSubModels(element, locations, flowLocations, labelLocations));
    }
    
    if (element instanceof SequenceFlow && null != flowLocations.get(elementId)) {
      // must be an edge
      mainModel.getFlowLocationMap().put(elementId, flowLocations.get(elementId));
    } else {
      // do not include data objects because they do not have a corresponding shape in the BPMNDI data
      if (!(element instanceof DataObject) && null != locations.get(elementId)) {
        // must be a shape
        mainModel.getLocationMap().put(elementId, locations.get(elementId));
      }
    }
    // also check for any labels
    if (null != labelLocations.get(elementId)) {
      mainModel.getLabelLocationMap().put(elementId, labelLocations.get(elementId));
    }
  }
  // add main process model to list
  subModels.add(mainModel);

  return subModels;
}