summaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-server/src
diff options
context:
space:
mode:
authorLvbo163 <lv.bo163@zte.com.cn>2017-09-28 11:12:24 +0800
committerLvbo163 <lv.bo163@zte.com.cn>2017-09-28 11:12:24 +0800
commit1061c1fd447e4fe341cc3ade66556d82f9f77d22 (patch)
treef367a86fdb3fd862815b4ce28bb6ebe7df5490a1 /sdc-workflow-designer-server/src
parent3ea4d9c46e82720e84dbad9126d6cc7cb3f50bff (diff)
extract json object keys to static variable
Issue-ID: SDC-413 Change-Id: Iaa4d823523448c6544b17865e235637250cd7668 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.java12
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/JsonKeys.java32
2 files changed, 38 insertions, 6 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 df11e402..8cad4d8c 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
@@ -51,7 +51,7 @@ public class Bpmn4ToscaJsonParser {
JsonNode rootNode = MAPPER.readValue(jsonFileUrl.toURL(), JsonNode.class);
log.debug("Creating Process models...");
- JsonNode nodes = rootNode.get("nodes");
+ JsonNode nodes = rootNode.get(JsonKeys.NODES);
if (nodes == null) {
return process;
}
@@ -75,14 +75,14 @@ public class Bpmn4ToscaJsonParser {
private List<SequenceFlow> getSequenceFlows(JsonNode jsonNode) {
List<SequenceFlow> flowList = new ArrayList<SequenceFlow>();
- JsonNode sequenceFlowNodes = jsonNode.get("sequenceFlows");
+ JsonNode sequenceFlowNodes = jsonNode.get(JsonKeys.SEQUENCE_FLOWS);
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");
+ String sourceRef = getValueFromJsonNode(connectionEntry, JsonKeys.SOURCE_REF);
+ String targetRef = getValueFromJsonNode(connectionEntry, JsonKeys.TARGET_REF);
+ String condition = getValueFromJsonNode(connectionEntry, JsonKeys.CONDITION);
SequenceFlow flow = new SequenceFlow();
flow.setId(sourceRef + targetRef);
flow.setSourceRef(sourceRef);
@@ -103,7 +103,7 @@ public class Bpmn4ToscaJsonParser {
String jsonObject = jsonNode.toString();
Element element;
- String nodeType = getValueFromJsonNode(jsonNode, "type");
+ String nodeType = getValueFromJsonNode(jsonNode, JsonKeys.TYPE);
switch (nodeType) {
case "startEvent":
element = MAPPER.readValue(jsonObject, StartEvent.class);
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/JsonKeys.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/JsonKeys.java
new file mode 100644
index 00000000..da97a348
--- /dev/null
+++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/JsonKeys.java
@@ -0,0 +1,32 @@
+/**
+ * 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.parser;
+
+public class JsonKeys {
+ // workflow keys
+ public static final String NODES = "nodes";
+ public static final String CONFIGS = "configs";
+
+ // configs keys
+ public static final String REST_CONFIGS = "restConfigs";
+ public static final String TYPE = "type";
+
+ // workflow node keys
+ public static final String SEQUENCE_FLOWS = "sequenceFlows";
+
+ // sequence flow keys
+ public static final String SOURCE_REF = "sourceRef";
+ public static final String TARGET_REF = "targetRef";
+ public static final String CONDITION = "condition";
+
+
+}