Search in sources :

Example 1 with SubProcess

use of org.eclipse.bpmn2.SubProcess in project kie-wb-common by kiegroup.

the class Bpmn2JsonMarshaller method setAdHocSubProcessProperties.

private void setAdHocSubProcessProperties(final AdHocSubProcess subProcess, final Map<String, Object> properties) {
    if (subProcess.getOrdering().equals(AdHocOrdering.PARALLEL)) {
        properties.put(ADHOCORDERING, "Parallel");
    } else if (subProcess.getOrdering().equals(AdHocOrdering.SEQUENTIAL)) {
        properties.put(ADHOCORDERING, "Sequential");
    } else {
        // default to parallel
        properties.put(ADHOCORDERING, "Parallel");
    }
    if (subProcess.getCompletionCondition() != null) {
        final FormalExpression expression = (FormalExpression) subProcess.getCompletionCondition();
        final String language = Utils.getScriptLanguage(expression.getLanguage());
        final String script = expression.getBody().replaceAll("\n", "\\\\n");
        final ScriptTypeValue value = new ScriptTypeValue(language, script);
        properties.put(ADHOCCOMPLETIONCONDITION, new ScriptTypeTypeSerializer().serialize(value));
    }
}
Also used : ScriptTypeTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ScriptTypeTypeSerializer) FormalExpression(org.eclipse.bpmn2.FormalExpression) ScriptTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue)

Example 2 with SubProcess

use of org.eclipse.bpmn2.SubProcess in project kie-wb-common by kiegroup.

the class SubProcessConverter method convertEventSubprocessNode.

private SubProcessPropertyWriter convertEventSubprocessNode(Node<View<EventSubprocess>, ?> n) {
    SubProcess process = bpmn2.createSubProcess();
    process.setId(n.getUUID());
    SubProcessPropertyWriter p = propertyWriterFactory.of(process);
    EventSubprocess definition = n.getContent().getDefinition();
    process.setTriggeredByEvent(true);
    BPMNGeneralSet general = definition.getGeneral();
    p.setName(general.getName().getValue());
    p.setDocumentation(general.getDocumentation().getValue());
    ProcessData processData = definition.getProcessData();
    p.setProcessVariables(processData.getProcessVariables());
    p.setSimulationSet(definition.getSimulationSet());
    p.setBounds(n.getContent().getBounds());
    return p;
}
Also used : SubProcess(org.eclipse.bpmn2.SubProcess) EventSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) SubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter) AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter) ProcessData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessData)

Example 3 with SubProcess

use of org.eclipse.bpmn2.SubProcess in project kie-wb-common by kiegroup.

the class Bpmn2JsonMarshaller method linkSequenceFlows.

private void linkSequenceFlows(List<FlowElement> flowElements) {
    Map<String, FlowNode> nodes = new HashMap<String, FlowNode>();
    for (FlowElement flowElement : flowElements) {
        if (flowElement instanceof FlowNode) {
            nodes.put(flowElement.getId(), (FlowNode) flowElement);
            if (flowElement instanceof SubProcess) {
                linkSequenceFlows(((SubProcess) flowElement).getFlowElements());
            }
        }
    }
    for (FlowElement flowElement : flowElements) {
        if (flowElement instanceof SequenceFlow) {
            SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
            if (sequenceFlow.getSourceRef() == null && sequenceFlow.getTargetRef() == null) {
                String id = sequenceFlow.getId();
                try {
                    String[] subids = id.split("-_");
                    String id1 = subids[0];
                    String id2 = "_" + subids[1];
                    FlowNode source = nodes.get(id1);
                    if (source != null) {
                        sequenceFlow.setSourceRef(source);
                    }
                    FlowNode target = nodes.get(id2);
                    if (target != null) {
                        sequenceFlow.setTargetRef(target);
                    }
                } catch (Throwable t) {
                // Do nothing
                }
            }
        }
    }
}
Also used : AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) FlowElement(org.eclipse.bpmn2.FlowElement) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) FlowNode(org.eclipse.bpmn2.FlowNode)

Example 4 with SubProcess

use of org.eclipse.bpmn2.SubProcess in project kie-wb-common by kiegroup.

the class Bpmn2JsonMarshaller method marshallItemAwareElements.

private void marshallItemAwareElements(Activity activity, List<? extends ItemAwareElement> elements, StringBuilder buffer, List<String> disallowedNames) {
    for (ItemAwareElement element : elements) {
        String name = null;
        if (element instanceof DataInput) {
            name = ((DataInput) element).getName();
        }
        if (element instanceof DataOutput) {
            name = ((DataOutput) element).getName();
        }
        if (name != null && !name.isEmpty() && !disallowedNames.contains(name)) {
            buffer.append(name);
            if (element.getItemSubjectRef() != null && element.getItemSubjectRef().getStructureRef() != null && !element.getItemSubjectRef().getStructureRef().isEmpty()) {
                buffer.append(":").append(element.getItemSubjectRef().getStructureRef());
            } else if (activity.eContainer() instanceof SubProcess) {
                // BZ1247105: for Outputs on Tasks inside sub-processes
                String dtype = getAnyAttributeValue(element, "dtype");
                if (dtype != null && !dtype.isEmpty()) {
                    buffer.append(":").append(dtype);
                }
            }
            buffer.append(",");
        }
    }
}
Also used : DataInput(org.eclipse.bpmn2.DataInput) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) DataOutput(org.eclipse.bpmn2.DataOutput) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement)

Example 5 with SubProcess

use of org.eclipse.bpmn2.SubProcess in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method updateShapeBoundsInSubprocess.

public void updateShapeBoundsInSubprocess(BPMNPlane plane, BaseElement ele, SubProcess sub, float parentX, float parentY) {
    boolean foundInSubprocess = false;
    for (FlowElement subEle : sub.getFlowElements()) {
        if (subEle.getId().equals(ele.getId())) {
            foundInSubprocess = true;
            Bounds subEleBounds = getBoundsForElement(subEle, plane);
            if (subEleBounds != null) {
                subEleBounds.setX(subEleBounds.getX() + parentX);
                subEleBounds.setY(subEleBounds.getY() + parentY);
            }
        }
    }
    if (!foundInSubprocess) {
        for (FlowElement subEle : sub.getFlowElements()) {
            if (subEle instanceof SubProcess) {
                Bounds subEleBounds = getBoundsForElement(subEle, plane);
                updateShapeBoundsInSubprocess(plane, ele, (SubProcess) subEle, subEleBounds.getX(), subEleBounds.getY());
            }
        }
    }
}
Also used : AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) FlowElement(org.eclipse.bpmn2.FlowElement) Bounds(org.eclipse.dd.dc.Bounds)

Aggregations

SubProcess (org.eclipse.bpmn2.SubProcess)13 FlowElement (org.eclipse.bpmn2.FlowElement)12 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)10 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)7 RootElement (org.eclipse.bpmn2.RootElement)7 Bounds (org.eclipse.dd.dc.Bounds)6 ArrayList (java.util.ArrayList)5 FlowNode (org.eclipse.bpmn2.FlowNode)5 Lane (org.eclipse.bpmn2.Lane)5 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)5 Artifact (org.eclipse.bpmn2.Artifact)4 BoundaryEvent (org.eclipse.bpmn2.BoundaryEvent)4 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)4 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)4 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)4 DataInput (org.eclipse.bpmn2.DataInput)3 DataObject (org.eclipse.bpmn2.DataObject)3 DataOutput (org.eclipse.bpmn2.DataOutput)3 FormalExpression (org.eclipse.bpmn2.FormalExpression)3 Process (org.eclipse.bpmn2.Process)3