org.activiti.bpmn.model.SubProcess Java Examples

The following examples show how to use org.activiti.bpmn.model.SubProcess. 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: BpmnAutoLayout.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void generateActivityDiagramInterchangeElements() {
  for (String flowElementId : generatedVertices.keySet()) {
    Object vertex = generatedVertices.get(flowElementId);
    mxCellState cellState = graph.getView().getState(vertex);
    GraphicInfo subProcessGraphicInfo = createDiagramInterchangeInformation(handledFlowElements.get(flowElementId), (int) cellState.getX(), (int) cellState.getY(), (int) cellState.getWidth(),
        (int) cellState.getHeight());

    // The DI for the elements of a subprocess are generated without
    // knowledge of the rest of the graph
    // So we must translate all it's elements with the x and y of the
    // subprocess itself
    if (handledFlowElements.get(flowElementId) instanceof SubProcess) {

      // Always expanded when auto layouting
      subProcessGraphicInfo.setExpanded(true);
    }
  }
}
 
Example #2
Source File: DataObjectValidator.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {

  // Gather data objects
  List<ValuedDataObject> allDataObjects = new ArrayList<ValuedDataObject>();
  allDataObjects.addAll(process.getDataObjects());
  List<SubProcess> subProcesses = process.findFlowElementsOfType(SubProcess.class, true);
  for (SubProcess subProcess : subProcesses) {
    allDataObjects.addAll(subProcess.getDataObjects());
  }

  // Validate
  for (ValuedDataObject dataObject : allDataObjects) {
    if (StringUtils.isEmpty(dataObject.getName())) {
      addError(errors, Problems.DATA_OBJECT_MISSING_NAME, process, dataObject, "Name is mandatory for a data object");
    }
  }

}
 
Example #3
Source File: BpmnImageTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void scaleFlowElements(Collection<FlowElement> elementList, BpmnModel bpmnModel, double scaleFactor) {
    for (FlowElement flowElement : elementList) {
    	List<GraphicInfo> graphicInfoList = new ArrayList<GraphicInfo>();
    	if (flowElement instanceof SequenceFlow) {
    		graphicInfoList.addAll(bpmnModel.getFlowLocationGraphicInfo(flowElement.getId()));
    	} else {
    		graphicInfoList.add(bpmnModel.getGraphicInfo(flowElement.getId()));
    	}
    	
    	scaleGraphicInfoList(graphicInfoList, scaleFactor);
    	
    	if (flowElement instanceof SubProcess) {
    		SubProcess subProcess = (SubProcess) flowElement;
    		scaleFlowElements(subProcess.getFlowElements(), bpmnModel, scaleFactor);
    	}
    }
}
 
Example #4
Source File: SubprocessValidator.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {
  List<SubProcess> subProcesses = process.findFlowElementsOfType(SubProcess.class);
  for (SubProcess subProcess : subProcesses) {

    if (!(subProcess instanceof EventSubProcess)) {

      // Verify start events
      List<StartEvent> startEvents = process.findFlowElementsInSubProcessOfType(subProcess, StartEvent.class, false);
      if (startEvents.size() > 1) {
        addError(errors, Problems.SUBPROCESS_MULTIPLE_START_EVENTS, process, subProcess, "Multiple start events not supported for subprocess");
      }

      for (StartEvent startEvent : startEvents) {
        if (!startEvent.getEventDefinitions().isEmpty()) {
          addError(errors, Problems.SUBPROCESS_START_EVENT_EVENT_DEFINITION_NOT_ALLOWED, process, startEvent, "event definitions only allowed on start event if subprocess is an event subprocess");
        }
      }

    }

  }

}
 
