From 9306c021d9434f4ce8d0dfa9dd9ecb63974f11e6 Mon Sep 17 00:00:00 2001 From: "Mnushkin, Dmitry" Date: Wed, 26 Jun 2019 11:14:28 -0400 Subject: enhance workflowaction to handle resume func init code for RESUME with junit passing overwrite URI on resume op from original request Change-Id: I1eee2bd66aa20804ba4a2834d269b5947565b9dc Issue-ID: SO-2055 Signed-off-by: Benjamin, Max (mb388a) --- .../so/db/request/client/RequestsDbClient.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'mso-api-handlers/mso-requests-db/src/main/java') diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java index 9ab0f3b680..c0ce59dc66 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java @@ -72,6 +72,8 @@ public class RequestsDbClient { private static final String REQUEST_ID = "REQUEST_ID"; private static final String OPERATIONAL_ENVIRONMENT_ID = "OPERATIONAL_ENV_ID"; private static final String SERVICE_MODEL_VERSION_ID = "SERVICE_MODEL_VERSION_ID"; + private static final String FLOW_EXECUTION_PATH = "flowExecutionPath"; + private static final String BPMN_EXECUTION_DATA_TAG = "BPMNExecutionData"; @Value("${mso.adapters.requestDb.endpoint:#{null}}") protected String endpoint; @@ -95,6 +97,8 @@ public class RequestsDbClient { private String findOneByServiceIdAndOperationIdURI = "/findOneByServiceIdAndOperationId"; + private String findOneByRequestId = "/infraActiveRequests/search/findOneByRequestId"; + private String findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestIdURI = "/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"; @@ -110,6 +114,8 @@ public class RequestsDbClient { private static final String findBySoRequestIdAndGroupIdAndName = "/requestProcessingData/search/findOneBySoRequestIdAndGroupingIdAndName"; + private static final String findBySoRequestIdAndName = "/requestProcessingData/search/findOneBySoRequestIdAndName"; + private static final String findBySoRequestIdOrderByGroupingIdDesc = "/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc"; @@ -136,6 +142,7 @@ public class RequestsDbClient { + findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestIdURI; findAllByOperationalEnvIdAndRequestIdURI = endpoint + OPERATIONAL_ENV_SERVICE_MODEL_STATUS_SEARCH + findAllByOperationalEnvIdAndRequestIdURI; + findOneByRequestId = endpoint + findOneByRequestId; } private ClientFactory getClientFactory() { @@ -361,6 +368,27 @@ public class RequestsDbClient { .queryParam(GROUPING_ID, groupingId).build().toString())); } + public RequestProcessingData getRequestProcessingDataBySoRequestIdAndName(String soRequestId, String name) { + return getClientFactory().create(RequestProcessingData.class) + .get(getUri(UriBuilder.fromUri(endpoint + findBySoRequestIdAndName) + .queryParam(SO_REQUEST_ID, soRequestId).queryParam(NAME, name).build().toString())); + } + + + public void persistProcessingData(String flowExecutionPath, String requestId) { + + HttpHeaders headers = getHttpHeaders(); + URI uri = getUri(requestProcessingDataURI); + RequestProcessingData rpd = new RequestProcessingData(); + rpd.setName(FLOW_EXECUTION_PATH); + rpd.setSoRequestId(requestId); + rpd.setValue(flowExecutionPath); + rpd.setTag(BPMN_EXECUTION_DATA_TAG); + + HttpEntity entity = new HttpEntity<>(rpd, headers); + restTemplate.postForLocation(uri, entity); + } + private List getRequestProcessingData(URI uri) { Iterable requestProcessingDataIterator = getClientFactory().create(RequestProcessingData.class).getAll(uri); @@ -370,6 +398,20 @@ public class RequestsDbClient { return requestProcessingDataList; } + public InfraActiveRequests findOneByRequestId(String requestId) { + try { + HttpEntity entity = getHttpEntity(); + return restTemplate.exchange( + getUri(UriBuilder.fromUri(findOneByRequestId).queryParam(REQUEST_ID, requestId).build().toString()), + HttpMethod.GET, entity, InfraActiveRequests.class).getBody(); + } catch (HttpClientErrorException e) { + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + return null; + } + throw e; + } + } + // From and To are defaulted to ignore start/endtime on query to database public List getRequest(final Map filters) { String url = UriBuilder.fromUri(getUri(getInfraActiveRequests)).queryParam("from", "0") -- cgit 1.2.3-korg