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