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 javax.validation.Valid;
46 import org.hibernate.validator.constraints.SafeHtml;
47 import org.onap.portalapp.portal.utils.PortalConstants;
48 import org.onap.portalsdk.core.domain.User;
49 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
51 import com.fasterxml.jackson.annotation.JsonIgnore;
53 public class EPUser extends User {
56 private Long managerId;
58 private String firstName;
60 private String middleInitial;
62 private String lastName;
68 private String cellular;
71 private Long addressId;
73 private String alertMethodCd;
77 private String orgUserId;
79 private String orgCode;
81 private String address1;
83 private String address2;
89 private String zipCode;
91 private String country;
93 private String orgManagerUserId;
95 private String locationClli;
97 private String businessCountryCode;
99 private String businessCountryName;
101 private String businessUnit;
103 private String businessUnitName;
105 private String department;
107 private String departmentName;
109 private String companyCode;
111 private String company;
113 private String zipCodeSuffix;
115 private String jobTitle;
117 private String commandChain;
119 private String siloStatus;
121 private String costCenter;
123 private String financialLocCode;
127 private String loginId;
129 private String loginPwd;
130 private Date lastLoginDate;
131 private boolean active;
132 private boolean internal;
133 private Long selectedProfileId;
134 private Long timeZoneId;
135 private boolean online;
137 private String chatId;
138 private boolean systemUser;
139 private Integer languageId;
140 private static final long serialVersionUID = 1L;
143 private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPUser.class);
144 private static final String ECOMP_PORTAL_NAME = "ECOMP";
145 private boolean isGuest = false;
147 private SortedSet<EPUserApp> userApps = new TreeSet<EPUserApp>();
149 private SortedSet<EPRole> pseudoRoles = new TreeSet<EPRole>();
153 public Long getAddressId() {
157 public String getAlertMethodCd() {
158 return alertMethodCd;
161 public String getCellular() {
165 public String getEmail() {
169 public String getFax() {
173 public String getFirstName() {
177 public String getHrid() {
181 public Date getLastLoginDate() {
182 return lastLoginDate;
185 public String getLastName() {
190 public String getFullName() {
191 return getFirstName() + " " + getLastName();
194 public String getLoginId() {
198 public String getLoginPwd() {
202 public Long getManagerId() {
206 public String getMiddleInitial() {
207 return middleInitial;
210 public String getOrgCode() {
214 public Long getOrgId() {
218 public String getPhone() {
222 public String getOrgUserId() {
226 public boolean getActive() {
230 public boolean getInternal() {
234 public String getAddress1() {
238 public String getAddress2() {
242 public String getCity() {
246 public String getCountry() {
250 public String getState() {
254 public String getZipCode() {
258 public String getBusinessCountryCode() {
259 return businessCountryCode;
262 public String getCommandChain() {
266 public String getCompany() {
270 public String getCompanyCode() {
274 public String getDepartment() {
278 public String getJobTitle() {
282 public String getLocationClli() {
286 public String getOrgManagerUserId() {
287 return orgManagerUserId;
290 public String getZipCodeSuffix() {
291 return zipCodeSuffix;
294 public String getBusinessCountryName() {
295 return businessCountryName;
298 public Long getSelectedProfileId() {
299 return selectedProfileId;
302 public void setAddressId(Long addressId) {
303 this.addressId = addressId;
306 public void setAlertMethodCd(String alertMethodCd) {
307 this.alertMethodCd = alertMethodCd;
310 public void setCellular(String cellular) {
311 this.cellular = cellular;
314 public void setEmail(String email) {
318 public void setFax(String fax) {
322 public void setFirstName(String firstName) {
323 this.firstName = firstName;
326 public void setHrid(String hrid) {
330 public void setLastLoginDate(Date lastLoginDate) {
331 this.lastLoginDate = lastLoginDate;
334 public void setLastName(String lastName) {
335 this.lastName = lastName;
338 public void setLoginId(String loginId) {
339 this.loginId = loginId;
342 public void setLoginPwd(String loginPwd) {
343 this.loginPwd = loginPwd;
346 public void setManagerId(Long managerId) {
347 this.managerId = managerId;
350 public void setMiddleInitial(String middleInitial) {
351 this.middleInitial = middleInitial;
354 public void setOrgCode(String orgCode) {
355 this.orgCode = orgCode;
358 public void setOrgId(Long orgId) {
362 public void setPhone(String phone) {
366 public void setOrgUserId(String orgUserId) {
367 this.orgUserId = orgUserId;
370 public void setActive(boolean active) {
371 this.active = active;
374 public void setInternal(boolean internal) {
375 this.internal = internal;
378 public void setAddress1(String address1) {
379 this.address1 = address1;
382 public void setAddress2(String address2) {
383 this.address2 = address2;
386 public void setCity(String city) {
390 public void setCountry(String country) {
391 this.country = country;
394 public void setState(String state) {
398 public void setZipCode(String zipCode) {
399 this.zipCode = zipCode;
402 public void setBusinessCountryCode(String businessCountryCode) {
403 this.businessCountryCode = businessCountryCode;
406 public void setCommandChain(String commandChain) {
407 this.commandChain = commandChain;
410 public void setCompany(String company) {
411 this.company = company;
414 public void setCompanyCode(String companyCode) {
415 this.companyCode = companyCode;
418 public void setDepartment(String department) {
419 this.department = department;
422 public void setJobTitle(String jobTitle) {
423 this.jobTitle = jobTitle;
426 public void setLocationClli(String locationClli) {
427 this.locationClli = locationClli;
430 public void setOrgManagerUserId(String orgManagerUserId) {
431 this.orgManagerUserId = orgManagerUserId;
434 public void setZipCodeSuffix(String zipCodeSuffix) {
435 this.zipCodeSuffix = zipCodeSuffix;
438 public void setBusinessCountryName(String businessCountryName) {
439 this.businessCountryName = businessCountryName;
442 public SortedSet<EPRole> getPseudoRoles() {
446 public void setPseudoRoles(SortedSet<EPRole> pseudoRoles) {
447 this.pseudoRoles = pseudoRoles;
450 public void setSelectedProfileId(Long selectedProfileId) {
451 this.selectedProfileId = selectedProfileId;
454 public Long getTimeZoneId() {
458 public void setTimeZoneId(Long timeZoneId) {
459 this.timeZoneId = timeZoneId;
462 public String getBusinessUnit() {
466 public void setBusinessUnit(String businessUnit) {
467 this.businessUnit = businessUnit;
470 public String getSiloStatus() {
474 public void setSiloStatus(String siloStatus) {
475 this.siloStatus = siloStatus;
478 public String getCostCenter() {
482 public void setCostCenter(String costCenter) {
483 this.costCenter = costCenter;
486 public String getFinancialLocCode() {
487 return financialLocCode;
490 public void setFinancialLocCode(String financialLocCode) {
491 this.financialLocCode = financialLocCode;
494 public String getBusinessUnitName() {
495 return businessUnitName;
498 public void setBusinessUnitName(String businessUnitName) {
499 this.businessUnitName = businessUnitName;
502 public String getDepartmentName() {
503 return departmentName;
506 public void setDepartmentName(String departmentName) {
507 this.departmentName = departmentName;
510 public int compareTo(Object obj){
511 EPUser user = (EPUser)obj;
513 String c1 = getLastName() + getFirstName() + getMiddleInitial();
514 String c2 = user.getLastName() + user.getFirstName() + user.getMiddleInitial();
516 return c1.compareTo(c2);
519 public boolean isOnline() {
523 public void setOnline(boolean online) {
524 this.online = online;
527 public String getChatId() {
531 public void setChatId(String chatId) {
532 this.chatId = chatId;
536 public Integer getLanguageId() {
540 public void setLanguageId(Integer languageId) {
541 this.languageId = languageId;
544 public void setPseudoEPRoles(SortedSet<EPRole> pseudoRoles) {
545 this.pseudoRoles = pseudoRoles;
548 public SortedSet<EPUserApp> getEPUserApps() {
552 public void setEPUserApps(SortedSet<EPUserApp> userApps) {
553 this.userApps = userApps;
556 public void addUserApp(EPUserApp userApp) {
557 userApps.add(userApp);
560 public void addAppRoles(EPApp app, SortedSet<EPRole> roles) {
563 SortedSet<EPUserApp> userApps = new TreeSet<EPUserApp>();
564 // this.userApps.removeAll(this.userApps);
565 Iterator<EPRole> itr = roles.iterator();
566 while (itr.hasNext()) {
567 EPRole role = (EPRole) itr.next();
568 EPUserApp userApp = new EPUserApp();
569 userApp.setUserId(this.id);
571 userApp.setRole(role);
572 userApps.add(userApp);
574 setEPUserApps(userApps);
582 public SortedSet<EPRole> getAppEPRoles(EPApp app) {
584 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - app = {}", app.getName());
586 SortedSet<EPRole> roles = new TreeSet<EPRole>();
587 SortedSet<EPUserApp> userAppRoles = getEPUserApps();
589 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - userApps = {} ", userAppRoles.size());
591 Iterator<EPUserApp> userAppRolesIterator = userAppRoles.iterator();
593 EPUserApp userAppRole = null;
594 // getting default app
595 while (userAppRolesIterator.hasNext()) {
596 EPUserApp tempUserApp = (EPUserApp) userAppRolesIterator.next();
597 if (tempUserApp.getApp().getId().equals(app.getId())) {
599 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - for user {}, found application {}", this.getFullName(), app.getName());
601 userAppRole = tempUserApp;
603 EPRole role = userAppRole.getRole();
604 if(role.getActive()){
605 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - Role {} is active - adding for user {} and app {}", role.getName(), this.getFullName(), app.getName());
606 roles.add((EPRole) role);
609 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - Role {} is NOT active - NOT adding for user {} and app {}", role.getName(), this.getFullName(), app.getName());
613 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - roles = {}" , roles.size());
620 * Attention! Not for use in ONAP
622 public SortedSet<EPRole> getAppRoles(EPApp app) {
623 SortedSet<EPRole> roles = new TreeSet<EPRole>();
624 SortedSet<EPUserApp> apps = getEPUserApps();
625 Iterator<EPUserApp> appsItr = apps.iterator();
626 EPUserApp userApp = null;
627 // getting default app
628 while (appsItr.hasNext()) {
629 EPUserApp tempUserApp = (EPUserApp) appsItr.next();
630 if (tempUserApp.getApp().getId().equals(app.getId())) {
631 userApp = tempUserApp;
632 roles.add((EPRole) userApp.getRole());
641 * Attention! Not for use in ONAP
643 public SortedSet<EPRole> getEPRoles() {
644 EPApp app = new EPApp();
645 app.setId(new Long(PortalConstants.PORTAL_APP_ID));
646 app.setName(ECOMP_PORTAL_NAME);
647 return getAppEPRoles(app);
651 * Attention! Not for use in ONAP
653 public void setEPRoles(SortedSet<EPRole> roles) {
654 EPApp app = new EPApp();
655 app.setId(new Long(PortalConstants.PORTAL_APP_ID));
656 app.setName(ECOMP_PORTAL_NAME);
657 addAppRoles(app, roles);
661 * Attention! Not for use in ONAP
663 public void removeEPRole(Long roleId) {
664 SortedSet<EPUserApp> apps = getEPUserApps();
665 Iterator<EPUserApp> appsItr = apps.iterator();
666 // getting default app
667 while (appsItr.hasNext()) {
668 EPUserApp tempUserApp = (EPUserApp) appsItr.next();
669 if (tempUserApp.equals(new Long(PortalConstants.PORTAL_APP_ID)) && tempUserApp.getRole().getId().equals(roleId)) {
676 * Attention! Not for use in ONAP
678 public void addEPRole(EPRole role) {
680 SortedSet<EPRole> roles = getEPRoles();
682 roles = new TreeSet<EPRole>();
689 public boolean isGuest() {
693 public void setGuest(boolean isGuest) {
694 this.isGuest = isGuest;
697 public boolean isSystemUser() {
701 public void setSystemUser(boolean systemUser) {
702 this.systemUser = systemUser;
706 public String toString() {
707 return "EPUser [orgId=" + orgId + ", managerId=" + managerId + ", firstName=" + firstName + ", middleInitial="
708 + middleInitial + ", lastName=" + lastName + ", phone=" + phone + ", fax=" + fax + ", cellular="
709 + cellular + ", email=" + email + ", addressId=" + addressId + ", alertMethodCd=" + alertMethodCd
710 + ", hrid=" + hrid + ", orgUserId=" + orgUserId + ", orgCode=" + orgCode + ", address1=" + address1
711 + ", address2=" + address2 + ", city=" + city + ", state=" + state + ", zipCode=" + zipCode
712 + ", country=" + country + ", orgManagerUserId=" + orgManagerUserId + ", locationClli=" + locationClli
713 + ", businessCountryCode=" + businessCountryCode + ", businessCountryName=" + businessCountryName
714 + ", businessUnit=" + businessUnit + ", businessUnitName=" + businessUnitName + ", department="
715 + department + ", departmentName=" + departmentName + ", companyCode=" + companyCode + ", company="
716 + company + ", zipCodeSuffix=" + zipCodeSuffix + ", jobTitle=" + jobTitle + ", commandChain="
717 + commandChain + ", siloStatus=" + siloStatus + ", costCenter=" + costCenter + ", financialLocCode="
718 + financialLocCode + ", loginId=" + loginId + ", loginPwd=" + loginPwd + ", lastLoginDate="
719 + lastLoginDate + ", active=" + active + ", internal=" + internal + ", selectedProfileId="
720 + selectedProfileId + ", timeZoneId=" + timeZoneId + ", online=" + online + ", chatId=" + chatId
721 + ", isGuest=" + isGuest + ", userApps=" + userApps + ", pseudoRoles=" + pseudoRoles + "]";