nexus site path corrected
[portal.git] / ecomp-portal-BE / src / main / java / org / openecomp / portalapp / portal / domain / EPUser.java
1 /*-
2  * ================================================================================
3  * eCOMP Portal
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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  * ================================================================================
19  */
20 package org.openecomp.portalapp.portal.domain;
21
22 import java.util.Date;
23 import java.util.Iterator;
24 import java.util.SortedSet;
25 import java.util.TreeSet;
26
27 import org.openecomp.portalsdk.core.domain.support.DomainVo;
28
29 public class EPUser extends DomainVo {
30             
31             private Long   orgId;
32             private Long   managerId;
33             private String firstName;
34             private String middleInitial;
35             private String lastName;
36             private String phone;
37             private String fax;
38             private String cellular;
39             private String email;
40             private Long   addressId;
41             private String alertMethodCd;
42             private String hrid;
43             private String orgUserId;
44             private String orgCode;
45             private String address1;
46             private String address2;
47             private String city;
48             private String state;
49             private String zipCode;
50             private String country;
51             private String orgManagerUserId;
52             private String locationClli;
53             private String businessCountryCode;
54             private String businessCountryName;
55             private String businessUnit;
56             private String businessUnitName;
57             private String department;
58             private String departmentName;
59             private String companyCode;
60             private String company;
61             private String zipCodeSuffix;
62             private String jobTitle;
63             private String commandChain;
64             private String siloStatus;
65             private String costCenter;
66             private String financialLocCode;
67             
68             
69           
70             private String loginId;
71             private String loginPwd;
72             private Date   lastLoginDate;
73             private boolean active;
74             private boolean internal;
75             private Long    selectedProfileId;
76             private Long timeZoneId;
77             private boolean online;
78             private String chatId;
79         
80             private static final long serialVersionUID = 1L;
81
82                 private static final long ECOMP_PORTAL_ID = 1L;
83                 private static final String ECOMP_PORTAL_NAME = "ECOMP";
84                 private boolean isGuest = false;
85                 
86                 private SortedSet<EPUserApp> userApps = new TreeSet<EPUserApp>();
87                 private SortedSet<EPRole> pseudoRoles = new TreeSet<EPRole>();
88
89             public EPUser() {}
90
91             public Long getAddressId() {
92                 return addressId;
93             }
94
95             public String getAlertMethodCd() {
96                 return alertMethodCd;
97             }
98
99             public String getCellular() {
100                 return cellular;
101             }
102
103             public String getEmail() {
104                 return email;
105             }
106
107             public String getFax() {
108                 return fax;
109             }
110
111             public String getFirstName() {
112                 return firstName;
113             }
114
115             public String getHrid() {
116                 return hrid;
117             }
118
119             public Date getLastLoginDate() {
120                 return lastLoginDate;
121             }
122
123             public String getLastName() {
124                 return lastName;
125             }
126
127             public String getFullName() {
128                 return getFirstName() + " " + getLastName();    
129             }
130             
131             public String getLoginId() {
132                 return loginId;
133             }
134
135             public String getLoginPwd() {
136                 return loginPwd;
137             }
138
139             public Long getManagerId() {
140                 return managerId;
141             }
142
143             public String getMiddleInitial() {
144                 return middleInitial;
145             }
146
147             public String getOrgCode() {
148                 return orgCode;
149             }
150
151             public Long getOrgId() {
152                 return orgId;
153             }
154
155             public String getPhone() {
156                 return phone;
157             }
158
159             public String getOrgUserId() {
160                 return orgUserId;
161             }
162
163             public boolean getActive() {
164                 return active;
165             }
166
167             public boolean getInternal() {
168                 return internal;
169             }
170
171             public String getAddress1() {
172                 return address1;
173             }
174
175             public String getAddress2() {
176                 return address2;
177             }
178
179             public String getCity() {
180                 return city;
181             }
182
183             public String getCountry() {
184                 return country;
185             }
186
187             public String getState() {
188                 return state;
189             }
190
191             public String getZipCode() {
192                 return zipCode;
193             }
194
195             public String getBusinessCountryCode() {
196                 return businessCountryCode;
197             }
198
199             public String getCommandChain() {
200                 return commandChain;
201             }
202
203             public String getCompany() {
204                 return company;
205             }
206
207             public String getCompanyCode() {
208                 return companyCode;
209             }
210
211             public String getDepartment() {
212                 return department;
213             }
214
215             public String getJobTitle() {
216                 return jobTitle;
217             }
218
219             public String getLocationClli() {
220                 return locationClli;
221             }
222
223             public String getOrgManagerUserId() {
224                 return orgManagerUserId;
225             }
226
227             public String getZipCodeSuffix() {
228                 return zipCodeSuffix;
229             }
230
231             public String getBusinessCountryName() {
232                 return businessCountryName;
233             }
234
235             public Long getSelectedProfileId() {
236                 return selectedProfileId;
237             }
238
239             public void setAddressId(Long addressId) {
240                 this.addressId = addressId;
241             }
242
243             public void setAlertMethodCd(String alertMethodCd) {
244                 this.alertMethodCd = alertMethodCd;
245             }
246
247             public void setCellular(String cellular) {
248                 this.cellular = cellular;
249             }
250
251             public void setEmail(String email) {
252                 this.email = email;
253             }
254
255             public void setFax(String fax) {
256                 this.fax = fax;
257             }
258
259             public void setFirstName(String firstName) {
260                 this.firstName = firstName;
261             }
262
263             public void setHrid(String hrid) {
264                 this.hrid = hrid;
265             }
266
267             public void setLastLoginDate(Date lastLoginDate) {
268                 this.lastLoginDate = lastLoginDate;
269             }
270
271             public void setLastName(String lastName) {
272                 this.lastName = lastName;
273             }
274
275             public void setLoginId(String loginId) {
276                 this.loginId = loginId;
277             }
278
279             public void setLoginPwd(String loginPwd) {
280                 this.loginPwd = loginPwd;
281             }
282
283             public void setManagerId(Long managerId) {
284                 this.managerId = managerId;
285             }
286
287             public void setMiddleInitial(String middleInitial) {
288                 this.middleInitial = middleInitial;
289             }
290
291             public void setOrgCode(String orgCode) {
292                 this.orgCode = orgCode;
293             }
294
295             public void setOrgId(Long orgId) {
296                 this.orgId = orgId;
297             }
298
299             public void setPhone(String phone) {
300                 this.phone = phone;
301             }
302
303             public void setOrgUserId(String orgUserId) {
304                 this.orgUserId = orgUserId;
305             }
306
307             public void setActive(boolean active) {
308                 this.active = active;
309             }
310
311             public void setInternal(boolean internal) {
312                 this.internal = internal;
313             }
314
315             public void setAddress1(String address1) {
316                 this.address1 = address1;
317             }
318
319             public void setAddress2(String address2) {
320                 this.address2 = address2;
321             }
322
323             public void setCity(String city) {
324                 this.city = city;
325             }
326
327             public void setCountry(String country) {
328                 this.country = country;
329             }
330
331             public void setState(String state) {
332                 this.state = state;
333             }
334
335             public void setZipCode(String zipCode) {
336                 this.zipCode = zipCode;
337             }
338
339             public void setBusinessCountryCode(String businessCountryCode) {
340                 this.businessCountryCode = businessCountryCode;
341             }
342
343             public void setCommandChain(String commandChain) {
344                 this.commandChain = commandChain;
345             }
346
347             public void setCompany(String company) {
348                 this.company = company;
349             }
350
351             public void setCompanyCode(String companyCode) {
352                 this.companyCode = companyCode;
353             }
354
355             public void setDepartment(String department) {
356                 this.department = department;
357             }
358
359             public void setJobTitle(String jobTitle) {
360                 this.jobTitle = jobTitle;
361             }
362
363             public void setLocationClli(String locationClli) {
364                 this.locationClli = locationClli;
365             }
366
367             public void setOrgManagerUserId(String orgManagerUserId) {
368                 this.orgManagerUserId = orgManagerUserId;
369             }
370
371             public void setZipCodeSuffix(String zipCodeSuffix) {
372                 this.zipCodeSuffix = zipCodeSuffix;
373             }
374
375             public void setBusinessCountryName(String businessCountryName) {
376                 this.businessCountryName = businessCountryName;
377             }
378
379             public SortedSet<EPRole> getPseudoRoles() {
380                         return pseudoRoles;
381                 }
382             
383             public void setPseudoRoles(SortedSet<EPRole> pseudoRoles) {
384                 this.pseudoRoles = pseudoRoles;
385             }
386
387             public void setSelectedProfileId(Long selectedProfileId) {
388                 this.selectedProfileId = selectedProfileId;
389             }
390             
391                 public Long getTimeZoneId() {
392                         return timeZoneId;
393                 }
394
395                 public void setTimeZoneId(Long timeZoneId) {
396                         this.timeZoneId = timeZoneId;
397                 }
398
399                 public String getBusinessUnit() {
400                         return businessUnit;
401                 }
402
403                 public void setBusinessUnit(String businessUnit) {
404                         this.businessUnit = businessUnit;
405                 }
406
407                 public String getSiloStatus() {
408                         return siloStatus;
409                 }
410
411                 public void setSiloStatus(String siloStatus) {
412                         this.siloStatus = siloStatus;
413                 }
414
415                 public String getCostCenter() {
416                         return costCenter;
417                 }
418
419                 public void setCostCenter(String costCenter) {
420                         this.costCenter = costCenter;
421                 }
422
423                 public String getFinancialLocCode() {
424                         return financialLocCode;
425                 }
426
427                 public void setFinancialLocCode(String financialLocCode) {
428                         this.financialLocCode = financialLocCode;
429                 }
430                 
431                 public String getBusinessUnitName() {
432                         return businessUnitName;
433                 }
434
435                 public void setBusinessUnitName(String businessUnitName) {
436                         this.businessUnitName = businessUnitName;
437                 }
438
439                 public String getDepartmentName() {
440                         return departmentName;
441                 }
442
443                 public void setDepartmentName(String departmentName) {
444                         this.departmentName = departmentName;
445                 }
446
447                 public int compareTo(Object obj){
448               EPUser user = (EPUser)obj;
449
450               String c1 = getLastName() + getFirstName() + getMiddleInitial();
451               String c2 = user.getLastName() + user.getFirstName() + user.getMiddleInitial();
452
453               return c1.compareTo(c2);
454             }
455
456                 public boolean isOnline() {
457                         return online;
458                 }
459
460                 public void setOnline(boolean online) {
461                         this.online = online;
462                 }
463
464                 public String getChatId() {
465                         return chatId;
466                 }
467
468                 public void setChatId(String chatId) {
469                         this.chatId = chatId;
470                 }
471
472                 
473         public void setPseudoEPRoles(SortedSet<EPRole> pseudoRoles) {
474                 this.pseudoRoles = pseudoRoles;
475         }
476         
477         public SortedSet<EPUserApp> getEPUserApps() {
478                 return userApps;
479         }
480
481         public void setEPUserApps(SortedSet<EPUserApp> userApps) {
482                 this.userApps = userApps;
483         }
484
485         public void addUserApp(EPUserApp userApp) {
486                 userApps.add(userApp);
487         }
488         
489         public void addAppRoles(EPApp app, SortedSet<EPRole> roles) {
490                 if (roles != null) {
491                         // add all
492                         SortedSet<EPUserApp> userApps = new TreeSet<EPUserApp>();
493                         // this.userApps.removeAll(this.userApps);
494                         Iterator<EPRole> itr = roles.iterator();
495                         while (itr.hasNext()) {
496                                 EPRole role = (EPRole) itr.next();
497                                 EPUserApp userApp = new EPUserApp();
498                                 userApp.setUserId(this.id);
499                                 userApp.setApp(app);
500                                 userApp.setRole(role);
501                                 userApps.add(userApp);
502                         }
503                         setEPUserApps(userApps);
504                 } else {
505                         // remove all
506                         setEPUserApps(null);
507                 }
508
509         }
510
511         public SortedSet<EPRole> getAppEPRoles(EPApp app) {
512                 SortedSet<EPRole> roles = new TreeSet<EPRole>();
513                 SortedSet<EPUserApp> apps = getEPUserApps();
514                 Iterator<EPUserApp> appsItr = apps.iterator();
515                 EPUserApp userApp = null;
516                 // getting default app
517                 while (appsItr.hasNext()) {
518                         EPUserApp tempUserApp = (EPUserApp) appsItr.next();
519                         if (tempUserApp.getApp().getId().equals(app)) {
520                                 userApp = tempUserApp;
521                                 roles.add((EPRole) userApp.getRole());
522                         }
523                 }
524                 return roles;
525         }
526
527         /**
528          * Attention! Not for use in ECOMP
529          */
530         public SortedSet<EPRole> getAppRoles(EPApp app) {
531                 SortedSet<EPRole> roles = new TreeSet<EPRole>();
532                 SortedSet<EPUserApp> apps = getEPUserApps();
533                 Iterator<EPUserApp> appsItr = apps.iterator();
534                 EPUserApp userApp = null;
535                 // getting default app
536                 while (appsItr.hasNext()) {
537                         EPUserApp tempUserApp = (EPUserApp) appsItr.next();
538                         if (tempUserApp.getApp().getId().equals(app.getId())) {
539                                 userApp = tempUserApp;
540                                 roles.add((EPRole) userApp.getRole());
541                         }
542                 }
543                 return roles;
544         }
545
546         /**
547          * Attention! Not for use in ECOMP
548          */
549         public SortedSet<EPRole> getEPRoles() {
550                 EPApp app = new EPApp();
551                 app.setId(new Long(ECOMP_PORTAL_ID));
552                 app.setName(ECOMP_PORTAL_NAME);
553                 return getAppEPRoles(app);
554         }
555
556         /**
557          * Attention! Not for use in ECOMP
558          */
559         public void setEPRoles(SortedSet<EPRole> roles) {
560                 EPApp app = new EPApp();
561                 app.setId(new Long(ECOMP_PORTAL_ID));
562                 app.setName(ECOMP_PORTAL_NAME);
563                 addAppRoles(app, roles);
564         }
565
566         /**
567          * Attention! Not for use in ECOMP
568          */
569         public void removeEPRole(Long roleId) {
570                 SortedSet<EPUserApp> apps = getEPUserApps();
571                 Iterator<EPUserApp> appsItr = apps.iterator();
572                 // getting default app
573                 while (appsItr.hasNext()) {
574                         EPUserApp tempUserApp = (EPUserApp) appsItr.next();
575                         if (tempUserApp.equals(new Long(ECOMP_PORTAL_ID)) && tempUserApp.getRole().getId().equals(roleId)) {
576                                 appsItr.remove();
577                         }
578                 }
579         }
580
581         /**
582          * Attention! Not for use in ECOMP
583          */
584         public void addEPRole(EPRole role) {
585                 if (role != null) {
586                         SortedSet<EPRole> roles = getEPRoles();
587                         if (roles == null) {
588                                 roles = new TreeSet<EPRole>();
589                         }
590                         roles.add(role);
591                         setEPRoles(roles);
592                 }
593         }
594         
595         public boolean isGuest() {
596                 return isGuest;
597         }
598
599         public void setGuest(boolean isGuest) {
600                 this.isGuest = isGuest;
601         }
602 }