Skip to content

Commit

Permalink
impl new DefaultBPMNSequenceFlowExtension
Browse files Browse the repository at this point in the history
Issue #175
  • Loading branch information
rsoika committed Feb 13, 2023
1 parent 0d8d831 commit cc67937
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 44 deletions.
88 changes: 48 additions & 40 deletions open-bpmn.glsp-client/workspace/sequenceflow.bpmn
Original file line number Diff line number Diff line change
@@ -1,40 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- origin at X=0.0 Y=0.0 -->
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xs="http://www.w3.org/2001/XMLSchema" id="Definitions_1" exporter="org.eclipse.bpmn2.modeler.core" exporterVersion="1.5.4.RC1-v20220528-0836-B1">
<bpmn2:process id="Process_1" name="Process 1" isExecutable="false">
<bpmn2:startEvent id="StartEvent_1" name="Start Event 1">
<bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:endEvent id="EndEvent_1" name="End Event 1">
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:sequenceFlow id="SequenceFlow_1" name="Flow-1" sourceRef="StartEvent_1" targetRef="EndEvent_1"/>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="BPMNShape_StartEvent_1" bpmnElement="StartEvent_1">
<dc:Bounds height="36.0" width="36.0" x="62.0" y="32.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_8" labelStyle="BPMNLabelStyle_1">
<dc:Bounds height="14.0" width="69.0" x="46.0" y="68.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_EndEvent_1" bpmnElement="EndEvent_1">
<dc:Bounds height="36.0" width="36.0" x="270.0" y="32.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_9" labelStyle="BPMNLabelStyle_1">
<dc:Bounds height="14.0" width="66.0" x="255.0" y="68.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="BPMNShape_StartEvent_1" targetElement="BPMNShape_EndEvent_1">
<di:waypoint xsi:type="dc:Point" x="98.0" y="50.0"/>
<di:waypoint xsi:type="dc:Point" x="184.0" y="50.0"/>
<di:waypoint xsi:type="dc:Point" x="270.0" y="50.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_10">
<dc:Bounds height="14.0" width="37.0" x="166.0" y="51.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
<bpmndi:BPMNLabelStyle id="BPMNLabelStyle_1">
<dc:Font name="arial" size="9.0"/>
</bpmndi:BPMNLabelStyle>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- origin at X=0.0 Y=0.0 --><bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exporter="org.eclipse.bpmn2.modeler.core" exporterVersion="1.5.4.RC1-v20220528-0836-B1" id="Definitions_1">
<bpmn2:process id="Process_1" isExecutable="false" name="Process 1" processType="Public">
<bpmn2:startEvent id="StartEvent_1" name="Start Event 1">
<bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
<bpmn2:documentation id="documentation_QOLAnw"/>
</bpmn2:startEvent>
<bpmn2:endEvent id="EndEvent_1" name="End Event 1">
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
<bpmn2:documentation id="documentation_qWPl1w"/>
</bpmn2:endEvent>
<bpmn2:sequenceFlow id="SequenceFlow_1" name="Flow-1" sourceRef="StartEvent_1" targetRef="EndEvent_1">
<bpmn2:documentation id="documentation_hqnTsw"><![CDATA[as]]></bpmn2:documentation>
<bpmn2:conditionExpression id="conditionExpression_tSguzw"><![CDATA[1==1]]></bpmn2:conditionExpression>
</bpmn2:sequenceFlow>
<bpmn2:documentation id="documentation_Swvz0Q"/>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane bpmnElement="Process_1" id="BPMNPlane_1">
<bpmndi:BPMNShape bpmnElement="StartEvent_1" id="BPMNShape_StartEvent_1">
<dc:Bounds height="36.0" width="36.0" x="62.0" y="32.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_8" labelStyle="BPMNLabelStyle_1">
<dc:Bounds height="14.0" width="69.0" x="46.0" y="68.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="EndEvent_1" id="BPMNShape_EndEvent_1">
<dc:Bounds height="36.0" width="36.0" x="270.0" y="32.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_9" labelStyle="BPMNLabelStyle_1">
<dc:Bounds height="14.0" width="66.0" x="255.0" y="68.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="SequenceFlow_1" id="BPMNEdge_SequenceFlow_1" sourceElement="BPMNShape_StartEvent_1" targetElement="BPMNShape_EndEvent_1">
<bpmndi:BPMNLabel id="BPMNLabel_10">
<dc:Bounds height="14.0" width="37.0" x="166.0" y="51.0"/>
</bpmndi:BPMNLabel>



