2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
38 package org.onap.portalapp.portal.domain;
40 import java.util.Date;
41 import java.util.Iterator;
42 import java.util.SortedSet;
43 import java.util.TreeSet;
45 import org.onap.portalapp.portal.utils.PortalConstants;
46 import org.onap.portalsdk.core.domain.User;
47 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
49 import com.fasterxml.jackson.annotation.JsonIgnore;
51 public class EPUser extends User {
54 private Long managerId;
55 private String firstName;
56 private String middleInitial;
57 private String lastName;
60 private String cellular;
62 private Long addressId;
63 private String alertMethodCd;
65 private String orgUserId;
66 private String orgCode;
67 private String address1;
68 private String address2;
71 private String zipCode;
72 private String country;
73 private String orgManagerUserId;
74 private String locationClli;
75 private String businessCountryCode;
76 private String businessCountryName;
77 private String businessUnit;
78 private String businessUnitName;
79 private String department;
80 private String departmentName;
81 private String companyCode;
82 private String company;
83 private String zipCodeSuffix;
84 private String jobTitle;
85 private String commandChain;
86 private String siloStatus;
87 private String costCenter;
88 private String financialLocCode;
92 private String loginId;
93 private String loginPwd;
94 private Date lastLoginDate;
95 private boolean active;
96 private boolean internal;
97 private Long selectedProfileId;
98 private Long timeZoneId;
99 private boolean online;
100 private String chatId;
101 private Integer languageId;
102 private static final long serialVersionUID = 1L;
104 private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPUser.class);
105 private static final String ECOMP_PORTAL_NAME = "ECOMP";
106 private boolean isGuest = false;
108 private SortedSet<EPUserApp> userApps = new TreeSet<EPUserApp>();
109 private SortedSet<EPRole> pseudoRoles = new TreeSet<EPRole>();
113 public Long getAddressId() {
117 public String getAlertMethodCd() {
118 return alertMethodCd;
121 public String getCellular() {
125 public String getEmail() {
129 public String getFax() {
133 public String getFirstName() {
137 public String getHrid() {
141 public Date getLastLoginDate() {
142 return lastLoginDate;
145 public String getLastName() {
150 public String getFullName() {
151 return getFirstName() + " " + getLastName();
154 public String getLoginId() {
158 public String getLoginPwd() {
162 public Long getManagerId() {
166 public String getMiddleInitial() {
167 return middleInitial;
170 public String getOrgCode() {
174 public Long getOrgId() {
178 public String getPhone() {
182 public String getOrgUserId() {
186 public boolean getActive() {
190 public boolean getInternal() {
194 public String getAddress1() {
198 public String getAddress2() {
202 public String getCity() {
206 public String getCountry() {
210 public String getState() {
214 public String getZipCode() {
218 public String getBusinessCountryCode() {
219 return businessCountryCode;
222 public String getCommandChain() {
226 public String getCompany() {
230 public String getCompanyCode() {
234 public String getDepartment() {
238 public String getJobTitle() {
242 public String getLocationClli() {
246 public String getOrgManagerUserId() {
247 return orgManagerUserId;
250 public String getZipCodeSuffix() {
251 return zipCodeSuffix;
254 public String getBusinessCountryName() {
255 return businessCountryName;
258 public Long getSelectedProfileId() {
259 return selectedProfileId;
262 public void setAddressId(Long addressId) {
263 this.addressId = addressId;
266 public void setAlertMethodCd(String alertMethodCd) {
267 this.alertMethodCd = alertMethodCd;
270 public void setCellular(String cellular) {
271 this.cellular = cellular;
274 public void setEmail(String email) {
278 public void setFax(String fax) {
282 public void setFirstName(String firstName) {
283 this.firstName = firstName;
286 public void setHrid(String hrid) {
290 public void setLastLoginDate(Date lastLoginDate) {
291 this.lastLoginDate = lastLoginDate;
294 public void setLastName(String lastName) {
295 this.lastName = lastName;
298 public void setLoginId(String loginId) {
299 this.loginId = loginId;
302 public void setLoginPwd(String loginPwd) {
303 this.loginPwd = loginPwd;
306 public void setManagerId(Long managerId) {
307 this.managerId = managerId;
310 public void setMiddleInitial(String middleInitial) {
311 this.middleInitial = middleInitial;
314 public void setOrgCode(String orgCode) {
315 this.orgCode = orgCode;
318 public void setOrgId(Long orgId) {
322 public void setPhone(String phone) {
326 public void setOrgUserId(String orgUserId) {
327 this.orgUserId = orgUserId;
330 public void setActive(boolean active) {
331 this.active = active;
334 public void setInternal(boolean internal) {
335 this.internal = internal;
338 public void setAddress1(String address1) {
339 this.address1 = address1;
342 public void setAddress2(String address2) {
343 this.address2 = address2;
346 public void setCity(String city) {
350 public void setCountry(String country) {
351 this.country = country;
354 public void setState(String state) {
358 public void setZipCode(String zipCode) {
359 this.zipCode = zipCode;
362 public void setBusinessCountryCode(String businessCountryCode) {
363 this.businessCountryCode = businessCountryCode;
366 public void setCommandChain(String commandChain) {
367 this.commandChain = commandChain;
370 public void setCompany(String company) {
371 this.company = company;
374 public void setCompanyCode(String companyCode) {
375 this.companyCode = companyCode;
378 public void setDepartment(String department) {
379 this.department = department;
382 public void setJobTitle(String jobTitle) {
383 this.jobTitle = jobTitle;
386 public void setLocationClli(String locationClli) {
387 this.locationClli = locationClli;
390 public void setOrgManagerUserId(String orgManagerUserId) {
391 this.orgManagerUserId = orgManagerUserId;
394 public void setZipCodeSuffix(String zipCodeSuffix) {
395 this.zipCodeSuffix = zipCodeSuffix;
398 public void setBusinessCountryName(String businessCountryName) {
399 this.businessCountryName = businessCountryName;
402 public SortedSet<EPRole> getPseudoRoles() {
406 public void setPseudoRoles(SortedSet<EPRole> pseudoRoles) {
407 this.pseudoRoles = pseudoRoles;
410 public void setSelectedProfileId(Long selectedProfileId) {
411 this.selectedProfileId = selectedProfileId;
414 public Long getTimeZoneId() {
418 public void setTimeZoneId(Long timeZoneId) {
419 this.timeZoneId = timeZoneId;
422 public String getBusinessUnit() {
426 public void setBusinessUnit(String businessUnit) {
427 this.businessUnit = businessUnit;
430 public String getSiloStatus() {
434 public void setSiloStatus(String siloStatus) {
435 this.siloStatus = siloStatus;
438 public String getCostCenter() {
442 public void setCostCenter(String costCenter) {
443 this.costCenter = costCenter;
446 public String getFinancialLocCode() {
447 return financialLocCode;
450 public void setFinancialLocCode(String financialLocCode) {
451 this.financialLocCode = financialLocCode;
454 public String getBusinessUnitName() {
455 return businessUnitName;
458 public void setBusinessUnitName(String businessUnitName) {
459 this.businessUnitName = businessUnitName;
462 public String getDepartmentName() {
463 return departmentName;
466 public void setDepartmentName(String departmentName) {
467 this.departmentName = departmentName;
470 public int compareTo(Object obj){
471 EPUser user = (EPUser)obj;
473 String c1 = getLastName() + getFirstName() + getMiddleInitial();
474 String c2 = user.getLastName() + user.getFirstName() + user.getMiddleInitial();
476 return c1.compareTo(c2);
479 public boolean isOnline() {
483 public void setOnline(boolean online) {
484 this.online = online;
487 public String getChatId() {
491 public void setChatId(String chatId) {
492 this.chatId = chatId;
496 public Integer getLanguageId() {
500 public void setLanguageId(Integer languageId) {
501 this.languageId = languageId;
504 public void setPseudoEPRoles(SortedSet<EPRole> pseudoRoles) {
505 this.pseudoRoles = pseudoRoles;
508 public SortedSet<EPUserApp> getEPUserApps() {
512 public void setEPUserApps(SortedSet<EPUserApp> userApps) {
513 this.userApps = userApps;
516 public void addUserApp(EPUserApp userApp) {
517 userApps.add(userApp);
520 public void addAppRoles(EPApp app, SortedSet<EPRole> roles) {
523 SortedSet<EPUserApp> userApps = new TreeSet<EPUserApp>();
524 // this.userApps.removeAll(this.userApps);
525 Iterator<EPRole> itr = roles.iterator();
526 while (itr.hasNext()) {
527 EPRole role = (EPRole) itr.next();
528 EPUserApp userApp = new EPUserApp();
529 userApp.setUserId(this.id);
531 userApp.setRole(role);
532 userApps.add(userApp);
534 setEPUserApps(userApps);
542 public SortedSet<EPRole> getAppEPRoles(EPApp app) {
544 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - app = {}", app.getName());
546 SortedSet<EPRole> roles = new TreeSet<EPRole>();
547 SortedSet<EPUserApp> userAppRoles = getEPUserApps();
549 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - userApps = {} ", userAppRoles.size());
551 Iterator<EPUserApp> userAppRolesIterator = userAppRoles.iterator();
553 EPUserApp userAppRole = null;
554 // getting default app
555 while (userAppRolesIterator.hasNext()) {
556 EPUserApp tempUserApp = (EPUserApp) userAppRolesIterator.next();
557 if (tempUserApp.getApp().getId().equals(app.getId())) {
559 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - for user {}, found application {}", this.getFullName(), app.getName());
561 userAppRole = tempUserApp;
563 EPRole role = userAppRole.getRole();
564 if(role.getActive()){
565 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - Role {} is active - adding for user {} and app {}", role.getName(), this.getFullName(), app.getName());
566 roles.add((EPRole) role);
569 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - Role {} is NOT active - NOT adding for user {} and app {}", role.getName(), this.getFullName(), app.getName());
573 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - roles = {}" , roles.size());
580 * Attention! Not for use in ONAP
582 public SortedSet<EPRole> getAppRoles(EPApp app) {
583 SortedSet<EPRole> roles = new TreeSet<EPRole>();
584 SortedSet<EPUserApp> apps = getEPUserApps();
585 Iterator<EPUserApp> appsItr = apps.iterator();
586 EPUserApp userApp = null;
587 // getting default app
588 while (appsItr.hasNext()) {
589 EPUserApp tempUserApp = (EPUserApp) appsItr.next();
590 if (tempUserApp.getApp().getId().equals(app.getId())) {
591 userApp = tempUserApp;
592 roles.add((EPRole) userApp.getRole());
601 * Attention! Not for use in ONAP
603 public SortedSet<EPRole> getEPRoles() {
604 EPApp app = new EPApp();
605 app.setId(new Long(PortalConstants.PORTAL_APP_ID));
606 app.setName(ECOMP_PORTAL_NAME);
607 return getAppEPRoles(app);
611 * Attention! Not for use in ONAP
613 public void setEPRoles(SortedSet<EPRole> roles) {
614 EPApp app = new EPApp();
615 app.setId(new Long(PortalConstants.PORTAL_APP_ID));
616 app.setName(ECOMP_PORTAL_NAME);
617 addAppRoles(app, roles);
621 * Attention! Not for use in ONAP
623 public void removeEPRole(Long roleId) {
624 SortedSet<EPUserApp> apps = getEPUserApps();
625 Iterator<EPUserApp> appsItr = apps.iterator();
626 // getting default app
627 while (appsItr.hasNext()) {
628 EPUserApp tempUserApp = (EPUserApp) appsItr.next();
629 if (tempUserApp.equals(new Long(PortalConstants.PORTAL_APP_ID)) && tempUserApp.getRole().getId().equals(roleId)) {
636 * Attention! Not for use in ONAP
638 public void addEPRole(EPRole role) {
640 SortedSet<EPRole> roles = getEPRoles();
642 roles = new TreeSet<EPRole>();
649 public boolean isGuest() {
653 public void setGuest(boolean isGuest) {
654 this.isGuest = isGuest;
658 public String toString() {
659 return "EPUser [orgId=" + orgId + ", managerId=" + managerId + ", firstName=" + firstName + ", middleInitial="
660 + middleInitial + ", lastName=" + lastName + ", phone=" + phone + ", fax=" + fax + ", cellular="
661 + cellular + ", email=" + email + ", addressId=" + addressId + ", alertMethodCd=" + alertMethodCd
662 + ", hrid=" + hrid + ", orgUserId=" + orgUserId + ", orgCode=" + orgCode + ", address1=" + address1
663 + ", address2=" + address2 + ", city=" + city + ", state=" + state + ", zipCode=" + zipCode
664 + ", country=" + country + ", orgManagerUserId=" + orgManagerUserId + ", locationClli=" + locationClli
665 + ", businessCountryCode=" + businessCountryCode + ", businessCountryName=" + businessCountryName
666 + ", businessUnit=" + businessUnit + ", businessUnitName=" + businessUnitName + ", department="
667 + department + ", departmentName=" + departmentName + ", companyCode=" + companyCode + ", company="
668 + company + ", zipCodeSuffix=" + zipCodeSuffix + ", jobTitle=" + jobTitle + ", commandChain="
669 + commandChain + ", siloStatus=" + siloStatus + ", costCenter=" + costCenter + ", financialLocCode="
670 + financialLocCode + ", loginId=" + loginId + ", loginPwd=" + loginPwd + ", lastLoginDate="
671 + lastLoginDate + ", active=" + active + ", internal=" + internal + ", selectedProfileId="
672 + selectedProfileId + ", timeZoneId=" + timeZoneId + ", online=" + online + ", chatId=" + chatId
673 + ", isGuest=" + isGuest + ", userApps=" + userApps + ", pseudoRoles=" + pseudoRoles + "]";