diff options
author | 2019-06-13 15:57:48 +0200 | |
---|---|---|
committer | 2019-06-13 15:58:44 +0200 | |
commit | e700fd66f7cfd019bcacb7203a1e01fad24e3f8b (patch) | |
tree | 2a92449ba6373965df1e83197eb472c5ef78ca69 /ecomp-portal-BE-common/src/main/java | |
parent | e98d94edaa2276b33959f5ef6d45f3fdeeab37ee (diff) |
FunctionalMenuItem DB constraints add
Java Bean Validation SR 380 annotations added to classes
Unnecessary boxing removed.
Issue-ID: PORTAL-626
Signed-off-by: Dominik Mizyn <d.mizyn@samsung.com>
Change-Id: Ic1c20870fd781d46061077fd14b81a65dea93e6e
Diffstat (limited to 'ecomp-portal-BE-common/src/main/java')
2 files changed, 47 insertions, 13 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java index 5b5e37c4..e321512a 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/FunctionalMenuItemWithAppID.java @@ -38,13 +38,18 @@ package org.onap.portalapp.portal.domain; import java.util.List; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Transient; +import javax.validation.constraints.Max; +import javax.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.SafeHtml; + /*** * * This class is almost identical to org.onap.portalapp.portal.transport.FunctionalMenuItem @@ -55,6 +60,8 @@ import javax.persistence.Transient; * */ @Entity +@NoArgsConstructor +@AllArgsConstructor public class FunctionalMenuItemWithAppID{ private static final long serialVersionUID = 1L; @@ -64,18 +71,29 @@ public class FunctionalMenuItemWithAppID{ public Long menuId; @Column(name = "COLUMN_NUM") + @Max(value = 99) + @NotNull public Integer column; @Column(name = "TEXT") + @Max(value = 100) + @SafeHtml + @NotNull public String text; @Column(name = "PARENT_MENU_ID") public Integer parentMenuId; @Column(name = "URL") + @Max(value = 128) + @SafeHtml + @NotNull public String url; @Column(name="ACTIVE_YN") + @Max(value = 1) + @SafeHtml + @NotNull public String active_yn; @Column(name="APP_ID") @@ -89,10 +107,10 @@ public class FunctionalMenuItemWithAppID{ public void normalize() { if (this.column == null) - this.column = new Integer(1); + this.column = 1; this.text = (this.text == null) ? "" : this.text.trim(); if (this.parentMenuId == null) - this.parentMenuId = new Integer(-1); + this.parentMenuId = -1; this.url = (this.url == null) ? "" : this.url.trim(); } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/FunctionalMenuItem.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/FunctionalMenuItem.java index 06acdb7b..6848d6ae 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/FunctionalMenuItem.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/transport/FunctionalMenuItem.java @@ -47,12 +47,17 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Transient; +import javax.validation.constraints.Max; +import javax.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.SafeHtml; @Entity @Table(name="fn_menu_functional") +@NoArgsConstructor +@AllArgsConstructor public class FunctionalMenuItem implements Serializable { - public FunctionalMenuItem(){}; - private static final long serialVersionUID = 1L; @Id @@ -61,23 +66,40 @@ public class FunctionalMenuItem implements Serializable { public Long menuId; @Column(name = "COLUMN_NUM") + @Max(value = 99) + @NotNull public Integer column; @Column(name = "TEXT") + @Max(value = 100) + @SafeHtml + @NotNull public String text; @Column(name = "PARENT_MENU_ID") public Integer parentMenuId; @Column(name = "URL") + @Max(value = 128) + @SafeHtml + @NotNull public String url; @Column(name="ACTIVE_YN") + @Max(value = 1) + @SafeHtml + @NotNull public String active_yn; @Transient public Integer appid; + @Transient + private List<Integer> roles; + + @Transient + public Boolean restrictedApp; + public List<Integer> getRoles() { return roles; } @@ -86,18 +108,12 @@ public class FunctionalMenuItem implements Serializable { this.roles = roles; } - @Transient - private List<Integer> roles; - - @Transient - public Boolean restrictedApp; - public void normalize() { if (this.column == null) - this.column = new Integer(1); + this.column = 1; this.text = (this.text == null) ? "" : this.text.trim(); if (this.parentMenuId == null) - this.parentMenuId = new Integer(-1); + this.parentMenuId = -1; this.url = (this.url == null) ? "" : this.url.trim(); } |