summaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src
diff options
context:
space:
mode:
Diffstat (limited to 'mso-catalog-db/src')
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java152
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java32
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HomingInstanceRepository.java30
3 files changed, 213 insertions, 1 deletions
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java
new file mode 100644
index 0000000000..ef474be159
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java
@@ -0,0 +1,152 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018. Intel Corp. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+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.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import uk.co.blackpepper.bowman.annotation.RemoteResource;
+import uk.co.blackpepper.bowman.annotation.ResourceId;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.net.URI;
+
+/**
+ * EntityBean class for a HomingInstance. This bean represents a homing instance
+ * of a service, populated on successful homing
+ *
+ */
+@RemoteResource("/homingInstance")
+@Entity
+@Table(name = "homing_instances")
+public class HomingInstance {
+ @JsonProperty
+ @BusinessKey
+ @Id
+ @Column(name = "SERVICE_INSTANCE_ID")
+ private String serviceInstanceId;
+
+ @JsonProperty("cloud_region_id")
+ @BusinessKey
+ @Column(name = "CLOUD_REGION_ID")
+ private String cloudRegionId;
+
+ @JsonProperty("cloud_owner")
+ @BusinessKey
+ @Column(name = "CLOUD_OWNER")
+ private String cloudOwner;
+
+
+
+ @JsonProperty("oof_directives")
+ @BusinessKey
+ @Column(name = "OOF_DIRECTIVES", columnDefinition = "LONGTEXT")
+ private String oofDirectives;
+
+ @Transient
+ private URI uri;
+
+ public HomingInstance () {
+
+ }
+
+ public HomingInstance (HomingInstance homingInstance) {
+ this.serviceInstanceId = homingInstance.getServiceInstanceId();
+ this.cloudRegionId = homingInstance.getCloudRegionId();
+ this.cloudOwner = homingInstance.getCloudOwner();
+ this.oofDirectives = homingInstance.getOofDirectives();
+ }
+
+
+ public String getServiceInstanceId() {
+ return this.serviceInstanceId;
+ }
+
+ public void setServiceInstanceId(String serviceInstanceId) {
+
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
+ public String getCloudRegionId() {
+
+ return this.cloudRegionId;
+ }
+
+ public void setCloudRegionId(String cloudRegionId) {
+
+ this.cloudRegionId = cloudRegionId;
+ }
+
+ public String getCloudOwner() {
+
+ return this.cloudOwner;
+ }
+
+ public void setCloudOwner (String cloudOwner) {
+
+ this.cloudOwner = cloudOwner;
+ }
+
+ public String getOofDirectives() {
+ return oofDirectives;
+ }
+
+ public void setOofDirectives(String oofDirectives) {
+ this.oofDirectives = oofDirectives;
+ }
+
+ @ResourceId
+ public URI getUri() {
+ return this.uri;
+ }
+
+ public void setUri(URI uri) {
+
+ this.uri = uri;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("serviceInstanceId", serviceInstanceId)
+ .append("cloudRegionId", cloudRegionId)
+ .append("cloudOwner", cloudOwner)
+ .append("oofDirectives", oofDirectives).toString();
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof HomingInstance)) {
+ return false;
+ }
+ HomingInstance castOther = (HomingInstance) other;
+ return new EqualsBuilder().append(serviceInstanceId, castOther.serviceInstanceId).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(serviceInstanceId).toHashCode();
+ }
+}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
index 8a61102322..98addf90aa 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
@@ -36,6 +36,7 @@ import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
import org.onap.so.db.catalog.beans.CvnfcCustomization;
import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
+import org.onap.so.db.catalog.beans.HomingInstance;
import org.onap.so.db.catalog.beans.InstanceGroup;
import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
import org.onap.so.db.catalog.beans.NetworkRecipe;
@@ -125,6 +126,7 @@ public class CatalogDbClient {
private static final String WORK_STEP = "workStep";
private static final String CLLI = "clli";
private static final String CLOUD_VERSION = "cloudVersion";
+ private static final String HOMING_INSTANCE = "/homingInstance";
private static final String TARGET_ENTITY = "SO:CatalogDB";
@@ -153,6 +155,8 @@ public class CatalogDbClient {
private String findOneByActionAndRequestScopeAndIsAlacarte = "/findOneByActionAndRequestScopeAndIsAlacarte";
private String findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep = "/findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep";
private String findByClliAndCloudVersion = "/findByClliAndCloudVersion";
+ private String findServiceByServiceInstanceId = "/findServiceByServiceInstanceId";
+
private String serviceURI;
private String vfModuleURI;
@@ -165,6 +169,7 @@ public class CatalogDbClient {
private String instanceGroupURI;
private String cloudifyManagerURI;
private String cloudSiteURI;
+ private String homingInstanceURI;
private final Client<Service> serviceClient;
@@ -210,6 +215,8 @@ public class CatalogDbClient {
private final Client<CloudSite> cloudSiteClient;
+ private final Client<HomingInstance> homingInstanceClient;
+
private final Client<CloudifyManager> cloudifyManagerClient;
private Client<CvnfcCustomization> cvnfcCustomizationClient;
@@ -262,6 +269,7 @@ public class CatalogDbClient {
instanceGroupURI = endpoint + INSTANCE_GROUP + URI_SEPARATOR;
cloudifyManagerURI = endpoint + CLOUDIFY_MANAGER + URI_SEPARATOR;
cloudSiteURI = endpoint + CLOUD_SITE + URI_SEPARATOR;
+ homingInstanceURI = endpoint + HOMING_INSTANCE + URI_SEPARATOR;
}
@@ -300,6 +308,7 @@ public class CatalogDbClient {
networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class);
collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class);
cloudSiteClient = clientFactory.create(CloudSite.class);
+ homingInstanceClient = clientFactory.create(HomingInstance.class);
cloudifyManagerClient = clientFactory.create(CloudifyManager.class);
serviceRecipeClient = clientFactory.create(ServiceRecipe.class);
cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class);
@@ -342,6 +351,7 @@ public class CatalogDbClient {
networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class);
collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class);
cloudSiteClient = clientFactory.create(CloudSite.class);
+ homingInstanceClient = clientFactory.create(HomingInstance.class);
cloudifyManagerClient = clientFactory.create(CloudifyManager.class);
serviceRecipeClient = clientFactory.create(ServiceRecipe.class);
cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class);
@@ -583,7 +593,13 @@ public class CatalogDbClient {
}
public CloudSite getCloudSite(String id){
- return this.getSingleResource(cloudSiteClient, getUri(cloudSiteURI + id));
+ return this.getSingleResource(cloudSiteClient,
+ getUri(cloudSiteURI + id));
+ }
+
+ public CloudSite getCloudSite(String id, String uri){
+ return this.getSingleResource(cloudSiteClient,
+ getUri(uri + id));
}
public void postCloudSite(CloudSite cloudSite){
@@ -596,6 +612,20 @@ public class CatalogDbClient {
.queryParam(CLLI,clli).queryParam(CLOUD_VERSION,cloudVersion).build().toString()));
}
+ public HomingInstance getHomingInstance (String serviceInstanceId){
+ return this.getSingleResource(homingInstanceClient,
+ getUri(homingInstanceURI + serviceInstanceId));
+ }
+
+ public HomingInstance getHomingInstance (String serviceInstanceId, String uri){
+ return this.getSingleResource(homingInstanceClient,
+ getUri(uri + serviceInstanceId));
+ }
+
+ public void postHomingInstance(HomingInstance homingInstance){
+ this.postSingleResource(homingInstanceClient, homingInstance);
+ }
+
public Service getServiceByModelVersionAndModelInvariantUUID(String modelVersion, String modelInvariantUUID) {
return this.getSingleResource(serviceClient, getUri(UriBuilder
.fromUri(findFirstByModelVersionAndModelInvariantUUIDURI)
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HomingInstanceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HomingInstanceRepository.java
new file mode 100644
index 0000000000..aea8d3e537
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HomingInstanceRepository.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018. Intel Corp. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.db.catalog.data.repository;
+
+import org.onap.so.db.catalog.beans.HomingInstance;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
+
+@RepositoryRestResource(collectionResourceRel = "homingInstance", path = "homingInstance")
+public interface HomingInstanceRepository extends JpaRepository<HomingInstance, String> {
+ HomingInstance findServiceByServiceInstanceId(String serviceInstanceId);
+}