diff options
author | xuegao <xg353y@intl.att.com> | 2019-12-18 11:17:53 +0100 |
---|---|---|
committer | xuegao <xg353y@intl.att.com> | 2019-12-18 11:17:53 +0100 |
commit | 62a0b7ca40d7810897fce2d1f8eb47e5647a2bf2 (patch) | |
tree | b54dd8a88ae304ca58c347686df07815f8aab84b /src/main | |
parent | 9047defa7549ebd9a84cef3e10bbfd90f068097b (diff) |
Move jsonRepresentation
Move the storage of jsonRepresentation to OperationalPolicy level
Issue-ID: CLAMP-582
Change-Id: Id555ebc1f2f04468f7bf0ffd813de7732bcee97f
Signed-off-by: xuegao <xg353y@intl.att.com>
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/onap/clamp/loop/Loop.java | 15 | ||||
-rw-r--r-- | src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java | 20 |
2 files changed, 19 insertions, 16 deletions
diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java index bf6836607..531587a75 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") @@ -102,11 +99,6 @@ public class Loop implements Serializable { @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") private JsonObject globalPropertiesJson; @@ -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<String, ExternalComponent> 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 c6ed49847..14112694e 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 |