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 com.fasterxml.jackson.annotation.JsonInclude;
24 import org.joda.time.DateTime;
25 import org.joda.time.DateTimeZone;
26 import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
27 import org.openecomp.sdc.be.resources.data.UserData;
31 public static final String FORCE_DELETE_HEADER_FLAG = "FORCE_DELETE";
33 private String firstName;
35 private String lastName;
37 private String userId;
43 private Long lastLoginTime;
45 private UserStatusEnum status = UserStatusEnum.ACTIVE;
50 public User(String userId) {
54 public User(UserData userDate) {
55 this(userDate.getFirstName(), userDate.getLastName(), userDate.getUserId(), userDate.getEmail(),
56 userDate.getRole(), userDate.getLastLoginTime());
59 public User(String firstName, String lastName, String userId, String emailAddress, String role,
61 this.firstName = firstName;
62 this.lastName = lastName;
64 this.email = emailAddress;
66 this.lastLoginTime = lastLoginTime;
69 public void copyData(User other) {
73 this.firstName = other.getFirstName();
74 this.lastName = other.getLastName();
75 this.userId = other.getUserId();
76 this.email = other.getEmail();
77 this.role = other.getRole();
78 this.lastLoginTime = other.getLastLoginTime();
82 public User(User aUser) {
83 this(aUser.getFirstName(), aUser.getLastName(), aUser.getUserId(), aUser.getEmail(), aUser.getRole(),
84 aUser.getLastLoginTime());
87 public String getFirstName() {
91 public void setFirstName(String firstName) {
92 this.firstName = firstName;
95 public String getLastName() {
99 public void setLastName(String lastName) {
100 this.lastName = lastName;
103 public String getUserId() {
107 public void setUserId(String userId) {
108 this.userId = userId;
111 public String getEmail() {
115 public void setEmail(String email) {
119 public String getRole() {
123 public void setRole(String role) {
127 public String getFullName() {
128 return this.getFirstName() + " " + this.getLastName();
131 public void setLastLoginTime() {
132 DateTime now = new DateTime(DateTimeZone.UTC);
133 this.lastLoginTime = now.getMillis();
136 public void setLastLoginTime(Long time) {
137 this.lastLoginTime = time;
140 public Long getLastLoginTime() {
141 return this.lastLoginTime;
145 public int hashCode() {
146 final int prime = 31;
148 result = prime * result + ((userId == null) ? 0 : userId.hashCode());
149 result = prime * result + ((email == null) ? 0 : email.hashCode());
150 result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
151 result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
152 result = prime * result + ((role == null) ? 0 : role.hashCode());
153 result = prime * result + ((lastLoginTime == null) ? 0 : lastLoginTime.hashCode());
158 public boolean equals(Object obj) {
163 if (getClass() != obj.getClass())
165 User other = (User) obj;
166 if (userId == null) {
167 if (other.userId != null)
169 } else if (!userId.equals(other.userId))
172 if (other.email != null)
174 } else if (!email.equals(other.email))
176 if (firstName == null) {
177 if (other.firstName != null)
179 } else if (!firstName.equals(other.firstName))
181 if (lastName == null) {
182 if (other.lastName != null)
184 } else if (!lastName.equals(other.lastName))
187 if (other.role != null)
189 } else if (!role.equals(other.role))
191 if (lastLoginTime == null) {
192 if (other.lastLoginTime != null)
194 } else if (!lastLoginTime.equals(other.lastLoginTime))
199 public UserStatusEnum getStatus() {
203 public void setStatus(UserStatusEnum status) {
204 this.status = status;
208 public String toString() {
209 return "User [firstName=" + firstName + ", lastName=" + lastName + ", userId=" + userId + ", email=" + email
210 + ", role=" + role + ", last login time=" + lastLoginTime + "]";