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.resources.data;
23 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
24 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
25 import org.openecomp.sdc.be.dao.utils.DaoUtils;
26 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
28 import java.util.Date;
29 import java.util.HashMap;
32 public class UserData extends GraphNode {
34 private String firstName;
36 private String lastName;
38 private String userId;
44 private String status;
46 private Long lastLoginTime;
48 public UserData(String firstName, String lastName, String userId, String email, String role, String status,
50 super(NodeTypeEnum.User);
51 this.firstName = firstName;
52 this.lastName = lastName;
57 this.lastLoginTime = lastLoginTime;
61 super(NodeTypeEnum.User);
64 public UserData(Map<String, Object> properties) {
65 super(NodeTypeEnum.User);
67 setFirstName((String) properties.get("firstName"));
68 setLastName((String) properties.get("lastName"));
69 setUserId((String) properties.get("userId"));
70 setEmail((String) properties.get("email"));
71 setRole((String) properties.get("role"));
72 setStatus((String) properties.get("status"));
73 setLastLoginTime((Long) properties.get("lastLoginTime"));
76 public String getFirstName() {
80 public void setFirstName(String firstName) {
81 this.firstName = firstName;
84 public String getLastName() {
88 public void setLastName(String lastName) {
89 this.lastName = lastName;
92 public String getUserId() {
96 public void setUserId(String userId) {
100 public String getEmail() {
104 public void setEmail(String email) {
108 public String getRole() {
112 public void setRole(String role) {
117 public void setLastLoginTime() {
119 this.lastLoginTime = new Long(d.getTime()); // this is in milli-seconds
120 // divide by 1000 to get
124 public void setLastLoginTime(Long time) {
125 this.lastLoginTime = time;
128 public Long getLastLoginTime() {
129 return this.lastLoginTime;
133 public String toString() {
134 return "UserData [firstName=" + firstName + ", lastName=" + lastName + ", userId=" + userId + ", email=" + email
135 + ", role=" + role + ", last Login time=" + lastLoginTime + ", parent: " + super.toString() + "]";
139 public int hashCode() {
140 final int prime = 31;
142 result = prime * result + ((userId == null) ? 0 : userId.hashCode());
143 result = prime * result + ((email == null) ? 0 : email.hashCode());
144 result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
145 result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
146 result = prime * result + ((role == null) ? 0 : role.hashCode());
147 result = prime * result + ((lastLoginTime == null) ? 0 : lastLoginTime.hashCode());
152 public boolean equals(Object obj) {
157 if (getClass() != obj.getClass())
159 UserData other = (UserData) obj;
160 if (userId == null) {
161 if (other.userId != null)
163 } else if (!userId.equals(other.userId))
166 if (other.email != null)
168 } else if (!email.equals(other.email))
170 if (firstName == null) {
171 if (other.firstName != null)
173 } else if (!firstName.equals(other.firstName))
175 if (lastName == null) {
176 if (other.lastName != null)
178 } else if (!lastName.equals(other.lastName))
181 if (other.role != null)
183 } else if (!role.equals(other.role))
185 if (lastLoginTime == null) {
186 if (other.lastLoginTime != null)
188 } else if (!lastLoginTime.equals(other.lastLoginTime))
193 public String toJson() {
194 return DaoUtils.convertToJson(toGraphMap());
198 public Map<String, Object> toGraphMap() {
199 Map<String, Object> map = new HashMap<String, Object>();
200 addIfExists(map, GraphPropertiesDictionary.USERID, userId);
201 addIfExists(map, GraphPropertiesDictionary.EMAIL, email);
202 addIfExists(map, GraphPropertiesDictionary.FIRST_NAME, firstName);
203 addIfExists(map, GraphPropertiesDictionary.LAST_NAME, lastName);
204 addIfExists(map, GraphPropertiesDictionary.ROLE, role);
205 addIfExists(map, GraphPropertiesDictionary.USER_STATUS, status);
206 addIfExists(map, GraphPropertiesDictionary.LAST_LOGIN_TIME, lastLoginTime);
211 public String getUniqueIdKey() {
212 return GraphPropertiesDictionary.USERID.getProperty();
216 public String getUniqueId() {
220 public String getStatus() {
224 public void setStatus(String status) {
225 this.status = status;