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