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