Example #5
Source File: ModelImageService.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void scaleFlowElements(Collection<FlowElement> elementList, BpmnModel bpmnModel, double scaleFactor) {
  for (FlowElement flowElement : elementList) {
    List<GraphicInfo> graphicInfoList = new ArrayList<GraphicInfo>();
    if (flowElement instanceof SequenceFlow) {
      List<GraphicInfo> flowList = bpmnModel.getFlowLocationGraphicInfo(flowElement.getId());
      if (flowList != null) {
        graphicInfoList.addAll(flowList);
      }
    } else {
      graphicInfoList.add(bpmnModel.getGraphicInfo(flowElement.getId()));
    }

    scaleGraphicInfoList(graphicInfoList, scaleFactor);

    if (flowElement instanceof SubProcess) {
      SubProcess subProcess = (SubProcess) flowElement;
      scaleFlowElements(subProcess.getFlowElements(), bpmnModel, scaleFactor);
    }
  }
}
 
Example #6
Source File: SubProcessParseHandler.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, SubProcess subProcess) {

    subProcess.setBehavior(bpmnParse.getActivityBehaviorFactory().createSubprocessActivityBehavior(subProcess));

    bpmnParse.processFlowElements(subProcess.getFlowElements());
    processArtifacts(bpmnParse, subProcess.getArtifacts());

    // no data objects for event subprocesses
    /*
     * if (!(subProcess instanceof EventSubProcess)) { // parse out any data objects from the template in order to set up the necessary process variables Map<String, Object> variables =
     * processDataObjects(bpmnParse, subProcess.getDataObjects(), activity); activity.setVariables(variables); }
     * 
     * bpmnParse.removeCurrentScope(); bpmnParse.removeCurrentSubProcess();
     * 
     * if (subProcess.getIoSpecification() != null) { IOSpecification ioSpecification = createIOSpecification(bpmnParse, subProcess.getIoSpecification()); activity.setIoSpecification(ioSpecification);
     * }
     */

  }
 
Example #7
Source File: SubProcessJsonConverter.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void convertElementToJson(ObjectNode propertiesNode, BaseElement baseElement) {
  SubProcess subProcess = (SubProcess) baseElement;

  propertiesNode.put("activitytype", "Sub-Process");
  propertiesNode.put("subprocesstype", "Embedded");
  ArrayNode subProcessShapesArrayNode = objectMapper.createArrayNode();
  GraphicInfo graphicInfo = model.getGraphicInfo(subProcess.getId());
  processor.processFlowElements(subProcess, model, subProcessShapesArrayNode, formKeyMap,
      decisionTableKeyMap, graphicInfo.getX(), graphicInfo.getY());
  flowElementNode.set("childShapes", subProcessShapesArrayNode);
  
  if (subProcess instanceof Transaction) {
    propertiesNode.put("istransaction", true);
  }
  
  BpmnJsonConverterUtil.convertDataPropertiesToJson(subProcess.getDataObjects(), propertiesNode);
}
 
Example #8
Source File: DeploymentServiceImpl.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void processUserTasks(Collection<FlowElement> flowElements, Process process, Map<String, StartEvent> startEventMap) {

    for (FlowElement flowElement : flowElements) {
      if (flowElement instanceof UserTask) {
        UserTask userTask = (UserTask) flowElement;
        if ("$INITIATOR".equals(userTask.getAssignee())) {
          if (startEventMap.get(process.getId()) != null) {
            userTask.setAssignee("${" + startEventMap.get(process.getId()).getInitiator() + "}");
          }
        }

      } else if (flowElement instanceof SubProcess) {
        processUserTasks(((SubProcess) flowElement).getFlowElements(), process, startEventMap);
      }
    }
  }
 
Example #9
Source File: BaseBpmnJsonConverter.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void processDataStoreReferences(FlowElementsContainer container, String dataStoreReferenceId, ArrayNode outgoingArrayNode) {
  for (FlowElement flowElement : container.getFlowElements()) {
    if (flowElement instanceof Activity) {
      Activity activity = (Activity) flowElement;

      if (CollectionUtils.isNotEmpty(activity.getDataInputAssociations())) {
        for (DataAssociation dataAssociation : activity.getDataInputAssociations()) {
          if (dataStoreReferenceId.equals(dataAssociation.getSourceRef())) {
            outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(dataAssociation.getId()));
          }
        }
      }

    } else if (flowElement instanceof SubProcess) {
      processDataStoreReferences((SubProcess) flowElement, dataStoreReferenceId, outgoingArrayNode);
    }
  }
}
 
