package org.onap.portal.domain.db.fn;
+import java.io.Serializable;
import java.time.LocalDateTime;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
import java.util.stream.Collectors;
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.ManyToMany;
import javax.persistence.ManyToOne;
-import javax.persistence.NamedNativeQueries;
-import javax.persistence.NamedNativeQuery;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
-import javax.persistence.OneToOne;
-import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
-import javax.validation.Valid;
import javax.validation.constraints.Digits;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.PastOrPresent;
import javax.validation.constraints.Size;
import lombok.AllArgsConstructor;
-import lombok.Builder.Default;
+import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
-import lombok.ToString;
+import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.validator.constraints.SafeHtml;
+import org.onap.portal.domain.db.DomainVo;
import org.onap.portal.domain.db.cr.CrReportFileHistory;
import org.onap.portal.domain.db.ep.EpPersUserWidgetPlacement;
import org.onap.portal.domain.db.ep.EpPersUserWidgetSel;
import org.onap.portal.domain.db.ep.EpUserNotification;
import org.onap.portal.domain.db.ep.EpUserRolesRequest;
import org.onap.portal.domain.db.ep.EpWidgetCatalogParameter;
-import org.onap.portal.domain.dto.DomainVo;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
)
*/
-@NamedNativeQueries({
- @NamedNativeQuery(
- name = "getUsersByOrgUserId",
- query = "SELECT * FROM FnUser WHERE where org_user_id in :orgIds"
- )
+@NamedQueries({
+ @NamedQuery(
+ name = "FnUser.getUserWithOrgUserId",
+ query = "FROM FnUser WHERE orgUserId = :orgId"),
+ @NamedQuery(
+ name = "FnUser.findByLoginId",
+ query = "FROM FnUser WHERE loginId = :loginId"),
+ @NamedQuery(
+ name = "FnUser.getActiveUsers",
+ query = "FROM FnUser WHERE activeYn = 'Y'"),
+ @NamedQuery(
+ name = "FnUser.getUsersByOrgIds",
+ query = "FROM FnUser WHERE orgUserId IN :orgIds"
+ )
})
@Table(name = "fn_user", indexes = {
- @Index(name = "fn_user_address_id", columnList = "address_id"),
- @Index(name = "fn_user_alert_method_cd", columnList = "alert_method_cd"),
- @Index(name = "fn_user_org_id", columnList = "org_id"),
- @Index(name = "fk_fn_user_ref_197_fn_user", columnList = "manager_id"),
- @Index(name = "fk_fn_user_ref_198_fn_user", columnList = "created_id"),
- @Index(name = "fk_fn_user_ref_199_fn_user", columnList = "modified_id"),
- @Index(name = "fk_timezone", columnList = "timezone")
+ @Index(name = "fn_user_address_id", columnList = "address_id"),
+ @Index(name = "fn_user_alert_method_cd", columnList = "alert_method_cd"),
+ @Index(name = "fn_user_org_id", columnList = "org_id"),
+// @Index(name = "fk_fn_user_ref_197_fn_user", columnList = "manager_id"),
+ @Index(name = "fk_fn_user_ref_198_fn_user", columnList = "created_id"),
+ @Index(name = "fk_fn_user_ref_199_fn_user", columnList = "modified_id"),
+ @Index(name = "fk_timezone", columnList = "timezone")
},
- uniqueConstraints = {
- @UniqueConstraint(name = "fn_user_hrid", columnNames = "hrid"),
- @UniqueConstraint(name = "fn_user_login_id", columnNames = "login_id")
- })
-@NoArgsConstructor
-@AllArgsConstructor
+ uniqueConstraints = {
+ @UniqueConstraint(name = "fn_user_hrid", columnNames = "hrid"),
+ @UniqueConstraint(name = "fn_user_login_id", columnNames = "login_id")
+
+ })
+
@Getter
@Setter
@Entity
-@SequenceGenerator(name="seq", initialValue=1000, allocationSize=100000)
-public class FnUser implements UserDetails {
-
- @Id
- @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq")
- @Column(name = "user_id", length = 11, nullable = false)
- @Digits(integer = 11, fraction = 0)
- private Long userId;
- @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
- @JoinColumn(name = "org_id", columnDefinition = "int(11) DEFAULT NULL")
- @Valid
- private FnOrg orgId;
- @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
- @JoinColumn(name = "manager_id")
- @Valid
- private FnUser managerId;
- @Column(name = "first_name", length = 50, columnDefinition = "varchar(50) DEFAULT NULL")
- @Size(max = 50)
- @SafeHtml
- private String firstName;
- @Column(name = "middle_name", length = 50, columnDefinition = "varchar(50) DEFAULT NULL")
- @Size(max = 50)
- @SafeHtml
- private String middleName;
- @Column(name = "last_name", length = 50, columnDefinition = "varchar(50) DEFAULT NULL")
- @Size(max = 50)
- @SafeHtml
- private String lastName;
- @Column(name = "phone", length = 25, columnDefinition = "varchar(25) DEFAULT NULL")
- @Size(max = 25)
- @SafeHtml
- private String phone;
- @Column(name = "fax", length = 25, columnDefinition = "varchar(25) DEFAULT NULL")
- @Size(max = 25)
- @SafeHtml
- private String fax;
- @Column(name = "cellular", length = 25, columnDefinition = "varchar(25) DEFAULT NULL")
- @Size(max = 25)
- @SafeHtml
- private String cellular;
- @Column(name = "email", length = 50, columnDefinition = "varchar(50) DEFAULT NULL")
- @Size(max = 50)
- @Email
- @SafeHtml
- private String email;
- @Column(name = "address_id", columnDefinition = "decimal(11,0) DEFAULT NULL")
- @Digits(integer = 11, fraction = 0)
- private Long addressId;
- @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
- @JoinColumn(name = "alert_method_cd", columnDefinition = "varchar(10) DEFAULT NULL")
- private FnLuAlertMethod alertMethodCd;
- @Column(name = "hrid", length = 20, columnDefinition = "varchar(20) DEFAULT NULL")
- @Size(max = 20)
- @SafeHtml
- private String hrid;
- @Column(name = "org_user_id", length = 20, columnDefinition = "varchar(20) DEFAULT NULL")
- @Size(max = 20)
- @SafeHtml
- private String orgUserId;
- @Column(name = "org_code", length = 30, columnDefinition = "varchar(30) DEFAULT NULL")
- @Size(max = 30)
- @SafeHtml
- private String org_code;
- @Column(name = "login_id", length = 25, columnDefinition = "varchar(25) DEFAULT NULL")
- @Size(max = 25)
- @SafeHtml
- private String loginId;
- @Column(name = "login_pwd", length = 100, columnDefinition = "varchar(100) DEFAULT NULL")
- @Size(max = 100)
- @SafeHtml
- private String loginPwd;
- @Column(name = "last_login_date", nullable = false, columnDefinition = "datetime DEFAULT current_timestamp() ON UPDATE current_timestamp()")
- @PastOrPresent
- protected LocalDateTime lastLoginDate;
- @Column(name = "active_yn", length = 1, columnDefinition = "character varying(1) default 'y'", nullable = false)
- @Size(max = 1)
- @SafeHtml
- //@NotNull(message = "activeYn must not be null")
- private String activeYn;
- @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
- @JoinColumn(name = "created_id")
- @Valid
- private FnUser createdId;
- @Column(name = "created_date", columnDefinition = "datetime DEFAULT current_timestamp()", nullable = false)
- @PastOrPresent
- protected LocalDateTime createdDate;
- @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
- @JoinColumn(name = "modified_id")
- @Valid
- private FnUser modifiedId;
- @Column(name = "modified_date", nullable = false, columnDefinition = "datetime default now()")
- @PastOrPresent
- protected LocalDateTime modifiedDate;
- @Column(name = "is_internal_yn", length = 1, columnDefinition = "character varying(1) default 'n'", nullable = false)
- @Size(max = 1)
- @SafeHtml
- //@NotNull(message = "isInternalYn must not be null")
- private String isInternalYn;
- @Column(name = "address_line_1", length = 100, columnDefinition = "varchar(100) DEFAULT NULL")
- @Size(max = 100)
- @SafeHtml
- private String addressLine1;
- @Column(name = "address_line_2", length = 100, columnDefinition = "varchar(100) DEFAULT NULL")
- @Size(max = 100)
- @SafeHtml
- private String addressLine2;
- @Column(name = "city", length = 50, columnDefinition = "varchar(50) DEFAULT NULL")
- @Size(max = 50)
- @SafeHtml
- private String city;
- @Column(name = "state_cd", length = 3, columnDefinition = "varchar(3) DEFAULT NULL")
- @Size(max = 3)
- @SafeHtml
- private String stateCd;
- @Column(name = "zip_code", length = 11, columnDefinition = "varchar(11) DEFAULT NULL")
- @Size(max = 11)
- @SafeHtml
- private String zipCode;
- @Column(name = "country_cd", length = 3, columnDefinition = "varchar(3) DEFAULT NULL")
- @Size(max = 3)
- @SafeHtml
- private String countryCd;
- @Column(name = "location_clli", length = 8, columnDefinition = "varchar(8) DEFAULT NULL")
- @Size(max = 8)
- @SafeHtml
- private String locationClli;
- @Column(name = "org_manager_userid", length = 20, columnDefinition = "varchar(20) DEFAULT NULL")
- @Size(max = 20)
- @SafeHtml
- private String orgManagerUserId;
- @Column(name = "company", length = 100, columnDefinition = "varchar(100) DEFAULT NULL")
- @Size(max = 100)
- @SafeHtml
- private String company;
- @Column(name = "department_name", length = 200, columnDefinition = "varchar(100) DEFAULT NULL")
- @Size(max = 200)
- @SafeHtml
- private String departmentName;
- @Column(name = "job_title", length = 100, columnDefinition = "varchar(100) DEFAULT NULL")
- @Size(max = 100)
- @SafeHtml
- private String jobTitle;
- @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
- @JoinColumn(name = "timezone", columnDefinition = "int(11) DEFAULT NULL")
- @Valid
- private FnLuTimezone timezone;
- @Column(name = "department", length = 25, columnDefinition = "varchar(25) DEFAULT NULL")
- @Size(max = 25)
- @SafeHtml
- private String department;
- @Column(name = "business_unit", length = 25, columnDefinition = "varchar(25) DEFAULT NULL")
- @Size(max = 25)
- @SafeHtml
- private String businessUnit;
- @Column(name = "business_unit_name", length = 100, columnDefinition = "varchar(100) DEFAULT NULL")
- @Size(max = 100)
- @SafeHtml
- private String businessUnitName;
- @Column(name = "cost_center", length = 25, columnDefinition = "varchar(25) DEFAULT NULL")
- @Size(max = 25)
- @SafeHtml
- private String cost_center;
- @Column(name = "fin_loc_code", length = 10, columnDefinition = "varchar(10) DEFAULT NULL")
- @Size(max = 10)
- @SafeHtml
- private String finLocCode;
- @Column(name = "silo_status", length = 10, columnDefinition = "varchar(10) DEFAULT NULL")
- @Size(max = 10)
- @SafeHtml
- private String siloStatus;
- @ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
- @JoinColumn(name = "language_id", nullable = false, columnDefinition = "int(11) DEFAULT 1")
- @Valid
- //@NotNull(message = "languageId must not be null")
- private FnLanguage languageId;
- @Column(name = "is_guest", columnDefinition = "boolean default 0", nullable = false)
- @NotNull(message = "guest must not be null")
- private boolean guest;
- @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "fnUserList")
- private List<CrReportFileHistory> crReportFileHistorie = new ArrayList<>();
- @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
- private List<FnRole> fnRoles = new ArrayList<>();
- @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
- private List<FnMenuFunctional> fnRoleList = new ArrayList<>();
- @OneToMany(
- targetEntity = FnAuditLog.class,
- mappedBy = "userId",
- cascade = CascadeType.ALL,
- fetch = FetchType.LAZY
- )
- private List<FnAuditLog> fnAuditLogs = new ArrayList<>();
- @OneToMany(
- targetEntity = FnUser.class,
- mappedBy = "createdId",
- cascade = CascadeType.ALL,
- fetch = FetchType.LAZY
- )
- private List<FnUser> fnUsersCreatedId = new ArrayList<>();
- @OneToMany(
- targetEntity = FnUser.class,
- mappedBy = "managerId",
- cascade = CascadeType.ALL,
- fetch = FetchType.LAZY
- )
- private List<FnUser> fnUsersManagerId = new ArrayList<>();
- @OneToMany(
- targetEntity = FnUser.class,
- mappedBy = "modifiedId",
- cascade = CascadeType.ALL,
- fetch = FetchType.LAZY
- )
- private List<FnUser> fnUsersModifiedId = new ArrayList<>();
- @OneToMany(
- targetEntity = EpUserRolesRequest.class,
- mappedBy = "userId",
- cascade = CascadeType.ALL,
- fetch = FetchType.LAZY
- )
- private List<EpUserRolesRequest> epUserRolesRequests = new ArrayList<>();
- @OneToMany(
- targetEntity = FnPersUserAppSel.class,
- mappedBy = "userId",
- cascade = CascadeType.ALL,
- fetch = FetchType.LAZY
- )
- private List<FnPersUserAppSel> persUserAppSels = new ArrayList<>();
- @OneToMany(
- targetEntity = EpWidgetCatalogParameter.class,
- mappedBy = "userId",
- cascade = CascadeType.ALL,
- fetch = FetchType.LAZY
- )
- private List<EpWidgetCatalogParameter> epWidgetCatalogParameters = new ArrayList<>();
- @OneToMany(
- targetEntity = EpPersUserWidgetPlacement.class,
- mappedBy = "userId",
- cascade = CascadeType.ALL,
- fetch = FetchType.LAZY
- )
- private List<EpPersUserWidgetPlacement> epPersUserWidgetPlacements = new ArrayList<>();
- @OneToMany(
- targetEntity = EpPersUserWidgetSel.class,
- mappedBy = "userId",
- cascade = CascadeType.ALL,
- fetch = FetchType.LAZY
- )
- private List<EpPersUserWidgetSel> epPersUserWidgetSels = new ArrayList<>();
- @OneToMany(
- targetEntity = FnUserRole.class,
- mappedBy = "userId",
- cascade = CascadeType.ALL,
- fetch = FetchType.LAZY
- )
- private List<FnUserRole> fnUserRoles = new ArrayList<>();
- @OneToMany(
- targetEntity = EpUserNotification.class,
- mappedBy = "userId",
- cascade = CascadeType.ALL,
- fetch = FetchType.LAZY
- )
- private List<EpUserNotification> epUserNotifications = new ArrayList<>();
-
- @Override
- public Collection<? extends GrantedAuthority> getAuthorities() {
- return fnRoles
- .stream()
- .map(fnRole -> new SimpleGrantedAuthority("ROLE_" + fnRole.getRoleName()))
- .collect(Collectors.toList());
- }
-
- @Override
- public String getPassword() {
- return this.getLoginPwd();
- }
-
- @Override
- public String getUsername() {
- return this.getLoginId();
- }
-
- @Override
- public boolean isAccountNonExpired() {
- return true;
- }
-
- @Override
- public boolean isAccountNonLocked() {
- return true;
- }
-
- @Override
- public boolean isCredentialsNonExpired() {
- return true;
- }
-
- @Override
- public boolean isEnabled() {
- return true;
- }
-
- public String getFullName() {
- return this.firstName + " " + this.lastName;
- }
+@NoArgsConstructor
+@AllArgsConstructor
+@DynamicUpdate
+public class FnUser extends DomainVo implements UserDetails, Serializable {
+
+ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FnUser.class);
+
+/* @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
+ @JoinColumn(name = "manager_id")
+ private FnUser managerId;*/
+ @ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
+ @JoinColumn(name = "org_id")
+ private FnOrg orgId;
+ @Column(name = "first_name", length = 50)
+ @Size(max = 50)
+ @SafeHtml
+ private String firstName;
+ @Column(name = "middle_name", length = 50)
+ @Size(max = 50)
+ @SafeHtml
+ private String middleName;
+ @Column(name = "last_name", length = 50)
+ @Size(max = 50)
+ @SafeHtml
+ private String lastName;
+ @Column(name = "phone", length = 25)
+ @Size(max = 25)
+ @SafeHtml
+ private String phone;
+ @Column(name = "fax", length = 25)
+ @Size(max = 25)
+ @SafeHtml
+ private String fax;
+ @Column(name = "cellular", length = 25)
+ @Size(max = 25)
+ @SafeHtml
+ private String cellular;
+ @Column(name = "email", length = 50)
+ @Size(max = 50)
+ @Email
+ @SafeHtml
+ private String email;
+ @Column(name = "address_id")
+ @Digits(integer = 11, fraction = 0)
+ private Long addressId;
+ @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
+ @JoinColumn(name = "alert_method_cd")
+ private FnLuAlertMethod alertMethodCd;
+ @Column(name = "hrid", length = 20)
+ @Size(max = 20)
+ @SafeHtml
+ private String hrid;
+ @Column(name = "org_user_id", length = 20)
+ @Size(max = 20)
+ @SafeHtml
+ private String orgUserId;
+ @Column(name = "org_code", length = 30)
+ @Size(max = 30)
+ @SafeHtml
+ private String org_code;
+ @Column(name = "login_id", length = 25)
+ @Size(max = 25)
+ @SafeHtml
+ private String loginId;
+ @Column(name = "login_pwd", length = 100)
+ @Size(max = 100)
+ @SafeHtml
+ private String loginPwd;
+ @Column(name = "last_login_date", nullable = false, columnDefinition = "datetime DEFAULT current_timestamp() ON UPDATE current_timestamp()")
+ @PastOrPresent
+ protected LocalDateTime lastLoginDate;
+ @Column(name = "active_yn", nullable = false)
+ private Boolean activeYn;
+ @Column(name = "created_date", columnDefinition = "datetime DEFAULT current_timestamp()", nullable = false)
+ @PastOrPresent
+ protected LocalDateTime createdDate;
+ @Column(name = "modified_date", nullable = false, columnDefinition = "datetime default now()")
+ @PastOrPresent
+ protected LocalDateTime modifiedDate;
+ @Column(name = "is_internal_yn", nullable = false, columnDefinition = "boolean DEFAULT false")
+ private Boolean isInternalYn = false;
+ @Column(name = "is_system_user", nullable = false, columnDefinition = "boolean DEFAULT false")
+ private Boolean isSystemUser = false;
+ @Column(name = "address_line_1", length = 100)
+ @Size(max = 100)
+ @SafeHtml
+ private String addressLine1;
+ @Column(name = "address_line_2", length = 100)
+ @Size(max = 100)
+ @SafeHtml
+ private String addressLine2;
+ @Column(name = "city", length = 50)
+ @Size(max = 50)
+ @SafeHtml
+ private String city;
+ @Column(name = "state_cd", length = 3)
+ @Size(max = 3)
+ @SafeHtml
+ private String stateCd;
+ @Column(name = "zip_code", length = 11)
+ @Size(max = 11)
+ @SafeHtml
+ private String zipCode;
+ @Column(name = "country_cd", length = 3)
+ @Size(max = 3)
+ @SafeHtml
+ private String countryCd;
+ @Column(name = "location_clli", length = 8)
+ @Size(max = 8)
+ @SafeHtml
+ private String locationClli;
+ @Column(name = "org_manager_userid", length = 20)
+ @Size(max = 20)
+ @SafeHtml
+ private String orgManagerUserId;
+ @Column(name = "company", length = 100)
+ @Size(max = 100)
+ @SafeHtml
+ private String company;
+ @Column(name = "department_name", length = 200)
+ @Size(max = 200)
+ @SafeHtml
+ private String departmentName;
+ @Column(name = "job_title", length = 100)
+ @Size(max = 100)
+ @SafeHtml
+ private String jobTitle;
+ @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
+ @JoinColumn(name = "timezone")
+ private FnLuTimezone timezone;
+ @Column(name = "department", length = 25)
+ @Size(max = 25)
+ @SafeHtml
+ private String department;
+ @Column(name = "business_unit", length = 25)
+ @Size(max = 25)
+ @SafeHtml
+ private String businessUnit;
+ @Column(name = "business_unit_name", length = 100)
+ @Size(max = 100)
+ @SafeHtml
+ private String businessUnitName;
+ @Column(name = "cost_center", length = 25)
+ @Size(max = 25)
+ @SafeHtml
+ private String cost_center;
+ @Column(name = "fin_loc_code", length = 10)
+ @Size(max = 10)
+ @SafeHtml
+ private String finLocCode;
+ @Column(name = "silo_status", length = 10)
+ @Size(max = 10)
+ @SafeHtml
+ private String siloStatus;
+ @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
+ @JoinColumn(name = "language_id", nullable = false)
+ @NotNull(message = "languageId must not be null")
+ private FnLanguage languageId;
+ @Column(name = "is_guest", nullable = false, columnDefinition = "boolean DEFAULT false")
+ @NotNull(message = "guest must not be null")
+ private Boolean guest = false;
+ @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY, mappedBy = "fnUserList")
+ private Set<CrReportFileHistory> crReportFileHistorie;
+ @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.EAGER, mappedBy = "fnUsers")
+ private Set<FnRole> fnRoles;
+ @ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
+ private Set<FnMenuFunctional> fnRoleList;
+ @OneToMany(
+ targetEntity = FnAuditLog.class,
+ mappedBy = "userId",
+ cascade = CascadeType.MERGE,
+ fetch = FetchType.LAZY
+ )
+ private Set<FnAuditLog> fnAuditLogs;
+ @OneToMany(
+ targetEntity = EpUserRolesRequest.class,
+ mappedBy = "userId",
+ cascade = CascadeType.MERGE,
+ fetch = FetchType.LAZY
+ )
+ private Set<EpUserRolesRequest> epUserRolesRequests;
+ @OneToMany(
+ targetEntity = FnPersUserAppSel.class,
+ mappedBy = "userId",
+ cascade = CascadeType.MERGE,
+ fetch = FetchType.LAZY
+ )
+ private Set<FnPersUserAppSel> persUserAppSels;
+ @OneToMany(
+ targetEntity = EpWidgetCatalogParameter.class,
+ mappedBy = "userId",
+ cascade = CascadeType.MERGE,
+ fetch = FetchType.LAZY
+ )
+ private Set<EpWidgetCatalogParameter> epWidgetCatalogParameters;
+ @OneToMany(
+ targetEntity = EpPersUserWidgetPlacement.class,
+ mappedBy = "userId",
+ cascade = CascadeType.MERGE,
+ fetch = FetchType.LAZY
+ )
+ private Set<EpPersUserWidgetPlacement> epPersUserWidgetPlacements;
+ @OneToMany(
+ targetEntity = EpPersUserWidgetSel.class,
+ mappedBy = "userId",
+ cascade = CascadeType.MERGE,
+ fetch = FetchType.LAZY
+ )
+ private Set<EpPersUserWidgetSel> epPersUserWidgetSels;
+ @OneToMany(
+ targetEntity = FnUserRole.class,
+ mappedBy = "userId",
+ cascade = CascadeType.MERGE,
+ fetch = FetchType.LAZY
+ )
+ private Set<FnUserRole> userApps;
+ @OneToMany(
+ targetEntity = EpUserNotification.class,
+ mappedBy = "userId",
+ cascade = CascadeType.MERGE,
+ fetch = FetchType.LAZY
+ )
+ private Set<EpUserNotification> epUserNotifications;
+/* @OneToMany(
+ targetEntity = FnUser.class,
+ mappedBy = "managerId",
+ cascade = CascadeType.MERGE,
+ fetch = FetchType.LAZY
+ )
+ private Set<FnUser> fnUsersManagerId;*/
+
+ @Override
+ public Collection<? extends GrantedAuthority> getAuthorities() {
+ return fnRoles
+ .stream()
+ .map(fnRole -> new SimpleGrantedAuthority("ROLE_" + fnRole.getRoleName()))
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public String getPassword() {
+ return this.getLoginPwd();
+ }
+
+ @Override
+ public String getUsername() {
+ return this.getLoginId();
+ }
+
+ @Override
+ public boolean isAccountNonExpired() {
+ return true;
+ }
+
+ @Override
+ public boolean isAccountNonLocked() {
+ return true;
+ }
+
+ @Override
+ public boolean isCredentialsNonExpired() {
+ return true;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ public String getFullName() {
+ return this.firstName + " " + this.lastName;
+ }
+
+ public SortedSet<FnRole> getAppEPRoles(FnApp app) {
+
+ logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - app = {}", app.getAppName());
+
+ SortedSet<FnRole> roles = new TreeSet<>();
+ Set<FnUserRole> userAppRoles = getUserApps();
+
+ logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - userApps = {} ", userAppRoles.size());
+
+ Iterator<FnUserRole> userAppRolesIterator = userAppRoles.iterator();
+
+ FnUserRole userAppRole;
+ // getting default app
+ while (userAppRolesIterator.hasNext()) {
+ FnUserRole tempUserApp = userAppRolesIterator.next();
+ if (tempUserApp.getFnAppId().getId().equals(app.getId())) {
+
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ "In EPUser.getAppEPRoles() - for user {}, found application {}", this.getFullName(),
+ app.getAppName());
+
+ userAppRole = tempUserApp;
+
+ FnRole role = userAppRole.getRoleId();
+ if (role.getActiveYn()) {
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ "In EPUser.getAppEPRoles() - Role {} is active - adding for user {} and app {}",
+ role.getRoleName(), this.getFullName(), app.getAppName());
+ roles.add(role);
+ } else {
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ "In EPUser.getAppEPRoles() - Role {} is NOT active - NOT adding for user {} and app {}",
+ role.getRoleName(), this.getFullName(), app.getAppName());
+ }
+ }
+ }
+ logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - roles = {}", roles.size());
+
+ return roles;
+ }
+
+ public void setRoles(Set<FnRole> roles) {
+ FnApp app = new FnApp();
+ app.setId(1L);
+ app.setAppName("Default");
+ this.addAppRoles(app, roles);
+ }
+
+ private void addAppRoles(FnApp app, Set<FnRole> roles) {
+ if (roles != null) {
+ Set<FnUserRole> newUserApps = new HashSet<>();
+ for (FnRole role : roles) {
+ FnUserRole userApp = new FnUserRole();
+ userApp.setUserId(this);
+ userApp.setFnAppId(app);
+ userApp.setRoleId(role);
+ newUserApps.add(userApp);
+ }
+
+ this.setUserApps(newUserApps);
+ } else {
+ this.userApps.clear();
+ }
+ }
+
+ @Builder
+ public FnUser(@Digits(integer = 11, fraction = 0) Long id, LocalDateTime created, LocalDateTime modified,
+ Long rowNum, Serializable auditUserId, DomainVo createdId, DomainVo modifiedId,
+ Set<DomainVo> fnUsersCreatedId, Set<DomainVo> fnUsersModifiedId, FnOrg orgId,
+ @Size(max = 50) @SafeHtml String firstName,
+ @Size(max = 50) @SafeHtml String middleName,
+ @Size(max = 50) @SafeHtml String lastName,
+ @Size(max = 25) @SafeHtml String phone,
+ @Size(max = 25) @SafeHtml String fax,
+ @Size(max = 25) @SafeHtml String cellular,
+ @Size(max = 50) @Email @SafeHtml String email,
+ @Digits(integer = 11, fraction = 0) Long addressId, FnLuAlertMethod alertMethodCd,
+ @Size(max = 20) @SafeHtml String hrid,
+ @Size(max = 20) @SafeHtml String orgUserId,
+ @Size(max = 30) @SafeHtml String org_code,
+ @Size(max = 25) @SafeHtml String loginId,
+ @Size(max = 100) @SafeHtml String loginPwd,
+ @PastOrPresent LocalDateTime lastLoginDate, Boolean activeYn,
+ @PastOrPresent LocalDateTime createdDate,
+ @PastOrPresent LocalDateTime modifiedDate, Boolean isInternalYn, Boolean isSystemUser,
+ @Size(max = 100) @SafeHtml String addressLine1,
+ @Size(max = 100) @SafeHtml String addressLine2,
+ @Size(max = 50) @SafeHtml String city,
+ @Size(max = 3) @SafeHtml String stateCd,
+ @Size(max = 11) @SafeHtml String zipCode,
+ @Size(max = 3) @SafeHtml String countryCd,
+ @Size(max = 8) @SafeHtml String locationClli,
+ @Size(max = 20) @SafeHtml String orgManagerUserId,
+ @Size(max = 100) @SafeHtml String company,
+ @Size(max = 200) @SafeHtml String departmentName,
+ @Size(max = 100) @SafeHtml String jobTitle, FnLuTimezone timezone,
+ @Size(max = 25) @SafeHtml String department,
+ @Size(max = 25) @SafeHtml String businessUnit,
+ @Size(max = 100) @SafeHtml String businessUnitName,
+ @Size(max = 25) @SafeHtml String cost_center,
+ @Size(max = 10) @SafeHtml String finLocCode,
+ @Size(max = 10) @SafeHtml String siloStatus,
+ @NotNull(message = "languageId must not be null") FnLanguage languageId,
+ @NotNull(message = "guest must not be null") Boolean guest,
+ Set<CrReportFileHistory> crReportFileHistorie, Set<FnRole> fnRoles,
+ Set<FnMenuFunctional> fnRoleList, Set<FnAuditLog> fnAuditLogs,
+ Set<EpUserRolesRequest> epUserRolesRequests,
+ Set<FnPersUserAppSel> persUserAppSels,
+ Set<EpWidgetCatalogParameter> epWidgetCatalogParameters,
+ Set<EpPersUserWidgetPlacement> epPersUserWidgetPlacements,
+ Set<EpPersUserWidgetSel> epPersUserWidgetSels, Set<FnUserRole> userApps,
+ Set<EpUserNotification> epUserNotifications) {
+ super(id, created, modified, rowNum, auditUserId, createdId, modifiedId, fnUsersCreatedId, fnUsersModifiedId);
+ this.orgId = orgId;
+ this.firstName = firstName;
+ this.middleName = middleName;
+ this.lastName = lastName;
+ this.phone = phone;
+ this.fax = fax;
+ this.cellular = cellular;
+ this.email = email;
+ this.addressId = addressId;
+ this.alertMethodCd = alertMethodCd;
+ this.hrid = hrid;
+ this.orgUserId = orgUserId;
+ this.org_code = org_code;
+ this.loginId = loginId;
+ this.loginPwd = loginPwd;
+ this.lastLoginDate = lastLoginDate;
+ this.activeYn = activeYn;
+ this.createdDate = createdDate;
+ this.modifiedDate = modifiedDate;
+ this.isInternalYn = isInternalYn;
+ this.isSystemUser = isSystemUser;
+ this.addressLine1 = addressLine1;
+ this.addressLine2 = addressLine2;
+ this.city = city;
+ this.stateCd = stateCd;
+ this.zipCode = zipCode;
+ this.countryCd = countryCd;
+ this.locationClli = locationClli;
+ this.orgManagerUserId = orgManagerUserId;
+ this.company = company;
+ this.departmentName = departmentName;
+ this.jobTitle = jobTitle;
+ this.timezone = timezone;
+ this.department = department;
+ this.businessUnit = businessUnit;
+ this.businessUnitName = businessUnitName;
+ this.cost_center = cost_center;
+ this.finLocCode = finLocCode;
+ this.siloStatus = siloStatus;
+ this.languageId = languageId;
+ this.guest = guest;
+ this.crReportFileHistorie = crReportFileHistorie;
+ this.fnRoles = fnRoles;
+ this.fnRoleList = fnRoleList;
+ this.fnAuditLogs = fnAuditLogs;
+ this.epUserRolesRequests = epUserRolesRequests;
+ this.persUserAppSels = persUserAppSels;
+ this.epWidgetCatalogParameters = epWidgetCatalogParameters;
+ this.epPersUserWidgetPlacements = epPersUserWidgetPlacements;
+ this.epPersUserWidgetSels = epPersUserWidgetSels;
+ this.userApps = userApps;
+ this.epUserNotifications = epUserNotifications;
+ }
}