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.Table;
35 import javax.persistence.Temporal;
36 import javax.persistence.TemporalType;
37 import javax.persistence.Transient;
38 import org.apache.commons.lang3.builder.EqualsBuilder;
39 import org.apache.commons.lang3.builder.HashCodeBuilder;
40 import org.apache.commons.lang3.builder.ToStringBuilder;
41 import org.apache.commons.lang3.builder.ToStringStyle;
42 import com.fasterxml.jackson.annotation.JsonAutoDetect;
43 import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
44 import com.fasterxml.jackson.annotation.JsonProperty;
45 import com.openpojo.business.annotation.BusinessKey;
46 import uk.co.blackpepper.bowman.annotation.RemoteResource;
47 import uk.co.blackpepper.bowman.annotation.ResourceId;
50 * EntityBean class for a CloudSite. This bean represents a cloud location (i.e. and LCP node) in the NVP/AIC cloud. It
51 * will be loaded via CloudConfig object, of which it is a component
54 @RemoteResource("/cloudSite")
56 @Table(name = "cloud_sites")
57 @JsonAutoDetect(fieldVisibility = Visibility.ANY)
58 public class CloudSite {
66 @JsonProperty("region_id")
68 @Column(name = "REGION_ID")
69 private String regionId;
71 @JsonProperty("aic_version")
73 @Column(name = "CLOUD_VERSION")
74 private String cloudVersion;
78 @Column(name = "CLLI")
81 @JsonProperty("platform")
83 @Column(name = "PLATFORM")
84 private String platform;
86 @JsonProperty("orchestrator")
88 @Column(name = "ORCHESTRATOR")
89 private String orchestrator;
91 @JsonProperty("cloudify_id")
93 @Column(name = "CLOUDIFY_ID")
94 private String cloudifyId;
96 // Derived property (set by CloudConfig loader based on identityServiceId)
98 @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
99 @JoinColumn(name = "IDENTITY_SERVICE_ID")
100 private CloudIdentity identityService;
103 @JsonProperty("identity_service_id")
104 private transient String identityServiceId;
106 @JsonProperty("last_updated_by")
108 @Column(name = "LAST_UPDATED_BY")
109 private String lastUpdatedBy;
111 @JsonProperty("creation_timestamp")
113 @Column(name = "CREATION_TIMESTAMP", updatable = false)
114 @Temporal(TemporalType.TIMESTAMP)
115 private Date created;
117 @JsonProperty("update_timestamp")
119 @Column(name = "UPDATE_TIMESTAMP")
120 @Temporal(TemporalType.TIMESTAMP)
121 private Date updated;
131 protected void onCreate() {
132 this.created = new Date();
133 this.updated = new Date();
136 public CloudSite(CloudSite site) {
137 this.cloudVersion = site.getCloudVersion();
138 this.clli = site.getClli();
139 this.id = site.getId();
140 this.identityService = site.getIdentityService();
141 this.orchestrator = site.getOrchestrator();
142 this.platform = site.getPlatform();
143 this.regionId = site.getRegionId();
144 this.identityServiceId = site.getIdentityServiceId();
148 public String getId() {
152 public void setId(String id) {
157 public URI getUri() {
161 public void setUri(URI uri) {
165 public String getRegionId() {
169 public void setRegionId(String regionId) {
170 this.regionId = regionId;
173 public String getIdentityServiceId() {
174 return identityServiceId == null ? (identityService == null ? null : identityService.getId())
178 public String getCloudVersion() {
182 public void setCloudVersion(String cloudVersion) {
183 this.cloudVersion = cloudVersion;
186 public String getClli() {
190 public void setClli(String clli) {
194 public String getCloudifyId() {
198 public void setCloudifyId(String cloudifyId) {
199 this.cloudifyId = cloudifyId;
202 public String getLastUpdatedBy() {
203 return lastUpdatedBy;
206 public Date getCreated() {
210 public Date getUpdated() {
214 public void setLastUpdatedBy(String lastUpdatedBy) {
215 this.lastUpdatedBy = lastUpdatedBy;
218 public void setCreated(Date created) {
219 this.created = created;
222 public void setUpdated(Date updated) {
223 this.updated = updated;
226 public String getPlatform() {
230 public void setPlatform(String platform) {
231 this.platform = platform;
234 public String getOrchestrator() {
238 public void setOrchestrator(String orchestrator) {
239 this.orchestrator = orchestrator;
242 public CloudIdentity getIdentityService() {
243 return identityService;
246 public void setIdentityService(CloudIdentity identity) {
247 this.identityService = identity;
251 public void setIdentityServiceId(String identityServiceId) {
252 this.identityServiceId = identityServiceId;
256 public String toString() {
257 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("regionId", getRegionId())
258 .append("identityServiceId", getIdentityServiceId()).append("cloudVersion", getCloudVersion())
259 .append("clli", getClli()).append("cloudifyId", getCloudifyId()).append("platform", getPlatform())
260 .append("orchestrator", getOrchestrator()).toString();
264 public boolean equals(final Object other) {
268 if (!getClass().equals(other.getClass())) {
271 CloudSite castOther = (CloudSite) other;
272 return new EqualsBuilder().append(getRegionId(), castOther.getRegionId())
273 .append(getIdentityServiceId(), castOther.getIdentityServiceId())
274 .append(getCloudVersion(), castOther.getCloudVersion()).append(getClli(), castOther.getClli())
279 public int hashCode() {
280 return new HashCodeBuilder(1, 31).append(getRegionId()).append(getIdentityServiceId()).append(getCloudVersion())
281 .append(getClli()).toHashCode();