Example #10
Source File: SubProcessMultiDiagramConverterNoDITest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
private void validateModel(BpmnModel model) {
  FlowElement flowElement = model.getMainProcess().getFlowElement("start1");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof StartEvent);
  assertEquals("start1", flowElement.getId());

  flowElement = model.getMainProcess().getFlowElement("userTask1");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof UserTask);
  assertEquals("userTask1", flowElement.getId());
  UserTask userTask = (UserTask) flowElement;
  assertTrue(userTask.getCandidateUsers().size() == 1);
  assertTrue(userTask.getCandidateGroups().size() == 1);

  flowElement = model.getMainProcess().getFlowElement("subprocess1");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof SubProcess);
  assertEquals("subprocess1", flowElement.getId());
  SubProcess subProcess = (SubProcess) flowElement;
  assertTrue(subProcess.getFlowElements().size() == 11);
}
 
Example #11
Source File: SubProcessMultiDiagramConverterTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
private void validateModel(BpmnModel model) {
  FlowElement flowElement = model.getMainProcess().getFlowElement("start1");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof StartEvent);
  assertEquals("start1", flowElement.getId());

  flowElement = model.getMainProcess().getFlowElement("userTask1");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof UserTask);
  assertEquals("userTask1", flowElement.getId());
  UserTask userTask = (UserTask) flowElement;
  assertTrue(userTask.getCandidateUsers().size() == 1);
  assertTrue(userTask.getCandidateGroups().size() == 1);

  flowElement = model.getMainProcess().getFlowElement("subprocess1");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof SubProcess);
  assertEquals("subprocess1", flowElement.getId());
  SubProcess subProcess = (SubProcess) flowElement;
  assertTrue(subProcess.getFlowElements().size() == 11);
}
 
Example #12
Source File: BpmnXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void processFlowElements(Collection<FlowElement> flowElementList, BaseElement parentScope) {
  for (FlowElement flowElement : flowElementList) {
    if (flowElement instanceof SequenceFlow) {
      SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
      FlowNode sourceNode = getFlowNodeFromScope(sequenceFlow.getSourceRef(), parentScope);
      if (sourceNode != null) {
        sourceNode.getOutgoingFlows().add(sequenceFlow);
        sequenceFlow.setSourceFlowElement(sourceNode);
      }
      
      FlowNode targetNode = getFlowNodeFromScope(sequenceFlow.getTargetRef(), parentScope);
      if (targetNode != null) {
        targetNode.getIncomingFlows().add(sequenceFlow);
        sequenceFlow.setTargetFlowElement(targetNode);
      }
      
    } else if (flowElement instanceof BoundaryEvent) {
      BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
      FlowElement attachedToElement = getFlowNodeFromScope(boundaryEvent.getAttachedToRefId(), parentScope);
      if (attachedToElement instanceof Activity) {
        Activity attachedActivity = (Activity) attachedToElement;
        boundaryEvent.setAttachedToRef(attachedActivity);
        attachedActivity.getBoundaryEvents().add(boundaryEvent);
      }
      
    } else if (flowElement instanceof SubProcess) {
      SubProcess subProcess = (SubProcess) flowElement;
      processFlowElements(subProcess.getFlowElements(), subProcess);
    }
  }
}
 
Example #13
Source File: BpmnAutoLayout.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
/**
 * Since subprocesses are autolayouted independently (see {@link #handleSubProcess(FlowElement)}), the elements have x and y coordinates relative to the bounds of the subprocess (thinking the
 * subprocess is on (0,0). This however, does not work for nested subprocesses, as they need to take in account the x and y coordinates for each of the parent subproceses.
 * 
 * This method is to be called after fully layouting one process, since ALL elements need to have x and y.
 */
