2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.db.catalog.beans;
25 import java.util.Date;
26 import javax.persistence.CascadeType;
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.FetchType;
30 import javax.persistence.Id;
31 import javax.persistence.JoinColumn;
32 import javax.persistence.OneToOne;
33 import javax.persistence.PrePersist;
34 import javax.persistence.PreUpdate;
35 import javax.persistence.Table;
36 import javax.persistence.Temporal;
37 import javax.persistence.TemporalType;
38 import javax.persistence.Transient;
39 import org.apache.commons.lang3.builder.EqualsBuilder;
40 import org.apache.commons.lang3.builder.HashCodeBuilder;
41 import org.apache.commons.lang3.builder.ToStringBuilder;
42 import org.apache.commons.lang3.builder.ToStringStyle;
43 import com.fasterxml.jackson.annotation.JsonAutoDetect;
44 import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
45 import com.fasterxml.jackson.annotation.JsonProperty;
46 import com.openpojo.business.annotation.BusinessKey;
47 import uk.co.blackpepper.bowman.annotation.RemoteResource;
48 import uk.co.blackpepper.bowman.annotation.ResourceId;
51 * EntityBean class for a CloudSite. This bean represents a cloud location (i.e. and LCP node) in the NVP/AIC cloud. It
52 * will be loaded via CloudConfig object, of which it is a component
56 @RemoteResource("/cloudSite")
57 @Table(name = "cloud_sites")
58 @JsonAutoDetect(fieldVisibility = Visibility.ANY)
59 public class CloudSite {
67 @JsonProperty("region_id")
69 @Column(name = "REGION_ID")
70 private String regionId;
72 @JsonProperty("aic_version")
74 @Column(name = "CLOUD_VERSION")
75 private String cloudVersion;
79 @Column(name = "CLLI")
82 @JsonProperty("platform")
84 @Column(name = "PLATFORM")
85 private String platform;
87 @JsonProperty("orchestrator")
89 @Column(name = "ORCHESTRATOR")
90 private String orchestrator;
92 @JsonProperty("cloudify_id")
94 @Column(name = "CLOUDIFY_ID")
95 private String cloudifyId;
97 @JsonProperty("cloud_owner")
99 @Column(name = "CLOUD_OWNER")
100 private String cloudOwner;
102 // Derived property (set by CloudConfig loader based on identityServiceId)
104 @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
105 @JoinColumn(name = "IDENTITY_SERVICE_ID")
106 private CloudIdentity identityService;
109 @JsonProperty("identity_service_id")
110 private transient String identityServiceId;
112 @JsonProperty("last_updated_by")
114 @Column(name = "LAST_UPDATED_BY")
115 private String lastUpdatedBy;
117 @JsonProperty("creation_timestamp")
119 @Column(name = "CREATION_TIMESTAMP", updatable = false)
120 @Temporal(TemporalType.TIMESTAMP)
121 private Date created;
123 @JsonProperty("update_timestamp")
125 @Column(name = "UPDATE_TIMESTAMP")
126 @Temporal(TemporalType.TIMESTAMP)
127 private Date updated;
129 @JsonProperty("support_fabric")
131 @Column(name = "SUPPORT_FABRIC", nullable = false)
132 private Boolean supportFabric = true;
142 protected void onCreate() {
143 this.created = new Date();
144 this.updated = new Date();
148 protected void onUpdate() {
149 this.updated = new Date();
152 public CloudSite(CloudSite site) {
153 this.cloudVersion = site.getCloudVersion();
154 this.clli = site.getClli();
155 this.id = site.getId();
156 this.identityService = site.getIdentityService();
157 this.orchestrator = site.getOrchestrator();
158 this.platform = site.getPlatform();
159 this.regionId = site.getRegionId();
160 this.identityServiceId = site.getIdentityServiceId();
161 this.supportFabric = site.getSupportFabric();
165 public String getId() {
169 public void setId(String id) {
174 public URI getUri() {
178 public void setUri(URI uri) {
182 public String getRegionId() {
186 public void setRegionId(String regionId) {
187 this.regionId = regionId;
190 public String getIdentityServiceId() {
191 return identityServiceId == null ? (identityService == null ? null : identityService.getId())
195 public String getCloudVersion() {
199 public void setCloudVersion(String cloudVersion) {
200 this.cloudVersion = cloudVersion;
203 public String getClli() {
207 public void setClli(String clli) {
211 public String getCloudifyId() {
215 public void setCloudifyId(String cloudifyId) {
216 this.cloudifyId = cloudifyId;
219 public String getLastUpdatedBy() {
220 return lastUpdatedBy;
223 public Date getCreated() {
227 public Date getUpdated() {
231 public void setLastUpdatedBy(String lastUpdatedBy) {
232 this.lastUpdatedBy = lastUpdatedBy;
235 public void setCreated(Date created) {
236 this.created = created;
239 public void setUpdated(Date updated) {
240 this.updated = updated;
243 public String getPlatform() {
247 public void setPlatform(String platform) {
248 this.platform = platform;
251 public String getOrchestrator() {
255 public void setOrchestrator(String orchestrator) {
256 this.orchestrator = orchestrator;
259 public CloudIdentity getIdentityService() {
260 return identityService;
263 public void setIdentityService(CloudIdentity identity) {
264 this.identityService = identity;
267 public Boolean getSupportFabric() {
268 return supportFabric;
271 public void setSupportFabric(Boolean supportFabric) {
272 this.supportFabric = supportFabric;
276 public void setIdentityServiceId(String identityServiceId) {
277 this.identityServiceId = identityServiceId;
280 public String getCloudOwner() {
284 public void setCloudOwner(String cloudOwner) {
285 this.cloudOwner = cloudOwner;
289 public String toString() {
290 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("regionId", getRegionId())
291 .append("identityServiceId", getIdentityServiceId()).append("cloudVersion", getCloudVersion())
292 .append("clli", getClli()).append("cloudifyId", getCloudifyId()).append("platform", getPlatform())
293 .append("orchestrator", getOrchestrator()).append("cloud-owner", getCloudOwner()).toString();
297 public boolean equals(final Object other) {
301 if (!getClass().equals(other.getClass())) {
304 CloudSite castOther = (CloudSite) other;
305 return new EqualsBuilder().append(getRegionId(), castOther.getRegionId())
306 .append(getIdentityServiceId(), castOther.getIdentityServiceId())
307 .append(getCloudVersion(), castOther.getCloudVersion()).append(getClli(), castOther.getClli())
312 public int hashCode() {
313 return new HashCodeBuilder(1, 31).append(getRegionId()).append(getIdentityServiceId()).append(getCloudVersion())
314 .append(getClli()).toHashCode();