30ebca86994f2aefffa473de18bbc4bb584f2f4f
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / CloudifyManager.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 java.util.Date;
24
25 import com.fasterxml.jackson.annotation.JsonProperty;
26 import com.openpojo.business.annotation.BusinessKey;
27
28 import org.apache.commons.lang3.builder.ToStringBuilder;
29 import org.apache.commons.lang3.builder.ToStringStyle;
30 import org.apache.commons.lang3.builder.HashCodeBuilder;
31 import org.apache.commons.lang3.builder.EqualsBuilder;
32
33 import javax.persistence.Column;
34 import javax.persistence.Entity;
35 import javax.persistence.Id;
36 import javax.persistence.PrePersist;
37 import javax.persistence.Table;
38 import javax.persistence.Temporal;
39 import javax.persistence.TemporalType;
40
41 /**
42  * EntityBean class for a Cloudify Manager.  This bean represents a Cloudify
43  * node through which TOSCA-based VNFs may be deployed.  Each CloudSite in the
44  * CloudConfig may have a Cloudify Manager for deployments using TOSCA blueprints.
45  * Cloudify Managers may support multiple Cloud Sites, but each site will have
46  * at most one Cloudify Manager.
47  * 
48  * This does not replace the ability to use the CloudSite directly via Openstack.
49  *
50  * @author JC1348
51  */
52 @Entity
53 @Table(name = "cloudify_managers")
54 public class CloudifyManager {
55         
56         @JsonProperty
57         @BusinessKey
58         @Id
59         @Column(name = "ID")
60         private String id;
61         
62         @BusinessKey
63         @JsonProperty ("cloudify_url")
64         @Column(name = "CLOUDIFY_URL")
65         private String cloudifyUrl;
66         
67         @BusinessKey
68         @JsonProperty("username")
69         @Column(name = "USERNAME")
70         private String username;
71         
72         @BusinessKey
73         @JsonProperty("password")
74         @Column(name = "PASSWORD")
75         private String password;
76         
77         @BusinessKey
78         @JsonProperty("version")
79         @Column(name = "VERSION")
80         private String version;
81
82         @JsonProperty("last_updated_by")
83         @BusinessKey
84         @Column(name = "LAST_UPDATED_BY")
85         private String lastUpdatedBy ;
86
87         @JsonProperty("creation_timestamp")
88         @BusinessKey
89         @Column(name = "CREATION_TIMESTAMP", updatable = false)
90         @Temporal(TemporalType.TIMESTAMP)
91         private Date created;
92
93         @JsonProperty("update_timestamp")
94         @BusinessKey
95         @Column(name = "UPDATE_TIMESTAMP")
96         @Temporal(TemporalType.TIMESTAMP)
97         private Date updated;
98
99         public CloudifyManager() {}
100
101         @PrePersist
102         protected void onCreate() {
103                 this.created = new Date();
104                 this.updated = new Date();
105         }
106         
107         public String getId() {
108                 return id;
109         }
110         public void setId(String id) {
111                 this.id = id;
112         }
113         
114         public String getCloudifyUrl() {
115                 return cloudifyUrl;
116         }
117
118         public void setCloudifyUrl(String cloudifyUrl) {
119                 this.cloudifyUrl = cloudifyUrl;
120         }
121
122         public String getUsername() {
123                 return username;
124         }
125
126         public void setUsername(String username) {
127                 this.username = username;
128         }
129
130         public String getPassword() {
131         return password;
132         }
133
134         public void setPassword(String password) {
135                 this.password = password;
136         }
137
138         public String getVersion() {
139                 return version;
140         }
141
142         public void setVersion(String version) {
143                 this.version = version;
144         }
145
146         public String getLastUpdatedBy() {
147                 return lastUpdatedBy;
148         }
149
150         public Date getCreated() {
151                 return created;
152         }
153
154         public Date getUpdated() {
155                 return updated;
156         }
157
158         public void setLastUpdatedBy(String lastUpdatedBy) {
159                 this.lastUpdatedBy = lastUpdatedBy;
160         }
161
162         public void setCreated(Date created) {
163                 this.created = created;
164         }
165
166         public void setUpdated(Date updated) {
167                 this.updated = updated;
168         }
169
170         @Override
171         public CloudifyManager clone() {
172                 CloudifyManager cloudifyManagerCopy = new CloudifyManager();
173                 cloudifyManagerCopy.id = this.id;
174                 cloudifyManagerCopy.cloudifyUrl = this.cloudifyUrl;
175                 cloudifyManagerCopy.username = this.username;
176                 cloudifyManagerCopy.password = this.password;
177                 cloudifyManagerCopy.version = this.version;
178                 return cloudifyManagerCopy;
179         }
180
181         @Override
182         public String toString() {
183                 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("id", getId())
184                                 .append("cloudifyUrl", getCloudifyUrl()).append("username", getUsername())
185                                 .append("password", getPassword()).append("version", getVersion()).toString();
186         }
187
188         @Override
189         public boolean equals(final Object other) {
190                 if (other == null) {
191                         return false;
192                 }
193                 if (!getClass().equals(other.getClass())) {
194                         return false;
195                 }
196                 CloudifyManager castOther = (CloudifyManager) other;
197                 return new EqualsBuilder().append(getId(), castOther.getId())
198                                 .append(getCloudifyUrl(), castOther.getCloudifyUrl()).append(getUsername(), castOther.getUsername())
199                                 .append(getPassword(), castOther.getPassword()).append(getVersion(), castOther.getVersion()).isEquals();
200         }
201
202         @Override
203         public int hashCode() {
204                 return new HashCodeBuilder(1, 31).append(getId()).append(getCloudifyUrl()).append(getUsername())
205                                 .append(getPassword()).append(getVersion()).toHashCode();
206         }
207 }