protected void translateNestedSubprocesses(Process process) {
     for (FlowElement flowElement : process.getFlowElements()) {
          if (flowElement instanceof SubProcess) {
            translateNestedSubprocessElements((SubProcess) flowElement);
          }
     }
}
 
Example #14
Source File: SubProcessConverterAutoLayoutTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void validateModel(BpmnModel model) {
  FlowElement flowElement = model.getMainProcess().getFlowElement("start1");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof StartEvent);
  assertEquals("start1", flowElement.getId());

  flowElement = model.getMainProcess().getFlowElement("userTask1");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof UserTask);
  assertEquals("userTask1", flowElement.getId());
  UserTask userTask = (UserTask) flowElement;
  assertTrue(userTask.getCandidateUsers().size() == 1);
  assertTrue(userTask.getCandidateGroups().size() == 1);

  flowElement = model.getMainProcess().getFlowElement("subprocess1");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof SubProcess);
  assertEquals("subprocess1", flowElement.getId());
  SubProcess subProcess = (SubProcess) flowElement;
  assertTrue(subProcess.getFlowElements().size() == 6);

  List<ValuedDataObject> dataObjects = ((SubProcess) flowElement).getDataObjects();
  assertTrue(dataObjects.size() == 1);

  ValuedDataObject dataObj = dataObjects.get(0);
  assertEquals("SubTest", dataObj.getName());
  assertEquals("xsd:string", dataObj.getItemSubjectRef().getStructureRef());
  assertTrue(dataObj.getValue() instanceof String);
  assertEquals("Testing", dataObj.getValue());
}
 
Example #15
Source File: ScopedConverterTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void validateModel(BpmnModel model) {
  FlowElement flowElement = model.getMainProcess().getFlowElement("outerSubProcess");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof SubProcess);
  assertEquals("outerSubProcess", flowElement.getId());
  SubProcess outerSubProcess = (SubProcess) flowElement;
  List<BoundaryEvent> eventList = outerSubProcess.getBoundaryEvents();
  assertEquals(1, eventList.size());
  BoundaryEvent boundaryEvent = eventList.get(0);
  assertEquals("outerBoundaryEvent", boundaryEvent.getId());

  FlowElement subElement = outerSubProcess.getFlowElement("innerSubProcess");
  assertNotNull(subElement);
  assertTrue(subElement instanceof SubProcess);
  assertEquals("innerSubProcess", subElement.getId());
  SubProcess innerSubProcess = (SubProcess) subElement;
  eventList = innerSubProcess.getBoundaryEvents();
  assertEquals(1, eventList.size());
  boundaryEvent = eventList.get(0);
  assertEquals("innerBoundaryEvent", boundaryEvent.getId());

  FlowElement taskElement = innerSubProcess.getFlowElement("usertask");
  assertNotNull(taskElement);
  assertTrue(taskElement instanceof UserTask);
  UserTask userTask = (UserTask) taskElement;
  assertEquals("usertask", userTask.getId());
  eventList = userTask.getBoundaryEvents();
  assertEquals(1, eventList.size());
  boundaryEvent = eventList.get(0);
  assertEquals("taskBoundaryEvent", boundaryEvent.getId());
}
 
Example #16
Source File: BpmnXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected FlowNode getFlowNodeFromScope(String elementId, BaseElement scope) {
  FlowNode flowNode = null;
  if (StringUtils.isNotEmpty(elementId)) {
    if (scope instanceof Process) {
      flowNode = (FlowNode) ((Process) scope).getFlowElement(elementId);
    } else if (scope instanceof SubProcess) {
      flowNode = (FlowNode) ((SubProcess) scope).getFlowElement(elementId);
    }
  }
  return flowNode;
}
 
