2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
20 package org.openecomp.portalapp.portal.domain;
22 import java.util.Date;
23 import java.util.Iterator;
24 import java.util.SortedSet;
25 import java.util.TreeSet;
27 import org.openecomp.portalapp.portal.utils.PortalConstants;
28 import org.openecomp.portalsdk.core.domain.User;
29 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
31 import com.fasterxml.jackson.annotation.JsonIgnore;
33 public class EPUser extends User {
36 private Long managerId;
37 private String firstName;
38 private String middleInitial;
39 private String lastName;
42 private String cellular;
44 private Long addressId;
45 private String alertMethodCd;
47 private String orgUserId;
48 private String orgCode;
49 private String address1;
50 private String address2;
53 private String zipCode;
54 private String country;
55 private String orgManagerUserId;
56 private String locationClli;
57 private String businessCountryCode;
58 private String businessCountryName;
59 private String businessUnit;
60 private String businessUnitName;
61 private String department;
62 private String departmentName;
63 private String companyCode;
64 private String company;
65 private String zipCodeSuffix;
66 private String jobTitle;
67 private String commandChain;
68 private String siloStatus;
69 private String costCenter;
70 private String financialLocCode;
74 private String loginId;
75 private String loginPwd;
76 private Date lastLoginDate;
77 private boolean active;
78 private boolean internal;
79 private Long selectedProfileId;
80 private Long timeZoneId;
81 private boolean online;
82 private String chatId;
84 private static final long serialVersionUID = 1L;
86 private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPUser.class);
87 private static final String ECOMP_PORTAL_NAME = "ECOMP";
88 private boolean isGuest = false;
90 private SortedSet<EPUserApp> userApps = new TreeSet<EPUserApp>();
91 private SortedSet<EPRole> pseudoRoles = new TreeSet<EPRole>();
95 public Long getAddressId() {
99 public String getAlertMethodCd() {
100 return alertMethodCd;
103 public String getCellular() {
107 public String getEmail() {
111 public String getFax() {
115 public String getFirstName() {
119 public String getHrid() {
123 public Date getLastLoginDate() {
124 return lastLoginDate;
127 public String getLastName() {
132 public String getFullName() {
133 return getFirstName() + " " + getLastName();
136 public String getLoginId() {
140 public String getLoginPwd() {
144 public Long getManagerId() {
148 public String getMiddleInitial() {
149 return middleInitial;
152 public String getOrgCode() {
156 public Long getOrgId() {
160 public String getPhone() {
164 public String getOrgUserId() {
168 public boolean getActive() {
172 public boolean getInternal() {
176 public String getAddress1() {
180 public String getAddress2() {
184 public String getCity() {
188 public String getCountry() {
192 public String getState() {
196 public String getZipCode() {
200 public String getBusinessCountryCode() {
201 return businessCountryCode;
204 public String getCommandChain() {
208 public String getCompany() {
212 public String getCompanyCode() {
216 public String getDepartment() {
220 public String getJobTitle() {
224 public String getLocationClli() {
228 public String getOrgManagerUserId() {
229 return orgManagerUserId;
232 public String getZipCodeSuffix() {
233 return zipCodeSuffix;
236 public String getBusinessCountryName() {
237 return businessCountryName;
240 public Long getSelectedProfileId() {
241 return selectedProfileId;
244 public void setAddressId(Long addressId) {
245 this.addressId = addressId;
248 public void setAlertMethodCd(String alertMethodCd) {
249 this.alertMethodCd = alertMethodCd;
252 public void setCellular(String cellular) {
253 this.cellular = cellular;
256 public void setEmail(String email) {
260 public void setFax(String fax) {
264 public void setFirstName(String firstName) {
265 this.firstName = firstName;
268 public void setHrid(String hrid) {
272 public void setLastLoginDate(Date lastLoginDate) {
273 this.lastLoginDate = lastLoginDate;
276 public void setLastName(String lastName) {
277 this.lastName = lastName;
280 public void setLoginId(String loginId) {
281 this.loginId = loginId;
284 public void setLoginPwd(String loginPwd) {
285 this.loginPwd = loginPwd;
288 public void setManagerId(Long managerId) {
289 this.managerId = managerId;
292 public void setMiddleInitial(String middleInitial) {
293 this.middleInitial = middleInitial;
296 public void setOrgCode(String orgCode) {
297 this.orgCode = orgCode;
300 public void setOrgId(Long orgId) {
304 public void setPhone(String phone) {
308 public void setOrgUserId(String orgUserId) {
309 this.orgUserId = orgUserId;
312 public void setActive(boolean active) {
313 this.active = active;
316 public void setInternal(boolean internal) {
317 this.internal = internal;
320 public void setAddress1(String address1) {
321 this.address1 = address1;
324 public void setAddress2(String address2) {
325 this.address2 = address2;
328 public void setCity(String city) {
332 public void setCountry(String country) {
333 this.country = country;
336 public void setState(String state) {
340 public void setZipCode(String zipCode) {
341 this.zipCode = zipCode;
344 public void setBusinessCountryCode(String businessCountryCode) {
345 this.businessCountryCode = businessCountryCode;
348 public void setCommandChain(String commandChain) {
349 this.commandChain = commandChain;
352 public void setCompany(String company) {
353 this.company = company;
356 public void setCompanyCode(String companyCode) {
357 this.companyCode = companyCode;
360 public void setDepartment(String department) {
361 this.department = department;
364 public void setJobTitle(String jobTitle) {
365 this.jobTitle = jobTitle;
368 public void setLocationClli(String locationClli) {
369 this.locationClli = locationClli;
372 public void setOrgManagerUserId(String orgManagerUserId) {
373 this.orgManagerUserId = orgManagerUserId;
376 public void setZipCodeSuffix(String zipCodeSuffix) {
377 this.zipCodeSuffix = zipCodeSuffix;
380 public void setBusinessCountryName(String businessCountryName) {
381 this.businessCountryName = businessCountryName;
384 public SortedSet<EPRole> getPseudoRoles() {
388 public void setPseudoRoles(SortedSet<EPRole> pseudoRoles) {
389 this.pseudoRoles = pseudoRoles;
392 public void setSelectedProfileId(Long selectedProfileId) {
393 this.selectedProfileId = selectedProfileId;
396 public Long getTimeZoneId() {
400 public void setTimeZoneId(Long timeZoneId) {
401 this.timeZoneId = timeZoneId;
404 public String getBusinessUnit() {
408 public void setBusinessUnit(String businessUnit) {
409 this.businessUnit = businessUnit;
412 public String getSiloStatus() {
416 public void setSiloStatus(String siloStatus) {
417 this.siloStatus = siloStatus;
420 public String getCostCenter() {
424 public void setCostCenter(String costCenter) {
425 this.costCenter = costCenter;
428 public String getFinancialLocCode() {
429 return financialLocCode;
432 public void setFinancialLocCode(String financialLocCode) {
433 this.financialLocCode = financialLocCode;
436 public String getBusinessUnitName() {
437 return businessUnitName;
440 public void setBusinessUnitName(String businessUnitName) {
441 this.businessUnitName = businessUnitName;
444 public String getDepartmentName() {
445 return departmentName;
448 public void setDepartmentName(String departmentName) {
449 this.departmentName = departmentName;
452 public int compareTo(Object obj){
453 EPUser user = (EPUser)obj;
455 String c1 = getLastName() + getFirstName() + getMiddleInitial();
456 String c2 = user.getLastName() + user.getFirstName() + user.getMiddleInitial();
458 return c1.compareTo(c2);
461 public boolean isOnline() {
465 public void setOnline(boolean online) {
466 this.online = online;
469 public String getChatId() {
473 public void setChatId(String chatId) {
474 this.chatId = chatId;
478 public void setPseudoEPRoles(SortedSet<EPRole> pseudoRoles) {
479 this.pseudoRoles = pseudoRoles;
482 public SortedSet<EPUserApp> getEPUserApps() {
486 public void setEPUserApps(SortedSet<EPUserApp> userApps) {
487 this.userApps = userApps;
490 public void addUserApp(EPUserApp userApp) {
491 userApps.add(userApp);
494 public void addAppRoles(EPApp app, SortedSet<EPRole> roles) {
497 SortedSet<EPUserApp> userApps = new TreeSet<EPUserApp>();
498 // this.userApps.removeAll(this.userApps);
499 Iterator<EPRole> itr = roles.iterator();
500 while (itr.hasNext()) {
501 EPRole role = (EPRole) itr.next();
502 EPUserApp userApp = new EPUserApp();
503 userApp.setUserId(this.id);
505 userApp.setRole(role);
506 userApps.add(userApp);
508 setEPUserApps(userApps);
516 public SortedSet<EPRole> getAppEPRoles(EPApp app) {
518 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - app = {}", app.getName());
520 SortedSet<EPRole> roles = new TreeSet<EPRole>();
521 SortedSet<EPUserApp> userAppRoles = getEPUserApps();
523 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - userApps = ", userAppRoles.size());
525 Iterator<EPUserApp> userAppRolesIterator = userAppRoles.iterator();
526 EPUserApp userAppRole = null;
527 // getting default app
528 while (userAppRolesIterator.hasNext()) {
529 EPUserApp tempUserApp = (EPUserApp) userAppRolesIterator.next();
530 if (tempUserApp.getApp().getId().equals(app.getId())) {
532 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - for user {}, found application {}", this.getFullName(), app.getName());
534 userAppRole = tempUserApp;
536 EPRole role = userAppRole.getRole();
537 if(role.getActive()){
538 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - Role {} is active - adding for user {} and app {}", role.getName(), this.getFullName(), app.getName());
539 roles.add((EPRole) role);
542 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - Role {} is NOT active - NOT adding for user {} and app {}", role.getName(), this.getFullName(), app.getName());
546 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - roles = ", roles.size());
553 * Attention! Not for use in ECOMP
555 public SortedSet<EPRole> getAppRoles(EPApp app) {
556 SortedSet<EPRole> roles = new TreeSet<EPRole>();
557 SortedSet<EPUserApp> apps = getEPUserApps();
558 Iterator<EPUserApp> appsItr = apps.iterator();
559 EPUserApp userApp = null;
560 // getting default app
561 while (appsItr.hasNext()) {
562 EPUserApp tempUserApp = (EPUserApp) appsItr.next();
563 if (tempUserApp.getApp().getId().equals(app.getId())) {
564 userApp = tempUserApp;
565 roles.add((EPRole) userApp.getRole());
574 * Attention! Not for use in ECOMP
576 public SortedSet<EPRole> getEPRoles() {
577 EPApp app = new EPApp();
578 app.setId(new Long(PortalConstants.PORTAL_APP_ID));
579 app.setName(ECOMP_PORTAL_NAME);
580 return getAppEPRoles(app);
584 * Attention! Not for use in ECOMP
586 public void setEPRoles(SortedSet<EPRole> roles) {
587 EPApp app = new EPApp();
588 app.setId(new Long(PortalConstants.PORTAL_APP_ID));
589 app.setName(ECOMP_PORTAL_NAME);
590 addAppRoles(app, roles);
594 * Attention! Not for use in ECOMP
596 public void removeEPRole(Long roleId) {
597 SortedSet<EPUserApp> apps = getEPUserApps();
598 Iterator<EPUserApp> appsItr = apps.iterator();
599 // getting default app
600 while (appsItr.hasNext()) {
601 EPUserApp tempUserApp = (EPUserApp) appsItr.next();
602 if (tempUserApp.equals(new Long(PortalConstants.PORTAL_APP_ID)) && tempUserApp.getRole().getId().equals(roleId)) {
609 * Attention! Not for use in ECOMP
611 public void addEPRole(EPRole role) {
613 SortedSet<EPRole> roles = getEPRoles();
615 roles = new TreeSet<EPRole>();
622 public boolean isGuest() {
626 public void setGuest(boolean isGuest) {
627 this.isGuest = isGuest;
631 public String toString() {
632 return "EPUser [orgId=" + orgId + ", managerId=" + managerId + ", firstName=" + firstName + ", middleInitial="
633 + middleInitial + ", lastName=" + lastName + ", phone=" + phone + ", fax=" + fax + ", cellular="
634 + cellular + ", email=" + email + ", addressId=" + addressId + ", alertMethodCd=" + alertMethodCd
635 + ", hrid=" + hrid + ", orgUserId=" + orgUserId + ", orgCode=" + orgCode + ", address1=" + address1
636 + ", address2=" + address2 + ", city=" + city + ", state=" + state + ", zipCode=" + zipCode
637 + ", country=" + country + ", orgManagerUserId=" + orgManagerUserId + ", locationClli=" + locationClli
638 + ", businessCountryCode=" + businessCountryCode + ", businessCountryName=" + businessCountryName
639 + ", businessUnit=" + businessUnit + ", businessUnitName=" + businessUnitName + ", department="
640 + department + ", departmentName=" + departmentName + ", companyCode=" + companyCode + ", company="
641 + company + ", zipCodeSuffix=" + zipCodeSuffix + ", jobTitle=" + jobTitle + ", commandChain="
642 + commandChain + ", siloStatus=" + siloStatus + ", costCenter=" + costCenter + ", financialLocCode="
643 + financialLocCode + ", loginId=" + loginId + ", loginPwd=" + loginPwd + ", lastLoginDate="
644 + lastLoginDate + ", active=" + active + ", internal=" + internal + ", selectedProfileId="
645 + selectedProfileId + ", timeZoneId=" + timeZoneId + ", online=" + online + ", chatId=" + chatId
646 + ", isGuest=" + isGuest + ", userApps=" + userApps + ", pseudoRoles=" + pseudoRoles + "]";