Search in sources :

Example 1 with BaseElement

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

the class Bpmn2JsonMarshaller method findOutgoingAssociation.

protected Association findOutgoingAssociation(BPMNPlane plane, BaseElement baseElement) {
    Association result = _diagramAssociations.get(baseElement.getId());
    if (result != null) {
        return result;
    }
    if (!(plane.getBpmnElement() instanceof Process)) {
        throw new IllegalArgumentException("Don't know how to get associations from a non-Process Diagram");
    }
    Process process = (Process) plane.getBpmnElement();
    for (Artifact artifact : process.getArtifacts()) {
        if (artifact instanceof Association) {
            Association association = (Association) artifact;
            if (association.getSourceRef() == baseElement) {
                _diagramAssociations.put(baseElement.getId(), association);
                return association;
            }
        }
    }
    return null;
}
Also used : Association(org.eclipse.bpmn2.Association) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) Process(org.eclipse.bpmn2.Process) SubProcess(org.eclipse.bpmn2.SubProcess) Artifact(org.eclipse.bpmn2.Artifact)

Example 2 with BaseElement

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

the class Bpmn2JsonMarshaller method findOutgoingAssociations.

protected List<Association> findOutgoingAssociations(BPMNPlane plane, BaseElement baseElement) {
    List<Association> retList = new ArrayList<Association>();
    if (!(plane.getBpmnElement() instanceof Process)) {
        throw new IllegalArgumentException("Don't know how to get associations from a non-Process Diagram");
    }
    Process process = (Process) plane.getBpmnElement();
    for (Artifact artifact : process.getArtifacts()) {
        if (artifact instanceof Association) {
            Association association = (Association) artifact;
            if (association.getSourceRef() == baseElement) {
                retList.add(association);
            }
        }
    }
    return retList;
}
Also used : Association(org.eclipse.bpmn2.Association) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) ArrayList(java.util.ArrayList) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) Process(org.eclipse.bpmn2.Process) SubProcess(org.eclipse.bpmn2.SubProcess) Artifact(org.eclipse.bpmn2.Artifact)

Example 3 with BaseElement

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

the class Bpmn2JsonUnmarshaller method applyOnEntryActions.

protected void applyOnEntryActions(BaseElement element, Map<String, String> properties) {
    if (properties.get("onentryactions") != null && properties.get("onentryactions").length() > 0) {
        ScriptTypeListValue onEntryActions = new ScriptTypeListTypeSerializer().parse(properties.get("onentryactions"));
        if (!onEntryActions.isEmpty()) {
            ScriptTypeValue onEntryAction = onEntryActions.getValues().get(0);
            if (onEntryAction.getScript() != null && !onEntryAction.getScript().isEmpty()) {
                OnEntryScriptType onEntryScript = DroolsFactory.eINSTANCE.createOnEntryScriptType();
                onEntryScript.setScript(wrapInCDATABlock(onEntryAction.getScript()));
                String scriptLanguage = Utils.getScriptLanguageFormat(onEntryAction.getLanguage());
                if (scriptLanguage == null) {
                    // default to java
                    scriptLanguage = "http://www.java.com/java";
                }
                onEntryScript.setScriptFormat(scriptLanguage);
                if (element.getExtensionValues() == null || element.getExtensionValues().size() < 1) {
                    ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
                    element.getExtensionValues().add(extensionElement);
                }
                FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((Internal) DroolsPackage.Literals.DOCUMENT_ROOT__ON_ENTRY_SCRIPT, onEntryScript);
                element.getExtensionValues().get(0).getValue().add(extensionElementEntry);
            }
        }
    }
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) OnEntryScriptType(org.jboss.drools.OnEntryScriptType) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue) ScriptTypeListTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ScriptTypeListTypeSerializer) ScriptTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeListValue) ScriptTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue)

Example 4 with BaseElement

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

the class Bpmn2JsonUnmarshaller method updateEdgeBoundsInLanes.

