/** * 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); } } }
@SuppressWarnings("unchecked") public <FlowElementType extends FlowElement> List<FlowElementType> findFlowElementsOfType(Class<FlowElementType> type, boolean goIntoSubprocesses) { List<FlowElementType> foundFlowElements = new ArrayList<>(); for (FlowElement flowElement : this.getFlowElements()) { if (type.isInstance(flowElement)) { foundFlowElements.add((FlowElementType) flowElement); } if (flowElement instanceof SubProcess) { if (goIntoSubprocesses) { foundFlowElements.addAll(findFlowElementsInSubProcessOfType((SubProcess) flowElement, type)); } } } return foundFlowElements; }
@SuppressWarnings("unchecked") public <FlowElementType extends FlowElement> List<FlowElementType> findFlowElementsOfType(Class<FlowElementType> type, boolean goIntoSubprocesses) { List<FlowElementType> foundFlowElements = new ArrayList<>(); for (FlowElement flowElement : this.getFlowElements()) { if (type.isInstance(flowElement)) { foundFlowElements.add((FlowElementType) flowElement); } if (flowElement instanceof SubProcess) { if (goIntoSubprocesses) { foundFlowElements.addAll(findFlowElementsInSubProcessOfType((SubProcess) flowElement, type)); } } } return foundFlowElements; }
public ObjectNode getSummary() { ObjectNode summary = objectMapper.createObjectNode(); for (Process process : bpmnModel.getProcesses()) { for (FlowElement flowElement : process.getFlowElements()) { summary.set(flowElement.getId(), getElement(flowElement.getId())); } } return summary; }
protected void addMessageEventSubscriptions(ProcessDefinitionEntity processDefinition, Process process, BpmnModel bpmnModel) { if (CollectionUtil.isNotEmpty(process.getFlowElements())) { for (FlowElement element : process.getFlowElements()) { if (element instanceof StartEvent) { StartEvent startEvent = (StartEvent) element; if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions())) { EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0); if (eventDefinition instanceof MessageEventDefinition) { MessageEventDefinition messageEventDefinition = (MessageEventDefinition) eventDefinition; insertMessageEvent(messageEventDefinition, startEvent, processDefinition, bpmnModel); } } } } } }
protected List<String> gatherCompletedFlows(Set<String> completedActivityInstances, Set<String> currentActivityinstances, BpmnModel pojoModel) { List<String> completedFlows = new ArrayList<>(); List<String> activities = new ArrayList<>(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; } }
protected List<String> gatherCompletedFlows(List<String> completedActivityInstances, List<String> currentActivityinstances, BpmnModel pojoModel) { List<String> completedFlows = new ArrayList<>(); List<String> activities = new ArrayList<>(completedActivityInstances); if (currentActivityinstances != null) { 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; }
@Override protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) { for (FlowElement flowElement : process.getFlowElements()) { if (flowElement instanceof Activity) { Activity activity = (Activity) flowElement; handleConstraints(process, activity, errors); handleMultiInstanceLoopCharacteristics(process, activity, errors); handleDataAssociations(process, activity, errors); } } }
@Override protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) { validateListeners(process, process, process.getExecutionListeners(), errors); for (FlowElement flowElement : process.getFlowElements()) { validateListeners(process, flowElement, flowElement.getExecutionListeners(), errors); } }
if (process.getFlowElements().isEmpty() && process.getLanes().isEmpty()) { for (FlowElement flowElement : process.getFlowElements()) { createXML(flowElement, model, xtw);
public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { String resourceId = xtr.getAttributeValue(null, ATTRIBUTE_ID); String resourceName = xtr.getAttributeValue(null, ATTRIBUTE_NAME); Resource resource; if (model.containsResourceId(resourceId)) { resource = model.getResource(resourceId); resource.setName(resourceName); for (org.flowable.bpmn.model.Process process : model.getProcesses()) { for (FlowElement fe : process.getFlowElements()) { if (fe instanceof UserTask && ((UserTask) fe).getCandidateGroups().contains(resourceId)) { ((UserTask) fe).getCandidateGroups().remove(resourceId); ((UserTask) fe).getCandidateGroups().add(resourceName); } } } } else { resource = new Resource(resourceId, resourceName); model.addResource(resource); } BpmnXMLUtil.addXMLLocation(resource, xtr); } }
protected List<TimerJobEntity> getTimerDeclarations(ProcessDefinitionEntity processDefinition, Process process) { List<TimerJobEntity> timers = new ArrayList<>(); if (CollectionUtil.isNotEmpty(process.getFlowElements())) { for (FlowElement element : process.getFlowElements()) { if (element instanceof StartEvent) { StartEvent startEvent = (StartEvent) element;
processElements(process.getFlowElements(), pojoModel, elementArray, flowArray, collapsedArray, diagramInfo, completedElements, currentElements, null);
boolean isFlowElementLocalizationChanged = localizeFlowElements(process.getFlowElements(), infoNode); boolean isDataObjectLocalizationChanged = localizeDataObjectElements(process.getDataObjects(), infoNode); if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) {
boolean isFlowElementLocalizationChanged = localizeFlowElements(process.getFlowElements(), infoNode); boolean isDataObjectLocalizationChanged = localizeDataObjectElements(process.getDataObjects(), infoNode); if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) {
protected void addSignalEventSubscriptions(CommandContext commandContext, ProcessDefinitionEntity processDefinition, org.flowable.bpmn.model.Process process, BpmnModel bpmnModel) { if (CollectionUtil.isNotEmpty(process.getFlowElements())) { for (FlowElement element : process.getFlowElements()) { if (element instanceof StartEvent) { StartEvent startEvent = (StartEvent) element; if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions())) { EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0); if (eventDefinition instanceof SignalEventDefinition) { SignalEventDefinition signalEventDefinition = (SignalEventDefinition) eventDefinition; SignalEventSubscriptionEntity subscriptionEntity = CommandContextUtil.getEventSubscriptionEntityManager(commandContext).createSignalEventSubscription(); Signal signal = bpmnModel.getSignal(signalEventDefinition.getSignalRef()); if (signal != null) { subscriptionEntity.setEventName(signal.getName()); } else { subscriptionEntity.setEventName(signalEventDefinition.getSignalRef()); } subscriptionEntity.setActivityId(startEvent.getId()); subscriptionEntity.setProcessDefinitionId(processDefinition.getId()); if (processDefinition.getTenantId() != null) { subscriptionEntity.setTenantId(processDefinition.getTenantId()); } CommandContextUtil.getEventSubscriptionEntityManager(commandContext).insert(subscriptionEntity); } } } } } }
protected void restorePreviousStartEventsIfNeeded(ProcessDefinition processDefinition) { ProcessDefinitionEntity latestProcessDefinition = findLatestProcessDefinition(processDefinition); if (latestProcessDefinition != null && processDefinition.getId().equals(latestProcessDefinition.getId())) { // Try to find a previous version (it could be some versions are missing due to deletions) ProcessDefinition previousProcessDefinition = findNewLatestProcessDefinitionAfterRemovalOf(processDefinition); if (previousProcessDefinition != null) { BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(previousProcessDefinition.getId()); org.flowable.bpmn.model.Process previousProcess = ProcessDefinitionUtil.getProcess(previousProcessDefinition.getId()); if (CollectionUtil.isNotEmpty(previousProcess.getFlowElements())) { List<StartEvent> startEvents = previousProcess.findFlowElementsOfType(StartEvent.class); if (CollectionUtil.isNotEmpty(startEvents)) { for (StartEvent startEvent : startEvents) { if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions())) { EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0); if (eventDefinition instanceof TimerEventDefinition) { restoreTimerStartEvent(previousProcessDefinition, startEvent, eventDefinition); } else if (eventDefinition instanceof SignalEventDefinition) { restoreSignalStartEvent(previousProcessDefinition, bpmnModel, startEvent, eventDefinition); } else if (eventDefinition instanceof MessageEventDefinition) { restoreMessageStartEvent(previousProcessDefinition, bpmnModel, startEvent, eventDefinition); } } } } } } } }
for (FlowElement flowElement : process.getFlowElements()) { if (flowElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) flowElement;
protected ProcessDefinitionEntity transformProcess(BpmnParse bpmnParse, Process process) { ProcessDefinitionEntity currentProcessDefinition = CommandContextUtil.getProcessDefinitionEntityManager().create(); bpmnParse.setCurrentProcessDefinition(currentProcessDefinition); /* * Mapping object model - bpmn xml: processDefinition.id -> generated by activiti engine processDefinition.key -> bpmn id (required) processDefinition.name -> bpmn name (optional) */ currentProcessDefinition.setKey(process.getId()); currentProcessDefinition.setName(process.getName()); currentProcessDefinition.setCategory(bpmnParse.getBpmnModel().getTargetNamespace()); currentProcessDefinition.setDescription(process.getDocumentation()); currentProcessDefinition.setDeploymentId(bpmnParse.getDeployment().getId()); if (bpmnParse.getDeployment().getEngineVersion() != null) { currentProcessDefinition.setEngineVersion(bpmnParse.getDeployment().getEngineVersion()); } createEventListeners(bpmnParse, process.getEventListeners()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Parsing process {}", currentProcessDefinition.getKey()); } bpmnParse.processFlowElements(process.getFlowElements()); processArtifacts(bpmnParse, process.getArtifacts()); return currentProcessDefinition; }
bpmnParse.processFlowElements(process.getFlowElements()); processArtifacts(bpmnParse, process.getArtifacts(), currentProcessDefinition);