Rework the submit operation
[clamp.git] / src / main / java / org / onap / clamp / policy / microservice / MicroServicePolicy.java
index 857a3d7..c2c60c9 100644 (file)
@@ -50,7 +50,7 @@ import org.onap.clamp.policy.Policy;
 @TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) })
 public class MicroServicePolicy implements Serializable, Policy {
     /**
-     *
+     * The serial version ID.
      */
     private static final long serialVersionUID = 6271238288583332616L;
 
@@ -59,6 +59,14 @@ public class MicroServicePolicy implements Serializable, Policy {
     @Column(nullable = false, name = "name", unique = true)
     private String name;
 
+    @Expose
+    @Column(nullable = false, name = "model_type")
+    private String modelType;
+
+    @Expose
+    @Column(nullable = false, name = "blueprint_name")
+    private String blueprintName;
+
     @Expose
     @Type(type = "json")
     @Column(columnDefinition = "json", name = "properties")
@@ -83,22 +91,45 @@ public class MicroServicePolicy implements Serializable, Policy {
         // serialization
     }
 
-    public MicroServicePolicy(String name, String policyTosca, Boolean shared, Set<Loop> usedByLoops) {
+    /**
+     * The constructor.
+     * @param name The name of the MicroService
+     * @param type The model type of the MicroService
+     * @param blueprintName The name in the blueprint
+     * @param policyTosca The policy Tosca of the MicroService
+     * @param shared The flag indicate whether the MicroService is shared
+     * @param usedByLoops The list of loops that uses this MicroService
+     */
+    public MicroServicePolicy(String name, String modelType, String policyTosca, Boolean shared, Set<Loop> usedByLoops, String blueprintName) {
         this.name = name;
+        this.modelType = modelType;
         this.policyTosca = policyTosca;
         this.shared = shared;
         this.jsonRepresentation = JsonUtils.GSON_JPA_MODEL
             .fromJson(new ToscaYamlToJsonConvertor(null).parseToscaYaml(policyTosca), JsonObject.class);
         this.usedByLoops = usedByLoops;
+        this.blueprintName = blueprintName;
     }
 
-    public MicroServicePolicy(String name, String policyTosca, Boolean shared, JsonObject jsonRepresentation,
-        Set<Loop> usedByLoops) {
+    /**
+     * The constructor.
+     * @param name The name of the MicroService
+     * @param type The model type of the MicroService
+     * @param blueprintName The name in the blueprint
+     * @param policyTosca The policy Tosca of the MicroService
+     * @param shared The flag indicate whether the MicroService is shared
+     * @param jsonRepresentation The UI representation in json format
+     * @param usedByLoops The list of loops that uses this MicroService
+     */
+    public MicroServicePolicy(String name, String modelType, String policyTosca, Boolean shared, JsonObject jsonRepresentation,
+        Set<Loop> usedByLoops, String blueprintName) {
         this.name = name;
+        this.modelType = modelType;
         this.policyTosca = policyTosca;
         this.shared = shared;
         this.usedByLoops = usedByLoops;
         this.jsonRepresentation = jsonRepresentation;
+        this.blueprintName = blueprintName;
     }
 
     @Override
@@ -106,6 +137,14 @@ public class MicroServicePolicy implements Serializable, Policy {
         return name;
     }
 
+    public String getModelType() {
+        return modelType;
+    }
+
+    public String getBlueprintName() {
+        return blueprintName;
+    }
+
     public JsonObject getProperties() {
         return properties;
     }
@@ -157,18 +196,23 @@ public class MicroServicePolicy implements Serializable, Policy {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         MicroServicePolicy other = (MicroServicePolicy) obj;
         if (name == null) {
-            if (other.name != null)
+            if (other.name != null) {
                 return false;
-        } else if (!name.equals(other.name))
+            }
+        } else if (!name.equals(other.name)) {
             return false;
+        }
         return true;
     }