Example #17
Source File: BpmnJsonConverter.java    From lemon with Apache License 2.0 5 votes vote down vote up
private void fillSubShapes(Map<String, SubProcess> subShapesMap,
        SubProcess subProcess) {
    for (FlowElement flowElement : subProcess.getFlowElements()) {
        if (flowElement instanceof SubProcess) {
            SubProcess childSubProcess = (SubProcess) flowElement;
            subShapesMap.put(childSubProcess.getId(), subProcess);
            fillSubShapes(subShapesMap, childSubProcess);
        } else {
            subShapesMap.put(flowElement.getId(), subProcess);
        }
    }
}
 
Example #18
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 #19
Source File: ExtensionElementsParser.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void parse(XMLStreamReader xtr, List<SubProcess> activeSubProcessList, Process activeProcess, BpmnModel model) throws Exception {
  BaseElement parentElement = null;
  if (!activeSubProcessList.isEmpty()) {
    parentElement = activeSubProcessList.get(activeSubProcessList.size() - 1);

  } else {
    parentElement = activeProcess;
  }

  boolean readyWithChildElements = false;
  while (readyWithChildElements == false && xtr.hasNext()) {
    xtr.next();
    if (xtr.isStartElement()) {
      if (ELEMENT_EXECUTION_LISTENER.equals(xtr.getLocalName())) {
        new ExecutionListenerParser().parseChildElement(xtr, parentElement, model);
      } else if (ELEMENT_EVENT_LISTENER.equals(xtr.getLocalName())) {
        new ActivitiEventListenerParser().parseChildElement(xtr, parentElement, model);
      } else if (ELEMENT_POTENTIAL_STARTER.equals(xtr.getLocalName())) {
        new PotentialStarterParser().parse(xtr, activeProcess);
      } else {
        ExtensionElement extensionElement = BpmnXMLUtil.parseExtensionElement(xtr);
        parentElement.addExtensionElement(extensionElement);
      }

    } else if (xtr.isEndElement()) {
      if (ELEMENT_EXTENSIONS.equals(xtr.getLocalName())) {
        readyWithChildElements = true;
      }
    }
  }
}
 
Example #20
Source File: AdhocSubProcessActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void execute(DelegateExecution execution) {
  SubProcess subProcess = getSubProcessFromExecution(execution);
  execution.setScope(true);

  // initialize the template-defined data objects as variables
  Map<String, Object> dataObjectVars = processDataObjects(subProcess.getDataObjects());
  if (dataObjectVars != null) {
    execution.setVariablesLocal(dataObjectVars);
  }
}
 
Example #21
Source File: SubProcessActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void execute(DelegateExecution execution) {
  SubProcess subProcess = getSubProcessFromExecution(execution);

  FlowElement startElement = null;
  if (CollectionUtil.isNotEmpty(subProcess.getFlowElements())) {
    for (FlowElement subElement : subProcess.getFlowElements()) {
      if (subElement instanceof StartEvent) {
        StartEvent startEvent = (StartEvent) subElement;

        // start none event
        if (CollectionUtil.isEmpty(startEvent.getEventDefinitions())) {
          startElement = startEvent;
          break;
        }
      }
    }
  }

  if (startElement == null) {
    throw new ActivitiException("No initial activity found for subprocess " + subProcess.getId());
  }

  ExecutionEntity executionEntity = (ExecutionEntity) execution;
  executionEntity.setScope(true);

  // initialize the template-defined data objects as variables
  Map<String, Object> dataObjectVars = processDataObjects(subProcess.getDataObjects());
  if (dataObjectVars != null) {
    executionEntity.setVariablesLocal(dataObjectVars);
  }

  ExecutionEntity startSubProcessExecution = Context.getCommandContext().getExecutionEntityManager()
      .createChildExecution(executionEntity);
  startSubProcessExecution.setCurrentFlowElement(startElement);
  Context.getAgenda().planContinueProcessOperation(startSubProcessExecution);
}
 
