diff options
author | Lvbo163 <lv.bo163@zte.com.cn> | 2017-09-28 15:35:05 +0800 |
---|---|---|
committer | Lvbo163 <lv.bo163@zte.com.cn> | 2017-09-28 15:35:05 +0800 |
commit | 87653efcc84fdf9304e1321831c9d51e2bcd8711 (patch) | |
tree | d27e25be2c3aa2901d58513012ddc42e11dd4f92 | |
parent | 98103b79dc1a884a6d12088e233fe03691794d4b (diff) |
support BPMN data object as default value
Issue-ID: SDC-416
Change-Id: I128870ef03d2ec35c97347b0c8a9d8f191fe158a
Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
3 files changed, 77 insertions, 4 deletions
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/DataObject.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/DataObject.java new file mode 100644 index 00000000..0ae76b5b --- /dev/null +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/DataObject.java @@ -0,0 +1,42 @@ +/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the Apache License, Version 2.0
+ * and the Eclipse Public License v1.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+package org.onap.sdc.workflowdesigner.model;
+
+public class DataObject {
+ private String id;
+ private String name;
+ private String value;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/Process.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/Process.java index c229c291..6413ad67 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/Process.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/Process.java @@ -19,6 +19,7 @@ public class Process { private boolean isExecutable;
private List<Element> elementList = new ArrayList<Element>();
private List<SequenceFlow> sequenceFlowList = new ArrayList<SequenceFlow>();
+ private List<DataObject> dataObjectList = new ArrayList<DataObject>();
public Process(String id) {
this.id = id;
@@ -56,4 +57,11 @@ public class Process { this.sequenceFlowList = sequenceFlowList;
}
+ public List<DataObject> getDataObjectList() {
+ return dataObjectList;
+ }
+
+ public void setDataObjectList(List<DataObject> dataObjectList) {
+ this.dataObjectList = dataObjectList;
+ }
}
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParser.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParser.java index 8cad4d8c..390dc0b9 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParser.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParser.java @@ -18,8 +18,10 @@ import java.util.ArrayList; import java.util.Iterator;
import java.util.List;
+import org.onap.sdc.workflowdesigner.model.DataObject;
import org.onap.sdc.workflowdesigner.model.Element;
import org.onap.sdc.workflowdesigner.model.EndEvent;
+import org.onap.sdc.workflowdesigner.model.Parameter;
import org.onap.sdc.workflowdesigner.model.Process;
import org.onap.sdc.workflowdesigner.model.SequenceFlow;
import org.onap.sdc.workflowdesigner.model.StartEvent;
@@ -67,12 +69,33 @@ public class Bpmn4ToscaJsonParser { // get sequence flows
List<SequenceFlow> flowList = getSequenceFlows(jsonNode);
process.getSequenceFlowList().addAll(flowList);
+
+ // add dataObject
+ if (element instanceof StartEvent) {
+ List<DataObject> dataObjects = this.getDataObject((StartEvent) element);
+ process.getDataObjectList().addAll(dataObjects);
+ }
}
return process;
}
+ private List<DataObject> getDataObject(StartEvent startEvent) {
+ List<DataObject> dataObjects = new ArrayList<DataObject>();
+
+ for (Parameter parameter : startEvent.getParameters()) {
+ DataObject dataObject = new DataObject();
+ dataObject.setId(parameter.getName());
+ dataObject.setName(parameter.getName());
+ dataObject.setValue((String) parameter.getValue());
+
+ dataObjects.add(dataObject);
+ }
+
+ return dataObjects;
+ }
+
private List<SequenceFlow> getSequenceFlows(JsonNode jsonNode) {
List<SequenceFlow> flowList = new ArrayList<SequenceFlow>();
JsonNode sequenceFlowNodes = jsonNode.get(JsonKeys.SEQUENCE_FLOWS);
@@ -94,10 +117,6 @@ public class Bpmn4ToscaJsonParser { return flowList;
}
- private String getValueFromJsonNode(JsonNode jsonNode, String key) {
- return jsonNode.get(key) == null ? null : jsonNode.get(key).asText();
- }
-
protected Element createElementFromJson(JsonNode jsonNode)
throws JsonParseException, JsonMappingException, IOException {
String jsonObject = jsonNode.toString();
@@ -119,4 +138,8 @@ public class Bpmn4ToscaJsonParser { return element;
}
+ private String getValueFromJsonNode(JsonNode jsonNode, String key) {
+ return jsonNode.get(key) == null ? null : jsonNode.get(key).asText();
+ }
+
}
|