public void updateEdgeBoundsInLanes(Definitions def, BPMNPlane plane, BPMNEdge edge, BaseElement ele) {
    if (ele instanceof SequenceFlow) {
        SequenceFlow sq = (SequenceFlow) ele;
        // update the source and target on BPMNEdge
        if (sq.getSourceRef() != null) {
            edge.setSourceElement(getBPMNShapeForElement(sq.getSourceRef(), plane));
        }
        if (sq.getTargetRef() != null) {
            edge.setTargetElement(getBPMNShapeForElement(sq.getTargetRef(), plane));
        }
        List<RootElement> rootElements = def.getRootElements();
        for (RootElement root : rootElements) {
            if (root instanceof Process) {
                Process process = (Process) root;
                if (sq.getSourceRef() != null && sq.getTargetRef() != null) {
                    if (process.getLaneSets() != null && process.getLaneSets().size() > 0) {
                        for (LaneSet ls : process.getLaneSets()) {
                            for (Lane newLane : ls.getLanes()) {
                                List<FlowNode> laneFlowNodes = newLane.getFlowNodeRefs();
                                Bounds laneBounds = getBoundsForElement(newLane, plane);
                                for (FlowNode newFlowNode : laneFlowNodes) {
                                    if (newFlowNode.getId().equals(sq.getSourceRef().getId())) {
                                        List<DiagramElement> diagramElements = plane.getPlaneElement();
                                        for (DiagramElement dia : diagramElements) {
                                            if (dia instanceof BPMNShape) {
                                                BPMNShape shape = (BPMNShape) dia;
                                                if (shape.getBpmnElement().getId().equals(sq.getSourceRef().getId())) {
                                                    Bounds eleBounds = shape.getBounds();
                                                    List<Point> edgePoints = edge.getWaypoint();
                                                    if (edgePoints != null && edgePoints.size() > 1) {
                                                        if (eleBounds != null) {
                                                            Point first = edgePoints.get(0);
                                                            first.setX(first.getX() + laneBounds.getX());
                                                            first.setY(first.getY() + laneBounds.getY());
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    } else if (newFlowNode.getId().equals(sq.getTargetRef().getId())) {
                                        List<DiagramElement> diagramElements = plane.getPlaneElement();
                                        for (DiagramElement dia : diagramElements) {
                                            if (dia instanceof BPMNShape) {
                                                BPMNShape shape = (BPMNShape) dia;
                                                if (shape.getBpmnElement().getId().equals(sq.getTargetRef().getId())) {
                                                    Bounds eleBounds = shape.getBounds();
                                                    List<Point> edgePoints = edge.getWaypoint();
                                                    if (edgePoints != null && edgePoints.size() > 1) {
                                                        if (eleBounds != null) {
                                                            Point last = edgePoints.get(edgePoints.size() - 1);
                                                            last.setX(last.getX() + laneBounds.getX());
                                                            last.setY(last.getY() + laneBounds.getY());
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : SequenceFlow(org.eclipse.bpmn2.SequenceFlow) Bounds(org.eclipse.dd.dc.Bounds) Lane(org.eclipse.bpmn2.Lane) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) LaneSet(org.eclipse.bpmn2.LaneSet) Point(org.eclipse.dd.dc.Point) BPMNShape(org.eclipse.bpmn2.di.BPMNShape) DiagramElement(org.eclipse.dd.di.DiagramElement) RootElement(org.eclipse.bpmn2.RootElement) ArrayList(java.util.ArrayList) List(java.util.List) FlowNode(org.eclipse.bpmn2.FlowNode)

Example 5 with BaseElement

use of org.eclipse.bpmn2.BaseElement 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)9 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)8 Bounds (org.eclipse.dd.dc.Bounds)7 Lane (org.eclipse.bpmn2.Lane)6 Process (org.eclipse.bpmn2.Process)5 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)5 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)5 ArrayList (java.util.ArrayList)4 ExtensionAttributeValue (org.eclipse.bpmn2.ExtensionAttributeValue)4 FlowElement (org.eclipse.bpmn2.FlowElement)4 Artifact (org.eclipse.bpmn2.Artifact)3 FlowNode (org.eclipse.bpmn2.FlowNode)3 RootElement (org.eclipse.bpmn2.RootElement)3 List (java.util.List)2 Association (org.eclipse.bpmn2.Association)2 BaseElement (org.eclipse.bpmn2.BaseElement)2 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)2 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)2 Definitions (org.eclipse.bpmn2.Definitions)2 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)2