Example #22
Source File: EventSubProcessMessageStartEventActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void trigger(DelegateExecution execution, String triggerName, Object triggerData) {
  CommandContext commandContext = Context.getCommandContext();
  ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager();
  ExecutionEntity executionEntity = (ExecutionEntity) execution;
  
  StartEvent startEvent = (StartEvent) execution.getCurrentFlowElement();
  if (startEvent.isInterrupting()) {  
    List<ExecutionEntity> childExecutions = executionEntityManager.findChildExecutionsByParentExecutionId(executionEntity.getParentId());
    for (ExecutionEntity childExecution : childExecutions) {
      if (childExecution.getId().equals(executionEntity.getId()) == false) {
        executionEntityManager.deleteExecutionAndRelatedData(childExecution, 
            DeleteReason.EVENT_SUBPROCESS_INTERRUPTING + "(" + startEvent.getId() + ")", false);
      }
    }
  }
  
  EventSubscriptionEntityManager eventSubscriptionEntityManager = Context.getCommandContext().getEventSubscriptionEntityManager();
  List<EventSubscriptionEntity> eventSubscriptions = executionEntity.getEventSubscriptions();
  for (EventSubscriptionEntity eventSubscription : eventSubscriptions) {
    if (eventSubscription instanceof MessageEventSubscriptionEntity && eventSubscription.getEventName().equals(messageEventDefinition.getMessageRef())) {

      eventSubscriptionEntityManager.delete(eventSubscription);
    }
  }
  
  executionEntity.setCurrentFlowElement((SubProcess) executionEntity.getCurrentFlowElement().getParentContainer());
  executionEntity.setScope(true);
  
  ExecutionEntity outgoingFlowExecution = executionEntityManager.createChildExecution(executionEntity);
  outgoingFlowExecution.setCurrentFlowElement(startEvent);
  
  leave(outgoingFlowExecution);
}
 
Example #23
Source File: SubProcessConverterTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void validateModel(BpmnModel model) {
  FlowElement flowElement = model.getMainProcess().getFlowElement("start1", true);
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof StartEvent);
  assertEquals("start1", flowElement.getId());

  flowElement = model.getMainProcess().getFlowElement("userTask1", true);
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof UserTask);
  assertEquals("userTask1", flowElement.getId());
  UserTask userTask = (UserTask) flowElement;
  assertTrue(userTask.getCandidateUsers().size() == 1);
  assertTrue(userTask.getCandidateGroups().size() == 1);
  assertTrue(userTask.getFormProperties().size() == 2);

  flowElement = model.getMainProcess().getFlowElement("subprocess1", true);
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof SubProcess);
  assertEquals("subprocess1", flowElement.getId());
  SubProcess subProcess = (SubProcess) flowElement;
  assertTrue(subProcess.getFlowElements().size() == 5);

  flowElement = model.getMainProcess().getFlowElement("boundaryEvent1", true);
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof BoundaryEvent);
  assertEquals("boundaryEvent1", flowElement.getId());
  BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
  assertNotNull(boundaryEvent.getAttachedToRef());
  assertEquals("subprocess1", boundaryEvent.getAttachedToRef().getId());
  assertEquals(1, boundaryEvent.getEventDefinitions().size());
  assertTrue(boundaryEvent.getEventDefinitions().get(0) instanceof TimerEventDefinition);
}
 
Example #24
Source File: SubProcessParseHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, SubProcess subProcess) {
  
  ActivityImpl activity = createActivityOnScope(bpmnParse, subProcess, BpmnXMLConstants.ELEMENT_SUBPROCESS, bpmnParse.getCurrentScope());
  
  activity.setAsync(subProcess.isAsynchronous());
  activity.setExclusive(!subProcess.isNotExclusive());

  boolean triggeredByEvent = false;
  if (subProcess instanceof EventSubProcess) {
    triggeredByEvent = true;
  }
  activity.setProperty("triggeredByEvent", triggeredByEvent);
  
  // event subprocesses are not scopes
  activity.setScope(!triggeredByEvent);
  activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createSubprocActivityBehavior(subProcess));
  
  bpmnParse.setCurrentScope(activity);
  bpmnParse.setCurrentSubProcess(subProcess);
  
  bpmnParse.processFlowElements(subProcess.getFlowElements());
  processArtifacts(bpmnParse, subProcess.getArtifacts(), activity);
  
  // no data objects for event subprocesses
  if (!(subProcess instanceof EventSubProcess)) {
    // parse out any data objects from the template in order to set up the necessary process variables
    Map<String, Object> variables = processDataObjects(bpmnParse, subProcess.getDataObjects(), activity);
    activity.setVariables(variables);
  }

  bpmnParse.removeCurrentScope();
  bpmnParse.removeCurrentSubProcess();
  
  if (subProcess.getIoSpecification() != null) {
    IOSpecification ioSpecification = createIOSpecification(bpmnParse, subProcess.getIoSpecification());
    activity.setIoSpecification(ioSpecification);
  }

}
 
