Search in sources :

Example 16 with Lane

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

the class DIZorderComparator method isChildParent.

private boolean isChildParent(BaseElement parent, BaseElement child) {
    LaneSet childLaneSet = ((Lane) parent).getChildLaneSet();
    if (childLaneSet == null) {
        return false;
    }
    List<Lane> lanes = childLaneSet.getLanes();
    for (Lane lane : lanes) {
        if (isParent(lane, child)) {
            return true;
        }
    }
    return false;
}
Also used : Lane(org.eclipse.bpmn2.Lane) LaneSet(org.eclipse.bpmn2.LaneSet)

Example 17 with Lane

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

the class AbstractProcessConverter method convertLaneSets.

private void convertLaneSets(List<LaneSet> laneSets, Map<String, BpmnNode> freeFloatingNodes, BpmnNode firstDiagramNode) {
    laneSets.stream().flatMap(laneSet -> laneSet.getLanes().stream()).forEach(lane -> {
        BpmnNode laneNode = converterFactory.laneConverter().convert(lane);
        laneNode.setParent(firstDiagramNode);
        lane.getFlowNodeRefs().forEach(node -> {
            freeFloatingNodes.get(node.getId()).setParent(laneNode);
        });
    });
}
Also used : LinkedHashMap(java.util.LinkedHashMap) Result(org.kie.workbench.common.stunner.bpmn.backend.converters.Result) List(java.util.List) LaneSet(org.eclipse.bpmn2.LaneSet) Map(java.util.Map) TypedFactoryManager(org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.ConverterFactory) DefinitionResolver(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver) FlowElement(org.eclipse.bpmn2.FlowElement) PropertyReaderFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.PropertyReaderFactory) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode)

Example 18 with Lane

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

the class Bpmn2JsonMarshaller method marshallLanes.

