org.camunda.bpm.model.bpmn.instance.SubProcess Java Examples
The following examples show how to use
org.camunda.bpm.model.bpmn.instance.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: BpmnProcessModelCustomizer.java From wecube-platform with Apache License 2.0 | 6 votes |
protected void enhanceSequenceFlow(SequenceFlow sf) { FlowNode srcFlowNode = sf.getSource(); if (sf.getConditionExpression() == null && "exclusiveGateway".equals(srcFlowNode.getElementType().getTypeName()) && srcFlowNode.getOutgoing().size() >= 2) { String sfName = sf.getName(); if (StringUtils.isBlank(sfName)) { log.warn("the name of squence flow {} is blank.", sf.getId()); throw new BpmnCustomizationException(String.format("The name of sequence flow %s cannot be blank.", sf.getId())); } List<SubProcess> preSubProcesses = srcFlowNode.getPreviousNodes().filterByType(SubProcess.class).list(); if (preSubProcesses.size() == 1) { log.debug("to add condition,sequenceFlowId={}", sf.getId()); SubProcess preSubProcess = preSubProcesses.get(0); ConditionExpression okCon = sf.getModelInstance().newInstance(ConditionExpression.class); okCon.setType(FORMAL_EXPR_TYPE); okCon.setTextContent( String.format("${ subProcRetCode_%s == '%s' }", preSubProcess.getId(), sfName.trim())); sf.builder().condition(okCon).done(); } } }
Example #2
Source File: TransactionImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public static void registerType(ModelBuilder modelBuilder) { ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(Transaction.class, BPMN_ELEMENT_TRANSACTION) .namespaceUri(BPMN20_NS) .extendsType(SubProcess.class) .instanceProvider(new ModelTypeInstanceProvider<Transaction>() { public Transaction newInstance(ModelTypeInstanceContext instanceContext) { return new TransactionImpl(instanceContext); } }); methodAttribute = typeBuilder.namedEnumAttribute(BPMN_ATTRIBUTE_METHOD, TransactionMethod.class) .defaultValue(TransactionMethod.Compensate) .build(); typeBuilder.build(); }
Example #3
Source File: EmbeddedSubProcessBuilder.java From camunda-bpmn-model with Apache License 2.0 | 6 votes |
public EventSubProcessBuilder eventSubProcess(String id) { // Create a subprocess, triggered by an event, and add it to modelInstance SubProcess subProcess = subProcessBuilder.createChild(SubProcess.class, id); subProcess.setTriggeredByEvent(true); // Create Bpmn shape so subprocess will be drawn BpmnShape targetBpmnShape = subProcessBuilder.createBpmnShape(subProcess); //find the lowest shape in the process // place event sub process underneath setCoordinates(targetBpmnShape); subProcessBuilder.resizeSubProcess(targetBpmnShape); // Return the eventSubProcessBuilder EventSubProcessBuilder eventSubProcessBuilder = new EventSubProcessBuilder(subProcessBuilder.modelInstance, subProcess); return eventSubProcessBuilder; }
Example #4
Source File: BpmnProcessModelCustomizer.java From wecube-platform with Apache License 2.0 | 6 votes |
protected void enhanceSubProcesses(BpmnModelInstance procModelInstance) { Collection<SubProcess> subProcesses = procModelInstance.getModelElementsByType(SubProcess.class); for (SubProcess subProc : subProcesses) { log.info("subprocess {} {}", subProc.getId(), subProc.getName()); Collection<StartEvent> internalStartEvents = subProc.getChildElementsByType(StartEvent.class); if (!internalStartEvents.isEmpty()) { log.debug("subprocess {} {} already have child nodes and no need to supplement any nodes", subProc.getId(), subProc.getName()); continue; } supplementSubProcess(subProc); } }
Example #5
Source File: ProcessBuilder.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public EventSubProcessBuilder eventSubProcess(String id) { // Create a subprocess, triggered by an event, and add it to modelInstance SubProcess subProcess = createChild(SubProcess.class, id); subProcess.setTriggeredByEvent(true); // Create Bpmn shape so subprocess will be drawn BpmnShape targetBpmnShape = createBpmnShape(subProcess); //find the lowest shape in the process // place event sub process underneath setEventSubProcessCoordinates(targetBpmnShape); resizeSubProcess(targetBpmnShape); // Return the eventSubProcessBuilder EventSubProcessBuilder eventSubProcessBuilder = new EventSubProcessBuilder(modelInstance, subProcess); return eventSubProcessBuilder; }
Example #6
Source File: ProcessBuilder.java From camunda-bpmn-model with Apache License 2.0 | 6 votes |
protected void setEventSubProcessCoordinates(BpmnShape targetBpmnShape) { SubProcess eventSubProcess = (SubProcess) targetBpmnShape.getBpmnElement(); Bounds targetBounds = targetBpmnShape.getBounds(); double lowestheight = 0; // find the lowest element in the model Collection<BpmnShape> allShapes = modelInstance.getModelElementsByType(BpmnShape.class); for (BpmnShape shape : allShapes) { Bounds bounds = shape.getBounds(); double bottom = bounds.getY() + bounds.getHeight(); if(bottom > lowestheight) { lowestheight = bottom; } } Double ycoord = lowestheight + 50.0; Double xcoord = 100.0; // move target targetBounds.setY(ycoord); targetBounds.setX(xcoord); }
Example #7
Source File: ProcessBuilder.java From camunda-bpmn-model with Apache License 2.0 | 6 votes |
public EventSubProcessBuilder eventSubProcess(String id) { // Create a subprocess, triggered by an event, and add it to modelInstance SubProcess subProcess = createChild(SubProcess.class, id); subProcess.setTriggeredByEvent(true); // Create Bpmn shape so subprocess will be drawn BpmnShape targetBpmnShape = createBpmnShape(subProcess); //find the lowest shape in the process // place event sub process underneath setEventSubProcessCoordinates(targetBpmnShape); resizeSubProcess(targetBpmnShape); // Return the eventSubProcessBuilder EventSubProcessBuilder eventSubProcessBuilder = new EventSubProcessBuilder(modelInstance, subProcess); return eventSubProcessBuilder; }
Example #8
Source File: ProcessBuilder.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected void setEventSubProcessCoordinates(BpmnShape targetBpmnShape) { SubProcess eventSubProcess = (SubProcess) targetBpmnShape.getBpmnElement(); Bounds targetBounds = targetBpmnShape.getBounds(); double lowestheight = 0; // find the lowest element in the model Collection<BpmnShape> allShapes = modelInstance.getModelElementsByType(BpmnShape.class); for (BpmnShape shape : allShapes) { Bounds bounds = shape.getBounds(); double bottom = bounds.getY() + bounds.getHeight(); if(bottom > lowestheight) { lowestheight = bottom; } } Double ycoord = lowestheight + 50.0; Double xcoord = 100.0; // move target targetBounds.setY(ycoord); targetBounds.setX(xcoord); }
Example #9
Source File: TransactionImpl.java From camunda-bpmn-model with Apache License 2.0 | 6 votes |
public static void registerType(ModelBuilder modelBuilder) { ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(Transaction.class, BPMN_ELEMENT_TRANSACTION) .namespaceUri(BPMN20_NS) .extendsType(SubProcess.class) .instanceProvider(new ModelTypeInstanceProvider<Transaction>() { public Transaction newInstance(ModelTypeInstanceContext instanceContext) { return new TransactionImpl(instanceContext); } }); methodAttribute = typeBuilder.namedEnumAttribute(BPMN_ATTRIBUTE_METHOD, TransactionMethod.class) .defaultValue(TransactionMethod.Compensate) .build(); typeBuilder.build(); }
Example #10
Source File: AbstractServiceTaskHandleDelegate.java From wecube-platform with Apache License 2.0 | 6 votes |
protected List<String> tryCalAllowedOptions(DelegateExecution execution) { List<String> allowedOptions = new ArrayList<>(); FlowElement flowElement = execution.getBpmnModelElementInstance(); ModelElementInstance parentEi = flowElement.getParentElement(); if (parentEi != null) { SubProcess subProcess = execution.getBpmnModelInstance() .getModelElementById(parentEi.getAttributeValue("id")); List<ExclusiveGateway> exGws = subProcess.getSucceedingNodes().filterByType(ExclusiveGateway.class).list(); if (exGws.size() == 1) { Collection<SequenceFlow> sfs = exGws.get(0).getOutgoing(); if (!sfs.isEmpty()) { for (SequenceFlow sf : sfs) { getLogger().debug("add sequence name: {}", sf.getName()); allowedOptions.add(sf.getName()); } } } } return allowedOptions; }
Example #11
Source File: BpmnProcessModelCustomizer.java From wecube-platform with Apache License 2.0 | 6 votes |
protected String getSubProcessTimeoutExpression(SubProcess subProc) { if (bpmnParseAttachment == null) { return null; } if (bpmnParseAttachment.getSubProcessAddtionalInfos() == null || bpmnParseAttachment.getSubProcessAddtionalInfos().isEmpty()) { return null; } SubProcessAdditionalInfo subProcessAdditionalInfo = null; for (SubProcessAdditionalInfo info : bpmnParseAttachment.getSubProcessAddtionalInfos()) { if (subProc.getId().equals(info.getSubProcessNodeId())) { subProcessAdditionalInfo = info; break; } } if (subProcessAdditionalInfo == null) { return null; } return subProcessAdditionalInfo.getTimeoutExpression(); }
Example #12
Source File: EmbeddedSubProcessBuilder.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public EventSubProcessBuilder eventSubProcess(String id) { // Create a subprocess, triggered by an event, and add it to modelInstance SubProcess subProcess = subProcessBuilder.createChild(SubProcess.class, id); subProcess.setTriggeredByEvent(true); // Create Bpmn shape so subprocess will be drawn BpmnShape targetBpmnShape = subProcessBuilder.createBpmnShape(subProcess); //find the lowest shape in the process // place event sub process underneath setCoordinates(targetBpmnShape); subProcessBuilder.resizeSubProcess(targetBpmnShape); // Return the eventSubProcessBuilder EventSubProcessBuilder eventSubProcessBuilder = new EventSubProcessBuilder(subProcessBuilder.modelInstance, subProcess); return eventSubProcessBuilder; }
Example #13
Source File: AbstractBpmnModelElementBuilder.java From camunda-bpmn-model with Apache License 2.0 | 5 votes |
/** * Finishes the building of an embedded sub-process. * * @return the parent sub-process builder * @throws BpmnModelException if no parent sub-process can be found */ public SubProcessBuilder subProcessDone() { BpmnModelElementInstance lastSubProcess = element.getScope(); if (lastSubProcess != null && lastSubProcess instanceof SubProcess) { return ((SubProcess) lastSubProcess).builder(); } else { throw new BpmnModelException("Unable to find a parent subProcess."); } }
Example #14
Source File: AbstractBpmnModelElementBuilder.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * Finishes the building of an embedded sub-process. * * @return the parent sub-process builder * @throws BpmnModelException if no parent sub-process can be found */ public SubProcessBuilder subProcessDone() { BpmnModelElementInstance lastSubProcess = element.getScope(); if (lastSubProcess != null && lastSubProcess instanceof SubProcess) { return ((SubProcess) lastSubProcess).builder(); } else { throw new BpmnModelException("Unable to find a parent subProcess."); } }
Example #15
Source File: SubProcessBuilder.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public SubProcessBuilder(BpmnModelInstance modelInstance, SubProcess element) { super(modelInstance, element, SubProcessBuilder.class); }
Example #16
Source File: AbstractSubProcessBuilder.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected AbstractSubProcessBuilder(BpmnModelInstance modelInstance, SubProcess element, Class<?> selfType) { super(modelInstance, element, selfType); }
Example #17
Source File: AbstractEventSubProcessBuilder.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected AbstractEventSubProcessBuilder(BpmnModelInstance modelInstance, SubProcess element, Class<?> selfType) { super(modelInstance, element, selfType); }
Example #18
Source File: AbstractSubProcessBuilder.java From camunda-bpmn-model with Apache License 2.0 | 4 votes |
protected AbstractSubProcessBuilder(BpmnModelInstance modelInstance, SubProcess element, Class<?> selfType) { super(modelInstance, element, selfType); }
Example #19
Source File: EventSubProcessBuilder.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public EventSubProcessBuilder(BpmnModelInstance modelInstance, SubProcess element) { super(modelInstance, element, EventSubProcessBuilder.class); }
Example #20
Source File: BpmnModelElementInstanceImpl.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public boolean isScope() { return this instanceof org.camunda.bpm.model.bpmn.instance.Process || this instanceof SubProcess; }
Example #21
Source File: SubProcessBuilder.java From camunda-bpmn-model with Apache License 2.0 | 4 votes |
public SubProcessBuilder(BpmnModelInstance modelInstance, SubProcess element) { super(modelInstance, element, SubProcessBuilder.class); }
Example #22
Source File: AbstractEventSubProcessBuilder.java From camunda-bpmn-model with Apache License 2.0 | 4 votes |
protected AbstractEventSubProcessBuilder(BpmnModelInstance modelInstance, SubProcess element, Class<?> selfType) { super(modelInstance, element, selfType); }
Example #23
Source File: EventSubProcessBuilder.java From camunda-bpmn-model with Apache License 2.0 | 4 votes |
public EventSubProcessBuilder(BpmnModelInstance modelInstance, SubProcess element) { super(modelInstance, element, EventSubProcessBuilder.class); }
Example #24
Source File: BpmnModelElementInstanceImpl.java From camunda-bpmn-model with Apache License 2.0 | 4 votes |
public boolean isScope() { return this instanceof org.camunda.bpm.model.bpmn.instance.Process || this instanceof SubProcess; }
Example #25
Source File: BpmnProcessModelCustomizer.java From wecube-platform with Apache License 2.0 | 4 votes |
protected void supplementSubProcess(SubProcess subProc) { String subProcId = subProc.getId(); String userTaskId = "exceptSubUT-" + subProcId; String srvBeanServiceTaskId = String.format("srvBeanST-%s", subProcId); String actRetryExpr = String.format("${ act_%s == 'retry' }", subProcId); String actSkipExpr = String.format("${ act_%s == 'skip' }", subProcId); String catchEventId = subProcId + "_ice1"; String signalId = subProcId + "_sig1"; String retCodeOkExpr = String.format("${retCode_%s != '1'}", catchEventId); String retCodeNotOkExpr = String.format("${retCode_%s == '1'}", catchEventId); StartEventBuilder b = subProc.builder().embeddedSubProcess().startEvent(subProcId + "_startEvent1") .name("St1_" + subProcId); EndEventBuilder eb = b.serviceTask(srvBeanServiceTaskId).name("T1_" + subProcId) // .eventBasedGateway().name("EGW1_" + subProcId) // .intermediateCatchEvent(catchEventId).name("ICE1_" + subProcId) // .signal(signalId) // .exclusiveGateway().gatewayDirection(GatewayDirection.Diverging) // .condition("con1", retCodeOkExpr) // .endEvent(subProcId + "_endEvent1").name("End1_" + subProcId) // .moveToLastGateway() // .condition("con2", retCodeNotOkExpr) // .serviceTask("srvFailBeanST-" + subProcId) // .name("SRV-FAIL-HANDLER_" + subProcId).camundaDelegateExpression("${srvFailBean}") // .userTask(userTaskId).name("EXCEPTION-HANDLER_" + subProcId) // .condition("con4", actRetryExpr) // .connectTo(srvBeanServiceTaskId) // .moveToActivity(userTaskId) // .condition("con3", actSkipExpr) // .endEvent().name("End2_" + subProcId); String subProcessTimeoutExpr = getSubProcessTimeoutExpression(subProc); if (StringUtils.isNotBlank(subProcessTimeoutExpr)) { AbstractFlowNodeBuilder<?, ?> ab = eb.moveToLastGateway().moveToLastGateway() .intermediateCatchEvent(subProcId + "_time1").timerWithDuration(subProcessTimeoutExpr) .serviceTask("srvTimeOutBeanST-" + subProcId).name("SRV-TIMEOUT-HANDLER_" + subProcId) .camundaDelegateExpression("${srvTimeoutBean}").connectTo(userTaskId); ab.done(); } else { eb.done(); } }
Example #26
Source File: EmbeddedSubProcessBuilder.java From camunda-bpmn-model with Apache License 2.0 | 3 votes |
protected void setCoordinates(BpmnShape targetBpmnShape) { SubProcess eventSubProcess = (SubProcess) targetBpmnShape.getBpmnElement(); SubProcess parentSubProcess = (SubProcess) eventSubProcess.getParentElement(); BpmnShape parentBpmnShape = subProcessBuilder.findBpmnShape(parentSubProcess); Bounds targetBounds = targetBpmnShape.getBounds(); Bounds parentBounds = parentBpmnShape.getBounds(); // these should just be offsets maybe Double ycoord = parentBounds.getHeight() + parentBounds.getY(); Double xcoord = (parentBounds.getWidth()/2) - (targetBounds.getWidth()/2) + parentBounds.getX(); if(xcoord-parentBounds.getX() < 50.0) { xcoord = 50.0+parentBounds.getX(); } // move target targetBounds.setY(ycoord); targetBounds.setX(xcoord); // parent expands automatically // nodes surrounding the parent subprocess will not be moved // they may end up inside the subprocess (but only graphically) }
Example #27
Source File: EmbeddedSubProcessBuilder.java From camunda-bpm-platform with Apache License 2.0 | 3 votes |
protected void setCoordinates(BpmnShape targetBpmnShape) { SubProcess eventSubProcess = (SubProcess) targetBpmnShape.getBpmnElement(); SubProcess parentSubProcess = (SubProcess) eventSubProcess.getParentElement(); BpmnShape parentBpmnShape = subProcessBuilder.findBpmnShape(parentSubProcess); Bounds targetBounds = targetBpmnShape.getBounds(); Bounds parentBounds = parentBpmnShape.getBounds(); // these should just be offsets maybe Double ycoord = parentBounds.getHeight() + parentBounds.getY(); Double xcoord = (parentBounds.getWidth()/2) - (targetBounds.getWidth()/2) + parentBounds.getX(); if(xcoord-parentBounds.getX() < 50.0) { xcoord = 50.0+parentBounds.getX(); } // move target targetBounds.setY(ycoord); targetBounds.setX(xcoord); // parent expands automatically // nodes surrounding the parent subprocess will not be moved // they may end up inside the subprocess (but only graphically) }