X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=portal-BE%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportal%2Fdomain%2Fdb%2Ffn%2FFnRole.java;h=275ce1e37cdec6fe849ad78b34a02dc19cb087c0;hb=d904fc786956891946e7bd92b559fdb98f62330f;hp=dc4578832323076f5316fdc524b95bb1116fca66;hpb=7ce177cd99096772ff42ef89d8820070c687fd9b;p=portal.git diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java index dc457883..275ce1e3 100644 --- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java +++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java @@ -40,8 +40,8 @@ package org.onap.portal.domain.db.fn; -import java.util.ArrayList; -import java.util.List; +import java.io.Serializable; +import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -59,7 +59,6 @@ import javax.persistence.OneToMany; import javax.persistence.Table; import javax.validation.constraints.Digits; import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import lombok.AllArgsConstructor; import lombok.Getter; @@ -70,6 +69,7 @@ import org.onap.portal.domain.db.ep.EpAppRoleFunction; import org.onap.portal.domain.db.ep.EpRoleNotification; import org.onap.portal.domain.db.ep.EpUserRolesRequestDet; import org.onap.portal.domain.db.ep.EpWidgetCatalogRole; +import org.onap.portal.domain.dto.DomainVo; /* CREATE TABLE `fn_role` ( @@ -99,7 +99,7 @@ CREATE TABLE `fn_role` ( query = "FROM FnRole where role_id =:roleId and app_id is null"), @NamedQuery( name = "FnRole.retrieveAppRoleByAppRoleIdAndByAppId", - query = "FROM FnRole where app_role_id =:appRoleId and app_id =:appId"), + query = "FROM FnRole where appRoleId =:appRoleId and appId =:appId"), @NamedQuery( name = "FnRole.retrieveAppRoleByRoleIdAndAppId", query = "FROM FnRole where role_id =:roleId and app_id =:appId"), @@ -110,8 +110,18 @@ CREATE TABLE `fn_role` ( name = "FnRole.retrieveActiveRolesOfApplication", query = "from FnRole where active_yn = 'Y' and app_id=:appId"), @NamedQuery(name = "FnRole.retrieveRoleToUpdateInExternalAuthSystem", - query = "FROM FnRole where role_name =:roleName and app_id =:appId") -}) + query = "FROM FnRole where role_name =:roleName and app_id =:appId"), + @NamedQuery( + name = "FnRole.getUserRoleOnUserIdAndAppId", + query = " FROM" + + " FnRole fr,\n" + + " FnUserRole fur\n" + + " WHERE\n" + + " fr.roleId = fur.roleId\n" + + " AND fur.userId = :userId" + + " AND fur.appId = :appId\n" + + " AND fr.activeYn = 'y'") + }) @Table(name = "fn_role", indexes = { @Index(name = "fn_role_name_app_id_idx", columnList = "role_name, app_id", unique = true) @@ -121,7 +131,7 @@ CREATE TABLE `fn_role` ( @Getter @Setter @Entity -public class FnRole { +public class FnRole extends DomainVo implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @@ -134,11 +144,8 @@ public class FnRole { @SafeHtml private String roleName; @Column(name = "active_yn", length = 1, columnDefinition = "character varying(1) default 'y'", nullable = false) - @Pattern(regexp = "[YNyn]") - @Size(max = 1) @NotNull - @SafeHtml - private String activeYn; + private Boolean activeYn; @Column(name = "priority", length = 4, columnDefinition = "decimal(4,0) DEFAULT NULL") @Digits(integer = 4, fraction = 0) private Long priority; @@ -154,7 +161,7 @@ public class FnRole { cascade = CascadeType.ALL, fetch = FetchType.LAZY ) - private List fnRoleFunctions = new ArrayList<>(); + private Set fnRoleFunctions; @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinTable( name = "fn_user_pseudo_role", @@ -164,7 +171,7 @@ public class FnRole { @Index(name = "fk_pseudo_role_user_id", columnList = "user_id") } ) - private List fnUsers = new ArrayList<>(); + private Set fnUsers; @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinTable( name = "fn_role_composite", @@ -174,49 +181,50 @@ public class FnRole { @Index(name = "fk_fn_role_composite_child", columnList = "child_role_id") } ) - private List fnRoles = new ArrayList<>(); - @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - private List fnRoleList = new ArrayList<>(); + private Set fnRoles; + @ManyToMany(cascade = CascadeType.ALL, + fetch = FetchType.LAZY) + private Set fnRoleList; @OneToMany( targetEntity = EpRoleNotification.class, mappedBy = "notificationID", cascade = CascadeType.ALL, fetch = FetchType.LAZY ) - private List epRoleNotifications = new ArrayList<>(); + private Set epRoleNotifications; @OneToMany( targetEntity = FnMenuFunctionalRoles.class, mappedBy = "roleId", cascade = CascadeType.ALL, fetch = FetchType.LAZY ) - private List fnMenuFunctionalRoles = new ArrayList<>(); + private Set fnMenuFunctionalRoles; @OneToMany( targetEntity = EpWidgetCatalogRole.class, mappedBy = "roleId", cascade = CascadeType.ALL, fetch = FetchType.LAZY ) - private List epWidgetCatalogRoles = new ArrayList<>(); + private Set epWidgetCatalogRoles; @OneToMany( targetEntity = EpAppRoleFunction.class, mappedBy = "fnRole", cascade = CascadeType.ALL, fetch = FetchType.LAZY ) - private List epAppRoleFunctions = new ArrayList<>(); + private Set epAppRoleFunctions; @OneToMany( targetEntity = EpUserRolesRequestDet.class, mappedBy = "requestedRoleId", cascade = CascadeType.ALL, fetch = FetchType.LAZY ) - private List epUserRolesRequestDets = new ArrayList<>(); + private Set epUserRolesRequestDets; @OneToMany( targetEntity = FnUserRole.class, mappedBy = "roleId", cascade = CascadeType.ALL, fetch = FetchType.LAZY ) - private List fnUserRoles = new ArrayList<>(); + private Set fnUserRoles; }