summaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src
diff options
context:
space:
mode:
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>2020-08-19 10:22:20 +0100
committerrameshiyer27 <ramesh.murugan.iyer@est.tech>2020-08-20 17:23:34 +0100
commit329da0d034a4645685ac0fe7f8e61d24e435d5dc (patch)
treeb4ead5e2c9c1471fb1b47f710fc90348cfd74d8a /mso-catalog-db/src
parent87260307fcdb8b4296558f564d36ad18653268cd (diff)
Picking workflow names dynamically for schema update procedure
Issue-ID: SO-3147 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: I4c9de93ea7b51657c2bc6ee24b4bb52e2068cf5a
Diffstat (limited to 'mso-catalog-db/src')
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java10
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java2
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java11
3 files changed, 22 insertions, 1 deletions
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 8d342b673d..ef90dd6984 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
@@ -20,6 +20,7 @@
package org.onap.so.db.catalog.client;
+import com.google.common.base.Strings;
import java.net.URI;
import java.util.ArrayList;
import java.util.Iterator;
@@ -83,7 +84,6 @@ import org.springframework.stereotype.Component;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
-import com.google.common.base.Strings;
import uk.co.blackpepper.bowman.Client;
import uk.co.blackpepper.bowman.ClientFactory;
import uk.co.blackpepper.bowman.Configuration;
@@ -162,6 +162,7 @@ public class CatalogDbClient {
protected static final String SOURCE = "source";
protected static final String RESOURCE_TARGET = "resourceTarget";
protected static final String FLAG = "flag";
+ protected static final String OPERATION_NAME = "operationName";
private static final String TARGET_ENTITY = "SO:CatalogDB";
private static final String ASTERISK = "*";
@@ -215,6 +216,7 @@ public class CatalogDbClient {
"/findBBNameSelectionReferenceByControllerActorAndScopeAndAction";
private String findWorkflowByResourceTarget = "/findByResourceTarget";
private String findProcessingFlagsByFlag = "/findByFlag";
+ private String findWorkflowByOperationName = "/findByOperationName";
private String serviceURI;
private String vfModuleURI;
@@ -365,6 +367,7 @@ public class CatalogDbClient {
+ findBBNameSelectionReferenceByControllerActorAndScopeAndAction;
findProcessingFlagsByFlag = endpoint + PROCESSING_FLAGS + SEARCH + findProcessingFlagsByFlag;
+ findWorkflowByOperationName = endpoint + WORKFLOW + SEARCH + findWorkflowByOperationName;
serviceURI = endpoint + SERVICE + URI_SEPARATOR;
vfModuleURI = endpoint + VFMODULE + URI_SEPARATOR;
@@ -1106,6 +1109,11 @@ public class CatalogDbClient {
.queryParam(RESOURCE_TARGET, resourceTarget).build().toString()));
}
+ public List<Workflow> findWorkflowByOperationName(String operationName) {
+ return this.getMultipleResources(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByOperationName)
+ .queryParam(OPERATION_NAME, operationName).build().toString()));
+ }
+
public ProcessingFlags findProcessingFlagsByFlag(String flag) {
return this.getSingleResource(processingFlagsClient,
getUri(UriBuilder.fromUri(findProcessingFlagsByFlag).queryParam(FLAG, flag).build().toString()));
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java
index 93ec54a2eb..74843e5531 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java
@@ -35,6 +35,8 @@ public interface WorkflowRepository extends JpaRepository<Workflow, Integer> {
List<Workflow> findByResourceTarget(String resourceTarget);
+ List<Workflow> findByOperationName(String operationName);
+
/**
* Used to fetch the @{link Workflow} by the Model UUID.
*
diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
index 79e3cbcc08..6a5daa601a 100644
--- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
@@ -204,4 +204,15 @@ public class CatalogDbClientTest {
.queryParam(CatalogDbClient.RESOURCE_TARGET, pnf_resource).build()));
}
+ @Test
+ public final void testFindWorkFlowByOperationName() {
+ final String operationName = "PNFSoftwareUpgrade";
+ doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any());
+ catalogDbClient.findWorkflowByOperationName(operationName);
+
+ // verify
+ verify(catalogDbClient).getMultipleResources(any(Client.class), eq(UriBuilder.fromUri("/findByOperationName")
+ .queryParam(CatalogDbClient.OPERATION_NAME, operationName).build()));
+ }
+
}