From 62a0b7ca40d7810897fce2d1f8eb47e5647a2bf2 Mon Sep 17 00:00:00 2001 From: xuegao Date: Wed, 18 Dec 2019 11:17:53 +0100 Subject: Move jsonRepresentation Move the storage of jsonRepresentation to OperationalPolicy level Issue-ID: CLAMP-582 Change-Id: Id555ebc1f2f04468f7bf0ffd813de7732bcee97f Signed-off-by: xuegao --- src/main/java/org/onap/clamp/loop/Loop.java | 15 --------------- .../clamp/policy/operational/OperationalPolicy.java | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 16 deletions(-) (limited to 'src/main/java/org/onap') diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java index bf683660..531587a7 100644 --- a/src/main/java/org/onap/clamp/loop/Loop.java +++ b/src/main/java/org/onap/clamp/loop/Loop.java @@ -26,10 +26,8 @@ package org.onap.clamp.loop; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; 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.util.HashMap; import java.util.HashSet; @@ -65,7 +63,6 @@ import org.onap.clamp.loop.log.LoopLog; import org.onap.clamp.loop.service.Service; import org.onap.clamp.policy.microservice.MicroServicePolicy; import org.onap.clamp.policy.operational.OperationalPolicy; -import org.onap.clamp.policy.operational.OperationalPolicyRepresentationBuilder; @Entity @Table(name = "loops") @@ -100,11 +97,6 @@ public class Loop implements Serializable { @Column(columnDefinition = "MEDIUMTEXT", name = "svg_representation") private String svgRepresentation; - @Expose - @Type(type = "json") - @Column(columnDefinition = "json", name = "operational_policy_schema") - private JsonObject operationalPolicySchema; - @Expose @Type(type = "json") @Column(columnDefinition = "json", name = "global_properties_json") @@ -274,13 +266,6 @@ public class Loop implements Serializable { void setModelService(Service modelService) { this.modelService = modelService; - try { - this.operationalPolicySchema = OperationalPolicyRepresentationBuilder - .generateOperationalPolicySchema(this.getModelService()); - } catch (JsonSyntaxException | IOException | NullPointerException e) { - logger.error("Unable to generate the operational policy Schema ... ", e); - this.operationalPolicySchema = new JsonObject(); - } } public Map getComponents() { 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 c6ed4984..14112694 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java @@ -30,8 +30,10 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; 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; import java.net.URLEncoder; @@ -79,6 +81,11 @@ public class OperationalPolicy implements Serializable, Policy { @Column(columnDefinition = "json", name = "configurations_json") private JsonObject configurationsJson; + @Expose + @Type(type = "json") + @Column(columnDefinition = "json", name = "json_representation", nullable = false) + private JsonObject jsonRepresentation; + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "loop_id", nullable = false) private Loop loop; @@ -100,6 +107,13 @@ public class OperationalPolicy implements Serializable, Policy { this.loop = loop; this.configurationsJson = configurationsJson; LegacyOperationalPolicy.preloadConfiguration(this.configurationsJson, loop); + try { + this.jsonRepresentation = OperationalPolicyRepresentationBuilder + .generateOperationalPolicySchema(loop.getModelService()); + } catch (JsonSyntaxException | IOException | NullPointerException e) { + logger.error("Unable to generate the operational policy Schema ... ", e); + this.jsonRepresentation = new JsonObject(); + } } @Override @@ -125,7 +139,11 @@ public class OperationalPolicy implements Serializable, Policy { @Override public JsonObject getJsonRepresentation() { - return null; + return jsonRepresentation; + } + + void setJsonRepresentation(JsonObject jsonRepresentation) { + this.jsonRepresentation = jsonRepresentation; } @Override -- cgit 1.2.3-korg