summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/EPUser.java
blob: d7cce0ec238ce69a4211294fdd41cd88e1fd0b8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
/*-
 * ============LICENSE_START==========================================
 * ONAP Portal
 * ===================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 * ===================================================================
 *
 * Unless otherwise specified, all software contained herein is licensed
 * under the Apache License, Version 2.0 (the "License");
 * you may not use this software except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *             http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Unless otherwise specified, all documentation contained herein is licensed
 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 * you may not use this documentation except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *             https://creativecommons.org/licenses/by/4.0/
 *
 * Unless required by applicable law or agreed to in writing, documentation
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * ============LICENSE_END============================================
 *
 * 
 */
package org.onap.portalapp.portal.domain;

import java.util.Date;
import java.util.Iterator;
import java.util.SortedSet;
import java.util.TreeSet;

import org.onap.portalapp.portal.utils.PortalConstants;
import org.onap.portalsdk.core.domain.User;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;

import com.fasterxml.jackson.annotation.JsonIgnore;

public class EPUser extends User {
	    
	    private Long   orgId;
	    private Long   managerId;
	    private String firstName;
	    private String middleInitial;
	    private String lastName;
	    private String phone;
	    private String fax;
	    private String cellular;
	    private String email;
	    private Long   addressId;
	    private String alertMethodCd;
	    private String hrid;
	    private String orgUserId;
	    private String orgCode;
	    private String address1;
	    private String address2;
	    private String city;
	    private String state;
	    private String zipCode;
	    private String country;
	    private String orgManagerUserId;
	    private String locationClli;
	    private String businessCountryCode;
	    private String businessCountryName;
	    private String businessUnit;
	    private String businessUnitName;
	    private String department;
	    private String departmentName;
	    private String companyCode;
	    private String company;
	    private String zipCodeSuffix;
	    private String jobTitle;
	    private String commandChain;
	    private String siloStatus;
	    private String costCenter;
	    private String financialLocCode;
	    
	    
	  
	    private String loginId;
	    private String loginPwd;
	    private Date   lastLoginDate;
	    private boolean active;
	    private boolean internal;
	    private Long    selectedProfileId;
	    private Long timeZoneId;
	    private boolean online;
	    private String chatId;
	
	    private static final long serialVersionUID = 1L;

