X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fclamp%2Fclds%2Fsdc%2Fcontroller%2Finstaller%2FBlueprintParser.java;h=7447fbae14e7402c3b253d6302a1f4cb4eeff49e;hb=a6d09fbe1046057b72247f97ac72a521949409ce;hp=c8de4c589a393d3470238a9b9d52ebfee0c805a3;hpb=c62d1b74275b8d5e9d4cef6c308ef16440cfa500;p=clamp.git diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java index c8de4c58..7447fbae 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java @@ -27,6 +27,7 @@ import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import java.util.Collections; import java.util.HashSet; @@ -51,6 +52,8 @@ public class BlueprintParser { private static final String TYPE = "type"; private static final String PROPERTIES = "properties"; private static final String NAME = "name"; + private static final String POLICYID = "policy_id"; + private static final String POLICY_TYPEID = "policy_type_id"; private static final String RELATIONSHIPS = "relationships"; private static final String CLAMP_NODE_RELATIONSHIPS_GETS_INPUT_FROM = "clamp_node.relationships.gets_input_from"; private static final String TARGET = "target"; @@ -85,7 +88,7 @@ public class BlueprintParser { } } String msName = theBiggestMicroServiceKey.toLowerCase().contains(HOLMES_PREFIX) ? HOLMES : TCA; - return Collections.singletonList(new MicroService(msName, "", "")); + return Collections.singletonList(new MicroService(msName, "", "", "", "")); } String getName(Entry entry) { @@ -114,10 +117,30 @@ public class BlueprintParser { return ""; } + String getModelType(Entry entry) { + JsonObject ob = entry.getValue().getAsJsonObject(); + if (ob.has(PROPERTIES)) { + JsonObject properties = ob.get(PROPERTIES).getAsJsonObject(); + if (properties.has(POLICYID)) { + JsonObject policyIdObj = properties.get(POLICYID).getAsJsonObject(); + if (policyIdObj.has(POLICY_TYPEID)) { + return policyIdObj.get(POLICY_TYPEID).getAsString(); + } + } + } + return ""; + } + + String getBlueprintName(Entry entry) { + return entry.getKey(); + } + MicroService getNodeRepresentation(Entry entry) { String name = getName(entry); String getInputFrom = getInput(entry); - return new MicroService(name, getInputFrom, ""); + String modelType = getModelType(entry); + String blueprintName = getBlueprintName(entry); + return new MicroService(name, modelType, getInputFrom, "", blueprintName); } private String getTarget(JsonObject elementObject) {