Example #25
Source File: SubProcessWithExtensionsConverterTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void validateModel(BpmnModel model) {
  FlowElement flowElement = model.getMainProcess().getFlowElement("start1");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof StartEvent);
  assertEquals("start1", flowElement.getId());

  flowElement = model.getMainProcess().getFlowElement("subprocess1");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof SubProcess);
  assertEquals("subprocess1", flowElement.getId());
  SubProcess subProcess = (SubProcess) flowElement;
  assertTrue(subProcess.getLoopCharacteristics().isSequential());
  assertEquals("10", subProcess.getLoopCharacteristics().getLoopCardinality());
  assertEquals("${assignee == \"\"}", subProcess.getLoopCharacteristics().getCompletionCondition());
  assertTrue(subProcess.getFlowElements().size() == 5);

  /*
   * Verify Subprocess attributes extension
   */
  Map<String, String> attributes = getSubprocessAttributes(flowElement);
  assertEquals(2, attributes.size());
  for (String key : attributes.keySet()) {
    if (key.equals("Attr3")) {
      assertTrue("3".equals(attributes.get(key)));
    } else if (key.equals("Attr4")) {
      assertTrue("4".equals(attributes.get(key)));
    } else {
      fail("Unknown key value");
    }
  }

  /*
   * Verify Subprocess localization extension
   */
  localization = getLocalization(flowElement);
  assertEquals("rbkfn-2", localization.getResourceBundleKeyForName());
  assertEquals("rbkfd-2", localization.getResourceBundleKeyForDescription());
  assertEquals("leifn-2", localization.getLabeledEntityIdForName());
  assertEquals("leifd-2", localization.getLabeledEntityIdForDescription());
}
 
Example #26
Source File: EventSubProcessJsonConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void convertElementToJson(ObjectNode propertiesNode, BaseElement baseElement) {
  SubProcess subProcess = (SubProcess) baseElement;
  propertiesNode.put("activitytype", "Event-Sub-Process");
  propertiesNode.put("subprocesstype", "Embedded");
  ArrayNode subProcessShapesArrayNode = objectMapper.createArrayNode();
  GraphicInfo graphicInfo = model.getGraphicInfo(subProcess.getId());
  processor.processFlowElements(subProcess, model, subProcessShapesArrayNode, formKeyMap, 
      decisionTableKeyMap, graphicInfo.getX(), graphicInfo.getY());
  flowElementNode.set("childShapes", subProcessShapesArrayNode);
}
 
Example #27
Source File: BpmnJsonConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void fillSubShapes(Map<String, SubProcess> subShapesMap, SubProcess subProcess) {
  for (FlowElement flowElement : subProcess.getFlowElements()) {
    if (flowElement instanceof SubProcess) {
      SubProcess childSubProcess = (SubProcess) flowElement;
      subShapesMap.put(childSubProcess.getId(), subProcess);
      fillSubShapes(subShapesMap, childSubProcess);
    } else {
      subShapesMap.put(flowElement.getId(), subProcess);
    }
  }
}
 
