From 4fb454c59d38b7748b678d5a58dd13c409d34962 Mon Sep 17 00:00:00 2001 From: 10090474 Date: Thu, 15 Dec 2016 19:44:24 +0800 Subject: Co-debug 'SubstitutionMapping' with tosca-yaml-parser. Change-Id: Ia7702741acbbdccd193d0f3ac5edde15d3ed9715 Issue-id: TOSCA-191 Signed-off-by: 10090474 --- .../parser/yaml/zte/ToscaYamlModelParser.java | 2 +- .../parser/yaml/zte/entity/ParseYamlResult.java | 45 +++++++--------------- 2 files changed, 15 insertions(+), 32 deletions(-) (limited to 'catalog-core/catalog-mgr') diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java index b02a6b23..632d60c4 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java @@ -229,7 +229,7 @@ public class ToscaYamlModelParser extends AbstractModelParser { if (result.getTopologyTemplate().getSubstitutionMappings() == null) { return null; } - return result.getTopologyTemplate().getSubstitutionMappings().getNodeType(); + return result.getTopologyTemplate().getSubstitutionMappings().getNode_type(); } } diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/entity/ParseYamlResult.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/entity/ParseYamlResult.java index 5bdab1c2..4fc2d825 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/entity/ParseYamlResult.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/entity/ParseYamlResult.java @@ -463,17 +463,16 @@ public class ParseYamlResult { } public class SubstitutionMapping { - private String nodeType; + private String node_type; private JsonObject requirements; private JsonObject capabilities; - private JsonObject properties; - - public String getNodeType() { - return nodeType; + + public String getNode_type() { + return node_type; } - public void setNodeType(String nodeType) { - this.nodeType = nodeType; + public void setNode_type(String node_type) { + this.node_type = node_type; } public JsonObject getRequirements() { @@ -489,8 +488,11 @@ public class ParseYamlResult { } private Map jsonObjects2Requirements(JsonObject requirements) { + if (requirements == null) { + return new HashMap(); + } + Map ret = new HashMap(); - Iterator> iterator = requirements.entrySet().iterator(); while (iterator.hasNext()) { Entry next = iterator.next(); @@ -529,8 +531,11 @@ public class ParseYamlResult { } private Map jsonObject2Capabilities(JsonObject capabilities) { + if (capabilities == null) { + return new HashMap(); + } + Map ret = new HashMap(); - Iterator> iterator = capabilities.entrySet().iterator(); while (iterator.hasNext()) { Entry next = iterator.next(); @@ -547,28 +552,6 @@ public class ParseYamlResult { return ret; } - - public JsonObject getProperties() { - return properties; - } - - public void setProperties(JsonObject properties) { - this.properties = properties; - } - - public Map getPropertyList() { - return jsonObject2Properties(properties); - } - - private Map jsonObject2Properties(JsonObject properties) { - Map ret = new HashMap<>(); - Iterator> iterator = properties.entrySet().iterator(); - while (iterator.hasNext()) { - Entry next = iterator.next(); - ret.put(next.getKey(), ToolUtil.getAsString(next.getValue())); - } - return ret; - } } } -- cgit 1.2.3-korg