aboutsummaryrefslogtreecommitdiffstats
path: root/deprecated-workflow-designer/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser
diff options
context:
space:
mode:
Diffstat (limited to 'deprecated-workflow-designer/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser')
-rw-r--r--deprecated-workflow-designer/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParser.java216
-rw-r--r--deprecated-workflow-designer/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/JsonKeys.java92
2 files changed, 0 insertions, 308 deletions
diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParser.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParser.java
deleted file mode 100644
index f41faa37..00000000
--- a/deprecated-workflow-designer/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParser.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/**
- * Copyright (c) 2017-2018 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.parser;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-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.ErrorEndEvent;
-import org.onap.sdc.workflowdesigner.model.ErrorStartEvent;
-import org.onap.sdc.workflowdesigner.model.ExclusiveGateway;
-import org.onap.sdc.workflowdesigner.model.IntermediateCatchEvent;
-import org.onap.sdc.workflowdesigner.model.ParallelGateway;
-import org.onap.sdc.workflowdesigner.model.Parameter;
-import org.onap.sdc.workflowdesigner.model.Process;
-import org.onap.sdc.workflowdesigner.model.RestServiceTask;
-import org.onap.sdc.workflowdesigner.model.ScriptTask;
-import org.onap.sdc.workflowdesigner.model.SequenceFlow;
-import org.onap.sdc.workflowdesigner.model.ServiceTask;
-import org.onap.sdc.workflowdesigner.model.StartEvent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-
-public class Bpmn4ToscaJsonParser {
-
- private static Logger log = LoggerFactory.getLogger(Bpmn4ToscaJsonParser.class);
-
- private static ObjectMapper MAPPER = new ObjectMapper();
-
- private Map<String, JsonNode> restConfigMap = new HashMap<String, JsonNode>();
-
- static {
- MAPPER.enable(SerializationFeature.INDENT_OUTPUT);
- MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- }
-
- public Process parse(String processName, URI jsonFileUrl)
- throws JsonParseException, JsonMappingException, MalformedURLException, IOException {
- Process process = new Process(processName);
-
- JsonNode rootNode = MAPPER.readValue(jsonFileUrl.toURL(), JsonNode.class);
-
- log.debug("Creating Process models...");
-// JsonNode nodes = rootNode.get(JsonKeys.NODES);
- JsonNode data = rootNode.get(JsonKeys.DATA);
- if(null == data) {
- return process;
- }
- JsonNode nodes = data.get(JsonKeys.NODES);
- if (nodes == null) {
- return process;
- }
-
- this.loadConfigs(rootNode.get(JsonKeys.CONFIGS));
-
- Iterator<JsonNode> iter = nodes.iterator();
- while (iter.hasNext()) {
- JsonNode jsonNode = (JsonNode) iter.next();
-
- // get element
- Element element = createElementFromJson(jsonNode);
- process.getElementList().add(element);
-
- // 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 void loadConfigs(JsonNode config) {
- if(config == null) {
- return;
- }
- loadRestConfigs(config.get(JsonKeys.REST_CONFIGS));
- }
-
- private void loadRestConfigs(JsonNode restConfigs) {
- if(restConfigs == null) {
- return;
- }
-
- Iterator<JsonNode> iter = restConfigs.iterator();
- while (iter.hasNext()) {
- JsonNode restConfig = (JsonNode) iter.next();
-
- String configId = getValueFromJsonNode(restConfig, JsonKeys.ID);
- restConfigMap.put(configId, restConfig);
- }
- }
-
- private List<SequenceFlow> getSequenceFlows(JsonNode jsonNode) {
- List<SequenceFlow> flowList = new ArrayList<SequenceFlow>();
- String elementId = getValueFromJsonNode(jsonNode, JsonKeys.ID);
- JsonNode connectionsNode = jsonNode.get(JsonKeys.CONNECTIONS);
-
- Iterator<JsonNode> iter = connectionsNode.iterator();
- while (iter.hasNext()) {
- JsonNode connectionEntry = (JsonNode) iter.next();
- String targetRef = getValueFromJsonNode(connectionEntry, JsonKeys.TARGET_REF);
- String condition = getValueFromJsonNode(connectionEntry, JsonKeys.CONDITION);
- SequenceFlow flow = new SequenceFlow();
- flow.setId(elementId + targetRef);
- flow.setSourceRef(elementId);
- flow.setTargetRef(targetRef);
- flow.setCondition(condition);
- flowList.add(flow);
- }
-
- return flowList;
- }
-
- protected Element createElementFromJson(JsonNode jsonNode)
- throws JsonParseException, JsonMappingException, IOException {
- String jsonObject = jsonNode.toString();
- Element element;
-
- String nodeType = getValueFromJsonNode(jsonNode, JsonKeys.TYPE);
- if (nodeType == null) {
- log.warn("Ignoring node: type is null");
- return null;
- }
-
- switch (nodeType) {
- case "startEvent":
- element = MAPPER.readValue(jsonObject, StartEvent.class);
- break;
- case "endEvent":
- element = MAPPER.readValue(jsonObject, EndEvent.class);
- break;
- case "errorStartEvent":
- element = MAPPER.readValue(jsonObject, ErrorStartEvent.class);
- break;
- case "errorEndEvent":
- element = MAPPER.readValue(jsonObject, ErrorEndEvent.class);
- break;
- case "intermediateCatchEvent":
- element = MAPPER.readValue(jsonObject, IntermediateCatchEvent.class);
- break;
- case "serviceTask":
- element = MAPPER.readValue(jsonObject, ServiceTask.class);
- break;
- case "restTask":
- // element = this.createRestServiceTask(jsonObject);
- element = MAPPER.readValue(jsonObject, RestServiceTask.class);
- break;
- case "scriptTask":
- element = MAPPER.readValue(jsonObject, ScriptTask.class);
- break;
- case "exclusiveGateway":
- element = MAPPER.readValue(jsonObject, ExclusiveGateway.class);
- break;
- case "parallelGateway":
- element = MAPPER.readValue(jsonObject, ParallelGateway.class);
- break;
- default:
- log.warn("Ignoring node: type '" + nodeType + "' is unkown");
- return null;
- }
-
- return element;
- }
-
-
- private String getValueFromJsonNode(JsonNode jsonNode, String key) {
- return jsonNode.get(key) == null ? null : jsonNode.get(key).asText();
- }
-
-}
diff --git a/deprecated-workflow-designer/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/JsonKeys.java b/deprecated-workflow-designer/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/JsonKeys.java
deleted file mode 100644
index 6128cfdf..00000000
--- a/deprecated-workflow-designer/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/JsonKeys.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * Copyright (c) 2017-2018 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.parser;
-
-public interface JsonKeys {
-
-
- /*
- * Field names of BPMN4Tosca Model
- */
- public static final String DATA = "data";
- public static final String NODES = "nodes";
- public static final String REST_CONFIGS = "restConfigs";
- public static final String CONFIGS = "configs";
-
-
- // microservice info
- public static final String MICROSERVICE_URL = "url";
- public static final String MICROSERVICE_NAME = "name";
- public static final String MICROSERVICE_VERSION = "version";
-
- public static final String NAME = "name";
-
- public static final String ID = "id";
-
- public static final String TYPE = "type";
-
- public static final String INPUT = "input";
-
- public static final String OUTPUT = "output";
-
- public static final String VALUE = "value";
-
- public static final String NODE_TEMPLATE = "node_template";
-
- public static final String NODE_OPERATION = "node_operation";
-
- public static final String NODE_INTERFACE_NAME = "interface";
-
- public static final String CONNECTIONS = "connection";
-
- public static final String SOURCE_REF = "sourceRef";
-
- public static final String TARGET_REF = "targetRef";
-
- public static final String CONDITIONS = "conditions";
-
- public static final String CONDITION = "condition";
-
- public static final String DEFAULT = "default";
-
-
- /*
- * Exclusive-Gateway, Event, Management-Task Types
- *
- */
- public static final String NODE_TYPE_MGMT_TASK = "ToscaNodeManagementTask";
-
- public static final String NODE_TYPE_START_EVENT = "StartEvent";
-
- public static final String NODE_TYPE_END_EVENT = "EndEvent";
-
- public static final String NODE_TYPE_GATEWAY_EXCLUSIVE = "ExclusiveGateway";
-
- public static final String NODE_TYPE_GATEWAY_EXCLUSIVE_END = "ExclusiveGatewayEnd";
-
-
- /*
- * Parameter Types
- */
- public static final String PARAM_TYPE_VALUE_STRING = "string";
-
- public static final String PARAM_TYPE_VALUE_TOPOLOGY = "topology";
-
- public static final String PARAM_TYPE_VALUE_PLAN = "plan";
-
- public static final String PARAM_TYPE_VALUE_CONCAT = "concat";
-
- public static final String PARAM_TYPE_VALUE_IA = "implementation_artifact";
-
- public static final String PARAM_TYPE_VALUE_DA = "deployment_artifact";
-
-}