Skip to content

Commit

Permalink
round-tripping version and taskName attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tihomir Surdilovic committed Feb 22, 2011
1 parent b5ac7f6 commit 2bf4744
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/com/intalio/bpmn2/impl/Bpmn2JsonMarshaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,19 @@ private void marshallDefinitions(Definitions def, JsonGenerator generator) throw
props.put("executable", ((Process) rootElement).isIsExecutable() + "");
props.put("id", ((Process) rootElement).getId());

// packageName is a jbpm-specific extension attribute
// packageName and version are jbpm-specific extension attribute
Iterator<FeatureMap.Entry> iter = ((Process) rootElement).getAnyAttribute().iterator();
while(iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if(entry.getEStructuralFeature().getName().equals("packageName")) {
props.put("package", entry.getValue());
break;
}

if(entry.getEStructuralFeature().getName().equals("version")) {
props.put("version", entry.getValue());
}
}

marshallProperties(props, generator);
marshallStencil("BPMNDiagram", generator);
linkSequenceFlows(((Process) rootElement).getFlowElements());
Expand Down Expand Up @@ -460,12 +464,15 @@ private void marshallTask(Task task, BPMNPlane plane, JsonGenerator generator, i
}

properties.put("tasktype", taskType);
// get out the droolsjbpm-specific attribute "ruleflowGroup"
// get out the droolsjbpm-specific attributes "ruleflowGroup" and "taskName"
Iterator<FeatureMap.Entry> iter = task.getAnyAttribute().iterator();
while(iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if(entry.getEStructuralFeature().getName().equals("ruleFlowGroup")) {
properties.put("ruleflowgroup", entry.getValue());
}
if(entry.getEStructuralFeature().getName().equals("taskName")) {
properties.put("taskname", entry.getValue());
break;
}
}
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/intalio/bpmn2/impl/Bpmn2JsonUnmarshaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,16 @@ private void applyProcessProperties(Process process, Map<String, String> propert
process.getAnyAttribute().add(extensionEntry);
}

// add version attrbute to process
if(properties.get("version") != null && properties.get("version").length() > 0) {
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
"http://www.jboss.org/drools", "version", false, false);
EStructuralFeatureImpl.SimpleFeatureMapEntry extensionEntry = new EStructuralFeatureImpl.SimpleFeatureMapEntry(extensionAttribute,
properties.get("version"));
process.getAnyAttribute().add(extensionEntry);
}

if (properties.get("monitoring") != null && !"".equals(properties.get("monitoring"))) {
Monitoring monitoring = Bpmn2Factory.eINSTANCE.createMonitoring();
monitoring.getDocumentation().add(createDocumentation(properties.get("monitoring")));
Expand Down Expand Up @@ -741,6 +751,16 @@ private void applyLaneProperties(Lane lane, Map<String, String> properties) {

private void applyTaskProperties(Task task, Map<String, String> properties) {
task.setName(properties.get("name"));

if(properties.get("taskname") != null && properties.get("taskname").length() > 0) {
// add droolsjbpm-specific attribute "taskName"
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
"http://www.jboss.org/drools", "taskName", false, false);
EStructuralFeatureImpl.SimpleFeatureMapEntry extensionEntry = new EStructuralFeatureImpl.SimpleFeatureMapEntry(extensionAttribute,
properties.get("taskname"));
task.getAnyAttribute().add(extensionEntry);
}
}

private void applyGatewayProperties(Gateway gateway, Map<String, String> properties) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/webapp/stencilsets/bpmn2.0drools/bpmn2.0drools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2323,6 +2323,16 @@
"description":"ruleFlowGroup",
"readonly":false,
"optional":true
},
{
"id":"taskName",
"type":"String",
"title":"Task Name",
"title_de":"Task Name",
"value":"",
"description":"Task Name",
"readonly":false,
"optional":true
}
]
},
Expand Down

0 comments on commit 2bf4744

Please sign in to comment.