2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ===================================================================
10 * Unless otherwise specified, all software contained herein is licensed
11 * under the Apache License, Version 2.0 (the "License");
12 * you may not use this software except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 * Unless otherwise specified, all documentation contained herein is licensed
24 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
25 * you may not use this documentation except in compliance with the License.
26 * You may obtain a copy of the License at
28 * https://creativecommons.org/licenses/by/4.0/
30 * Unless required by applicable law or agreed to in writing, documentation
31 * distributed under the License is distributed on an "AS IS" BASIS,
32 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33 * See the License for the specific language governing permissions and
34 * limitations under the License.
36 * ============LICENSE_END============================================
41 package org.onap.portal.domain.dto.ecomp;
43 import com.fasterxml.jackson.annotation.JsonIgnore;
44 import java.util.Date;
45 import java.util.Iterator;
46 import java.util.SortedSet;
47 import java.util.TreeSet;
48 import javax.validation.Valid;
49 import lombok.AllArgsConstructor;
50 import lombok.Builder;
52 import lombok.NoArgsConstructor;
54 import lombok.ToString;
55 import org.hibernate.validator.constraints.SafeHtml;
56 import org.onap.portalsdk.core.domain.User;
57 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
65 public class EPUser extends User {
68 private Long managerId;
70 private String firstName;
72 private String middleInitial;
74 private String lastName;
80 private String cellular;
83 private Long addressId;
85 private String alertMethodCd;
89 private String orgUserId;
91 private String orgCode;
93 private String address1;
95 private String address2;
101 private String zipCode;
103 private String country;
105 private String orgManagerUserId;
107 private String locationClli;
109 private String businessCountryCode;
111 private String businessCountryName;
113 private String businessUnit;
115 private String businessUnitName;
117 private String department;
119 private String departmentName;
121 private String companyCode;
123 private String company;
125 private String zipCodeSuffix;
127 private String jobTitle;
129 private String commandChain;
131 private String siloStatus;
133 private String costCenter;
135 private String financialLocCode;
137 private String loginId;
139 private String loginPwd;
140 private Date lastLoginDate;
141 private boolean active;
142 private boolean internal;
143 private Long selectedProfileId;
144 private Long timeZoneId;
145 private boolean online;
147 private String chatId;
148 private boolean systemUser;
149 private Integer languageId;
150 private static final long serialVersionUID = 1L;
151 private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPUser.class);
152 private static final String ECOMP_PORTAL_NAME = "ECOMP";
153 private boolean isGuest = false;
155 private SortedSet<EPUserApp> userApps = new TreeSet<>();
157 private SortedSet<EPRole> pseudoRoles = new TreeSet<>();
160 public String getFullName() {
161 return getFirstName() + " " + getLastName();
164 public int compareTo(Object obj) {
165 EPUser user = (EPUser) obj;
167 String c1 = getLastName() + getFirstName() + getMiddleInitial();
168 String c2 = user.getLastName() + user.getFirstName() + user.getMiddleInitial();
170 return c1.compareTo(c2);
174 public void addAppRoles(EPApp app, SortedSet<EPRole> roles) {
177 SortedSet<EPUserApp> userApps = new TreeSet<>();
178 // this.userApps.removeAll(this.userApps);
179 for (EPRole role : roles) {
180 EPUserApp userApp = new EPUserApp();
181 userApp.setUserId(this.id);
183 userApp.setRole(role);
184 userApps.add(userApp);
186 setUserApps(userApps);
193 public SortedSet<EPRole> getAppEPRoles(EPApp app) {
195 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - app = {}", app.getName());
197 SortedSet<EPRole> roles = new TreeSet<>();
198 SortedSet<EPUserApp> userAppRoles = getUserApps();
200 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - userApps = {} ",
201 userAppRoles.size());
203 Iterator<EPUserApp> userAppRolesIterator = userAppRoles.iterator();
205 EPUserApp userAppRole;
206 // getting default app
207 while (userAppRolesIterator.hasNext()) {
208 EPUserApp tempUserApp = userAppRolesIterator.next();
209 if (tempUserApp.getApp().getId().equals(app.getId())) {
211 logger.debug(EELFLoggerDelegate.debugLogger,
212 "In EPUser.getAppEPRoles() - for user {}, found application {}", this.getFullName(),
215 userAppRole = tempUserApp;
217 EPRole role = userAppRole.getRole();
218 if (role.isActive()) {
219 logger.debug(EELFLoggerDelegate.debugLogger,
220 "In EPUser.getAppEPRoles() - Role {} is active - adding for user {} and app {}",
221 role.getName(), this.getFullName(), app.getName());
224 logger.debug(EELFLoggerDelegate.debugLogger,
225 "In EPUser.getAppEPRoles() - Role {} is NOT active - NOT adding for user {} and app {}",
226 role.getName(), this.getFullName(), app.getName());
230 logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - roles = {}", roles.size());