summaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-server/src
diff options
context:
space:
mode:
authorLvbo163 <lv.bo163@zte.com.cn>2017-09-26 09:03:50 +0800
committerLvbo163 <lv.bo163@zte.com.cn>2017-09-26 09:03:50 +0800
commitc48747269ff30e101835877cb57d4df87bdead3c (patch)
tree8cd23afb129388fa7e5bd2c25ae270ddb65ae8e4 /sdc-workflow-designer-server/src
parent2e910cdd98bebd2035aaa40732d71a1eb3703954 (diff)
support sequence flow convert
Issue-ID: SDC-395 Change-Id: Ibd28a640cceade20b3115f097778355fd5d5ac54 Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-server/src')
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParser.java32
1 files changed, 32 insertions, 0 deletions
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 81b41d98..64bff27b 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
@@ -14,10 +14,13 @@ package org.onap.sdc.workflowdesigner.parser;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import org.onap.sdc.workflowdesigner.model.Element;
import org.onap.sdc.workflowdesigner.model.Process;
+import org.onap.sdc.workflowdesigner.model.SequenceFlow;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,12 +60,41 @@ public class Bpmn4ToscaJsonParser {
// get element
Element element = createElementFromJson(jsonNode);
process.getElementList().add(element);
+
+ // get sequence flows
+ List<SequenceFlow> flowList = getSequenceFlows(jsonNode);
+ process.getSequenceFlowList().addAll(flowList);
}
return process;
}
+ private List<SequenceFlow> getSequenceFlows(JsonNode jsonNode) {
+ List<SequenceFlow> flowList = new ArrayList<SequenceFlow>();
+ JsonNode sequenceFlowNodes = jsonNode.get("sequenceFlows");
+
+ Iterator<JsonNode> iter = sequenceFlowNodes.iterator();
+ while (iter.hasNext()) {
+ JsonNode connectionEntry = (JsonNode) iter.next();
+ String sourceRef = getValueFromJsonNode(connectionEntry, "sourceRef");
+ String targetRef = getValueFromJsonNode(connectionEntry, "targetRef");
+ String condition = getValueFromJsonNode(connectionEntry, "condition");
+ SequenceFlow flow = new SequenceFlow();
+ flow.setId(sourceRef + targetRef);
+ flow.setSourceRef(sourceRef);
+ flow.setTargetRef(targetRef);
+ flow.setCondition(condition);
+ flowList.add(flow);
+ }
+
+ 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();
return MAPPER.readValue(jsonObject, Element.class);