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());
});
}
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();
}
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());
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
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);
}
}
}
}
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);
});
}
Aggregations