Refine search
@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"); FlowElement source = process.getFlowElement(sourceRef, true); FlowElement target = process.getFlowElement(targetRef, true);
public void validateExclusiveGateway(Process process, ExclusiveGateway exclusiveGateway, List<ValidationError> errors) { if (exclusiveGateway.getOutgoingFlows().isEmpty()) { addError(errors, Problems.EXCLUSIVE_GATEWAY_NO_OUTGOING_SEQ_FLOW, process, exclusiveGateway, "Exclusive gateway has no outgoing sequence flow"); } else if (exclusiveGateway.getOutgoingFlows().size() == 1) { SequenceFlow sequenceFlow = exclusiveGateway.getOutgoingFlows().get(0); if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) { addError(errors, Problems.EXCLUSIVE_GATEWAY_CONDITION_NOT_ALLOWED_ON_SINGLE_SEQ_FLOW, process, exclusiveGateway, "Exclusive gateway has only one outgoing sequence flow. This is not allowed to have a condition."); } } else { String defaultSequenceFlow = exclusiveGateway.getDefaultFlow(); List<SequenceFlow> flowsWithoutCondition = new ArrayList<SequenceFlow>(); for (SequenceFlow flow : exclusiveGateway.getOutgoingFlows()) { String condition = flow.getConditionExpression(); boolean isDefaultFlow = flow.getId() != null && flow.getId().equals(defaultSequenceFlow); boolean hasConditon = StringUtils.isNotEmpty(condition); if (!hasConditon && !isDefaultFlow) { flowsWithoutCondition.add(flow); } if (hasConditon && isDefaultFlow) { addError(errors, Problems.EXCLUSIVE_GATEWAY_CONDITION_ON_DEFAULT_SEQ_FLOW, process, exclusiveGateway, "Default sequenceflow has a condition, which is not allowed"); } } if (!flowsWithoutCondition.isEmpty()) { addWarning(errors, Problems.EXCLUSIVE_GATEWAY_SEQ_FLOW_WITHOUT_CONDITIONS, process, exclusiveGateway, "Exclusive gateway has at least one outgoing sequence flow without a condition (which isn't the default one)"); } } }
public BpmnModel createTwoTasksTestProcess() { BpmnModel model = new BpmnModel(); org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process(); model.addProcess(process); process.setId("twoTasksProcess"); process.setName("The two tasks process"); StartEvent startEvent = new StartEvent(); startEvent.setId("start"); process.addFlowElement(startEvent); UserTask userTask = new UserTask(); userTask.setName("The First Task"); userTask.setId("task1"); userTask.setAssignee("kermit"); process.addFlowElement(userTask); UserTask userTask2 = new UserTask(); userTask2.setName("The Second Task"); userTask2.setId("task2"); userTask2.setAssignee("kermit"); process.addFlowElement(userTask2); EndEvent endEvent = new EndEvent(); endEvent.setId("theEnd"); process.addFlowElement(endEvent); process.addFlowElement(new SequenceFlow("start", "task1")); process.addFlowElement(new SequenceFlow("start", "task2")); process.addFlowElement(new SequenceFlow("task1", "theEnd")); process.addFlowElement(new SequenceFlow("task2", "theEnd")); return model; }
protected void executeParse(BpmnParse bpmnParse, SequenceFlow sequenceFlow) { org.activiti.bpmn.model.Process process = bpmnParse.getCurrentProcess(); sequenceFlow.setSourceFlowElement(process.getFlowElement(sequenceFlow.getSourceRef(), true)); sequenceFlow.setTargetFlowElement(process.getFlowElement(sequenceFlow.getTargetRef(), true)); }
@Override protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception { SequenceFlow sequenceFlow = new SequenceFlow(); BpmnXMLUtil.addXMLLocation(sequenceFlow, xtr); sequenceFlow.setSourceRef(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_SOURCE_REF)); sequenceFlow.setTargetRef(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_TARGET_REF)); sequenceFlow.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME)); sequenceFlow.setSkipExpression(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_SKIP_EXPRESSION)); parseChildElements(getXMLElementName(), sequenceFlow, model, xtr); return sequenceFlow; }
double maxX = 0.0; double maxY = 0.0; for (GraphicInfo flowInfo : model.getLocationMap().values()) { if ((flowInfo.getX() + flowInfo.getWidth()) > maxX) { maxX = flowInfo.getX() + flowInfo.getWidth(); if (model.getPools().size() > 0) { mainProcess = model.getProcess(model.getPools().get(0).getId()); } else { mainProcess = model.getMainProcess(); if (StringUtils.isNotEmpty(mainProcess.getId())) { propertiesNode.put(PROPERTY_PROCESS_ID, mainProcess.getId()); if (StringUtils.isNotEmpty(mainProcess.getName())) { propertiesNode.put(PROPERTY_NAME, mainProcess.getName()); if (StringUtils.isNotEmpty(mainProcess.getDocumentation())) { propertiesNode.put(PROPERTY_DOCUMENTATION, mainProcess.getDocumentation()); if (flowElement instanceof SequenceFlow) { SequenceFlow sequenceFlow = (SequenceFlow) flowElement; lookForElement = model.getFlowElement(sequenceFlow.getSourceRef()); } else { lookForElement = flowElement;
Map<String, String> decisionTableKeyMap) { BpmnModel bpmnModel = new BpmnModel(); bpmnModel.setTargetNamespace("http://activiti.org/test"); Map<String, JsonNode> shapeMap = new HashMap<String, JsonNode>(); Map<String, JsonNode> sourceRefMap = new HashMap<String, JsonNode>(); shapeNode, true)); bpmnModel.getPools().add(pool); Process process = new Process(); process.setId(pool.getProcessRef()); process.setName(pool.getName()); String signalScope = signalDefinitionJsonNode.get(PROPERTY_SIGNAL_DEFINITION_SCOPE).asText(); if (subShapesMap.containsKey(sequenceFlow.getSourceRef())) { SubProcess subProcess = subShapesMap.get(sequenceFlow.getSourceRef()); if (subProcess.getFlowElement(sequenceFlow.getId()) == null) { subProcess.addFlowElement(sequenceFlow); removeSubFlowsList.add(sequenceFlow.getId()); if (allFlowMap.containsKey(flowValue)) { FlowWithContainer flowWithContainer = allFlowMap.get(flowValue); flowWithContainer.getFlowContainer().removeFlowElement(flowWithContainer.getSequenceFlow().getId()); flowWithContainer.getFlowContainer().addFlowElement(flowWithContainer.getSequenceFlow());
ObjectNode flowNode = BpmnJsonConverterUtil.createChildShape(sequenceFlow.getId(), STENCIL_SEQUENCE_FLOW, 172, 212, 128, 212); ArrayNode dockersArrayNode = objectMapper.createArrayNode(); ObjectNode dockNode = objectMapper.createObjectNode(); dockNode.put(EDITOR_BOUNDS_X, model.getGraphicInfo(sequenceFlow.getSourceRef()).getWidth() / 2.0); dockNode.put(EDITOR_BOUNDS_Y, model.getGraphicInfo(sequenceFlow.getSourceRef()).getHeight() / 2.0); dockersArrayNode.add(dockNode); if (model.getFlowLocationGraphicInfo(sequenceFlow.getId()).size() > 2) { for (int i = 1; i < model.getFlowLocationGraphicInfo(sequenceFlow.getId()).size() - 1; i++) { GraphicInfo graphicInfo = model.getFlowLocationGraphicInfo(sequenceFlow.getId()).get(i); dockNode = objectMapper.createObjectNode(); dockNode.put(EDITOR_BOUNDS_X, graphicInfo.getX()); dockNode.put(EDITOR_BOUNDS_X, model.getGraphicInfo(sequenceFlow.getTargetRef()).getWidth() / 2.0); dockNode.put(EDITOR_BOUNDS_Y, model.getGraphicInfo(sequenceFlow.getTargetRef()).getHeight() / 2.0); dockersArrayNode.add(dockNode); flowNode.set("dockers", dockersArrayNode); ArrayNode outgoingArrayNode = objectMapper.createArrayNode(); outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(sequenceFlow.getTargetRef())); flowNode.set("outgoing", outgoingArrayNode); flowNode.set("target", BpmnJsonConverterUtil.createResourceNode(sequenceFlow.getTargetRef())); propertiesNode.put(PROPERTY_OVERRIDE_ID, sequenceFlow.getId()); if (StringUtils.isNotEmpty(sequenceFlow.getName())) { propertiesNode.put(PROPERTY_NAME, sequenceFlow.getName()); if (StringUtils.isNotEmpty(sequenceFlow.getDocumentation())) { propertiesNode.put(PROPERTY_DOCUMENTATION, sequenceFlow.getDocumentation());
if (StringUtils.isNotEmpty(messageEventDef.getMessageRef())) { if (bpmnModel.getMessage(messageEventDef.getMessageRef()) == null) { bpmnModel.addMessage(new Message(messageEventDef.getMessageRef(), messageEventDef.getMessageRef(), } else if (flowElement instanceof SequenceFlow) { SequenceFlow sequenceFlow = (SequenceFlow) flowElement; FlowElement sourceFlowElement = parentContainer.getFlowElement(sequenceFlow.getSourceRef()); if (sourceFlowElement != null && sourceFlowElement instanceof FlowNode) { if (sequenceFlow.getExtensionElements().get("EDITOR_RESOURCEID") != null && sequenceFlow.getExtensionElements().get("EDITOR_RESOURCEID").size() > 0) { allFlowMap.put(sequenceFlow.getExtensionElements().get("EDITOR_RESOURCEID").get(0).getElementText(), flowWithContainer); sequenceFlow.getExtensionElements().remove("EDITOR_RESOURCEID"); JsonNode edgeNode = edgeMap.get(sequenceFlow.getId()); if (edgeNode != null) { boolean isDefault = JsonConverterUtil.getPropertyValueAsBoolean(PROPERTY_SEQUENCEFLOW_DEFAULT, if (isDefault) { if (sourceFlowElement instanceof Activity) { ((Activity) sourceFlowElement).setDefaultFlow(sequenceFlow.getId()); } else if (sourceFlowElement instanceof Gateway) { ((Gateway) sourceFlowElement).setDefaultFlow(sequenceFlow.getId()); FlowElement targetFlowElement = parentContainer.getFlowElement(sequenceFlow.getTargetRef()); if (targetFlowElement != null && targetFlowElement instanceof FlowNode) { ((FlowNode) targetFlowElement).getIncomingFlows().add(sequenceFlow);
this.subProcessY = subProcessY; this.shapesArrayNode = shapesArrayNode; GraphicInfo graphicInfo = model.getGraphicInfo(baseElement.getId()); if (StringUtils.isNotEmpty(flowElement.getName())) { propertiesNode.put(PROPERTY_NAME, flowElement.getName()); if (StringUtils.isNotEmpty(flowElement.getDocumentation())) { propertiesNode.put(PROPERTY_DOCUMENTATION, flowElement.getDocumentation()); FlowNode flowNode = (FlowNode) baseElement; for (SequenceFlow sequenceFlow : flowNode.getOutgoingFlows()) { outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(sequenceFlow.getId())); for (MessageFlow messageFlow : model.getMessageFlows().values()) { if (messageFlow.getSourceRef().equals(flowNode.getId())) { outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(messageFlow.getId())); if (StringUtils.isNotEmpty(loopDef.getLoopCardinality()) || StringUtils.isNotEmpty(loopDef.getInputDataItem()) || StringUtils.isNotEmpty(loopDef.getCompletionCondition())) { if (model.getFlowElement(dataAssociation.getSourceRef()) != null) { createDataAssociation(dataAssociation, true,
@Override protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception { SequenceFlow sequenceFlow = (SequenceFlow) element; writeDefaultAttribute(ATTRIBUTE_FLOW_SOURCE_REF, sequenceFlow.getSourceRef(), xtw); writeDefaultAttribute(ATTRIBUTE_FLOW_TARGET_REF, sequenceFlow.getTargetRef(), xtw); if (StringUtils.isNotEmpty(sequenceFlow.getSkipExpression())) { writeDefaultAttribute(ATTRIBUTE_FLOW_SKIP_EXPRESSION, sequenceFlow.getSkipExpression(), xtw); } }
@Override protected void writeAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception { SequenceFlow sequenceFlow = (SequenceFlow) element; if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) { xtw.writeStartElement(ELEMENT_FLOW_CONDITION); xtw.writeAttribute(XSI_PREFIX, XSI_NAMESPACE, "type", "tFormalExpression"); xtw.writeCData(sequenceFlow.getConditionExpression()); xtw.writeEndElement(); } } }
/** * Add a sequence-flow to the current process from source to target. * Sequence-flow name is set to a user-friendly name, containing an * incrementing number. * * @param conversion * @param sourceActivityId * @param targetActivityId * @param condition */ protected SequenceFlow addSequenceFlow(WorkflowDefinitionConversion conversion, String sourceActivityId, String targetActivityId, String condition) { SequenceFlow sequenceFlow = new SequenceFlow(); sequenceFlow.setId(conversion.getUniqueNumberedId(getSequenceFlowPrefix())); sequenceFlow.setSourceRef(sourceActivityId); sequenceFlow.setTargetRef(targetActivityId); if (StringUtils.isNotEmpty(condition)) { sequenceFlow.setConditionExpression(condition); } conversion.getProcess().addFlowElement(sequenceFlow); return sequenceFlow; }
GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(flowNode.getId()); if (flowNode instanceof SubProcess) { collapsed = graphicInfo.getExpanded() != null && !graphicInfo.getExpanded(); bpmnModel.getGraphicInfo(flowNode.getId())); boolean highLighted = (highLightedFlows.contains(sequenceFlow.getId())); String defaultFlow = null; if (flowNode instanceof Activity) { if (defaultFlow != null && defaultFlow.equalsIgnoreCase(sequenceFlow.getId())) { isDefault = true; boolean drawConditionalIndicator = sequenceFlow.getConditionExpression() != null && !(flowNode instanceof Gateway); String sourceRef = sequenceFlow.getSourceRef(); String targetRef = sequenceFlow.getTargetRef(); FlowElement sourceElement = bpmnModel.getFlowElement(sourceRef); FlowElement targetElement = bpmnModel.getFlowElement(targetRef); List<GraphicInfo> graphicInfoList = bpmnModel.getFlowLocationGraphicInfo(sequenceFlow.getId()); if (graphicInfoList != null && graphicInfoList.size() > 0) { graphicInfoList = connectionPerfectionizer(processDiagramCanvas, GraphicInfo labelGraphicInfo = bpmnModel.getLabelGraphicInfo(sequenceFlow.getId()); if (labelGraphicInfo != null) { processDiagramCanvas.drawLabel(sequenceFlow.getName(), labelGraphicInfo, false);
double maxY = 0; for (Pool pool : bpmnModel.getPools()) { GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(pool.getId()); minX = graphicInfo.getX(); maxX = graphicInfo.getX() + graphicInfo.getWidth(); for (FlowNode flowNode : flowNodes) { GraphicInfo flowNodeGraphicInfo = bpmnModel.getGraphicInfo(flowNode.getId()); List<GraphicInfo> graphicInfoList = bpmnModel.getFlowLocationGraphicInfo(sequenceFlow.getId()); if (graphicInfoList != null) { for (GraphicInfo graphicInfo : graphicInfoList) { for (Process process : bpmnModel.getProcesses()) { for (Lane l : process.getLanes()) {
ActivityImpl sourceActivity = scope.findActivity(sequenceFlow.getSourceRef()); ActivityImpl destinationActivity = scope.findActivity(sequenceFlow.getTargetRef()); bpmnModel.addProblem("Invalid source '" + sequenceFlow.getSourceRef() + "' of sequence flow '" + sequenceFlow.getId() + "'", sequenceFlow); } else if (destinationActivity == null) { throw new ActivitiException("Invalid destination '" + sequenceFlow.getTargetRef() + "' of sequence flow '" + sequenceFlow.getId() + "'"); } else if (!(sourceActivity.getActivityBehavior() instanceof EventBasedGatewayActivityBehavior) && destinationActivity.getActivityBehavior() instanceof IntermediateCatchEventActivityBehavior && (destinationActivity.getParentActivity() != null) && (destinationActivity.getParentActivity().getActivityBehavior() instanceof EventBasedGatewayActivityBehavior)) { bpmnModel.addProblem("Invalid incoming sequenceflow " + sequenceFlow.getId() + " for intermediateCatchEvent with id '" + destinationActivity.getId() + "' connected to an event-based gateway.", sequenceFlow); } else { TransitionImpl transition = sourceActivity.createOutgoingTransition(sequenceFlow.getId()); bpmnParse.getSequenceFlows().put(sequenceFlow.getId(), transition); transition.setProperty("name", sequenceFlow.getName()); transition.setProperty("documentation", sequenceFlow.getDocumentation()); transition.setDestination(destinationActivity); if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) { Condition expressionCondition = new UelExpressionCondition(bpmnParse.getExpressionManager().createExpression(sequenceFlow.getConditionExpression())); transition.setProperty(PROPERTYNAME_CONDITION_TEXT, sequenceFlow.getConditionExpression()); transition.setProperty(PROPERTYNAME_CONDITION, expressionCondition); createExecutionListenersOnTransition(bpmnParse, sequenceFlow.getExecutionListeners(), transition);
/** * 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."); } } } } }
protected void processSequenceFlows() { for (SequenceFlow sequenceFlow : sequenceFlows) { Node sourceNode = nodeMap.get(sequenceFlow.getSourceRef()); Node targetNode = nodeMap.get(sequenceFlow.getTargetRef()); Relationship sequenceflowRelationship = sourceNode.createRelationshipTo(targetNode, RelTypes.SEQ_FLOW); sequenceflowRelationship.setProperty("id", sequenceFlow.getId()); if (sequenceFlow.getConditionExpression() != null) { sequenceflowRelationship.setProperty("condition", sequenceFlow.getConditionExpression()); } } }
public static List<FlowElement> findSucessorFlowElementsFor( Process process, FlowElement sourceFlowElement) { List<FlowElement> successors = new ArrayList<FlowElement>(); for (SequenceFlow sequenceFlow : process.findFlowElementsOfType(SequenceFlow.class)) { if (sequenceFlow.getSourceRef().equals(sourceFlowElement.getId())) { successors.add(process.getFlowElement(sequenceFlow.getTargetRef())); } } return successors; }