Skip to content

Commit

Permalink
impl
Browse files Browse the repository at this point in the history
Issue #85
  • Loading branch information
rsoika committed Oct 2, 2022
1 parent eca7ac5 commit a2340e9
Show file tree
Hide file tree
Showing 8 changed files with 480 additions and 21 deletions.
17 changes: 10 additions & 7 deletions open-bpmn.metamodel/src/main/java/org/openbpmn/bpmn/BPMNModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public void setBpmnPlane(Element bpmnPlane) {
}

/**
* This method returns true if the current model contains a COllaborationDiagram
* This method returns true if the current model contains a CollaborationDiagram
*
* @return
*/
Expand All @@ -306,16 +306,12 @@ public boolean isCollaborationDiagram() {
* In case the diagram type switches from a process diagram to a collaboration
* diagram, the method also updates the attribute 'bpmnElement' of the bpmnPlane
* to the new created bpmn2:collaboration element id.
*
*
*
* <p>
* {@code
* <bpmn2:collaboration id="Collaboration_1" name="Default Collaboration">
* <bpmn2:participant id="Participant_1" name="Pool 1"/>
*
* @param id
* }
* @param name
* @param type - EventType
* @return the BPMNParticipant
* @throws BPMNModelException
*/
Expand Down Expand Up @@ -896,6 +892,13 @@ public Node findBPMNPlaneElement(String nodeName, String id) {
public static Logger getLogger() {
return logger;
}

public static void log(String message) {
logger.info(message);
}
public static void debug(String message) {
logger.info(message);
}

/**
* This helper method loads the participant elements from a collaboration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public BPMNLabel(BPMNModel model, Node _bpmnShape) throws BPMNMissingElementExce
label = model.createElement(BPMNNS.BPMNDI, "BPMNLabel");
label.setAttribute("id", BPMNModel.generateShortID("BPMNLabel"));
bpmnShape.appendChild(label);
// Element _dcounds = model.createElement(BPMNNS.DC, "Bounds");
// label.appendChild(_dcounds);
bounds = new BPMNBounds(label, model);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package org.openbpmn.bpmn.elements;

import java.util.ArrayList;
import java.util.List;

import org.openbpmn.bpmn.BPMNModel;
import org.openbpmn.bpmn.BPMNNS;
import org.openbpmn.bpmn.exceptions.BPMNInvalidReferenceException;
import org.openbpmn.bpmn.exceptions.BPMNMissingElementException;
import org.w3c.dom.Element;
import org.w3c.dom.Text;

/**
* The BPMNLane object represents a lane in a laneset contianed by a process
* <p>
* e.g.:
* <p>
*
* <pre>{@code
* <bpmn2:process definitionalCollaborationRef="collaboration_1" id=
"process_1" name="Process 1" processType="Private">
<bpmn2:laneSet id="laneset_1" name="Lane Set 1">
<bpmn2:lane id="lane_1" name="Lane 1">
<bpmn2:flowNodeRef>task_1</bpmn2:flowNodeRef>
</bpmn2:lane>
</bpmn2:laneSet>
<bpmn2:task id="task_1" name="Task"/>
</bpmn2:process>
* }
* </pre>
* </p>
* A dc:Bounds element is part of a bpmndi:BPMNShape or bpmndi:BPMNLabel
*
* @author rsoika
*
*/
public class BPMNLane extends BPMNBaseElement {

/**
* Creates a BPMNLane out of the bpmn elemnet
* <p>
* < <bpmn2:lane id="lane_1" name="Lane 1">
* </p>
*
* @param width
* @throws BPMNMissingElementException
*/
public BPMNLane(BPMNModel model, Element node) {
super(model, node);

}

/**
* This method insets a given BPMNFlowElment to this lane
* <p>
* {@code
* <bpmn2:laneSet id="LaneSet_1" name="Lane Set 1">
<bpmn2:lane id="Lane_1" name="Lane 1">
<bpmn2:flowNodeRef>StartEvent_4</bpmn2:flowNodeRef>
}
*
* @param element
* @param laneId
* @throws BPMNInvalidReferenceException
*/
public void insert(BPMNFlowElement bpmnFlowEement) throws BPMNInvalidReferenceException {
// append flowNodeRef
Element flowNodeRef = model.createElement(BPMNNS.BPMN2, "flowNodeRef");
Text textNode = this.getDoc().createTextNode(bpmnFlowEement.getId());
flowNodeRef.appendChild(textNode);
this.getElementNode().appendChild(flowNodeRef);
}

/**
* Returns true if the given BPMNFlow Element is part of this lane
*
* @param element a BPMNFlowElement
* @return
*/
public boolean contains(BPMNFlowElement bpmnElement) {
// get all bpmn2:flowNodeRef
List<Element> refs = BPMNModel.findChildNodesByName(this.getElementNode(),
BPMNNS.BPMN2.prefix + ":flowNodeRef");
for (Element element : refs) {
if (bpmnElement.getId().equals(element.getTextContent())) {
return true;
}
}
// not found
return false;
}

/**
* Returns a list of a all BPMNFlowElement IDs contained by this lane
*
* @return - list of ids
*/
public List<String> getFlowElementIDs() {
List<String> result = new ArrayList<String>();
List<Element> refs = BPMNModel.findChildNodesByName(this.getElementNode(),
BPMNNS.BPMN2.prefix + ":flowNodeRef");
for (Element element : refs) {
result.add(element.getTextContent());
}
return result;
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.openbpmn.bpmn.elements;

import org.openbpmn.bpmn.BPMNModel;
import org.openbpmn.bpmn.BPMNNS;
import org.openbpmn.bpmn.BPMNTypes;
import org.openbpmn.bpmn.exceptions.BPMNModelException;
import org.w3c.dom.Element;

Expand Down Expand Up @@ -83,4 +85,8 @@ public double getDefaultWidth() {
public double getDefaultHeigth() {
return DEFAULT_HEIGHT;
}




}
Loading

0 comments on commit a2340e9

Please sign in to comment.