From 2f4f12caf3bf04249ed3a0427e36c6b0693c74dd Mon Sep 17 00:00:00 2001 From: Lvbo163 Date: Tue, 26 Sep 2017 09:35:43 +0800 Subject: Support start and end event Support convert start and end event json object Issue-ID: SDC-396 Change-Id: I70d55908b0bd95f38e90a9bdda0a748cdcd3b08e Signed-off-by: Lvbo163 --- .../onap/sdc/workflowdesigner/model/EndEvent.java | 15 +++++++++++++++ .../onap/sdc/workflowdesigner/model/StartEvent.java | 15 +++++++++++++++ .../parser/Bpmn4ToscaJsonParser.java | 21 +++++++++++++++++++-- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/EndEvent.java create mode 100644 sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/StartEvent.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 index 00000000..86b1c8fc --- /dev/null +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/EndEvent.java @@ -0,0 +1,15 @@ +/** + * Copyright (c) 2017 ZTE Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and the Apache License 2.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 EndEvent extends Element { +} 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 index 00000000..963d332b --- /dev/null +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/StartEvent.java @@ -0,0 +1,15 @@ +/** + * Copyright (c) 2017 ZTE Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and the Apache License 2.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 StartEvent extends Element { +} 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 64bff27b..a7511482 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 @@ -19,8 +19,10 @@ import java.util.Iterator; import java.util.List; import org.onap.sdc.workflowdesigner.model.Element; +import org.onap.sdc.workflowdesigner.model.EndEvent; import org.onap.sdc.workflowdesigner.model.Process; import org.onap.sdc.workflowdesigner.model.SequenceFlow; +import org.onap.sdc.workflowdesigner.model.StartEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -96,8 +98,23 @@ public class Bpmn4ToscaJsonParser { } protected Element createElementFromJson(JsonNode jsonNode) throws JsonParseException, JsonMappingException, IOException { - String jsonObject = jsonNode.toString(); - return MAPPER.readValue(jsonObject, Element.class); + String jsonObject = jsonNode.toString(); + Element element; + + String nodeType = getValueFromJsonNode(jsonNode, "type"); + switch (nodeType) { + case "startEvent": + element = MAPPER.readValue(jsonObject, StartEvent.class); + break; + case "endEvent": + element = MAPPER.readValue(jsonObject, EndEvent.class); + break; + default: + log.warn("Ignoring node: type '" + nodeType + "' is unkown"); + return null; + } + + return element; } } -- cgit 1.2.3-korg