2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.be.model;
23 import org.joda.time.DateTime;
24 import org.joda.time.DateTimeZone;
25 import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
26 import org.openecomp.sdc.be.resources.data.UserData;
29 public static final String FORCE_DELETE_HEADER_FLAG = "FORCE_DELETE";
31 private String firstName;
33 private String lastName;
35 private String userId;
41 private Long lastLoginTime;
43 private UserStatusEnum status = UserStatusEnum.ACTIVE;
48 public User(UserData userDate) {
49 this(userDate.getFirstName(), userDate.getLastName(), userDate.getUserId(), userDate.getEmail(),
50 userDate.getRole(), userDate.getLastLoginTime());
53 public User(String firstName, String lastName, String userId, String emailAddress, String role,
55 this.firstName = firstName;
56 this.lastName = lastName;
58 this.email = emailAddress;
60 this.lastLoginTime = lastLoginTime;
64 public void copyData(User other) {
68 this.firstName = other.getFirstName();
69 this.lastName = other.getLastName();
70 this.userId = other.getUserId();
71 this.email = other.getEmail();
72 this.role = other.getRole();
73 this.lastLoginTime = other.getLastLoginTime();
77 public User(User aUser) {
78 this(aUser.getFirstName(), aUser.getLastName(), aUser.getUserId(), aUser.getEmail(), aUser.getRole(),
79 aUser.getLastLoginTime());
82 public String getFirstName() {
86 public void setFirstName(String firstName) {
87 this.firstName = firstName;
90 public String getLastName() {
94 public void setLastName(String lastName) {
95 this.lastName = lastName;
98 public String getUserId() {
102 public void setUserId(String userId) {
103 this.userId = userId;
106 public String getEmail() {
110 public void setEmail(String email) {
114 public String getRole() {
118 public void setRole(String role) {
122 public String getFullName() {
123 return this.getFirstName() + " " + this.getLastName();
126 public void setLastLoginTime() {
127 DateTime now = new DateTime(DateTimeZone.UTC);
128 this.lastLoginTime = now.getMillis();
131 public void setLastLoginTime(Long time) {
132 this.lastLoginTime = time;
135 public Long getLastLoginTime() {
136 return this.lastLoginTime;
140 public int hashCode() {
141 final int prime = 31;
143 result = prime * result + ((userId == null) ? 0 : userId.hashCode());
144 result = prime * result + ((email == null) ? 0 : email.hashCode());
145 result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
146 result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
147 result = prime * result + ((role == null) ? 0 : role.hashCode());
148 result = prime * result + ((lastLoginTime == null) ? 0 : lastLoginTime.hashCode());
153 public boolean equals(Object obj) {
158 if (getClass() != obj.getClass())
160 User other = (User) obj;
161 if (userId == null) {
162 if (other.userId != null)
164 } else if (!userId.equals(other.userId))
167 if (other.email != null)
169 } else if (!email.equals(other.email))
171 if (firstName == null) {
172 if (other.firstName != null)
174 } else if (!firstName.equals(other.firstName))
176 if (lastName == null) {
177 if (other.lastName != null)
179 } else if (!lastName.equals(other.lastName))
182 if (other.role != null)
184 } else if (!role.equals(other.role))
186 if (lastLoginTime == null) {
187 if (other.lastLoginTime != null)
189 } else if (!lastLoginTime.equals(other.lastLoginTime))
194 public UserStatusEnum getStatus() {
198 public void setStatus(UserStatusEnum status) {
199 this.status = status;
203 public String toString() {
204 return "User [firstName=" + firstName + ", lastName=" + lastName + ", userId=" + userId + ", email=" + email
205 + ", role=" + role + ", last login time=" + lastLoginTime + "]";