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;
24 import java.util.Date;
26 import com.fasterxml.jackson.annotation.JsonProperty;
27 import com.openpojo.business.annotation.BusinessKey;
28 import org.apache.commons.lang3.builder.HashCodeBuilder;
29 import org.apache.commons.lang3.builder.EqualsBuilder;
30 import org.apache.commons.lang3.builder.ToStringBuilder;
31 import org.apache.commons.lang3.builder.ToStringStyle;
33 import javax.persistence.CascadeType;
34 import javax.persistence.Column;
35 import javax.persistence.Entity;
36 import javax.persistence.FetchType;
37 import javax.persistence.Id;
38 import javax.persistence.JoinColumn;
39 import javax.persistence.OneToOne;
40 import javax.persistence.PrePersist;
41 import javax.persistence.Table;
42 import javax.persistence.Temporal;
43 import javax.persistence.TemporalType;
46 * EntityBean class for a CloudSite. This bean represents a cloud location
47 * (i.e. and LCP node) in the NVP/AIC cloud. It will be loaded via CloudConfig
48 * object, of which it is a component
52 @Table(name = "cloud_sites")
53 public class CloudSite {
61 @JsonProperty("region_id")
63 @Column(name = "REGION_ID")
64 private String regionId;
66 @JsonProperty("aic_version")
68 @Column(name = "CLOUD_VERSION")
69 private String cloudVersion;
73 @Column(name = "CLLI")
76 @JsonProperty("platform")
78 @Column(name = "PLATFORM")
79 private String platform;
81 @JsonProperty("orchestrator")
83 @Column(name = "ORCHESTRATOR")
84 private String orchestrator;
86 @JsonProperty("cloudify_id")
88 @Column(name = "CLOUDIFY_ID")
89 private String cloudifyId;
91 // Derived property (set by CloudConfig loader based on identityServiceId)
93 @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
94 @JoinColumn(name = "IDENTITY_SERVICE_ID")
95 private CloudIdentity identityService;
98 @JsonProperty("identity_service_id")
99 private transient String identityServiceId;
101 @JsonProperty("last_updated_by")
103 @Column(name = "LAST_UPDATED_BY")
104 private String lastUpdatedBy ;
106 @JsonProperty("creation_timestamp")
108 @Column(name = "CREATION_TIMESTAMP", updatable = false)
109 @Temporal(TemporalType.TIMESTAMP)
110 private Date created;
112 @JsonProperty("update_timestamp")
114 @Column(name = "UPDATE_TIMESTAMP")
115 @Temporal(TemporalType.TIMESTAMP)
116 private Date updated;
123 protected void onCreate() {
124 this.created = new Date();
125 this.updated = new Date();
128 public CloudSite(CloudSite site) {
129 this.cloudVersion = site.getCloudVersion();
130 this.clli = site.getClli();
131 this.id = site.getId();
132 this.identityService = site.getIdentityService();
133 this.orchestrator = site.getOrchestrator();
134 this.platform = site.getPlatform();
135 this.regionId = site.getRegionId();
136 this.identityServiceId = site.getIdentityServiceId();
140 public String getId() {
144 public void setId(String id) {
148 public String getRegionId() {
152 public void setRegionId(String regionId) {
153 this.regionId = regionId;
156 public String getIdentityServiceId() {
157 return identityServiceId == null ? (identityService== null? null:identityService.getId()):identityServiceId;
160 public String getCloudVersion() {
164 public void setCloudVersion(String cloudVersion) {
165 this.cloudVersion = cloudVersion;
168 public String getClli() {
172 public void setClli(String clli) {
176 public String getCloudifyId() {
180 public void setCloudifyId(String cloudifyId) {
181 this.cloudifyId = cloudifyId;
184 public String getLastUpdatedBy() {
185 return lastUpdatedBy;
188 public Date getCreated() {
192 public Date getUpdated() {
196 public void setLastUpdatedBy(String lastUpdatedBy) {
197 this.lastUpdatedBy = lastUpdatedBy;
200 public void setCreated(Date created) {
201 this.created = created;
204 public void setUpdated(Date updated) {
205 this.updated = updated;
208 public String getPlatform() {
212 public void setPlatform(String platform) {
213 this.platform = platform;
216 public String getOrchestrator() {
220 public void setOrchestrator(String orchestrator) {
221 this.orchestrator = orchestrator;
224 public CloudIdentity getIdentityService () {
225 return identityService;
228 public void setIdentityService (CloudIdentity identity) {
229 this.identityService = identity;
232 public void setIdentityServiceId(String identityServiceId) {
233 this.identityServiceId = identityServiceId;
237 public String toString() {
238 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("regionId", getRegionId())
239 .append("identityServiceId", getIdentityServiceId()).append("cloudVersion", getCloudVersion())
240 .append("clli", getClli()).append("cloudifyId", getCloudifyId()).append("platform", getPlatform())
241 .append("orchestrator", getOrchestrator()).toString();
245 public boolean equals(final Object other) {
249 if (!getClass().equals(other.getClass())) {
252 CloudSite castOther = (CloudSite) other;
253 return new EqualsBuilder().append(getRegionId(), castOther.getRegionId())
254 .append(getIdentityServiceId(), castOther.getIdentityServiceId())
255 .append(getCloudVersion(), castOther.getCloudVersion()).append(getClli(), castOther.getClli()).isEquals();
259 public int hashCode() {
260 return new HashCodeBuilder(1, 31).append(getRegionId()).append(getIdentityServiceId()).append(getCloudVersion())
261 .append(getClli()).toHashCode();