Support start and end event 73/15273/1
authorLvbo163 <lv.bo163@zte.com.cn>
Tue, 26 Sep 2017 01:35:43 +0000 (09:35 +0800)
committerLvbo163 <lv.bo163@zte.com.cn>
Tue, 26 Sep 2017 01:35:43 +0000 (09:35 +0800)
Support convert start and end event json object

Issue-ID: SDC-396

Change-Id: I70d55908b0bd95f38e90a9bdda0a748cdcd3b08e
Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/EndEvent.java [new file with mode: 0644]
sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/StartEvent.java [new file with mode: 0644]
sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParser.java

diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/EndEvent.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/EndEvent.java
new file mode 100644 (file)
index 0000000..86b1c8f
--- /dev/null
@@ -0,0 +1,15 @@
+/**\r
+ * Copyright (c) 2017 ZTE Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * and the Apache License 2.0 which both accompany this distribution,\r
+ * and are available at http://www.eclipse.org/legal/epl-v10.html\r
+ * and http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Contributors:\r
+ *     ZTE - initial API and implementation and/or initial documentation\r
+ */\r
+package org.onap.sdc.workflowdesigner.model;\r
+\r
+public class EndEvent extends Element {\r
+}\r
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/StartEvent.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/StartEvent.java
new file mode 100644 (file)
index 0000000..963d332
--- /dev/null
@@ -0,0 +1,15 @@
+/**\r
+ * Copyright (c) 2017 ZTE Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * and the Apache License 2.0 which both accompany this distribution,\r
+ * and are available at http://www.eclipse.org/legal/epl-v10.html\r
+ * and http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Contributors:\r
+ *     ZTE - initial API and implementation and/or initial documentation\r
+ */\r
+package org.onap.sdc.workflowdesigner.model;\r
+\r
+public class StartEvent extends Element {\r
+}\r
index 64bff27..a751148 100644 (file)
@@ -19,8 +19,10 @@ import java.util.Iterator;
 import java.util.List;\r
 \r
 import org.onap.sdc.workflowdesigner.model.Element;\r
+import org.onap.sdc.workflowdesigner.model.EndEvent;\r
 import org.onap.sdc.workflowdesigner.model.Process;\r
 import org.onap.sdc.workflowdesigner.model.SequenceFlow;\r
+import org.onap.sdc.workflowdesigner.model.StartEvent;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
@@ -96,8 +98,23 @@ public class Bpmn4ToscaJsonParser {
     }\r
        \r
        protected Element createElementFromJson(JsonNode jsonNode) throws JsonParseException, JsonMappingException, IOException {\r
-               String jsonObject = jsonNode.toString();\r
-               return MAPPER.readValue(jsonObject, Element.class);\r
+           String jsonObject = jsonNode.toString();\r
+        Element element;\r
+        \r
+        String nodeType = getValueFromJsonNode(jsonNode, "type");\r
+        switch (nodeType) {\r
+        case "startEvent":\r
+            element = MAPPER.readValue(jsonObject, StartEvent.class);\r
+            break;\r
+        case "endEvent":\r
+            element = MAPPER.readValue(jsonObject, EndEvent.class);\r
+            break;\r
+        default:\r
+            log.warn("Ignoring node: type '" + nodeType + "' is unkown");\r
+            return null;\r
+        }\r
+\r
+        return element;\r
        }\r
        \r
 }\r