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