Example #28
Source File: CompleteConverterTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void validateModel(BpmnModel model) {
  FlowElement flowElement = model.getMainProcess().getFlowElement("userTask1");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof UserTask);
  assertEquals("userTask1", flowElement.getId());

  flowElement = model.getMainProcess().getFlowElement("catchsignal");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof IntermediateCatchEvent);
  assertEquals("catchsignal", flowElement.getId());
  IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) flowElement;
  assertEquals(1, catchEvent.getEventDefinitions().size());
  assertTrue(catchEvent.getEventDefinitions().get(0) instanceof SignalEventDefinition);
  SignalEventDefinition signalEvent = (SignalEventDefinition) catchEvent.getEventDefinitions().get(0);
  assertEquals("testSignal", signalEvent.getSignalRef());

  flowElement = model.getMainProcess().getFlowElement("subprocess");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof SubProcess);
  assertEquals("subprocess", flowElement.getId());
  SubProcess subProcess = (SubProcess) flowElement;

  flowElement = subProcess.getFlowElement("receiveTask");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof ReceiveTask);
  assertEquals("receiveTask", flowElement.getId());
}
 
Example #29
Source File: ScopedConverterTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void validateModel(BpmnModel model) {
  FlowElement flowElement = model.getMainProcess().getFlowElement("outerSubProcess", true);
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof SubProcess);
  assertEquals("outerSubProcess", flowElement.getId());
  SubProcess outerSubProcess = (SubProcess) flowElement;
  List<BoundaryEvent> eventList = outerSubProcess.getBoundaryEvents();
  assertEquals(1, eventList.size());
  BoundaryEvent boundaryEvent = eventList.get(0);
  assertEquals("outerBoundaryEvent", boundaryEvent.getId());

  FlowElement subElement = outerSubProcess.getFlowElement("innerSubProcess");
  assertNotNull(subElement);
  assertTrue(subElement instanceof SubProcess);
  assertEquals("innerSubProcess", subElement.getId());
  SubProcess innerSubProcess = (SubProcess) subElement;
  eventList = innerSubProcess.getBoundaryEvents();
  assertEquals(1, eventList.size());
  boundaryEvent = eventList.get(0);
  assertEquals("innerBoundaryEvent", boundaryEvent.getId());

  FlowElement taskElement = innerSubProcess.getFlowElement("usertask");
  assertNotNull(taskElement);
  assertTrue(taskElement instanceof UserTask);
  UserTask userTask = (UserTask) taskElement;
  assertEquals("usertask", userTask.getId());
  eventList = userTask.getBoundaryEvents();
  assertEquals(1, eventList.size());
  boundaryEvent = eventList.get(0);
  assertEquals("taskBoundaryEvent", boundaryEvent.getId());
}
 
Example #30
Source File: FlowNodeInSubProcessConverterTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void validateModel(BpmnModel model) {
  FlowElement flowElement = model.getMainProcess().getFlowElement("subprocess1", true);
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof SubProcess);
  SubProcess subProcess = (SubProcess) flowElement;
  ParallelGateway gateway = (ParallelGateway) subProcess.getFlowElement("sid-A0E0B174-36DF-4C4F-A952-311CC3C031FC");
  assertNotNull(gateway);
  List<SequenceFlow> sequenceFlows = gateway.getOutgoingFlows();
  assertTrue(sequenceFlows.size() == 2);
  assertTrue(sequenceFlows.get(0).getId().equals("sid-9C669980-C274-4A48-BF7F-B9C5CA577DD2") || sequenceFlows.get(0).getId().equals("sid-A299B987-396F-46CA-8D63-85991FBFCE6E"));
  assertTrue(sequenceFlows.get(1).getId().equals("sid-9C669980-C274-4A48-BF7F-B9C5CA577DD2") || sequenceFlows.get(1).getId().equals("sid-A299B987-396F-46CA-8D63-85991FBFCE6E"));
  assertTrue(sequenceFlows.get(0).getSourceRef().equals("sid-A0E0B174-36DF-4C4F-A952-311CC3C031FC"));
  assertTrue(sequenceFlows.get(1).getSourceRef().equals("sid-A0E0B174-36DF-4C4F-A952-311CC3C031FC"));
}