From c4e03f8a933ce35044597ec44d40848cf7957bf5 Mon Sep 17 00:00:00 2001 From: "Smokowski, Steve (ss835w)" Date: Tue, 14 Aug 2018 16:30:49 -0400 Subject: Cloud Config Updates Update Cloud Config to be writable over REST API. This allows easier environment setup, so sql scripts are not required Issue-ID: SO-862 Change-Id: I70931f09ff2600a15094199f46fc8d9ac36403f4 Change-Id: I70931f09ff2600a15094199f46fc8d9ac36403f4 Signed-off-by: Smokowski, Steve (ss835w) --- .../onap/so/db/catalog/beans/CloudIdentity.java | 1 - .../org/onap/so/db/catalog/beans/CloudSite.java | 416 +++++++++++---------- .../data/repository/CloudIdentityRepository.java | 10 - .../repository/CloudIdentityRepositoryTest.java | 21 -- 4 files changed, 209 insertions(+), 239 deletions(-) delete mode 100644 mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CloudIdentityRepository.java delete mode 100644 mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudIdentityRepositoryTest.java (limited to 'mso-catalog-db') diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java index e6d02c6836..b1c81cf8d8 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java @@ -23,7 +23,6 @@ package org.onap.so.db.catalog.beans; import com.fasterxml.jackson.annotation.JsonProperty; import com.openpojo.business.annotation.BusinessKey; import org.apache.commons.lang3.builder.HashCodeBuilder; - import java.util.Date; import org.apache.commons.lang3.builder.EqualsBuilder; diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java index 53c97fbce6..9cce212c36 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java @@ -51,211 +51,213 @@ import javax.persistence.TemporalType; @Entity @Table(name = "cloud_sites") public class CloudSite { - - @JsonProperty - @BusinessKey - @Id - @Column(name = "ID") - private String id; - - @JsonProperty("region_id") - @BusinessKey - @Column(name = "REGION_ID") - private String regionId; - - @JsonProperty("aic_version") - @BusinessKey - @Column(name = "CLOUD_VERSION") - private String cloudVersion; - - @JsonProperty("clli") - @BusinessKey - @Column(name = "CLLI") - private String clli; - - @JsonProperty("platform") - @BusinessKey - @Column(name = "PLATFORM") - private String platform; - - @JsonProperty("orchestrator") - @BusinessKey - @Column(name = "ORCHESTRATOR") - private String orchestrator; - - @JsonProperty("cloudify_id") - @BusinessKey - @Column(name = "CLOUDIFY_ID") - private String cloudifyId; - - // Derived property (set by CloudConfig loader based on identityServiceId) - @BusinessKey - @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "IDENTITY_SERVICE_ID") - private CloudIdentity identityService; - - @BusinessKey - @JsonProperty("identity_service_id") - transient private String identityServiceId; - - @JsonProperty("last_updated_by") - @BusinessKey - @Column(name = "LAST_UPDATED_BY") - private String lastUpdatedBy ; - - @JsonProperty("creation_timestamp") - @BusinessKey - @Column(name = "CREATION_TIMESTAMP", updatable = false) - @Temporal(TemporalType.TIMESTAMP) - private Date created; - - @JsonProperty("update_timestamp") - @BusinessKey - @Column(name = "UPDATE_TIMESTAMP") - @Temporal(TemporalType.TIMESTAMP) - private Date updated; - - public CloudSite() { - - } - - @PrePersist - protected void onCreate() { - this.created = new Date(); - this.updated = new Date(); - } - - public CloudSite(CloudSite site) { - this.cloudVersion = site.getCloudVersion(); - this.clli = site.getClli(); - this.id = site.getId(); - this.identityService = site.getIdentityService(); - this.orchestrator = site.getOrchestrator(); - this.platform = site.getPlatform(); - this.regionId = site.getRegionId(); - this.identityServiceId = site.getIdentityServiceId(); - } - public String getId() { - return this.id; - } - - public void setId(String id) { - this.id = id; - } - - public String getRegionId() { - return regionId; - } - - public void setRegionId(String regionId) { - this.regionId = regionId; - } - - public String getIdentityServiceId() { - return identityServiceId == null ? (identityService== null? null:identityService.getId()):identityServiceId; - } - - public String getCloudVersion() { - return cloudVersion; - } - - public void setCloudVersion(String cloudVersion) { - this.cloudVersion = cloudVersion; - } - - public String getClli() { - return clli; - } - - public void setClli(String clli) { - this.clli = clli; - } - - public String getCloudifyId() { - return cloudifyId; - } - - public void setCloudifyId(String cloudifyId) { - this.cloudifyId = cloudifyId; - } - - public String getLastUpdatedBy() { - return lastUpdatedBy; - } - - public Date getCreated() { - return created; - } - - public Date getUpdated() { - return updated; - } - - public void setLastUpdatedBy(String lastUpdatedBy) { - this.lastUpdatedBy = lastUpdatedBy; - } - - public void setCreated(Date created) { - this.created = created; - } - - public void setUpdated(Date updated) { - this.updated = updated; - } - - public String getPlatform() { - return platform; - } - - public void setPlatform(String platform) { - this.platform = platform; - } - - public String getOrchestrator() { - return orchestrator; - } - - public void setOrchestrator(String orchestrator) { - this.orchestrator = orchestrator; - } - - public CloudIdentity getIdentityService () { - return identityService; - } - - public void setIdentityService (CloudIdentity identity) { - this.identityService = identity; - } - @Deprecated - public void setIdentityServiceId(String identityServiceId) { - this.identityServiceId = identityServiceId; - } - - @Override - public String toString() { - return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("regionId", getRegionId()) - .append("identityServiceId", getIdentityServiceId()).append("cloudVersion", getCloudVersion()) - .append("clli", getClli()).append("cloudifyId", getCloudifyId()).append("platform", getPlatform()) - .append("orchestrator", getOrchestrator()).toString(); - } - - @Override - public boolean equals(final Object other) { - if (other == null) { - return false; - } - if (!getClass().equals(other.getClass())) { - return false; - } - CloudSite castOther = (CloudSite) other; - return new EqualsBuilder().append(getRegionId(), castOther.getRegionId()) - .append(getIdentityServiceId(), castOther.getIdentityServiceId()) - .append(getCloudVersion(), castOther.getCloudVersion()).append(getClli(), castOther.getClli()).isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(1, 31).append(getRegionId()).append(getIdentityServiceId()).append(getCloudVersion()) - .append(getClli()).toHashCode(); - } + + @JsonProperty + @BusinessKey + @Id + @Column(name = "ID") + private String id; + + @JsonProperty("region_id") + @BusinessKey + @Column(name = "REGION_ID") + private String regionId; + + @JsonProperty("aic_version") + @BusinessKey + @Column(name = "CLOUD_VERSION") + private String cloudVersion; + + @JsonProperty("clli") + @BusinessKey + @Column(name = "CLLI") + private String clli; + + @JsonProperty("platform") + @BusinessKey + @Column(name = "PLATFORM") + private String platform; + + @JsonProperty("orchestrator") + @BusinessKey + @Column(name = "ORCHESTRATOR") + private String orchestrator; + + @JsonProperty("cloudify_id") + @BusinessKey + @Column(name = "CLOUDIFY_ID") + private String cloudifyId; + + // Derived property (set by CloudConfig loader based on identityServiceId) + @BusinessKey + @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "IDENTITY_SERVICE_ID") + private CloudIdentity identityService; + + @BusinessKey + @JsonProperty("identity_service_id") + private transient String identityServiceId; + + @JsonProperty("last_updated_by") + @BusinessKey + @Column(name = "LAST_UPDATED_BY") + private String lastUpdatedBy ; + + @JsonProperty("creation_timestamp") + @BusinessKey + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @JsonProperty("update_timestamp") + @BusinessKey + @Column(name = "UPDATE_TIMESTAMP") + @Temporal(TemporalType.TIMESTAMP) + private Date updated; + + public CloudSite() { + + } + + @PrePersist + protected void onCreate() { + this.created = new Date(); + this.updated = new Date(); + } + + public CloudSite(CloudSite site) { + this.cloudVersion = site.getCloudVersion(); + this.clli = site.getClli(); + this.id = site.getId(); + this.identityService = site.getIdentityService(); + this.orchestrator = site.getOrchestrator(); + this.platform = site.getPlatform(); + this.regionId = site.getRegionId(); + this.identityServiceId = site.getIdentityServiceId(); + } + + + public String getId() { + return this.id; + } + + public void setId(String id) { + this.id = id; + } + + public String getRegionId() { + return regionId; + } + + public void setRegionId(String regionId) { + this.regionId = regionId; + } + + public String getIdentityServiceId() { + return identityServiceId == null ? (identityService== null? null:identityService.getId()):identityServiceId; + } + + public String getCloudVersion() { + return cloudVersion; + } + + public void setCloudVersion(String cloudVersion) { + this.cloudVersion = cloudVersion; + } + + public String getClli() { + return clli; + } + + public void setClli(String clli) { + this.clli = clli; + } + + public String getCloudifyId() { + return cloudifyId; + } + + public void setCloudifyId(String cloudifyId) { + this.cloudifyId = cloudifyId; + } + + public String getLastUpdatedBy() { + return lastUpdatedBy; + } + + public Date getCreated() { + return created; + } + + public Date getUpdated() { + return updated; + } + + public void setLastUpdatedBy(String lastUpdatedBy) { + this.lastUpdatedBy = lastUpdatedBy; + } + + public void setCreated(Date created) { + this.created = created; + } + + public void setUpdated(Date updated) { + this.updated = updated; + } + + public String getPlatform() { + return platform; + } + + public void setPlatform(String platform) { + this.platform = platform; + } + + public String getOrchestrator() { + return orchestrator; + } + + public void setOrchestrator(String orchestrator) { + this.orchestrator = orchestrator; + } + + public CloudIdentity getIdentityService () { + return identityService; + } + + public void setIdentityService (CloudIdentity identity) { + this.identityService = identity; + } + @Deprecated + public void setIdentityServiceId(String identityServiceId) { + this.identityServiceId = identityServiceId; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("regionId", getRegionId()) + .append("identityServiceId", getIdentityServiceId()).append("cloudVersion", getCloudVersion()) + .append("clli", getClli()).append("cloudifyId", getCloudifyId()).append("platform", getPlatform()) + .append("orchestrator", getOrchestrator()).toString(); + } + + @Override + public boolean equals(final Object other) { + if (other == null) { + return false; + } + if (!getClass().equals(other.getClass())) { + return false; + } + CloudSite castOther = (CloudSite) other; + return new EqualsBuilder().append(getRegionId(), castOther.getRegionId()) + .append(getIdentityServiceId(), castOther.getIdentityServiceId()) + .append(getCloudVersion(), castOther.getCloudVersion()).append(getClli(), castOther.getClli()).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(1, 31).append(getRegionId()).append(getIdentityServiceId()).append(getCloudVersion()) + .append(getClli()).toHashCode(); + } } \ No newline at end of file diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CloudIdentityRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CloudIdentityRepository.java deleted file mode 100644 index c1714821ee..0000000000 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/CloudIdentityRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.onap.so.db.catalog.data.repository; - -import org.onap.so.db.catalog.beans.CloudIdentity; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; - -@RepositoryRestResource(collectionResourceRel = "cloudIdentity", path = "cloudIdentity") -public interface CloudIdentityRepository extends JpaRepository { - -} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudIdentityRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudIdentityRepositoryTest.java deleted file mode 100644 index 8fb65c2080..0000000000 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudIdentityRepositoryTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.onap.so.db.catalog.data.repository; - -import org.junit.Assert; -import org.junit.Test; -import org.onap.so.BaseTest; -import org.onap.so.db.catalog.beans.CloudIdentity; -import org.springframework.beans.factory.annotation.Autowired; - -public class CloudIdentityRepositoryTest extends BaseTest { - - @Autowired - private CloudIdentityRepository cloudIdentityRepository; - - @Test - public void findOneTest() throws Exception { - CloudIdentity cloudIdentity = cloudIdentityRepository.findOne("mtn13"); - Assert.assertNotNull(cloudIdentity); - Assert.assertEquals("mtn13",cloudIdentity.getId()); - } - -} \ No newline at end of file -- cgit 1.2.3-korg