Search in sources :

Example 1 with LaneSet

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

the class ProcessPropertyWriter method addLaneSet.

public void addLaneSet(List<LanePropertyWriter> lanes) {
    if (lanes.isEmpty()) {
        return;
    }
    LaneSet laneSet = bpmn2.createLaneSet();
    List<org.eclipse.bpmn2.Lane> laneList = laneSet.getLanes();
    lanes.forEach(l -> laneList.add(l.getElement()));
    process.getLaneSets().add(laneSet);
    lanes.forEach(l -> {
        this.childElements.put(l.getElement().getId(), l);
        addChildShape(l.getShape());
    });
}
Also used : LaneSet(org.eclipse.bpmn2.LaneSet)

Example 2 with LaneSet

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

the class Bpmn2JsonMarshaller method marshallProcess.

protected void marshallProcess(Process process, Definitions def, JsonGenerator generator, String preProcessingData) throws JsonGenerationException, IOException {
    BPMNPlane plane = null;
    for (BPMNDiagram d : def.getDiagrams()) {
        if (d != null) {
            BPMNPlane p = d.getPlane();
            if (p != null) {
                if (p.getBpmnElement() == process) {
                    plane = p;
                    break;
                }
            }
        }
    }
    if (plane == null) {
        throw new IllegalArgumentException("Could not find BPMNDI information");
    }
    generator.writeArrayFieldStart("childShapes");
    List<String> laneFlowElementsIds = new ArrayList<String>();
    for (LaneSet laneSet : process.getLaneSets()) {
        for (Lane lane : laneSet.getLanes()) {
            // we only want to marshall lanes if we have the bpmndi info for them!
            if (findDiagramElement(plane, lane) != null) {
                laneFlowElementsIds.addAll(marshallLanes(lane, plane, generator, 0, 0, preProcessingData, def));
            }
        }
    }
    for (FlowElement flowElement : process.getFlowElements()) {
        if (!laneFlowElementsIds.contains(flowElement.getId())) {
            marshallFlowElement(flowElement, plane, generator, 0, 0, preProcessingData, def);
        }
    }
    for (Artifact artifact : process.getArtifacts()) {
        marshallArtifact(artifact, plane, generator, 0, 0, preProcessingData, def);
    }
    generator.writeEndArray();
}
Also used : BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) FlowElement(org.eclipse.bpmn2.FlowElement) ArrayList(java.util.ArrayList) Lane(org.eclipse.bpmn2.Lane) LaneSet(org.eclipse.bpmn2.LaneSet) BPMNPlane(org.eclipse.bpmn2.di.BPMNPlane) Artifact(org.eclipse.bpmn2.Artifact)

Example 3 with LaneSet

use of org.eclipse.bpmn2.LaneSet 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 4 with LaneSet

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

the class Bpmn2JsonUnmarshaller method revisitLanes.

public void revisitLanes(Definitions def) {
    List<RootElement> rootElements = def.getRootElements();
    for (RootElement root : rootElements) {
        if (root instanceof Process) {
            Process process = (Process) root;
            if ((process.getLaneSets() == null || process.getLaneSets().size() < 1) && _lanes.size() > 0) {
                LaneSet ls = Bpmn2Factory.eINSTANCE.createLaneSet();
                for (Lane lane : _lanes) {
                    ls.getLanes().add(lane);
                    List<FlowNode> laneFlowNodes = lane.getFlowNodeRefs();
                    for (FlowNode fl : laneFlowNodes) {
                        process.getFlowElements().add(fl);
                    }
                }
                process.getLaneSets().add(ls);
            }
        }
    }
}
Also used : RootElement(org.eclipse.bpmn2.RootElement) 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) FlowNode(org.eclipse.bpmn2.FlowNode)

Example 5 with LaneSet

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

the class SubProcessPropertyWriter method addLaneSet.

public void addLaneSet(Collection<LanePropertyWriter> lanes) {
    if (lanes.isEmpty()) {
        return;
    }
    LaneSet laneSet = bpmn2.createLaneSet();
    List<org.eclipse.bpmn2.Lane> laneList = laneSet.getLanes();
    lanes.forEach(l -> laneList.add(l.getElement()));
    process.getLaneSets().add(laneSet);
    lanes.forEach(l -> {
        this.childElements.put(l.getElement().getId(), l);
    });
}
Also used : LaneSet(org.eclipse.bpmn2.LaneSet)

Aggregations

LaneSet (org.eclipse.bpmn2.LaneSet)13 Lane (org.eclipse.bpmn2.Lane)8 FlowElement (org.eclipse.bpmn2.FlowElement)5 ArrayList (java.util.ArrayList)4 List (java.util.List)3 Map (java.util.Map)3 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)3 FlowNode (org.eclipse.bpmn2.FlowNode)3 Process (org.eclipse.bpmn2.Process)3 RootElement (org.eclipse.bpmn2.RootElement)3 SubProcess (org.eclipse.bpmn2.SubProcess)3 BpmnNode (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode)3 Artifact (org.eclipse.bpmn2.Artifact)2 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)2 BPMNDiagram (org.eclipse.bpmn2.di.BPMNDiagram)2 BPMNPlane (org.eclipse.bpmn2.di.BPMNPlane)2 Result (org.kie.workbench.common.stunner.bpmn.backend.converters.Result)2 TypedFactoryManager (org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager)2 DefinitionResolver (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver)2 PropertyReaderFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.PropertyReaderFactory)2