<di:waypoint x="98.0" y="50.0"/>
<di:waypoint x="184.0" y="50.0"/>
<di:waypoint x="270.0" y="50.0"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
<bpmndi:BPMNLabelStyle id="BPMNLabelStyle_1">
<dc:Font name="arial" size="9.0"/>
</bpmndi:BPMNLabelStyle>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
9 changes: 6 additions & 3 deletions open-bpmn.glsp-client/workspace/test-signal.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@
<bpmn2:documentation id="documentation_GHJJpA"/>
<bpmn2:intermediateCatchEvent id="event_Mb6RHg" name="Event-1">
<bpmn2:documentation id="documentation_QHL8lQ"/>
<bpmn2:signalEventDefinition id="signalEventDefinition_ecjjKQ" signalRef="signal_1"/>
<bpmn2:signalEventDefinition id="signalEventDefinition_XWYS7A" signalRef="signal_3"/>
<bpmn2:signalEventDefinition id="signalEventDefinition_5FSzHg" signalRef="signal_1"/>
<bpmn2:signalEventDefinition id="signalEventDefinition_mb5bIw" signalRef="signal_2"/>
</bpmn2:intermediateCatchEvent>
</bpmn2:process>
<bpmn2:signal id="signal_1" name="Signal 1b"/>
<bpmn2:signal id="signal_2" name="Signal 2b"/>
<bpmn2:signal id="signal_3" name="My SUPER Signal"/>
<bpmndi:BPMNDiagram id="BPMNDiagram_1" name="OpenBPMN Diagram">
<bpmndi:BPMNPlane bpmnElement="process_1" id="BPMNPlane_1">
<bpmndi:BPMNShape bpmnElement="event_Mb6RHg" id="BPMNShape_DndWfg">
<dc:Bounds height="36.0" width="36.0" x="85.0" y="35.0"/>
<dc:Bounds height="36.0" width="36.0" x="85.0" y="34.0"/>
<bpmndi:BPMNLabel id="BPMNLabel_u0K6xg">
<dc:Bounds height="24.0" width="100.0" x="53.0" y="71.0"/>
<dc:Bounds height="24.0" width="100.0" x="53.0" y="70.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void buildPropertiesForm(final BPMNElement bpmnElement, final DataBuilder
addLayout(Layout.HORIZONTAL). //
addElements("name"). //
addLayout(Layout.VERTICAL). //
addElement("documentation", "Data", multilineOption);
addElement("documentation", "Documentation", multilineOption);

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/********************************************************************************
* Copyright (c) 2022 Imixs Software Solutions GmbH and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
package org.openbpmn.extension;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import javax.json.JsonObject;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.glsp.graph.GModelElement;
import org.openbpmn.bpmn.BPMNTypes;
import org.openbpmn.bpmn.elements.SequenceFlow;
import org.openbpmn.bpmn.elements.core.BPMNElement;
import org.openbpmn.glsp.jsonforms.DataBuilder;
import org.openbpmn.glsp.jsonforms.SchemaBuilder;
import org.openbpmn.glsp.jsonforms.UISchemaBuilder;
import org.openbpmn.glsp.jsonforms.UISchemaBuilder.Layout;
import org.openbpmn.glsp.model.BPMNGModelState;

import com.google.inject.Inject;

/**
* The DefaultBPMNSequenceFlowExtension add an addional section for the
* conditional SquenceFlows.
*
* @author rsoika
*
*/
public class DefaultBPMNSequenceFlowExtension extends AbstractBPMNElementExtension {

@SuppressWarnings("unused")
private static Logger logger = LogManager.getLogger(DefaultBPMNSequenceFlowExtension.class);

@Inject
protected BPMNGModelState modelState;

public DefaultBPMNSequenceFlowExtension() {
super();
}

@Override
public int getPriority() {
return 100; // below default settings from Edge element
}

/**
* Returns if this Extension is of type SEQUENCE_FLOW
*/
@Override
public boolean handlesElementTypeId(final String elementTypeId) {
return BPMNTypes.SEQUENCE_FLOW.equals(elementTypeId);
}

/**
* This Extension is for SequenceFlow elements only
*/
@Override
public boolean handlesBPMNElement(final BPMNElement bpmnElement) {
return (bpmnElement instanceof SequenceFlow);
}

/**
* This Helper Method generates a JSON Object with the BPMNElement properties.
* <p>
* This json object is used on the GLSP Client to generate the EMF JsonForms
*/
@Override
public void buildPropertiesForm(final BPMNElement bpmnElement, final DataBuilder dataBuilder,
final SchemaBuilder schemaBuilder, final UISchemaBuilder uiSchemaBuilder) {

SequenceFlow sequenceFlow = (SequenceFlow) bpmnElement;
dataBuilder //
.addData("conditionExpression", sequenceFlow.getConditionExpression()) //
.addData("Default", "test");

schemaBuilder. //
addProperty("conditionExpression", "string", "add an optional conditional expression."). //
addProperty("default", "boolean", null);

Map<String, String> multilineOption = new HashMap<>();
multilineOption.put("multi", "true");
uiSchemaBuilder. //
addCategory("Condition"). //
addLayout(Layout.VERTICAL). //
addElement("conditionExpression", "Expression", multilineOption);

}

@Override
public void updatePropertiesData(final JsonObject json, final BPMNElement bpmnElement,
final GModelElement gNodeElement) {

SequenceFlow sequenceFlow = (SequenceFlow) bpmnElement;
// check conditionExpression features
Set<String> features = json.keySet();
for (String feature : features) {
if ("conditionExpression".equals(feature)) {
sequenceFlow.setConditionExpression(json.getString(feature));
continue;
}
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.openbpmn.extension.DefaultBPMNGatewayExtension;
import org.openbpmn.extension.DefaultBPMNMessageExtension;
import org.openbpmn.extension.DefaultBPMNParticipantExtension;
import org.openbpmn.extension.DefaultBPMNSequenceFlowExtension;
import org.openbpmn.extension.DefaultBPMNTaskExtension;
import org.openbpmn.extension.DefaultBPMNTextAnnotationExtension;
import org.openbpmn.glsp.elements.data.BPMNApplyEditLabelOperationHandler;
Expand Down Expand Up @@ -228,6 +229,7 @@ public void configureBPMNExtensions(final Multibinder<BPMNExtension> binding) {
binding.addBinding().to(DefaultBPMNMessageExtension.class);
binding.addBinding().to(DefaultBPMNTextAnnotationExtension.class);
binding.addBinding().to(DefaultBPMNEdgeExtension.class);
binding.addBinding().to(DefaultBPMNSequenceFlowExtension.class);

}
}

0 comments on commit cc67937

Please sign in to comment.