Skip to content

Commit

Permalink
docu, refactoring
Browse files Browse the repository at this point in the history
Issue #70
  • Loading branch information
rsoika committed Sep 18, 2022
1 parent 3664d9b commit c964d8e
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 22 deletions.
8 changes: 5 additions & 3 deletions doc/BPMN_EXTENSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,34 @@ This Method is called to generate a JSON Forms Object when the element is loaded

You can add a new data field by calling

```java
builder.add("myField","someData")
uiSchemaBuilder. //
addCategory("General"). //
addLayout(Layout.HORIZONTAL). //
addElements("name", "category"). //

schemaBuilder.addProperty("name", "string", "Please enter your name");
```

This JsonObjectBuilder is used on the BPMNGmodelFactory to generate the JsonForms


### updatePropertiesData

Updates the properties data provided by the modeling tool in the corresponding BPMN Element
Updates the properties data provided by the modeling tool in the corresponding BPMN Element. The method receives the BPMNElement and a json object containing all new values. An extension can also update the given json object during this operation if needed.


## Register a BPMNExtension

To register a BPMNExtension the method `configureBPMNExtensions` of the `BPMNDiagramModule` can be overwritten. In this method you can register new custom Extension:

```java
public void configureBPMNExtensions(final Multibinder<BPMNExtension> binding) {
// bind BPMN default extensions
super.configureBPMNExtensions(binding);

// register custom Extensions
binding.addBinding().to(MyBPMNTaskExtension.class);

}

```
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ default int getPriority() {
addCategory("General"). //
addLayout(Layout.HORIZONTAL). //
addElements("name", "category"). //
schemaBuilder.addProperty("name", "string", "Please enter your name");
*
* }
Expand All @@ -133,7 +133,10 @@ void buildPropertiesForm(BPMNBaseElement bpmnElement, DataBuilder dataBuilder, S
UISchemaBuilder uiSchemaBuilder);

/**
* Updates the properties data of a BPMN Element
* Updates the properties data of a BPMN Element.
* <p>
* An extension can also update the given json object during this operation if
* needed.
*
* @param json - a JSON structure representing the data
* @param bpmnElement - the BPMN element to be updated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,10 @@ public void buildPropertiesForm(final BPMNBaseElement bpmnElement, final DataBui

dataBuilder. //
addData("name", bpmnElement.getName()). //
addData("rating", "3"). //
addData("documentation", bpmnElement.getDocumentation());

schemaBuilder. //
addProperty("name", "string", null). //
addProperty("rating", "integer", null). //
addProperty("documentation", "string", null);

BPMNEvent bpmnEvent = (BPMNEvent) bpmnElement;
Expand All @@ -97,7 +95,6 @@ public void buildPropertiesForm(final BPMNBaseElement bpmnElement, final DataBui
addCategory("General"). //
addLayout(Layout.VERTICAL). //
addElements("name"). //
addElements("rating"). //
addElement("documentation", "Documentation", multilineOption);

// check Event Definitions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void buildPropertiesForm(final BPMNBaseElement bpmnElement, final DataBui
BPMNFlowElement taskElement = (BPMNFlowElement) bpmnElement;
if (BPMNTypes.SCRIPT_TASK.equals(taskElement.getType())) {
dataBuilder //
.addData("scriptformat", "") //
.addData("scriptformat", taskElement.getAttribute("scriptFormat")) //
.addData("script", "");

schemaBuilder. //
Expand All @@ -109,6 +109,9 @@ public void buildPropertiesForm(final BPMNBaseElement bpmnElement, final DataBui
addElements("scriptformat"). //
addElement("script", "Script", multilineOption); //
}

// update corresponding GModelElement....

}

@Override
Expand All @@ -123,7 +126,12 @@ public void updatePropertiesData(final JsonObject json, final BPMNBaseElement bp
for (String feature : features) {
value = json.getString(feature);

logger.fine("...update feature = " + feature);
logger.info("...update feature = " + feature);

if ("scriptformat".equals(feature)) {
bpmnElement.setAttribute("scriptFormat", value);
continue;
}

// TODO implement Event features
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,20 @@ protected void executeOperation(final BPMNApplyPropertiesUpdateOperation operati
}

// Now call the extensions to update the property data according to the BPMN
// element
// element. The updatePropertiesData can also update the given JSON object!
if (extensions != null) {
for (BPMNExtension extension : extensions) {
// validate if the extension can handle this BPMN element
if (extension.handlesBPMNElement(bpmnElement)) {
logger.info("...We need to update the BPMN Element with the extension " + extension.getNamespace());
extension.updatePropertiesData(json, bpmnElement);
}
}
}

// finally we need ot update the JSONFormsData property of the selected element
element.get().getArgs().put("JSONFormsData", json.toString());
logger.info("....execute Update " + operation.getId() + " in " + (System.currentTimeMillis() - l) + "ms");

// we do not need to reset the modelState here!
// modelState.reset();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,9 @@ public class BPMNGModelFactory implements GModelFactory {

@Override
public void createGModel() {
// call extension.....
if (extensions != null) {
System.out.println("-------_> Wir haben " + extensions.size() + " BPMNExtensions :-)");

} else {
System.out.println("-------_> Wir haben KEINE BPMNExtension :-(((");
// verify extensions....
if (extensions == null || extensions.size() == 0) {
logger.warning("no BPMNExtension found! Check DiagramModule->configureBPMNExtensions");
}

if (!modelState.isInitalized()) {
Expand All @@ -126,7 +123,7 @@ public void createGModel() {
modelState.setInitalized(true);
logger.info("===> createGModel took " + (System.currentTimeMillis() - l) + "ms");
} else {
logger.info("===> createGModel skipped!");
logger.fine("===> createGModel skipped!");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.openbpmn.bpmn.BPMNModel;
import org.openbpmn.bpmn.exceptions.BPMNModelException;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

/**
* An Activity is work that is performed within a Business Process. An Activity
Expand Down

0 comments on commit c964d8e

Please sign in to comment.