bb01f6f804573b6c278020dc07b04b4483fb73db
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / CloudIdentity.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
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  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.db.catalog.beans;
22
23 import com.fasterxml.jackson.annotation.JsonProperty;
24 import com.openpojo.business.annotation.BusinessKey;
25 import org.apache.commons.lang3.builder.HashCodeBuilder;
26
27 import java.util.Date;
28
29 import org.apache.commons.lang3.builder.EqualsBuilder;
30 import org.apache.commons.lang3.builder.ToStringBuilder;
31 import org.apache.commons.lang3.builder.ToStringStyle;
32
33 import javax.persistence.Column;
34 import javax.persistence.Entity;
35 import javax.persistence.EnumType;
36 import javax.persistence.Enumerated;
37 import javax.persistence.Id;
38 import javax.persistence.PrePersist;
39 import javax.persistence.Table;
40 import javax.persistence.Temporal;
41 import javax.persistence.TemporalType;
42
43 /**
44  * EntityBean class for a CloudIdentity. This bean represents a cloud identity
45  * service instance (i.e. a DCP node) in the NVP/AIC cloud. It will be loaded via
46  * CloudConfig object, of which it is a component.
47  *
48  */
49 @Entity
50 @Table(name = "identity_services")
51 public class CloudIdentity {
52
53     @JsonProperty
54     @BusinessKey
55     @Id
56     @Column(name = "ID")
57     private String id;
58     
59     @JsonProperty("identity_url")
60     @BusinessKey
61     @Column(name = "IDENTITY_URL")
62     private String identityUrl;
63     
64     @JsonProperty("mso_id")
65     @BusinessKey
66     @Column(name = "MSO_ID")
67     private String msoId;
68     
69     @JsonProperty("mso_pass")
70     @BusinessKey
71     @Column(name = "MSO_PASS")
72     private String msoPass;
73     
74     @JsonProperty("project_domain_name")
75     @BusinessKey
76     @Column(name = "PROJECT_DOMAIN_NAME")
77     private String projectDomainName;
78     
79     @JsonProperty("user_domain_name")
80     @BusinessKey
81     @Column(name = "USER_DOMAIN_NAME")
82     private String userDomainName;
83     
84     @JsonProperty("admin_tenant")
85     @BusinessKey
86     @Column(name = "ADMIN_TENANT")
87     private String adminTenant;
88     
89     @JsonProperty("member_role")
90     @BusinessKey
91     @Column(name = "MEMBER_ROLE")
92     private String memberRole;
93     
94     @JsonProperty("tenant_metadata")
95     @BusinessKey
96     @Column(name = "TENANT_METADATA")
97     private Boolean tenantMetadata;
98     
99     @JsonProperty("identity_server_type")
100     @BusinessKey
101     @Enumerated(EnumType.STRING)
102     @Column(name = "IDENTITY_SERVER_TYPE")
103     private ServerType identityServerType;
104     
105     @JsonProperty("identity_authentication_type")
106     @BusinessKey
107     @Enumerated(EnumType.STRING)
108     @Column(name = "IDENTITY_AUTHENTICATION_TYPE")
109     private AuthenticationType identityAuthenticationType;
110
111     @JsonProperty("last_updated_by")
112     @BusinessKey
113     @Column(name = "LAST_UPDATED_BY")
114     private String lastUpdatedBy ;
115
116     @JsonProperty("creation_timestamp")
117     @BusinessKey
118     @Column(name = "CREATION_TIMESTAMP", updatable = false)
119     @Temporal(TemporalType.TIMESTAMP)
120     private Date created;
121
122     @JsonProperty("update_timestamp")
123     @BusinessKey
124     @Column(name = "UPDATE_TIMESTAMP")
125     @Temporal(TemporalType.TIMESTAMP)
126     private Date updated;
127     
128     public CloudIdentity() {}
129
130     @PrePersist
131     protected void onCreate() {
132         this.created = new Date();
133         this.updated = new Date();
134     }
135
136     public String getId () {
137         return id;
138     }
139
140     public void setId (String id) {
141         this.id = id;
142     }
143
144     public String getIdentityUrl() {
145         return this.identityUrl;
146     }
147     public void setIdentityUrl(String url) {
148         this.identityUrl = url;
149     }
150
151     public String getMsoId () {
152         return msoId;
153     }
154
155     public void setMsoId (String id) {
156         this.msoId = id;
157     }
158
159     public String getMsoPass () {
160         return msoPass;
161     }
162
163     public void setMsoPass (String pwd) {
164         this.msoPass = pwd;
165     }
166
167     public String getAdminTenant () {
168         return adminTenant;
169     }
170
171     public String getLastUpdatedBy() {
172         return lastUpdatedBy;
173     }
174
175     public Date getCreated() {
176         return created;
177     }
178
179     public Date getUpdated() {
180         return updated;
181     }
182
183     public void setLastUpdatedBy(String lastUpdatedBy) {
184         this.lastUpdatedBy = lastUpdatedBy;
185     }
186
187     public void setCreated(Date created) {
188         this.created = created;
189     }
190
191     public void setUpdated(Date updated) {
192         this.updated = updated;
193     }
194
195     public void setAdminTenant (String tenant) {
196         this.adminTenant = tenant;
197     }
198
199     public String getMemberRole () {
200         return memberRole;
201     }
202
203     public void setMemberRole (String role) {
204         this.memberRole = role;
205     }
206
207     public Boolean getTenantMetadata() {
208         return tenantMetadata;
209     }
210
211     public void setTenantMetadata (Boolean meta) {
212         this.tenantMetadata = meta;
213     }
214     
215     public ServerType getIdentityServerType() {
216         return this.identityServerType;
217     }
218     public void setIdentityServerType(ServerType ist) {
219         this.identityServerType = ist;
220     }
221     public String getIdentityServerTypeAsString() {
222         return this.identityServerType.toString();
223     }
224     /**
225          * @return the identityAuthenticationType
226          */
227         public AuthenticationType getIdentityAuthenticationType() {
228                 return identityAuthenticationType;
229         }
230
231         /**
232          * @param identityAuthenticationType the identityAuthenticationType to set
233          */
234         public void setIdentityAuthenticationType(AuthenticationType identityAuthenticationType) {
235                 this.identityAuthenticationType = identityAuthenticationType;
236         }
237
238         public String getProjectDomainName() {
239                 return projectDomainName;
240         }
241         
242         public void setProjectDomainName(String projectDomainName) {
243                 this.projectDomainName = projectDomainName;
244         }
245         
246         public String getUserDomainName() {
247                 return userDomainName;
248         }
249         
250         public void setUserDomainName(String userDomainName) {
251                 this.userDomainName = userDomainName;
252         }
253         @Override
254         public CloudIdentity clone() {
255                 CloudIdentity cloudIdentityCopy = new CloudIdentity();
256
257                 cloudIdentityCopy.id = this.id;
258                 cloudIdentityCopy.identityUrl = this.identityUrl;
259                 cloudIdentityCopy.msoId = this.msoId;
260                 cloudIdentityCopy.msoPass = this.msoPass;
261                 cloudIdentityCopy.adminTenant = this.adminTenant;
262                 cloudIdentityCopy.memberRole = this.memberRole;
263                 cloudIdentityCopy.tenantMetadata = this.tenantMetadata;
264                 cloudIdentityCopy.identityServerType = this.identityServerType;
265                 cloudIdentityCopy.identityAuthenticationType = this.identityAuthenticationType;
266                 cloudIdentityCopy.projectDomainName = this.projectDomainName;
267                 cloudIdentityCopy.userDomainName = this.userDomainName;
268
269                 return cloudIdentityCopy;
270         }
271
272         @Override
273         public String toString() {
274                 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("id", getId())
275                                 .append("identityUrl", getIdentityUrl()).append("msoId", getMsoId())
276                                 .append("projectDomain", getProjectDomainName()).append("userDomain", getUserDomainName())
277                                 .append("adminTenant", getAdminTenant()).append("memberRole", getMemberRole())
278                                 .append("tenantMetadata", getTenantMetadata()).append("identityServerType", getIdentityServerType())
279                                 .append("identityAuthenticationType", getIdentityAuthenticationType()).toString();
280         }
281
282         @Override
283         public boolean equals(final Object other) {
284                 if (other == null) {
285                         return false;
286                 }
287                 if (!getClass().equals(other.getClass())) {
288                         return false;
289                 }
290                 CloudIdentity castOther = (CloudIdentity) other;
291                 return new EqualsBuilder().append(getId(), castOther.getId())
292                                 .append(getIdentityUrl(), castOther.getIdentityUrl()).append(getMsoId(), castOther.getMsoId())
293                                 .append(getMsoPass(), castOther.getMsoPass()).append(getAdminTenant(), castOther.getAdminTenant())
294                                 .append(getProjectDomainName(), castOther.getProjectDomainName()).append(getUserDomainName(), castOther.getUserDomainName())
295                                 .append(getMemberRole(), castOther.getMemberRole())
296                                 .append(getTenantMetadata(), castOther.getTenantMetadata())
297                                 .append(getIdentityServerType(), castOther.getIdentityServerType())
298                                 .append(getIdentityAuthenticationType(), castOther.getIdentityAuthenticationType()).isEquals();
299         }
300
301         @Override
302         public int hashCode() {
303                 return new HashCodeBuilder(1, 31).append(getId()).append(getIdentityUrl()).append(getMsoId())
304                                 .append(getMsoPass()).append(getProjectDomainName()).append(getUserDomainName()).append(getAdminTenant()).append(getMemberRole()).append(getTenantMetadata())
305                                 .append(getIdentityServerType()).append(getIdentityAuthenticationType()).toHashCode();
306         }
307 }