diff options
author | sebdet <sebastien.determe@intl.att.com> | 2020-02-27 14:43:57 -0800 |
---|---|---|
committer | sebdet <sebastien.determe@intl.att.com> | 2020-02-27 15:13:19 -0800 |
commit | 2d28cbf6954c50de004a0d8f1a2ada7ec400fea3 (patch) | |
tree | ef3bb61762221737c3716a0431d0f90f1c7a7a6c /src/main/java | |
parent | 95fc10c2f7db4ac8279e9eb595380b265e1614e8 (diff) |
Fix bug in operational policy
Fix bugs in camel routes and operational policy due to changes done for op policy insertion/removal
Issue-ID: CLAMP-647
Change-Id: I68524bd3d5bfbf5dd7a4bcf6d59853df07fd4dd9
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/main/java')
4 files changed, 17 insertions, 19 deletions
diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java b/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java index 5ec59dba..509d4e41 100755 --- a/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java +++ b/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java @@ -83,13 +83,12 @@ public class Painter { for (MicroServicePolicy ms : microServices) { ib.arrow().rectangle(ms.getName(), - RectTypes.MICROSERVICE, ms.getPolicyModel().getPolicyAcronym()).arrow(); + RectTypes.MICROSERVICE, ms.getPolicyModel().getPolicyAcronym()); } for (OperationalPolicy policy : policies) { - ib.arrow().rectangle(policy.getName(), RectTypes.POLICY, policy.getPolicyModel().getPolicyAcronym()) - .arrow(); + ib.arrow().rectangle(policy.getName(), RectTypes.POLICY, policy.getPolicyModel().getPolicyAcronym()); } - ib.circle("stop-circle", THICK_LINE); + ib.arrow().circle("stop-circle", THICK_LINE); } private void adjustGraphics2DProperties() { diff --git a/src/main/java/org/onap/clamp/loop/LoopController.java b/src/main/java/org/onap/clamp/loop/LoopController.java index 2ad47a3c..7ee088c4 100644 --- a/src/main/java/org/onap/clamp/loop/LoopController.java +++ b/src/main/java/org/onap/clamp/loop/LoopController.java @@ -39,11 +39,10 @@ public class LoopController { private final LoopService loopService; private static final Type OPERATIONAL_POLICY_TYPE = new TypeToken<List<OperationalPolicy>>() { - } - .getType(); + }.getType(); + private static final Type MICROSERVICE_POLICY_TYPE = new TypeToken<List<MicroServicePolicy>>() { - } - .getType(); + }.getType(); @Autowired public LoopController(LoopService loopService) { @@ -103,13 +102,13 @@ public class LoopController { /** * This method add an operational policy to a loop instance. * - * @param loopName The loop name - * @param policyType The policy model type + * @param loopName The loop name + * @param policyType The policy model type * @param policyVersion The policy model version * @return The loop modified */ public Loop addOperationalPolicy(String loopName, String policyType, String policyVersion) { - return loopService.addOperationalPolicy(loopName,policyType,policyVersion); + return loopService.addOperationalPolicy(loopName, policyType, policyVersion); } /** diff --git a/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java index 725bfe88..ff7777f7 100644 --- a/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java +++ b/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java @@ -173,7 +173,7 @@ public class LegacyOperationalPolicy { * @param loop The parent loop object */ public static void preloadConfiguration(JsonObject configurationsJson, Loop loop) { - if (configurationsJson.entrySet().isEmpty()) { + if (configurationsJson != null && configurationsJson.entrySet().isEmpty()) { JsonObject controlLoopName = new JsonObject(); controlLoopName.addProperty("controlLoopName", loop != null ? loop.getName() : "Empty (NO loop loaded yet)"); diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java index 52b87720..1c784057 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java @@ -32,7 +32,6 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; import com.google.gson.annotations.Expose; - import java.io.IOException; import java.io.Serializable; import java.io.UnsupportedEncodingException; @@ -40,7 +39,6 @@ import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -50,7 +48,6 @@ import javax.persistence.JoinColumns; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Transient; - import org.hibernate.annotations.TypeDef; import org.hibernate.annotations.TypeDefs; import org.onap.clamp.dao.model.jsontype.StringJsonUserType; @@ -94,12 +91,13 @@ public class OperationalPolicy extends Policy implements Serializable { /** * The constructor. - * @param name The name of the operational policy + * + * @param name The name of the operational policy * @param loop The loop that uses this operational policy * @param configurationsJson The operational policy property in the format of - * json + * json * @param policyModel The policy model associated if any, can be null - * @param loopElementModel The loop element from which this instance is supposed to be created + * @param loopElementModel The loop element from which this instance is supposed to be created */ public OperationalPolicy(String name, Loop loop, JsonObject configurationsJson, PolicyModel policyModel, LoopElementModel loopElementModel) { @@ -108,7 +106,9 @@ public class OperationalPolicy extends Policy implements Serializable { this.setPolicyModel(policyModel); this.setConfigurationsJson(configurationsJson); this.setLoopElementModel(loopElementModel); - LegacyOperationalPolicy.preloadConfiguration(configurationsJson, loop); + if (policyModel != null && policyModel.getPolicyModelType().contains("legacy")) { + LegacyOperationalPolicy.preloadConfiguration(configurationsJson, loop); + } try { this.setJsonRepresentation( OperationalPolicyRepresentationBuilder.generateOperationalPolicySchema(loop.getModelService())); |