created Api for closed loop managing
[clamp.git] / src / main / java / org / onap / clamp / loop / Loop.java
@@ -21,7 +21,7 @@
  *
  */
 
-package org.onap.clamp.dao.model;
+package org.onap.clamp.loop;
 
 import com.google.gson.JsonObject;
 import com.google.gson.annotations.Expose;
@@ -46,6 +46,9 @@ import javax.persistence.Table;
 import org.hibernate.annotations.Type;
 import org.hibernate.annotations.TypeDef;
 import org.hibernate.annotations.TypeDefs;
+import org.onap.clamp.loop.log.LoopLog;
+import org.onap.clamp.policy.microservice.MicroServicePolicy;
+import org.onap.clamp.policy.operational.OperationalPolicy;
 import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
 
 @Entity
@@ -75,7 +78,6 @@ public class Loop implements Serializable {
     @Column(name = "dcae_blueprint_id")
     private String dcaeBlueprintId;
 
-    @Expose
     @Column(name = "svg_representation")
     private String svgRepresentation;
 
@@ -84,7 +86,6 @@ public class Loop implements Serializable {
     @Column(columnDefinition = "json", name = "global_properties_json")
     private JsonObject globalPropertiesJson;
 
-    @Expose
     @Column(nullable = false, name = "blueprint_yaml")
     private String blueprint;
 
@@ -106,11 +107,22 @@ public class Loop implements Serializable {
     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "loop")
     private Set<LoopLog> loopLogs = new HashSet<>();
 
+    public Loop() {
+    }
+
+    public Loop(String name, String blueprint, String svgRepresentation) {
+        this.name = name;
+        this.svgRepresentation = svgRepresentation;
+        this.blueprint = blueprint;
+        this.lastComputedState = LoopState.DESIGN;
+        this.globalPropertiesJson = new JsonObject();
+    }
+
     public String getName() {
         return name;
     }
 
-    public void setName(String name) {
+    void setName(String name) {
         this.name = name;
     }
 
@@ -118,7 +130,7 @@ public class Loop implements Serializable {
         return dcaeDeploymentId;
     }
 
-    public void setDcaeDeploymentId(String dcaeDeploymentId) {
+    void setDcaeDeploymentId(String dcaeDeploymentId) {
         this.dcaeDeploymentId = dcaeDeploymentId;
     }
 
@@ -126,7 +138,7 @@ public class Loop implements Serializable {
         return dcaeDeploymentStatusUrl;
     }
 
-    public void setDcaeDeploymentStatusUrl(String dcaeDeploymentStatusUrl) {
+    void setDcaeDeploymentStatusUrl(String dcaeDeploymentStatusUrl) {
         this.dcaeDeploymentStatusUrl = dcaeDeploymentStatusUrl;
     }
 
@@ -134,7 +146,7 @@ public class Loop implements Serializable {
         return svgRepresentation;
     }
 
-    public void setSvgRepresentation(String svgRepresentation) {
+    void setSvgRepresentation(String svgRepresentation) {
         this.svgRepresentation = svgRepresentation;
     }
 
@@ -142,61 +154,61 @@ public class Loop implements Serializable {
         return blueprint;
     }
 
-    public void setBlueprint(String blueprint) {
+    void setBlueprint(String blueprint) {
         this.blueprint = blueprint;
     }
 
-    public LoopState getLastComputedState() {
+    LoopState getLastComputedState() {
         return lastComputedState;
     }
 
-    public void setLastComputedState(LoopState lastComputedState) {
+    void setLastComputedState(LoopState lastComputedState) {
         this.lastComputedState = lastComputedState;
     }
 
-    public Set<OperationalPolicy> getOperationalPolicies() {
+    Set<OperationalPolicy> getOperationalPolicies() {
         return operationalPolicies;
     }
 
-    public void setOperationalPolicies(Set<OperationalPolicy> operationalPolicies) {
+    void setOperationalPolicies(Set<OperationalPolicy> operationalPolicies) {
         this.operationalPolicies = operationalPolicies;
     }
 
-    public Set<MicroServicePolicy> getMicroServicePolicies() {
+    Set<MicroServicePolicy> getMicroServicePolicies() {
         return microServicePolicies;
     }
 
-    public void setMicroServicePolicies(Set<MicroServicePolicy> microServicePolicies) {
+    void setMicroServicePolicies(Set<MicroServicePolicy> microServicePolicies) {
         this.microServicePolicies = microServicePolicies;
     }
 
-    public JsonObject getGlobalPropertiesJson() {
+    JsonObject getGlobalPropertiesJson() {
         return globalPropertiesJson;
     }
 
-    public void setGlobalPropertiesJson(JsonObject globalPropertiesJson) {
+    void setGlobalPropertiesJson(JsonObject globalPropertiesJson) {
         this.globalPropertiesJson = globalPropertiesJson;
     }
 
-    public Set<LoopLog> getLoopLogs() {
+    Set<LoopLog> getLoopLogs() {
         return loopLogs;
     }
 
-    public void setLoopLogs(Set<LoopLog> loopLogs) {
+    void setLoopLogs(Set<LoopLog> loopLogs) {
         this.loopLogs = loopLogs;
     }
 
-    public void addOperationalPolicy(OperationalPolicy opPolicy) {
-        opPolicy.setLoop(this);
+    void addOperationalPolicy(OperationalPolicy opPolicy) {
         operationalPolicies.add(opPolicy);
+        opPolicy.setLoop(this);
     }
 
-    public void addMicroServicePolicy(MicroServicePolicy microServicePolicy) {
+    void addMicroServicePolicy(MicroServicePolicy microServicePolicy) {
         microServicePolicies.add(microServicePolicy);
         microServicePolicy.getUsedByLoops().add(this);
     }
 
-    public void addLog(LoopLog log) {
+    void addLog(LoopLog log) {
         loopLogs.add(log);
         log.setLoop(this);
     }