summaryrefslogtreecommitdiffstats
path: root/mso-catalog-db
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2020-02-18 17:14:40 +0000
committerGerrit Code Review <gerrit@onap.org>2020-02-18 17:14:40 +0000
commit2d11a7092c292a3987ad0b105fe31ee8a0390294 (patch)
treedd81ebe972cb7656e09050213d8e8fff19967429 /mso-catalog-db
parenta71813fd697298b9a9bddea6eacc9de5fada2de0 (diff)
parent9737ae116859da4548dcd1bf3ba73d339f326c52 (diff)
Merge "Based on Controller Actor calling CDS or APPC(Current Flow)"
Diffstat (limited to 'mso-catalog-db')
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BBNameSelectionReference.java115
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java20
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/BBNameSelectionReferenceRepository.java36
-rw-r--r--mso-catalog-db/src/test/resources/data.sql6
-rw-r--r--mso-catalog-db/src/test/resources/schema.sql12
5 files changed, 189 insertions, 0 deletions
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BBNameSelectionReference.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BBNameSelectionReference.java
new file mode 100644
index 0000000000..9b71c970a7
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BBNameSelectionReference.java
@@ -0,0 +1,115 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Tech Mahindra
+ * ================================================================================
+ * 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 java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import com.openpojo.business.annotation.BusinessKey;
+
+@Entity
+@Table(name = "bbname_selection_reference")
+public class BBNameSelectionReference implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @Column(name = "ID", nullable = false, updatable = false)
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer ID;
+
+ @BusinessKey
+ @Column(name = "CONTROLLER_ACTOR")
+ private String controllerActor;
+
+ @Column(name = "SCOPE")
+ private String scope;
+
+ @Column(name = "ACTION")
+ private String action;
+
+ @BusinessKey
+ @Column(name = "BB_NAME")
+ private String bbName;
+
+ public String getControllerActor() {
+ return controllerActor;
+ }
+
+ public void setControllerActor(String controllerActor) {
+ this.controllerActor = controllerActor;
+ }
+
+ public String getScope() {
+ return scope;
+ }
+
+ public void setScope(String scope) {
+ this.scope = scope;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public Integer getID() {
+ return ID;
+ }
+
+ public String getBbName() {
+ return bbName;
+ }
+
+ public void setBbName(String bbName) {
+ this.bbName = bbName;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("ID", ID).append("controllerActor", controllerActor)
+ .append("scope", scope).append("action", action).append("bbName", bbName).toString();
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof BBNameSelectionReference)) {
+ return false;
+ }
+ BBNameSelectionReference castOther = (BBNameSelectionReference) other;
+ return new EqualsBuilder().append(controllerActor, castOther.controllerActor).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(controllerActor).append(bbName).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 4090e19d34..cf066f9721 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
@@ -32,6 +32,7 @@ import javax.ws.rs.core.UriBuilder;
import org.apache.http.HttpStatus;
import org.onap.logging.filter.base.Constants;
import org.onap.logging.filter.spring.SpringClientPayloadFilter;
+import org.onap.so.db.catalog.beans.BBNameSelectionReference;
import org.onap.so.db.catalog.beans.BuildingBlockDetail;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.CloudifyManager;
@@ -119,6 +120,7 @@ public class CatalogDbClient {
private static final String PNF_RESOURCE = "/pnfResource";
private static final String PNF_RESOURCE_CUSTOMIZATION = "/pnfResourceCustomization";
private static final String WORKFLOW = "/workflow";
+ private static final String BB_NAME_SELECTION_REFERENCE = "/bbNameSelectionReference";
private static final String SEARCH = "/search";
@@ -205,6 +207,8 @@ public class CatalogDbClient {
private String findWorkflowByPnfModelUUID = "/findWorkflowByPnfModelUUID";
private String findWorkflowBySource = "/findBySource";
private String findVnfResourceCustomizationByModelUuid = "/findVnfResourceCustomizationByModelUuid";
+ private String findBBNameSelectionReferenceByControllerActorAndScopeAndAction =
+ "/findBBNameSelectionReferenceByControllerActorAndScopeAndAction";
private String serviceURI;
private String vfModuleURI;
@@ -277,6 +281,8 @@ public class CatalogDbClient {
private final Client<Workflow> workflowClient;
+ private final Client<BBNameSelectionReference> bbNameSelectionReferenceClient;
+
@Value("${mso.catalog.db.spring.endpoint:#{null}}")
private String endpoint;
@@ -346,6 +352,9 @@ public class CatalogDbClient {
findVnfResourceCustomizationByModelUuid =
endpoint + VNF_RESOURCE_CUSTOMIZATION + SEARCH + findVnfResourceCustomizationByModelUuid;
+ findBBNameSelectionReferenceByControllerActorAndScopeAndAction = endpoint + BB_NAME_SELECTION_REFERENCE + SEARCH
+ + findBBNameSelectionReferenceByControllerActorAndScopeAndAction;
+
serviceURI = endpoint + SERVICE + URI_SEPARATOR;
vfModuleURI = endpoint + VFMODULE + URI_SEPARATOR;
vnfResourceURI = endpoint + VNF_RESOURCE + URI_SEPARATOR;
@@ -412,6 +421,8 @@ public class CatalogDbClient {
pnfResourceClient = clientFactory.create(PnfResource.class);
pnfResourceCustomizationClient = clientFactory.create(PnfResourceCustomization.class);
workflowClient = clientFactory.create(Workflow.class);
+ bbNameSelectionReferenceClient = clientFactory.create(BBNameSelectionReference.class);
+
}
public CatalogDbClient(String baseUri, String auth) {
@@ -462,6 +473,7 @@ public class CatalogDbClient {
pnfResourceClient = clientFactory.create(PnfResource.class);
pnfResourceCustomizationClient = clientFactory.create(PnfResourceCustomization.class);
workflowClient = clientFactory.create(Workflow.class);
+ bbNameSelectionReferenceClient = clientFactory.create(BBNameSelectionReference.class);
}
public NetworkCollectionResourceCustomization getNetworkCollectionResourceCustomizationByID(
@@ -689,6 +701,14 @@ public class CatalogDbClient {
UriBuilder.fromUri(findFirstByModelNameURI).queryParam(MODEL_NAME, modelName).build());
}
+ public BBNameSelectionReference getBBNameSelectionReference(String controllerActor, String scope, String action) {
+
+ return this.getSingleResource(bbNameSelectionReferenceClient,
+ getUri(UriBuilder.fromUri(findBBNameSelectionReferenceByControllerActorAndScopeAndAction)
+ .queryParam("CONTROLLER_ACTOR", controllerActor).queryParam("SCOPE", scope)
+ .queryParam("ACTION", action).build().toString()));
+ }
+
public ExternalServiceToInternalService findExternalToInternalServiceByServiceName(String serviceName) {
return this.getSingleResource(externalServiceToInternalServiceClient,
getUri(UriBuilder.fromUri(findExternalToInternalServiceByServiceName)
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/BBNameSelectionReferenceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/BBNameSelectionReferenceRepository.java
new file mode 100644
index 0000000000..38f1291f37
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/BBNameSelectionReferenceRepository.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Tech Mahindra
+ * ================================================================================
+ * 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.BBNameSelectionReference;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.repository.query.Param;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
+
+
+@RepositoryRestResource(collectionResourceRel = "bbNameSelectionReference", path = "bbNameSelectionReference")
+public interface BBNameSelectionReferenceRepository extends JpaRepository<BBNameSelectionReference, Integer> {
+
+ public BBNameSelectionReference findBBNameSelectionReferenceByControllerActorAndScopeAndAction(
+ @Param("CONTROLLER_ACTOR") String controllerActor, @Param("SCOPE") String scope,
+ @Param("ACTION") String action);
+}
diff --git a/mso-catalog-db/src/test/resources/data.sql b/mso-catalog-db/src/test/resources/data.sql
index e5963c183f..0852aa026d 100644
--- a/mso-catalog-db/src/test/resources/data.sql
+++ b/mso-catalog-db/src/test/resources/data.sql
@@ -957,3 +957,9 @@ VALUES
(select ID from user_parameters where NAME='existing_software_version')),
((select ID from activity_spec where NAME='VNFUpgradeSoftwareActivity' and VERSION=1.0),
(select ID from user_parameters where NAME='new_software_version'));
+
+INSERT INTO bbname_selection_reference (CONTROLLER_ACTOR,SCOPE,ACTION,BB_NAME)
+VALUES
+('APPC', 'vfModule', 'healthCheck','GenericVnfHealthCheckBB'),
+('APPC', 'vfModule', 'configScaleOut','ConfigurationScaleOutBB'),
+('APPC', 'vnf', 'healthCheck','GenericVnfHealthCheckBB'); \ No newline at end of file
diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql
index 9037e431d4..6573def570 100644
--- a/mso-catalog-db/src/test/resources/schema.sql
+++ b/mso-catalog-db/src/test/resources/schema.sql
@@ -1387,6 +1387,18 @@ CREATE TABLE IF NOT EXISTS `activity_spec_to_user_parameters` (
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
+--
+-- Table structure for table `bbname_selection_reference`
+--
+DROP TABLE IF EXISTS `bbname_selection_reference`;
+CREATE TABLE IF NOT EXISTS `bbname_selection_reference` (
+ `ID` INT(11) NOT NULL AUTO_INCREMENT,
+ `CONTROLLER_ACTOR` varchar(200) NOT NULL ,
+ `SCOPE` varchar(200) NOT NULL,
+ `ACTION` varchar(200) NOT NULL,
+ `BB_NAME` varchar(200) NOT NULL,
+ PRIMARY KEY (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;