Co-debug 'SubstitutionMapping' with tosca-yaml-parser.
author10090474 <yuan.hu1@zte.com.cn>
Thu, 15 Dec 2016 11:44:24 +0000 (19:44 +0800)
committer10090474 <yuan.hu1@zte.com.cn>
Thu, 15 Dec 2016 11:44:24 +0000 (19:44 +0800)
Change-Id: Ia7702741acbbdccd193d0f3ac5edde15d3ed9715
Issue-id: TOSCA-191
Signed-off-by: 10090474 <yuan.hu1@zte.com.cn>
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/entity/ParseYamlResult.java

index b02a6b2..632d60c 100644 (file)
@@ -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();
   }
 
 }
index 5bdab1c..4fc2d82 100644 (file)
@@ -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<String, String[]> jsonObjects2Requirements(JsonObject requirements) {
+        if (requirements == null) {
+          return new HashMap<String, String[]>();
+        }
+        
         Map<String, String[]> ret = new HashMap<String, String[]>();
-
         Iterator<Entry<String, JsonElement>> iterator = requirements.entrySet().iterator();
         while (iterator.hasNext()) {
           Entry<String, JsonElement> next = iterator.next();
@@ -529,8 +531,11 @@ public class ParseYamlResult {
       }
 
       private Map<String, String[]> jsonObject2Capabilities(JsonObject capabilities) {
+        if (capabilities == null) {
+          return new HashMap<String, String[]>();
+        }
+        
         Map<String, String[]> ret = new HashMap<String, String[]>();
-
         Iterator<Entry<String, JsonElement>> iterator = capabilities.entrySet().iterator();
         while (iterator.hasNext()) {
           Entry<String, JsonElement> 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<String, Object> getPropertyList() {
-        return jsonObject2Properties(properties);
-      }
-
-      private Map<String, Object> jsonObject2Properties(JsonObject properties) {
-        Map<String, Object> ret = new HashMap<>();
-        Iterator<Entry<String, JsonElement>> iterator = properties.entrySet().iterator();
-        while (iterator.hasNext()) {
-          Entry<String, JsonElement> next = iterator.next();
-          ret.put(next.getKey(), ToolUtil.getAsString(next.getValue()));
-        }
-        return ret;
-      }
     }
   }