use of org.eclipse.bpmn2.SequenceFlow in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method linkSequenceFlows.
private void linkSequenceFlows(List<FlowElement> flowElements) {
Map<String, FlowNode> nodes = new HashMap<String, FlowNode>();
for (FlowElement flowElement : flowElements) {
if (flowElement instanceof FlowNode) {
nodes.put(flowElement.getId(), (FlowNode) flowElement);
if (flowElement instanceof SubProcess) {
linkSequenceFlows(((SubProcess) flowElement).getFlowElements());
}
}
}
for (FlowElement flowElement : flowElements) {
if (flowElement instanceof SequenceFlow) {
SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
if (sequenceFlow.getSourceRef() == null && sequenceFlow.getTargetRef() == null) {
String id = sequenceFlow.getId();
try {
String[] subids = id.split("-_");
String id1 = subids[0];
String id2 = "_" + subids[1];
FlowNode source = nodes.get(id1);
if (source != null) {
sequenceFlow.setSourceRef(source);
}
FlowNode target = nodes.get(id2);
if (target != null) {
sequenceFlow.setTargetRef(target);
}
} catch (Throwable t) {
// Do nothing
}
}
}
}
}
use of org.eclipse.bpmn2.SequenceFlow 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.SequenceFlow in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method createSubProcessDiagram.
private void createSubProcessDiagram(BPMNPlane plane, FlowElement flowElement, BpmnDiFactory factory) {
SubProcess sp = (SubProcess) flowElement;
for (FlowElement subProcessFlowElement : sp.getFlowElements()) {
if (subProcessFlowElement instanceof SubProcess) {
createBpmnShapeForElement(factory, plane, subProcessFlowElement);
createSubProcessDiagram(plane, subProcessFlowElement, factory);
} else if (subProcessFlowElement instanceof FlowNode) {
createBpmnShapeForElement(factory, plane, subProcessFlowElement);
if (subProcessFlowElement instanceof BoundaryEvent) {
createDockersForBoundaryEvent((BoundaryEvent) subProcessFlowElement);
}
} else if (subProcessFlowElement instanceof SequenceFlow) {
createBpmnEdgeForSequenceFlow(factory, plane, (SequenceFlow) subProcessFlowElement);
}
}
if (sp.getArtifacts() != null) {
List<Association> incompleteAssociations = new ArrayList<Association>();
for (Artifact artifact : sp.getArtifacts()) {
// if (artifact instanceof TextAnnotation || artifact instanceof Group) {
if (artifact instanceof Group) {
createBpmnShapeForElement(factory, plane, artifact);
}
if (artifact instanceof Association) {
Association association = (Association) artifact;
if (association.getSourceRef() != null && association.getTargetRef() != null) {
createBpmnEdgeForAssociation(factory, plane, association);
} else {
incompleteAssociations.add(association);
}
}
}
if (!incompleteAssociations.isEmpty()) {
for (Association incompleteAssociation : incompleteAssociations) {
sp.getArtifacts().remove(incompleteAssociation);
}
}
}
}
use of org.eclipse.bpmn2.SequenceFlow in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method applySequenceFlowProperties.
protected void applySequenceFlowProperties(SequenceFlow sequenceFlow, Map<String, String> properties) {
// sequence flow name is options
if (properties.get("name") != null && !"".equals(properties.get("name"))) {
sequenceFlow.setName(StringEscapeUtils.escapeXml(properties.get("name")).replaceAll("\\r\\n|\\r|\\n", " "));
// add unescaped and untouched name value as extension eleent as well
Utils.setMetaDataExtensionValue(sequenceFlow, "elementname", wrapInCDATABlock(properties.get("name").replaceAll("\\\\n", "\n")));
}
if (properties.get("bgcolor") != null && properties.get("bgcolor").length() > 0) {
if (!(_elementColors.containsKey(sequenceFlow.getId()))) {
List<String> colorsList = new ArrayList<String>();
colorsList.add("bgcolor:" + properties.get("bgcolor"));
_elementColors.put(sequenceFlow.getId(), colorsList);
} else {
_elementColors.get(sequenceFlow.getId()).add("bgcolor:" + properties.get("bgcolor"));
}
}
if (properties.get("bordercolor") != null && properties.get("bordercolor").length() > 0) {
if (!(_elementColors.containsKey(sequenceFlow.getId()))) {
List<String> colorsList = new ArrayList<String>();
colorsList.add("bordercolor:" + properties.get("bordercolor"));
_elementColors.put(sequenceFlow.getId(), colorsList);
} else {
_elementColors.get(sequenceFlow.getId()).add("bordercolor:" + properties.get("bordercolor"));
}
}
if (properties.get("fontsize") != null && properties.get("fontsize").length() > 0) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "fontsize", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("fontsize"));
sequenceFlow.getAnyAttribute().add(extensionEntry);
}
if (properties.get("fontcolor") != null && properties.get("fontcolor").length() > 0) {
if (!(_elementColors.containsKey(sequenceFlow.getId()))) {
List<String> colorsList = new ArrayList<String>();
colorsList.add("fontcolor:" + properties.get("fontcolor"));
_elementColors.put(sequenceFlow.getId(), colorsList);
} else {
_elementColors.get(sequenceFlow.getId()).add("fontcolor:" + properties.get("fontcolor"));
}
}
// Custom extended auto connection property for Stunner.
String sourceConnAutoPropertyName = Bpmn2OryxManager.MAGNET_AUTO_CONNECTION + Bpmn2OryxManager.SOURCE;
String sourceConnAutoRaw = properties.get(sourceConnAutoPropertyName);
if (null != sourceConnAutoRaw && Boolean.TRUE.equals(Boolean.parseBoolean(sourceConnAutoRaw))) {
Utils.setMetaDataExtensionValue(sequenceFlow, sourceConnAutoPropertyName, Boolean.toString(true));
}
String targetConnAutoPropertyName = Bpmn2OryxManager.MAGNET_AUTO_CONNECTION + Bpmn2OryxManager.TARGET;
String targetConnAutoRaw = properties.get(targetConnAutoPropertyName);
if (null != targetConnAutoRaw && Boolean.TRUE.equals(Boolean.parseBoolean(targetConnAutoRaw))) {
Utils.setMetaDataExtensionValue(sequenceFlow, targetConnAutoPropertyName, Boolean.toString(true));
}
if (properties.get("isselectable") != null && properties.get("isselectable").length() > 0) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "selectable", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("isselectable"));
sequenceFlow.getAnyAttribute().add(extensionEntry);
}
if (properties.get("auditing") != null && !"".equals(properties.get("auditing"))) {
Auditing audit = Bpmn2Factory.eINSTANCE.createAuditing();
audit.getDocumentation().add(createDocumentation(properties.get("auditing")));
sequenceFlow.setAuditing(audit);
}
applySequenceFlowCondition(sequenceFlow, properties);
if (properties.get("priority") != null && !"".equals(properties.get("priority"))) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl priorityElement = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "priority", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(priorityElement, properties.get("priority"));
sequenceFlow.getAnyAttribute().add(extensionEntry);
}
if (properties.get("monitoring") != null && !"".equals(properties.get("monitoring"))) {
Monitoring monitoring = Bpmn2Factory.eINSTANCE.createMonitoring();
monitoring.getDocumentation().add(createDocumentation(properties.get("monitoring")));
sequenceFlow.setMonitoring(monitoring);
}
sequenceFlow.setIsImmediate(Boolean.parseBoolean(properties.get("isimmediate")));
// simulation properties
if (properties.get("probability") != null && properties.get("probability").length() > 0) {
ControlParameters controlParams = BpsimFactory.eINSTANCE.createControlParameters();
Parameter probParam = BpsimFactory.eINSTANCE.createParameter();
FloatingParameterType probParamValueParam = BpsimFactory.eINSTANCE.createFloatingParameterType();
DecimalFormat twoDForm = new DecimalFormat("#.##");
probParamValueParam.setValue(Double.valueOf(twoDForm.format(Double.valueOf(properties.get("probability")))));
probParam.getParameterValue().add(probParamValueParam);
controlParams.setProbability(probParam);
if (_simulationElementParameters.containsKey(sequenceFlow.getId())) {
_simulationElementParameters.get(sequenceFlow.getId()).add(controlParams);
} else {
List<EObject> values = new ArrayList<EObject>();
values.add(controlParams);
_simulationElementParameters.put(sequenceFlow.getId(), values);
}
}
}
use of org.eclipse.bpmn2.SequenceFlow in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method createBpmnEdgeForSequenceFlow.
private void createBpmnEdgeForSequenceFlow(BpmnDiFactory factory, BPMNPlane plane, SequenceFlow sequenceFlow) {
BPMNEdge edge = factory.createBPMNEdge();
edge.setBpmnElement(sequenceFlow);
DcFactory dcFactory = DcFactory.eINSTANCE;
Point point = dcFactory.createPoint();
List<Point> dockers = _dockers.get(sequenceFlow.getId());
if (sequenceFlow.getSourceRef() != null) {
Bounds sourceBounds = _bounds.get(sequenceFlow.getSourceRef().getId());
// Test for valid docker with X and Y > -1, created by EdgeParser
if (dockers != null && dockers.size() > 0 && dockers.get(0).getX() > -1 && dockers.get(0).getY() > -1) {
// First docker is connection to Source
point.setX(sourceBounds.getX() + dockers.get(0).getX());
point.setY(sourceBounds.getY() + dockers.get(0).getY());
} else {
// Default is right middle of Source
point.setX(sourceBounds.getX() + sourceBounds.getWidth());
point.setY(sourceBounds.getY() + (sourceBounds.getHeight() / 2));
}
}
edge.getWaypoint().add(point);
for (int i = 1; i < dockers.size() - 1; i++) {
edge.getWaypoint().add(dockers.get(i));
}
point = dcFactory.createPoint();
if (sequenceFlow.getTargetRef() != null) {
Bounds targetBounds = _bounds.get(sequenceFlow.getTargetRef().getId());
// Test for valid docker with X and Y > -1, created by EdgeParser
if (dockers != null && dockers.size() > 1 && dockers.get(dockers.size() - 1).getX() > -1 && dockers.get(dockers.size() - 1).getY() > -1) {
// Last docker is connection to Target
point.setX(targetBounds.getX() + dockers.get(dockers.size() - 1).getX());
point.setY(targetBounds.getY() + dockers.get(dockers.size() - 1).getY());
} else {
// Default is left middle of Target
point.setX(targetBounds.getX());
point.setY(targetBounds.getY() + (targetBounds.getHeight() / 2));
}
}
edge.getWaypoint().add(point);
plane.getPlaneElement().add(edge);
}
Aggregations