From 9737ae116859da4548dcd1bf3ba73d339f326c52 Mon Sep 17 00:00:00 2001 From: Manamohan Date: Mon, 17 Feb 2020 16:13:45 +0530 Subject: Based on Controller Actor calling CDS or APPC(Current Flow) -Added BBNameSelectionReference table having bbName along with action,scope,actor -Updated CatalogDbClient to use BBNameSelectionReference Table -Updated ControllerExecution bmpn to select flow as per Controller Actor -Corrected Format Error Issue-ID: SO-2316 Signed-off-by: Pooja03 Change-Id: I21fad846249f773308e34abcac134d3ee0694027 Signed-off-by: Manamohan --- .../V8.4__AddBBNameSelectionReference.sql | 16 ++ .../so/db/catalog/client/CatalogDbClientTest.java | 17 ++ .../BuildingBlock/ControllerExecutionBB.bpmn | 241 +++++++++++++++++++++ .../flowspecific/tasks/ControllerExecution.java | 109 ++++++++++ .../tasks/ControllerExecutionTest.java | 127 +++++++++++ .../db/catalog/beans/BBNameSelectionReference.java | 115 ++++++++++ .../onap/so/db/catalog/client/CatalogDbClient.java | 20 ++ .../BBNameSelectionReferenceRepository.java | 36 +++ mso-catalog-db/src/test/resources/data.sql | 6 + mso-catalog-db/src/test/resources/schema.sql | 12 + 10 files changed, 699 insertions(+) create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.4__AddBBNameSelectionReference.sql create mode 100644 bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecutionTest.java create mode 100644 mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/BBNameSelectionReference.java create mode 100644 mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/BBNameSelectionReferenceRepository.java diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.4__AddBBNameSelectionReference.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.4__AddBBNameSelectionReference.sql new file mode 100644 index 0000000000..2b8d4ea69f --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.4__AddBBNameSelectionReference.sql @@ -0,0 +1,16 @@ +use catalogdb; + +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; + +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/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index 739b4b62de..e0d5d3803f 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -33,6 +33,7 @@ import org.junit.Before; import org.junit.Test; import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest; import org.onap.so.db.catalog.beans.AuthenticationType; +import org.onap.so.db.catalog.beans.BBNameSelectionReference; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.CloudifyManager; @@ -754,5 +755,21 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { assertNotEquals(0, cloudSites.size()); } + @Test + public void getBBNameSelectionReference_validData_expectedOutput() { + BBNameSelectionReference bbNameSelectionReference = + client.getBBNameSelectionReference("APPC", "vfModule", "healthCheck"); + assertNotNull(bbNameSelectionReference); + assertEquals("GenericVnfHealthCheckBB", bbNameSelectionReference.getBbName()); + } + + @Test + public void getBBNameSelectionReference_invalidData_nullOutput() { + BBNameSelectionReference bbNameSelectionReference = + client.getBBNameSelectionReference("ABC", "vfModule", "healthCheck"); + assertNull(bbNameSelectionReference); + + } + } diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn new file mode 100644 index 0000000000..32d3bce469 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn @@ -0,0 +1,241 @@ + + + + + SequenceFlow_0gmfit3 + + + + SequenceFlow_1mkhog2 + SequenceFlow_0no1qag + + + + + + + + + SequenceFlow_05qembo + SequenceFlow_0cvsnuu + + + SequenceFlow_07tqu82 + SequenceFlow_1mkhog2 + + + + SequenceFlow_0vzx2yr + SequenceFlow_05qembo + + + SequenceFlow_0cvsnuu + SequenceFlow_07tqu82 + SequenceFlow_15gxql1 + + + + #{execution.getVariable("CDSStatus").equals("Success")} + + + SequenceFlow_15gxql1 + + + + + SequenceFlow_0gmfit3 + SequenceFlow_05j6hg6 + SequenceFlow_1lspfyy + + + + SequenceFlow_1lspfyy + SequenceFlow_05j6hg6 + SequenceFlow_1t7hs4k + SequenceFlow_0vzx2yr + + + + + + + + + + + + SequenceFlow_0fv03vt + SequenceFlow_0no1qag + SequenceFlow_0op5irz + + + + + + SequenceFlow_1t7hs4k + SequenceFlow_0fv03vt + + + SequenceFlow_0op5irz + + + + + ${execution.getVariable("controller_actor") == "CDS"} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java new file mode 100644 index 0000000000..86d56005f6 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecution.java @@ -0,0 +1,109 @@ +/*- + * ============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.bpmn.infrastructure.flowspecific.tasks; + +import java.util.Optional; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.db.catalog.beans.BBNameSelectionReference; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class ControllerExecution { + private static final Logger logger = LoggerFactory.getLogger(ControllerExecution.class); + private static final String CONTROLLER_ACTOR = "controllerActor"; + private static final String BUILDING_BLOCK = "buildingBlock"; + private static final String SCOPE = "scope"; + private static final String ACTION = "action"; + private static final String BBNAME = "bbName"; + @Autowired + private ExceptionBuilder exceptionUtil; + @Autowired + private CatalogDbClient catalogDbClient; + @Autowired + private ExtractPojosForBB extractPojosForBB; + + /** + * Setting Controller Actor, Scope and Action Variables in BuildingBlockExecution object + * + * @param execution - BuildingBlockExecution object + */ + public void setControllerActorScopeAction(BuildingBlockExecution execution) { + try { + GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + String modleUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid(); + VnfResourceCustomization vnfResourceCustomization = + catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modleUuid); + + // Fetching Controller Actor at VNF level if null then Controller Actor is set as "APPC" + String controllerActor = Optional.ofNullable(vnfResourceCustomization.getControllerActor()).orElse("APPC"); + ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK); + BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock(); + String scope = Optional.ofNullable(buildingBlock.getBpmnScope()).orElseThrow( + () -> new NullPointerException("BPMN Scope is NULL in the orchestration_flow_reference table ")); + String action = Optional.ofNullable(buildingBlock.getBpmnAction()).orElseThrow( + () -> new NullPointerException("BPMN Action is NULL in the orchestration_flow_reference table ")); + execution.setVariable(SCOPE, scope); + execution.setVariable(ACTION, action); + execution.setVariable(CONTROLLER_ACTOR, controllerActor); + logger.debug("Executing Controller Execution for ControllerActor: {}, Scope: {} , Action: {}", + controllerActor, scope, action); + + } catch (Exception ex) { + logger.error("An exception occurred while fetching Controller Actor,Scope and Action ", ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + /** + * Selecting bbName from BBNameSelectionReference and setting the value in a variable of BuildingBlockExecution + * + * @param execution - BuildingBlockExecution object + */ + public void selectBB(BuildingBlockExecution execution) { + try { + + String controllerActor = execution.getVariable(CONTROLLER_ACTOR); + String action = Optional.of((String) execution.getVariable(ACTION)).get(); + String scope = Optional.of((String) execution.getVariable(SCOPE)).get(); + BBNameSelectionReference bbNameSelectionReference = + catalogDbClient.getBBNameSelectionReference(controllerActor, scope, action); + String bbName = bbNameSelectionReference.getBbName(); + execution.setVariable(BBNAME, bbName); + logger.debug(" Executing {} BPMN", bbName); + } catch (Exception ex) { + logger.error("An exception occurred while getting bbname from catalogdb ", ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + + } + + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecutionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecutionTest.java new file mode 100644 index 0000000000..72a987c395 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ControllerExecutionTest.java @@ -0,0 +1,127 @@ +/*- + * ============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.bpmn.infrastructure.flowspecific.tasks; + + +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.when; +import java.util.UUID; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.db.catalog.beans.BBNameSelectionReference; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; + + +public class ControllerExecutionTest extends BaseTaskTest { + + @InjectMocks + private ControllerExecution controllerExecution = new ControllerExecution(); + + private static final String TEST_SCOPE = "vfModule"; + private static final String TEST_BBNAME = "ConfigurationScaleOut"; + private static final String TEST_ACTION = "configScaleOut"; + private static final String TEST_CONTROLLER_ACTOR = "APPC"; + + private BuildingBlock buildingBlock = new BuildingBlock(); + VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); + private ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock(); + private GenericVnf genericVnf; + private ServiceInstance serviceInstance; + private RequestContext requestContext; + private String msoRequestId; + + + @Before + public void before() throws BBObjectNotFoundException { + + genericVnf = setGenericVnf(); + serviceInstance = setServiceInstance(); + msoRequestId = UUID.randomUUID().toString(); + requestContext = setRequestContext(); + requestContext.setMsoRequestId(msoRequestId); + gBBInput.setRequestContext(requestContext); + buildingBlock.setBpmnAction(TEST_ACTION); + buildingBlock.setBpmnScope(TEST_SCOPE); + executeBuildingBlock.setBuildingBlock(buildingBlock); + execution.setVariable("buildingBlock", executeBuildingBlock); + + doThrow(new BpmnError("BPMN Error")).when(exceptionUtil) + .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class)); + + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID))) + .thenReturn(genericVnf); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))) + .thenReturn(serviceInstance); + + + } + + @Test + public void testSetControllerActorScopeAction() throws Exception { + + + doReturn(vnfResourceCustomization).when(catalogDbClient).getVnfResourceCustomizationByModelCustomizationUUID( + genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid()); + controllerExecution.setControllerActorScopeAction(execution); + assertEquals(TEST_SCOPE, execution.getVariable("scope")); + assertEquals(TEST_ACTION, execution.getVariable("action")); + assertEquals(TEST_CONTROLLER_ACTOR, execution.getVariable("controllerActor")); + + } + + + @Test + public void testSelectBB() throws Exception { + // given + BBNameSelectionReference bbNameSelectionReference = new BBNameSelectionReference(); + bbNameSelectionReference.setBbName(TEST_BBNAME); + bbNameSelectionReference.setAction(TEST_ACTION); + bbNameSelectionReference.setControllerActor(TEST_CONTROLLER_ACTOR); + bbNameSelectionReference.setScope(TEST_SCOPE); + doReturn(bbNameSelectionReference).when(catalogDbClient).getBBNameSelectionReference(TEST_CONTROLLER_ACTOR, + TEST_SCOPE, TEST_ACTION); + execution.setVariable("controllerActor", TEST_CONTROLLER_ACTOR); + execution.setVariable("scope", TEST_SCOPE); + execution.setVariable("action", TEST_ACTION); + + // when + controllerExecution.selectBB(execution); + // verify + assertEquals(TEST_BBNAME, execution.getVariable("bbName")); + } + +} 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 161ca2a2fb..015a063024 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 workflowClient; + private final Client 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 { + + 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; -- cgit 1.2.3-korg