Domain model change
[portal.git] / portal-BE / src / main / java / org / onap / portal / domain / db / ep / EpWidgetCatalogParameter.java
index 3e6e1c6..ababeab 100644 (file)
@@ -45,23 +45,23 @@ import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
 import javax.persistence.Index;
 import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
 import javax.persistence.Table;
 import javax.validation.Valid;
-import javax.validation.constraints.Digits;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 import lombok.AllArgsConstructor;
+import lombok.Builder;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 import lombok.Setter;
 import org.hibernate.validator.constraints.SafeHtml;
 import org.onap.portal.domain.db.fn.FnUser;
+import org.onap.portal.domain.db.DomainVo;
 
 /*
 CREATE TABLE `ep_widget_catalog_parameter` (
@@ -80,33 +80,44 @@ CREATE TABLE `ep_widget_catalog_parameter` (
         )
 */
 
+
+@NamedQueries({
+        @NamedQuery(
+                name = "EpWidgetCatalogParameter.retrieveByParamId",
+                query = "FROM EpWidgetCatalogParameter WHERE paramId.id = :PARAMID"),
+        @NamedQuery(
+                name = "EpWidgetCatalogParameter.deleteWidgetCatalogParameter",
+                query = "DELETE FROM EpWidgetCatalogParameter WHERE paramId.id = :PARAMID"),
+        @NamedQuery(
+                name = "EpWidgetCatalogParameter.getUserParamById",
+                query = "FROM EpWidgetCatalogParameter WHERE paramId.id = :PARAMID and userId.id = :USERID and widgetId.widgetId = :WIDGETID"
+        )
+})
+
 @Table(name = "ep_widget_catalog_parameter", indexes = {
         @Index(name = "EP_FN_USER_WIDGET_PARAMETER_FK", columnList = "user_id"),
         @Index(name = "EP_WIDGET_CATALOG_WIDGET_PARAMETER_FK", columnList = "widget_id"),
         @Index(name = "EP_PARAMETER_ID_WIDGET_PARAMETER_FK", columnList = "param_id")
 })
-@NoArgsConstructor
-@AllArgsConstructor
+
 @Getter
 @Setter
 @Entity
-public class EpWidgetCatalogParameter implements Serializable {
-       @Id
-       @GeneratedValue(strategy = GenerationType.AUTO)
-       @Column(name = "id", length = 11, nullable = false, columnDefinition = "int(11) AUTO_INCREMENT")
-       @Digits(integer = 11, fraction = 0)
-       private Integer id;
-       @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class EpWidgetCatalogParameter extends DomainVo implements Serializable {
+       @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
        @JoinColumn(name = "widget_id", nullable = false)
        @NotNull
        @Valid
        private EpWidgetCatalog widgetId;
-       @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
-       @JoinColumn(name = "user_id", nullable = false)
+       @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
+       @JoinColumn(name = "user_id", nullable = false, columnDefinition = "bigint")
        @NotNull
        @Valid
        private FnUser userId;
-       @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
+       @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
        @JoinColumn(name = "param_id", nullable = false)
        @NotNull
        @Valid