summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-05-08 11:33:43 +0200
committersebdet <sebastien.determe@intl.att.com>2019-05-08 12:15:39 +0200
commit7eb234559c64c4702ae621d7d2f531868677cdae (patch)
tree41197bb7f212889c8ffe26daef65ded277dff388 /src/main
parent41e8ba1581415521546a4f6e91bfcc1ed32710d6 (diff)
Fix model_type missing
Fix model missing in some cases (new DCAE Blueprint), also removed useless fields in MicroService Object Issue-ID: CLAMP-370 Change-Id: Ia246b5d58309aceb3168107a4bf76b92b23add7a Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java40
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java18
-rw-r--r--src/main/resources/clds/camel/routes/flexible-flow.xml6
3 files changed, 36 insertions, 28 deletions
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 809904f22..aca2ed01d 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
@@ -29,6 +29,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import java.util.AbstractMap;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -61,12 +62,12 @@ public class BlueprintParser {
public Set<MicroService> getMicroServices(String blueprintString) {
Set<MicroService> microServices = new HashSet<>();
JsonObject jsonObject = BlueprintParser.convertToJson(blueprintString);
- JsonObject results = jsonObject.get(NODE_TEMPLATES).getAsJsonObject();
+ JsonObject nodeTemplateList = jsonObject.get(NODE_TEMPLATES).getAsJsonObject();
- for (Entry<String, JsonElement> entry : results.entrySet()) {
+ for (Entry<String, JsonElement> entry : nodeTemplateList.entrySet()) {
JsonObject nodeTemplate = entry.getValue().getAsJsonObject();
if (nodeTemplate.get(TYPE).getAsString().contains(DCAE_NODES)) {
- MicroService microService = getNodeRepresentation(entry);
+ MicroService microService = getNodeRepresentation(entry, nodeTemplateList);
microServices.add(microService);
}
}
@@ -89,7 +90,7 @@ public class BlueprintParser {
}
String msName = theBiggestMicroServiceKey.toLowerCase().contains(HOLMES_PREFIX) ? HOLMES : TCA;
return Collections
- .singletonList(new MicroService(msName, "onap.policies.monitoring.cdap.tca.hi.lo.app", "", "", ""));
+ .singletonList(new MicroService(msName, "onap.policies.monitoring.cdap.tca.hi.lo.app", "", ""));
}
String getName(Entry<String, JsonElement> entry) {
@@ -118,8 +119,22 @@ public class BlueprintParser {
return "";
}
- String getModelType(Entry<String, JsonElement> entry) {
+ String findModelTypeInTargetArray(JsonArray jsonArray, JsonObject nodeTemplateList) {
+ for (JsonElement elem : jsonArray) {
+ String modelType = getModelType(
+ new AbstractMap.SimpleEntry<String, JsonElement>(elem.getAsJsonObject().get(TARGET).getAsString(),
+ nodeTemplateList.get(elem.getAsJsonObject().get(TARGET).getAsString()).getAsJsonObject()),
+ nodeTemplateList);
+ if (!modelType.isEmpty()) {
+ return modelType;
+ }
+ }
+ return "";
+ }
+
+ String getModelType(Entry<String, JsonElement> entry, JsonObject nodeTemplateList) {
JsonObject ob = entry.getValue().getAsJsonObject();
+ // Search first in this node template
if (ob.has(PROPERTIES)) {
JsonObject properties = ob.get(PROPERTIES).getAsJsonObject();
if (properties.has(POLICYID)) {
@@ -129,19 +144,18 @@ public class BlueprintParser {
}
}
}
+ // Then it's may be a relationship
+ if (ob.has(RELATIONSHIPS)) {
+ return findModelTypeInTargetArray(ob.get(RELATIONSHIPS).getAsJsonArray(), nodeTemplateList);
+ }
return "";
}
- String getBlueprintName(Entry<String, JsonElement> entry) {
- return entry.getKey();
- }
-
- MicroService getNodeRepresentation(Entry<String, JsonElement> entry) {
+ MicroService getNodeRepresentation(Entry<String, JsonElement> entry, JsonObject nodeTemplateList) {
String name = getName(entry);
String getInputFrom = getInput(entry);
- String modelType = getModelType(entry);
- String blueprintName = getBlueprintName(entry);
- return new MicroService(name, modelType, getInputFrom, "", blueprintName);
+ String modelType = getModelType(entry, nodeTemplateList);
+ return new MicroService(name, modelType, getInputFrom, "");
}
private String getTarget(JsonObject elementObject) {
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java
index ac4daeffb..9bc7a022a 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java
@@ -29,16 +29,14 @@ import java.util.Objects;
public class MicroService {
private final String name;
private final String modelType;
- private final String blueprintName;
private final String inputFrom;
private String mappedNameJpa;
- public MicroService(String name, String modelType, String inputFrom, String mappedNameJpa, String blueprintName) {
+ public MicroService(String name, String modelType, String inputFrom, String mappedNameJpa) {
this.name = name;
this.inputFrom = inputFrom;
this.mappedNameJpa = mappedNameJpa;
- this.modelType = modelType;
- this.blueprintName = blueprintName;
+ this.modelType = modelType;
}
public String getName() {
@@ -53,15 +51,10 @@ public class MicroService {
return inputFrom;
}
- public String getBlueprintName() {
- return blueprintName;
- }
-
@Override
public String toString() {
return "MicroService{" + "name='" + name + '\'' + ", modelType='" + modelType + '\'' + ", inputFrom='"
- + inputFrom + '\'' + ", mappedNameJpa='" + mappedNameJpa + '\'' + ", blueprintName='"
- + blueprintName + '\'' + '}';
+ + inputFrom + '\'' + ", mappedNameJpa='" + mappedNameJpa + '\'' + '}';
}
public String getMappedNameJpa() {
@@ -81,11 +74,12 @@ public class MicroService {
return false;
}
MicroService that = (MicroService) o;
- return name.equals(that.name) && modelType.equals(that.modelType) && inputFrom.equals(that.inputFrom) && mappedNameJpa.equals(that.mappedNameJpa) && blueprintName.equals(that.blueprintName);
+ return name.equals(that.name) && modelType.equals(that.modelType) && inputFrom.equals(that.inputFrom)
+ && mappedNameJpa.equals(that.mappedNameJpa);
}
@Override
public int hashCode() {
- return Objects.hash(name, modelType, inputFrom, mappedNameJpa, blueprintName);
+ return Objects.hash(name, modelType, inputFrom, mappedNameJpa);
}
}
diff --git a/src/main/resources/clds/camel/routes/flexible-flow.xml b/src/main/resources/clds/camel/routes/flexible-flow.xml
index b24525fe9..5f8577720 100644
--- a/src/main/resources/clds/camel/routes/flexible-flow.xml
+++ b/src/main/resources/clds/camel/routes/flexible-flow.xml
@@ -601,7 +601,7 @@
<doTry>
<log
loggingLevel="INFO"
- message="Query Closed Loop status from policy DPD: ${exchangeProperty[loopObject].getName()}" />
+ message="Query Closed Loop status from policy PDP: ${exchangeProperty[loopObject].getName()}" />
<to
uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Query operational policies to PDP group')" />
<setProperty propertyName="operationalPolicyName">
@@ -625,9 +625,9 @@
</setHeader>
<log
loggingLevel="INFO"
- message="Endpoint to query from Policy DPD: {{clamp.config.policy.pap.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicyName]}/versions/deployed"></log>
+ message="Endpoint to query from Policy PDP: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicyName]}/versions/deployed"></log>
<toD
- uri="{{clamp.config.policy.pap.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicyName]}/versions/deployed?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;httpClient.connectTimeout=10000&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.pap.userName}}&amp;authPassword={{clamp.config.policy.pap.password}}" />
+ uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicyName]}/versions/deployed?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;httpClient.connectTimeout=10000&amp;authMethod=Basic&amp;authUsername={{clamp.config.policy.pap.userName}}&amp;authPassword={{clamp.config.policy.pap.password}}" />
<doFinally>
<to uri="direct:reset-raise-http-exception-flag" />
<to