Create get Pdp Groups flow
[clamp.git] / src / main / java / org / onap / clamp / loop / template / PolicyModel.java
index 52f662b..7334ece 100644 (file)
 
 package org.onap.clamp.loop.template;
 
+import com.google.gson.JsonObject;
 import com.google.gson.annotations.Expose;
-
 import java.io.Serializable;
 import java.util.HashSet;
 import java.util.Set;
-
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
@@ -37,6 +36,10 @@ import javax.persistence.IdClass;
 import javax.persistence.ManyToMany;
 import javax.persistence.Table;
 
+import org.hibernate.annotations.Type;
+import org.hibernate.annotations.TypeDef;
+import org.hibernate.annotations.TypeDefs;
+import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
 import org.onap.clamp.loop.common.AuditEntity;
 import org.onap.clamp.util.SemanticVersioning;
 
@@ -47,6 +50,7 @@ import org.onap.clamp.util.SemanticVersioning;
 @Entity
 @Table(name = "policy_models")
 @IdClass(PolicyModelId.class)
+@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)})
 public class PolicyModel extends AuditEntity implements Serializable, Comparable<PolicyModel> {
 
     /**
@@ -68,7 +72,7 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable
      */
     @Id
     @Expose
-    @Column(name = "version")
+    @Column(name = "version",nullable = false)
     private String version;
 
     @Column(columnDefinition = "MEDIUMTEXT", name = "policy_tosca")
@@ -81,18 +85,40 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable
     @ManyToMany(mappedBy = "policyModels", fetch = FetchType.EAGER)
     private Set<LoopElementModel> usedByElementModels = new HashSet<>();
 
+    @Type(type = "json")
+    @Column(columnDefinition = "json", name = "policy_pdp_group")
+    private JsonObject policyPdpGroup;
+
     /**
      * usedByElementModels getter.
-     * 
+     *
      * @return the usedByElementModels
      */
     public Set<LoopElementModel> getUsedByElementModels() {
         return usedByElementModels;
     }
 
+    /**
+     * policyPdpGroup getter.
+     *
+     * @return the policyPdpGroup
+     */
+    public JsonObject getPolicyPdpGroup() {
+        return policyPdpGroup;
+    }
+
+    /**
+     * policyPdpGroup setter.
+     *
+     * @param policyPdpGroup the policyPdpGroup to set
+     */
+    public void setPolicyPdpGroup(JsonObject policyPdpGroup) {
+        this.policyPdpGroup = policyPdpGroup;
+    }
+
     /**
      * policyModelTosca getter.
-     * 
+     *
      * @return the policyModelTosca
      */
     public String getPolicyModelTosca() {
@@ -101,7 +127,7 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable
 
     /**
      * policyModelTosca setter.
-     * 
+     *
      * @param policyModelTosca the policyModelTosca to set
      */
     public void setPolicyModelTosca(String policyModelTosca) {
@@ -110,7 +136,7 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable
 
     /**
      * policyModelType getter.
-     * 
+     *
      * @return the modelType
      */
     public String getPolicyModelType() {
@@ -119,7 +145,7 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable
 
     /**
      * policyModelType setter.
-     * 
+     *
      * @param modelType the modelType to set
      */
     public void setPolicyModelType(String modelType) {
@@ -128,7 +154,7 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable
 
     /**
      * version getter.
-     * 
+     *
      * @return the version
      */
     public String getVersion() {
@@ -137,7 +163,7 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable
 
     /**
      * version setter.
-     * 
+     *
      * @param version the version to set
      */
     public void setVersion(String version) {
@@ -147,7 +173,7 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable
 
     /**
      * policyAcronym getter.
-     * 
+     *
      * @return the policyAcronym value
      */
     public String getPolicyAcronym() {
@@ -156,7 +182,7 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable
 
     /**
      * policyAcronym setter.
-     * 
+     *
      * @param policyAcronym The policyAcronym to set
      */
     public void setPolicyAcronym(String policyAcronym) {
@@ -171,17 +197,21 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable
 
     /**
      * Constructor.
-     * 
-     * @param policyType       The policyType (referenced in the blueprint
+     *
+     * @param policyType The policyType (referenced in the blueprint
      * @param policyModelTosca The policy tosca model in yaml
-     * @param version          the version like 1.0.0
-     * @param policyAcronym    Subtype for policy if it exists (could be used by UI)
+     * @param version the version like 1.0.0
+     * @param policyAcronym Subtype for policy if it exists (could be used by UI)
      */
-    public PolicyModel(String policyType, String policyModelTosca, String version, String policyAcronym) {
+    public PolicyModel(String policyType, String policyModelTosca, String version,
+        String policyAcronym) {
         this.policyModelType = policyType;
         this.policyModelTosca = policyModelTosca;
         this.version = version;
-        this.policyAcronym = policyAcronym;
+        this.policyAcronym=policyAcronym;
+        if (this.policyAcronym == null) {
+            this.policyAcronym = createDefaultPolicyAcronym(policyType);
+        }
     }
 
     /**
@@ -192,7 +222,7 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable
      * @param version          the version like 1.0.0
      */
     public PolicyModel(String policyType, String policyModelTosca, String version) {
-        this(policyType, policyModelTosca, version, createDefaultPolicyAcronym(policyType));
+        this(policyType, policyModelTosca, version, null);
     }
 
     public static String createDefaultPolicyAcronym(String policyType) {