Search in sources :

Example 6 with RootElement

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

the class Bpmn2JsonUnmarshaller method revisitSignalRef.

/**
 * Updates the signal ref on catch and throw event definitions (including boundary)
 * @param def Definitions
 */
public void revisitSignalRef(Definitions def) {
    revisitSignalIds(def);
    List<RootElement> rootElements = def.getRootElements();
    for (RootElement root : rootElements) {
        if (root instanceof Process) {
            setSignalRefForCatchEvents((Process) root, def);
            setSignalRefForThrowEvents((Process) root, def);
            setSignalRefForBoundaryEvents((Process) root, def);
        }
    }
}
Also used : RootElement(org.eclipse.bpmn2.RootElement) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process)

Example 7 with RootElement

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

the class Bpmn2JsonUnmarshaller method updateIDs.

public void updateIDs(Definitions def) {
    // data object id update
    List<RootElement> rootElements = def.getRootElements();
    for (RootElement root : rootElements) {
        if (root instanceof Process) {
            Process process = (Process) root;
            if (process.getId() != null) {
                String processId = process.getId().trim();
                processId = processId.replaceAll("\\s", "");
                process.setId(processId);
            }
            List<FlowElement> flowElements = process.getFlowElements();
            for (FlowElement fe : flowElements) {
                if (fe instanceof DataObject) {
                    DataObject da = (DataObject) fe;
                    if (da.getName() != null) {
                        String daId = da.getName().trim();
                        daId = daId.replaceAll("\\W", "");
                        da.setId(daId);
                    }
                }
            }
        }
    }
}
Also used : RootElement(org.eclipse.bpmn2.RootElement) DataObject(org.eclipse.bpmn2.DataObject) FlowElement(org.eclipse.bpmn2.FlowElement) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process)

Example 8 with RootElement

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

the class Bpmn2JsonUnmarshaller method revisitMessages.

/**
 * Revisit message to set their item ref to a item definition
 * @param def Definitions
 */
private void revisitMessages(Definitions def) {
    List<RootElement> rootElements = def.getRootElements();
    List<ItemDefinition> toAddDefinitions = new ArrayList<ItemDefinition>();
    for (RootElement root : rootElements) {
        if (root instanceof Message) {
            if (!existsMessageItemDefinition(rootElements, root.getId())) {
                ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition();
                itemdef.setId(root.getId() + "Type");
                toAddDefinitions.add(itemdef);
                ((Message) root).setItemRef(itemdef);
            }
        }
    }
    for (ItemDefinition id : toAddDefinitions) {
        def.getRootElements().add(id);
    }
}
Also used : RootElement(org.eclipse.bpmn2.RootElement) Message(org.eclipse.bpmn2.Message) ItemDefinition(org.eclipse.bpmn2.ItemDefinition) ArrayList(java.util.ArrayList)

Example 9 with RootElement

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

the class Bpmn2JsonUnmarshaller method revisitItemDefinitions.

public void revisitItemDefinitions(Definitions def) {
    List<String> itemIds = new ArrayList<String>();
    for (RootElement root : def.getRootElements()) {
        if (root instanceof ItemDefinition) {
            if (!itemIds.contains(root.getId())) {
                itemIds.add(root.getId());
            } else {
                ItemDefinition idef = (ItemDefinition) root;
                Random rand = new Random();
                int randomNum = rand.nextInt((1000 - 10) + 1) + 10;
                idef.setId(idef.getId() + randomNum);
            }
        }
    }
}
Also used : RootElement(org.eclipse.bpmn2.RootElement) Random(java.util.Random) ArrayList(java.util.ArrayList) ItemDefinition(org.eclipse.bpmn2.ItemDefinition) Point(org.eclipse.dd.dc.Point)

Example 10 with RootElement

use of org.eclipse.bpmn2.RootElement 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)

Aggregations

RootElement (org.eclipse.bpmn2.RootElement)34 Process (org.eclipse.bpmn2.Process)27 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)24 SubProcess (org.eclipse.bpmn2.SubProcess)24 ArrayList (java.util.ArrayList)17 FlowElement (org.eclipse.bpmn2.FlowElement)14 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)13 Entry (java.util.Map.Entry)11 Message (org.eclipse.bpmn2.Message)11 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)11 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)10 CallActivity (org.eclipse.bpmn2.CallActivity)8 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)8 List (java.util.List)7 Activity (org.eclipse.bpmn2.Activity)7 Escalation (org.eclipse.bpmn2.Escalation)7 FlowNode (org.eclipse.bpmn2.FlowNode)7 Signal (org.eclipse.bpmn2.Signal)7 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)6 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)6