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 Integer languageId;
139 private static final long serialVersionUID = 1L;
141 private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPUser.class);
142 private static final String ECOMP_PORTAL_NAME = "ECOMP";
143 private boolean isGuest = false;
145 private SortedSet<EPUserApp> userApps = new TreeSet<EPUserApp>();
147 private SortedSet<EPRole> pseudoRoles = new TreeSet<EPRole>();
151 public Long getAddressId() {
155 public String getAlertMethodCd() {
156 return alertMethodCd;
159 public String getCellular() {
163 public String getEmail() {
167 public String getFax() {
171 public String getFirstName() {
175 public String getHrid() {
179 public Date getLastLoginDate() {
180 return lastLoginDate;
183 public String getLastName() {
188 public String getFullName() {
189 return getFirstName() + " " + getLastName();
192 public String getLoginId() {
196 public String getLoginPwd() {
200 public Long getManagerId() {
204 public String getMiddleInitial() {
205 return middleInitial;
208 public String getOrgCode() {
212 public Long getOrgId() {
216 public String getPhone() {
220 public String getOrgUserId() {
224 public boolean getActive() {
228 public boolean getInternal() {
232 public String getAddress1() {
236 public String getAddress2() {
240 public String getCity() {
244 public String getCountry() {
248 public String getState() {
252 public String getZipCode() {
256 public String getBusinessCountryCode() {
257 return businessCountryCode;
260 public String getCommandChain() {
264 public String getCompany() {
268 public String getCompanyCode() {
272 public String getDepartment() {
276 public String getJobTitle() {
280 public String getLocationClli() {
284 public String getOrgManagerUserId() {
285 return orgManagerUserId;
288 public String getZipCodeSuffix() {
289 return zipCodeSuffix;
292 public String getBusinessCountryName() {
293 return businessCountryName;
296 public Long getSelectedProfileId() {
297 return selectedProfileId;
300 public void setAddressId(Long addressId) {
301 this.addressId = addressId;
304 public void setAlertMethodCd(String alertMethodCd) {
305 this.alertMethodCd = alertMethodCd;
308 public void setCellular(String cellular) {
309 this.cellular = cellular;
312 public void setEmail(String email) {
316 public void setFax(String fax) {
320 public void setFirstName(String firstName) {
321 this.firstName = firstName;
324 public void setHrid(String hrid) {
328 public void setLastLoginDate(Date lastLoginDate) {
329 this.lastLoginDate = lastLoginDate;
332 public void setLastName(String lastName) {
333 this.lastName = lastName;
336 public void setLoginId(String loginId) {
337 this.loginId = loginId;
340 public void setLoginPwd(String loginPwd) {
341 this.loginPwd = loginPwd;
344 public void setManagerId(Long managerId) {
345 this.managerId = managerId;
348 public void setMiddleInitial(String middleInitial) {
349 this.middleInitial = middleInitial;
352 public void setOrgCode(String orgCode) {
353 this.orgCode = orgCode;
356 public void setOrgId(Long orgId) {
360 public void setPhone(String phone) {
364 public void setOrgUserId(String orgUserId) {
365 this.orgUserId = orgUserId;
368 public void setActive(boolean active) {
369 this.active = active;
372 public void setInternal(boolean internal) {
373 this.internal = internal;
376 public void setAddress1(String address1) {
377 this.address1 = address1;
380 public void setAddress2(String address2) {
381 this.address2 = address2;
384 public void setCity(String city) {
388 public void setCountry(String country) {
389 this.country = country;
392 public void setState(String state) {
396 public void setZipCode(String zipCode) {
397 this.zipCode = zipCode;
400 public void setBusinessCountryCode(String businessCountryCode) {
401 this.businessCountryCode = businessCountryCode;
404 public void setCommandChain(String commandChain) {
405 this.commandChain = commandChain;
408 public void setCompany(String company) {
409 this.company = company;
412 public void setCompanyCode(String companyCode) {
413 this.companyCode = companyCode;
416 public void setDepartment(String department) {
417 this.department = department;
420 public void setJobTitle(String jobTitle) {
421 this.jobTitle = jobTitle;
424 public void setLocationClli(String locationClli) {
425 this.locationClli = locationClli;
428 public void setOrgManagerUserId(String orgManagerUserId) {
429 this.orgManagerUserId = orgManagerUserId;
432 public void setZipCodeSuffix(String zipCodeSuffix) {
433 this.zipCodeSuffix = zipCodeSuffix;
436 public void setBusinessCountryName(String businessCountryName) {
437 this.businessCountryName = businessCountryName;
440 public SortedSet<EPRole> getPseudoRoles() {
444 public void setPseudoRoles(SortedSet<EPRole> pseudoRoles) {
445 this.pseudoRoles = pseudoRoles;
448 public void setSelectedProfileId(Long selectedProfileId) {
449 this.selectedProfileId = selectedProfileId;
452 public Long getTimeZoneId() {
456 public void setTimeZoneId(Long timeZoneId) {
457 this.timeZoneId = timeZoneId;
460 public String getBusinessUnit() {
464 public void setBusinessUnit(String businessUnit) {
465 this.businessUnit = businessUnit;
468 public String getSiloStatus() {
472 public void setSiloStatus(String siloStatus) {
473 this.siloStatus = siloStatus;
476 public String getCostCenter() {
480 public void setCostCenter(String costCenter) {
481 this.costCenter = costCenter;
484 public String getFinancialLocCode() {
485 return financialLocCode;
488 public void setFinancialLocCode(String financialLocCode) {
489 this.financialLocCode = financialLocCode;
492 public String getBusinessUnitName() {
493 return businessUnitName;
496 public void setBusinessUnitName(String businessUnitName) {
497 this.businessUnitName = businessUnitName;
500 public String getDepartmentName() {
501 return departmentName;
504 public void setDepartmentName(String departmentName) {
505 this.departmentName = departmentName;
508 public int compareTo(Object obj){
509 EPUser user = (EPUser)obj;
511 String c1 = getLastName() + getFirstName() + getMiddleInitial();
512 String c2 = user.getLastName() + user.getFirstName() + user.getMiddleInitial();
514 return c1.compareTo(c2);
517 public boolean isOnline() {
521 public void setOnline(boolean online) {
522 this.online = online;
525 public String getChatId() {
529 public void setChatId(String chatId) {
530 this.chatId = chatId;
534 public Integer getLanguageId() {
538 public void setLanguageId(Integer languageId) {
539 this.languageId = languageId;
542 public void setPseudoEPRoles(SortedSet<EPRole> pseudoRoles) {
543 this.pseudoRoles = pseudoRoles;
546 public SortedSet<EPUserApp> getEPUserApps() {
550 public void setEPUserApps(SortedSet<EPUserApp> userApps) {
551 this.userApps = userApps;
554 public void addUserApp(EPUserApp userApp) {
555 userApps.add(userApp);
558 public void addAppRoles(EPApp app, SortedSet<EPRole> roles) {
561 SortedSet<EPUserApp> userApps = new TreeSet<EPUserApp>();
562 // this.userApps.removeAll(this.userApps);
563 Iterator<EPRole> itr = roles.iterator();
564 while (itr.hasNext()) {
565 EPRole role = (EPRole) itr.next();
566 EPUserApp userApp = new EPUserApp();
567 userApp.setUserId(this.id);
569 userApp.setRole(role);
570 userApps.add(userApp);
572 setEPUserApps(userApps);
580 public SortedSet<EPRole> getAppEPRoles(EPApp app) {
582 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - app = {}", app.getName());
584 SortedSet<EPRole> roles = new TreeSet<EPRole>();
585 SortedSet<EPUserApp> userAppRoles = getEPUserApps();
587 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - userApps = {} ", userAppRoles.size());
589 Iterator<EPUserApp> userAppRolesIterator = userAppRoles.iterator();
591 EPUserApp userAppRole = null;
592 // getting default app
593 while (userAppRolesIterator.hasNext()) {
594 EPUserApp tempUserApp = (EPUserApp) userAppRolesIterator.next();
595 if (tempUserApp.getApp().getId().equals(app.getId())) {
597 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - for user {}, found application {}", this.getFullName(), app.getName());
599 userAppRole = tempUserApp;
601 EPRole role = userAppRole.getRole();
602 if(role.getActive()){
603 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - Role {} is active - adding for user {} and app {}", role.getName(), this.getFullName(), app.getName());
604 roles.add((EPRole) role);
607 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - Role {} is NOT active - NOT adding for user {} and app {}", role.getName(), this.getFullName(), app.getName());
611 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - roles = {}" , roles.size());
618 * Attention! Not for use in ONAP
620 public SortedSet<EPRole> getAppRoles(EPApp app) {
621 SortedSet<EPRole> roles = new TreeSet<EPRole>();
622 SortedSet<EPUserApp> apps = getEPUserApps();
623 Iterator<EPUserApp> appsItr = apps.iterator();
624 EPUserApp userApp = null;
625 // getting default app
626 while (appsItr.hasNext()) {
627 EPUserApp tempUserApp = (EPUserApp) appsItr.next();
628 if (tempUserApp.getApp().getId().equals(app.getId())) {
629 userApp = tempUserApp;
630 roles.add((EPRole) userApp.getRole());
639 * Attention! Not for use in ONAP
641 public SortedSet<EPRole> getEPRoles() {
642 EPApp app = new EPApp();
643 app.setId(new Long(PortalConstants.PORTAL_APP_ID));
644 app.setName(ECOMP_PORTAL_NAME);
645 return getAppEPRoles(app);
649 * Attention! Not for use in ONAP
651 public void setEPRoles(SortedSet<EPRole> roles) {
652 EPApp app = new EPApp();
653 app.setId(new Long(PortalConstants.PORTAL_APP_ID));
654 app.setName(ECOMP_PORTAL_NAME);
655 addAppRoles(app, roles);
659 * Attention! Not for use in ONAP
661 public void removeEPRole(Long roleId) {
662 SortedSet<EPUserApp> apps = getEPUserApps();
663 Iterator<EPUserApp> appsItr = apps.iterator();
664 // getting default app
665 while (appsItr.hasNext()) {
666 EPUserApp tempUserApp = (EPUserApp) appsItr.next();
667 if (tempUserApp.equals(new Long(PortalConstants.PORTAL_APP_ID)) && tempUserApp.getRole().getId().equals(roleId)) {
674 * Attention! Not for use in ONAP
676 public void addEPRole(EPRole role) {
678 SortedSet<EPRole> roles = getEPRoles();
680 roles = new TreeSet<EPRole>();
687 public boolean isGuest() {
691 public void setGuest(boolean isGuest) {
692 this.isGuest = isGuest;
696 public String toString() {
697 return "EPUser [orgId=" + orgId + ", managerId=" + managerId + ", firstName=" + firstName + ", middleInitial="
698 + middleInitial + ", lastName=" + lastName + ", phone=" + phone + ", fax=" + fax + ", cellular="
699 + cellular + ", email=" + email + ", addressId=" + addressId + ", alertMethodCd=" + alertMethodCd
700 + ", hrid=" + hrid + ", orgUserId=" + orgUserId + ", orgCode=" + orgCode + ", address1=" + address1
701 + ", address2=" + address2 + ", city=" + city + ", state=" + state + ", zipCode=" + zipCode
702 + ", country=" + country + ", orgManagerUserId=" + orgManagerUserId + ", locationClli=" + locationClli
703 + ", businessCountryCode=" + businessCountryCode + ", businessCountryName=" + businessCountryName
704 + ", businessUnit=" + businessUnit + ", businessUnitName=" + businessUnitName + ", department="
705 + department + ", departmentName=" + departmentName + ", companyCode=" + companyCode + ", company="
706 + company + ", zipCodeSuffix=" + zipCodeSuffix + ", jobTitle=" + jobTitle + ", commandChain="
707 + commandChain + ", siloStatus=" + siloStatus + ", costCenter=" + costCenter + ", financialLocCode="
708 + financialLocCode + ", loginId=" + loginId + ", loginPwd=" + loginPwd + ", lastLoginDate="
709 + lastLoginDate + ", active=" + active + ", internal=" + internal + ", selectedProfileId="
710 + selectedProfileId + ", timeZoneId=" + timeZoneId + ", online=" + online + ", chatId=" + chatId
711 + ", isGuest=" + isGuest + ", userApps=" + userApps + ", pseudoRoles=" + pseudoRoles + "]";