	    private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPUser.class);
		private static final String ECOMP_PORTAL_NAME = "ECOMP";
		private boolean isGuest = false;
		
		private SortedSet<EPUserApp> userApps = new TreeSet<EPUserApp>();
		private SortedSet<EPRole> pseudoRoles = new TreeSet<EPRole>();

	    public EPUser() {}

	    public Long getAddressId() {
	        return addressId;
	    }

	    public String getAlertMethodCd() {
	        return alertMethodCd;
	    }

	    public String getCellular() {
	        return cellular;
	    }

	    public String getEmail() {
	        return email;
	    }

	    public String getFax() {
	        return fax;
	    }

	    public String getFirstName() {
	        return firstName;
	    }

	    public String getHrid() {
	        return hrid;
	    }

	    public Date getLastLoginDate() {
	        return lastLoginDate;
	    }

	    public String getLastName() {
	        return lastName;
	    }

	    @JsonIgnore
	    public String getFullName() {
	        return getFirstName() + " " + getLastName();	
	    }
	    
	    public String getLoginId() {
	        return loginId;
	    }

	    public String getLoginPwd() {
	        return loginPwd;
	    }

	    public Long getManagerId() {
	        return managerId;
	    }

	    public String getMiddleInitial() {
	        return middleInitial;
	    }

	    public String getOrgCode() {
	        return orgCode;
	    }

	    public Long getOrgId() {
	        return orgId;
	    }

	    public String getPhone() {
	        return phone;
	    }

	    public String getOrgUserId() {
	        return orgUserId;
	    }

	    public boolean getActive() {
	        return active;
	    }

	    public boolean getInternal() {
	        return internal;
	    }

	    public String getAddress1() {
	        return address1;
	    }

	    public String getAddress2() {
	        return address2;
	    }

	    public String getCity() {
	        return city;
	    }

	    public String getCountry() {
	        return country;
	    }

	    public String getState() {
	        return state;
	    }

	    public String getZipCode() {
	        return zipCode;
	    }

	    public String getBusinessCountryCode() {
	        return businessCountryCode;
	    }

	    public String getCommandChain() {
	        return commandChain;
	    }

	    public String getCompany() {
	        return company;
	    }

	    public String getCompanyCode() {
	        return companyCode;
	    }

	    public String getDepartment() {
	        return department;
	    }

	    public String getJobTitle() {
	        return jobTitle;
	    }

	    public String getLocationClli() {
	        return locationClli;
	    }

	    public String getOrgManagerUserId() {
	        return orgManagerUserId;
	    }

	    public String getZipCodeSuffix() {
	        return zipCodeSuffix;
	    }

	    public String getBusinessCountryName() {
	        return businessCountryName;
	    }

	    public Long getSelectedProfileId() {
	        return selectedProfileId;
	    }

	    public void setAddressId(Long addressId) {
	        this.addressId = addressId;
	    }

	    public void setAlertMethodCd(String alertMethodCd) {
	        this.alertMethodCd = alertMethodCd;
	    }

	    public void setCellular(String cellular) {
	        this.cellular = cellular;
	    }

	    public void setEmail(String email) {
	        this.email = email;
	    }

	    public void setFax(String fax) {
	        this.fax = fax;
	    }

	    public void setFirstName(String firstName) {
	        this.firstName = firstName;
	    }

	    public void setHrid(String hrid) {
	        this.hrid = hrid;
	    }

	    public void setLastLoginDate(Date lastLoginDate) {
	        this.lastLoginDate = lastLoginDate;
	    }

	    public void setLastName(String lastName) {
	        this.lastName = lastName;
	    }

	    public void setLoginId(String loginId) {
	        this.loginId = loginId;
	    }

	    public void setLoginPwd(String loginPwd) {
	        this.loginPwd = loginPwd;
	    }

	    public void setManagerId(Long managerId) {
	        this.managerId = managerId;
	    }

	    public void setMiddleInitial(String middleInitial) {
	        this.middleInitial = middleInitial;
	    }

	    public void setOrgCode(String orgCode) {
	        this.orgCode = orgCode;
	    }

	    public void setOrgId(Long orgId) {
	        this.orgId = orgId;
	    }

	    public void setPhone(String phone) {
	        this.phone = phone;
	    }

	    public void setOrgUserId(String orgUserId) {
	        this.orgUserId = orgUserId;
	    }

	    public void setActive(boolean active) {
	        this.active = active;
	    }

	    public void setInternal(boolean internal) {
	        this.internal = internal;
	    }

	    public void setAddress1(String address1) {
	        this.address1 = address1;
	    }

	    public void setAddress2(String address2) {
	        this.address2 = address2;
	    }

	    public void setCity(String city) {
	        this.city = city;
	    }

	    public void setCountry(String country) {
	        this.country = country;
	    }

	    public void setState(String state) {
	        this.state = state;
	    }

	    public void setZipCode(String zipCode) {
	        this.zipCode = zipCode;
	    }

	    public void setBusinessCountryCode(String businessCountryCode) {
	        this.businessCountryCode = businessCountryCode;
	    }

	    public void setCommandChain(String commandChain) {
	        this.commandChain = commandChain;
	    }

	    public void setCompany(String company) {
	        this.company = company;
	    }

	    public void setCompanyCode(String companyCode) {
	        this.companyCode = companyCode;
	    }

	    public void setDepartment(String department) {
	        this.department = department;
	    }

	    public void setJobTitle(String jobTitle) {
	        this.jobTitle = jobTitle;
	    }

	    public void setLocationClli(String locationClli) {
	        this.locationClli = locationClli;
	    }

	    public void setOrgManagerUserId(String orgManagerUserId) {
	        this.orgManagerUserId = orgManagerUserId;
	    }

	    public void setZipCodeSuffix(String zipCodeSuffix) {
	        this.zipCodeSuffix = zipCodeSuffix;
	    }

	    public void setBusinessCountryName(String businessCountryName) {
	        this.businessCountryName = businessCountryName;
	    }

	    public SortedSet<EPRole> getPseudoRoles() {
			return pseudoRoles;
		}
	    
	    public void setPseudoRoles(SortedSet<EPRole> pseudoRoles) {
	        this.pseudoRoles = pseudoRoles;
	    }

	    public void setSelectedProfileId(Long selectedProfileId) {
	        this.selectedProfileId = selectedProfileId;
	    }
	    
		public Long getTimeZoneId() {
			return timeZoneId;
		}

		public void setTimeZoneId(Long timeZoneId) {
			this.timeZoneId = timeZoneId;
		}

		public String getBusinessUnit() {
			return businessUnit;
		}

		public void setBusinessUnit(String businessUnit) {
			this.businessUnit = businessUnit;
		}

		public String getSiloStatus() {
			return siloStatus;
		}

		public void setSiloStatus(String siloStatus) {
			this.siloStatus = siloStatus;
		}

		public String getCostCenter() {
			return costCenter;
		}

		public void setCostCenter(String costCenter) {
			this.costCenter = costCenter;
		}

		public String getFinancialLocCode() {
			return financialLocCode;
		}

		public void setFinancialLocCode(String financialLocCode) {
			this.financialLocCode = financialLocCode;
		}
		
		public String getBusinessUnitName() {
			return businessUnitName;
		}

		public void setBusinessUnitName(String businessUnitName) {
			this.businessUnitName = businessUnitName;
		}

		public String getDepartmentName() {
			return departmentName;
		}

		public void setDepartmentName(String departmentName) {
			this.departmentName = departmentName;
		}

		public int compareTo(Object obj){
	      EPUser user = (EPUser)obj;

	      String c1 = getLastName() + getFirstName() + getMiddleInitial();
	      String c2 = user.getLastName() + user.getFirstName() + user.getMiddleInitial();

	      return c1.compareTo(c2);
	    }

		public boolean isOnline() {
			return online;
		}

		public void setOnline(boolean online) {
			this.online = online;
		}

		public String getChatId() {
			return chatId;
		}

		public void setChatId(String chatId) {
			this.chatId = chatId;
		}

		
	public void setPseudoEPRoles(SortedSet<EPRole> pseudoRoles) {
		this.pseudoRoles = pseudoRoles;
	}
	
	public SortedSet<EPUserApp> getEPUserApps() {
		return userApps;
	}

	public void setEPUserApps(SortedSet<EPUserApp> userApps) {
		this.userApps = userApps;
	}

	public void addUserApp(EPUserApp userApp) {
		userApps.add(userApp);
	}
	
	public void addAppRoles(EPApp app, SortedSet<EPRole> roles) {
		if (roles != null) {
			// add all
			SortedSet<EPUserApp> userApps = new TreeSet<EPUserApp>();
			// this.userApps.removeAll(this.userApps);
			Iterator<EPRole> itr = roles.iterator();
			while (itr.hasNext()) {
				EPRole role = (EPRole) itr.next();
				EPUserApp userApp = new EPUserApp();
				userApp.setUserId(this.id);
				userApp.setApp(app);
				userApp.setRole(role);
				userApps.add(userApp);
			}
			setEPUserApps(userApps);
		} else {
			// remove all
			setEPUserApps(null);
		}

	}

	public SortedSet<EPRole> getAppEPRoles(EPApp app) {
		
		logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - app = {}", app.getName());
		
		SortedSet<EPRole> roles = new TreeSet<EPRole>();
		SortedSet<EPUserApp> userAppRoles = getEPUserApps();
		
		logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - userApps = {} ", userAppRoles.size());

		Iterator<EPUserApp> userAppRolesIterator = userAppRoles.iterator();

		EPUserApp userAppRole = null;
		// getting default app
		while (userAppRolesIterator.hasNext()) {
			EPUserApp tempUserApp = (EPUserApp) userAppRolesIterator.next();
			if (tempUserApp.getApp().getId().equals(app.getId())) {

				logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - for user {}, found application {}", this.getFullName(), app.getName());
				
				userAppRole = tempUserApp;
				
				EPRole role = userAppRole.getRole();
				if(role.getActive()){
					logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - Role {} is active - adding for user {} and app {}", role.getName(), this.getFullName(), app.getName());
					roles.add((EPRole) role);
				}
				else{
					logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - Role {} is NOT active - NOT adding for user {} and app {}", role.getName(), this.getFullName(), app.getName());
				}				
			}
		}
		logger.debug(EELFLoggerDelegate.debugLogger, "In EPUser.getAppEPRoles() - roles = {}" , roles.size());

		return roles;
	}

	
	/**
	 * Attention! Not for use in ONAP
	 */
	public SortedSet<EPRole> getAppRoles(EPApp app) {
		SortedSet<EPRole> roles = new TreeSet<EPRole>();
		SortedSet<EPUserApp> apps = getEPUserApps();
		Iterator<EPUserApp> appsItr = apps.iterator();
		EPUserApp userApp = null;
		// getting default app
		while (appsItr.hasNext()) {
			EPUserApp tempUserApp = (EPUserApp) appsItr.next();
			if (tempUserApp.getApp().getId().equals(app.getId())) {
				userApp = tempUserApp;
				roles.add((EPRole) userApp.getRole());
			}
		}
		return roles;
	}

	

	/**
	 * Attention! Not for use in ONAP
	 */
	public SortedSet<EPRole> getEPRoles() {
		EPApp app = new EPApp();
		app.setId(new Long(PortalConstants.PORTAL_APP_ID));
		app.setName(ECOMP_PORTAL_NAME);
		return getAppEPRoles(app);
	}

	/**
	 * Attention! Not for use in ONAP
	 */
	public void setEPRoles(SortedSet<EPRole> roles) {
		EPApp app = new EPApp();
		app.setId(new Long(PortalConstants.PORTAL_APP_ID));
		app.setName(ECOMP_PORTAL_NAME);
		addAppRoles(app, roles);
	}

	/**
	 * Attention! Not for use in ONAP
	 */
	public void removeEPRole(Long roleId) {
		SortedSet<EPUserApp> apps = getEPUserApps();
		Iterator<EPUserApp> appsItr = apps.iterator();
		// getting default app
		while (appsItr.hasNext()) {
			EPUserApp tempUserApp = (EPUserApp) appsItr.next();
			if (tempUserApp.equals(new Long(PortalConstants.PORTAL_APP_ID)) && tempUserApp.getRole().getId().equals(roleId)) {
				appsItr.remove();
			}
		}
	}

	/**
	 * Attention! Not for use in ONAP
	 */
	public void addEPRole(EPRole role) {
		if (role != null) {
			SortedSet<EPRole> roles = getEPRoles();
			if (roles == null) {
				roles = new TreeSet<EPRole>();
			}
			roles.add(role);
			setEPRoles(roles);
		}
	}
	
	public boolean isGuest() {
		return isGuest;
	}

	public void setGuest(boolean isGuest) {
		this.isGuest = isGuest;
	}

	@Override
	public String toString() {
		return "EPUser [orgId=" + orgId + ", managerId=" + managerId + ", firstName=" + firstName + ", middleInitial="
				+ middleInitial + ", lastName=" + lastName + ", phone=" + phone + ", fax=" + fax + ", cellular="
				+ cellular + ", email=" + email + ", addressId=" + addressId + ", alertMethodCd=" + alertMethodCd
				+ ", hrid=" + hrid + ", orgUserId=" + orgUserId + ", orgCode=" + orgCode + ", address1=" + address1
				+ ", address2=" + address2 + ", city=" + city + ", state=" + state + ", zipCode=" + zipCode
				+ ", country=" + country + ", orgManagerUserId=" + orgManagerUserId + ", locationClli=" + locationClli
				+ ", businessCountryCode=" + businessCountryCode + ", businessCountryName=" + businessCountryName
				+ ", businessUnit=" + businessUnit + ", businessUnitName=" + businessUnitName + ", department="
				+ department + ", departmentName=" + departmentName + ", companyCode=" + companyCode + ", company="
				+ company + ", zipCodeSuffix=" + zipCodeSuffix + ", jobTitle=" + jobTitle + ", commandChain="
				+ commandChain + ", siloStatus=" + siloStatus + ", costCenter=" + costCenter + ", financialLocCode="
				+ financialLocCode + ", loginId=" + loginId + ", loginPwd=" + loginPwd + ", lastLoginDate="
				+ lastLoginDate + ", active=" + active + ", internal=" + internal + ", selectedProfileId="
				+ selectedProfileId + ", timeZoneId=" + timeZoneId + ", online=" + online + ", chatId=" + chatId
				+ ", isGuest=" + isGuest + ", userApps=" + userApps + ", pseudoRoles=" + pseudoRoles + "]";
	}
	
	
}