private List<String> marshallLanes(Lane lane, BPMNPlane plane, JsonGenerator generator, float xOffset, float yOffset, String preProcessingData, Definitions def) throws JsonGenerationException, IOException {
    Bounds bounds = ((BPMNShape) findDiagramElement(plane, lane)).getBounds();
    List<String> nodeRefIds = new ArrayList<String>();
    if (bounds != null) {
        generator.writeStartObject();
        generator.writeObjectField("resourceId", lane.getId());
        Map<String, Object> laneProperties = new LinkedHashMap<String, Object>();
        if (lane.getName() != null) {
            laneProperties.put(NAME, StringEscapeUtils.unescapeXml(lane.getName()));
        } else {
            laneProperties.put(NAME, "");
        }
        // overwrite name if elementname extension element is present
        String elementName = Utils.getMetaDataValue(lane.getExtensionValues(), "elementname");
        if (elementName != null) {
            laneProperties.put(NAME, elementName);
        }
        putDocumentationProperty(lane, laneProperties);
        Iterator<FeatureMap.Entry> iter = lane.getAnyAttribute().iterator();
        boolean foundBgColor = false;
        boolean foundBrColor = false;
        boolean foundFontColor = false;
        boolean foundSelectable = false;
        while (iter.hasNext()) {
            FeatureMap.Entry entry = iter.next();
            if (entry.getEStructuralFeature().getName().equals("background-color") || entry.getEStructuralFeature().getName().equals("bgcolor")) {
                laneProperties.put(BGCOLOR, entry.getValue());
                foundBgColor = true;
            }
            if (entry.getEStructuralFeature().getName().equals("border-color") || entry.getEStructuralFeature().getName().equals("bordercolor")) {
                laneProperties.put(BORDERCOLOR, entry.getValue());
                foundBrColor = true;
            }
            if (entry.getEStructuralFeature().getName().equals("fontsize")) {
                laneProperties.put(FONTSIZE, entry.getValue());
                foundBrColor = true;
            }
            if (entry.getEStructuralFeature().getName().equals("color") || entry.getEStructuralFeature().getName().equals("fontcolor")) {
                laneProperties.put(FONTCOLOR, entry.getValue());
                foundFontColor = true;
            }
            if (entry.getEStructuralFeature().getName().equals("selectable")) {
                laneProperties.put(ISSELECTABLE, entry.getValue());
                foundSelectable = true;
            }
        }
        if (!foundBgColor) {
            laneProperties.put(BGCOLOR, defaultBgColor_Swimlanes);
        }
        if (!foundBrColor) {
            laneProperties.put(BORDERCOLOR, defaultBrColor);
        }
        if (!foundFontColor) {
            laneProperties.put(FONTCOLOR, defaultFontColor);
        }
        if (!foundSelectable) {
            laneProperties.put(ISSELECTABLE, "true");
        }
        marshallProperties(laneProperties, generator);
        generator.writeObjectFieldStart("stencil");
        generator.writeObjectField("id", "Lane");
        generator.writeEndObject();
        generator.writeArrayFieldStart("childShapes");
        for (FlowElement flowElement : lane.getFlowNodeRefs()) {
            nodeRefIds.add(flowElement.getId());
            if (coordianteManipulation) {
                marshallFlowElement(flowElement, plane, generator, bounds.getX(), bounds.getY(), preProcessingData, def);
            } else {
                marshallFlowElement(flowElement, plane, generator, 0, 0, preProcessingData, def);
            }
        }
        generator.writeEndArray();
        generator.writeArrayFieldStart("outgoing");
        Process process = (Process) plane.getBpmnElement();
        writeAssociations(process, lane.getId(), generator);
        generator.writeEndArray();
        generator.writeObjectFieldStart("bounds");
        generator.writeObjectFieldStart("lowerRight");
        generator.writeObjectField("x", bounds.getX() + bounds.getWidth() - xOffset);
        generator.writeObjectField("y", bounds.getY() + bounds.getHeight() - yOffset);
        generator.writeEndObject();
        generator.writeObjectFieldStart("upperLeft");
        generator.writeObjectField("x", bounds.getX() - xOffset);
        generator.writeObjectField("y", bounds.getY() - yOffset);
        generator.writeEndObject();
        generator.writeEndObject();
        generator.writeEndObject();
    } else {
        // dont marshall the lane unless it has BPMNDI info (eclipse editor does not generate it for lanes currently.
        for (FlowElement flowElement : lane.getFlowNodeRefs()) {
            nodeRefIds.add(flowElement.getId());
            // we dont want an offset here!
            marshallFlowElement(flowElement, plane, generator, 0, 0, preProcessingData, def);
        }
    }
    return nodeRefIds;
}
Also used : Bounds(org.eclipse.dd.dc.Bounds) ArrayList(java.util.ArrayList) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) Process(org.eclipse.bpmn2.Process) SubProcess(org.eclipse.bpmn2.SubProcess) BPMNShape(org.eclipse.bpmn2.di.BPMNShape) LinkedHashMap(java.util.LinkedHashMap) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Entry(java.util.Map.Entry) FlowElement(org.eclipse.bpmn2.FlowElement) DataObject(org.eclipse.bpmn2.DataObject)

Example 19 with Lane

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

the class SubProcessPropertyWriter 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);
    });
}
Also used : LaneSet(org.eclipse.bpmn2.LaneSet)

Aggregations

SubProcess (org.eclipse.bpmn2.SubProcess)13 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)12 Lane (org.eclipse.bpmn2.Lane)12 Process (org.eclipse.bpmn2.Process)11 RootElement (org.eclipse.bpmn2.RootElement)11 FlowElement (org.eclipse.bpmn2.FlowElement)9 ArrayList (java.util.ArrayList)8 FlowNode (org.eclipse.bpmn2.FlowNode)8 LaneSet (org.eclipse.bpmn2.LaneSet)8 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)5 Message (org.eclipse.bpmn2.Message)5 Bounds (org.eclipse.dd.dc.Bounds)5 Entry (java.util.Map.Entry)4 Error (org.eclipse.bpmn2.Error)4 Escalation (org.eclipse.bpmn2.Escalation)4 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)4 Signal (org.eclipse.bpmn2.Signal)4 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)4 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)4 List (java.util.List)3