summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2020-04-16 18:30:24 +0000
committerGerrit Code Review <gerrit@onap.org>2020-04-16 18:30:24 +0000
commit9e9fe0469937a0ce246b5b16af1e3b1d6b69e664 (patch)
treefad69298ebc176318b40b633e4cd83084f56cae7
parentfa9a707c87654330dfb5788a6029b8199c6cdf17 (diff)
parentd255e437b624bb88eab336b1c0b74372e821e99c (diff)
Merge "Implement processing_flags table and corresponding"
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java112
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.7__AddProcessingFlags.sql13
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java42
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java8
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql6
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ProcessingFlags.java187
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java15
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ProcessingFlagsRepository.java33
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/ProcessingFlagsRepositoryTest.java40
-rw-r--r--mso-catalog-db/src/test/resources/data.sql6
-rw-r--r--mso-catalog-db/src/test/resources/schema.sql12
11 files changed, 469 insertions, 5 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
index 98abf15645..f283af1ba6 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
@@ -27,6 +27,7 @@ package org.onap.so.adapters.catalogdb.rest;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
@@ -46,8 +47,34 @@ import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceMacroHolder;
import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceNetworks;
import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceVnfs;
import org.onap.so.adapters.catalogdb.catalogrest.QueryVfModule;
-import org.onap.so.db.catalog.beans.*;
-import org.onap.so.db.catalog.data.repository.*;
+import org.onap.so.db.catalog.beans.AllottedResource;
+import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
+import org.onap.so.db.catalog.beans.InstanceGroup;
+import org.onap.so.db.catalog.beans.NetworkResource;
+import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.ProcessingFlags;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.ToscaCsar;
+import org.onap.so.db.catalog.beans.VfModule;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.VnfRecipe;
+import org.onap.so.db.catalog.beans.VnfResource;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
+import org.onap.so.db.catalog.data.repository.ArRecipeRepository;
+import org.onap.so.db.catalog.data.repository.InstanceGroupRepository;
+import org.onap.so.db.catalog.data.repository.NetworkRecipeRepository;
+import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
+import org.onap.so.db.catalog.data.repository.ProcessingFlagsRepository;
+import org.onap.so.db.catalog.data.repository.ServiceRepository;
+import org.onap.so.db.catalog.data.repository.ToscaCsarRepository;
+import org.onap.so.db.catalog.data.repository.VFModuleRepository;
+import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.VnfRecipeRepository;
+import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
import org.onap.so.db.catalog.rest.beans.ServiceMacroHolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -102,6 +129,9 @@ public class CatalogDbAdapterRest {
@Autowired
private InstanceGroupRepository instanceGroupRepository;
+ @Autowired
+ private ProcessingFlagsRepository processingFlagsRepo;
+
private static final String NO_MATCHING_PARAMETERS = "no matching parameters";
public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) {
@@ -547,4 +577,82 @@ public class CatalogDbAdapterRest {
.entity(new GenericEntity<CatalogQueryException>(excResp) {}).build();
}
}
+
+ @GET
+ @Path("processingFlags/{flag}")
+ @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ @Transactional(readOnly = true)
+ public Response getProcessingFlags(@PathParam("flag") String flag) {
+ return getProcessingFlagsImpl(flag);
+ }
+
+ public Response getProcessingFlagsImpl(String flag) {
+ ProcessingFlags processingFlags = null;
+ logger.debug("Flag is: " + flag);
+ int respStatus = HttpStatus.SC_OK;
+ try {
+ processingFlags = processingFlagsRepo.findByFlag(flag);
+ if (processingFlags == null) {
+ logger.debug("ProcessingFlag not found");
+ respStatus = HttpStatus.SC_NOT_FOUND;
+
+ } else {
+
+ logger.debug("ProcessingFlags processingFlags = {}", processingFlags.toString());
+ }
+ return Response.status(respStatus).entity(processingFlags)
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build();
+ } catch (Exception e) {
+ logger.error("Exception - queryProcesssingFlags", e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
+ CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {}).build();
+ }
+ }
+
+ @PUT
+ @Path("processingFlags/{flag}")
+ @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+ @Transactional
+ public Response updateProcessingFlagsValue(@PathParam("flag") String flag, ProcessingFlags updatedProcessingFlag) {
+ return updateProcessingFlagsValueImpl(flag, updatedProcessingFlag);
+ }
+
+ public Response updateProcessingFlagsValueImpl(String flag, ProcessingFlags updatedProcessingFlag) {
+ ProcessingFlags processingFlags = null;
+ logger.debug("Flag is: " + flag);
+ int respStatus = HttpStatus.SC_OK;
+ try {
+ if (updatedProcessingFlag == null) {
+ logger.debug("No valid updatedProcessingFlag is provided");
+ throw new RuntimeException("No valid updatedProcessingFlag is provided");
+ }
+ String value = updatedProcessingFlag.getValue();
+ if (value == null || (!value.equalsIgnoreCase("YES") && !value.equalsIgnoreCase("NO"))) {
+ logger.debug("Value " + value + " is invalid, only yes/no are allowed");
+ throw new RuntimeException("Invalid value specified");
+ }
+ processingFlags = processingFlagsRepo.findByFlag(flag);
+ if (processingFlags == null) {
+ logger.debug("ProcessingFlag not found");
+ respStatus = HttpStatus.SC_NOT_FOUND;
+ } else {
+ logger.debug("ProcessingFlags processingFlags = {}", processingFlags.toString());
+ processingFlags.setValue(value);
+ processingFlagsRepo.saveAndFlush(processingFlags);
+ return Response.status(respStatus).entity(null)
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build();
+ }
+ } catch (Exception e) {
+ logger.error("Exception - queryProcesssingFlags", e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
+ CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {}).build();
+ }
+
+ return Response.status(HttpStatus.SC_NOT_FOUND).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .build();
+ }
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.7__AddProcessingFlags.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.7__AddProcessingFlags.sql
new file mode 100644
index 0000000000..2686df13a3
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.7__AddProcessingFlags.sql
@@ -0,0 +1,13 @@
+use catalogdb;
+
+CREATE TABLE IF NOT EXISTS `processing_flags` (
+ `ID` INT(11) NOT NULL AUTO_INCREMENT,
+ `FLAG` varchar(200) NOT NULL,
+ `VALUE` varchar(200) NOT NULL,
+ `ENDPOINT` varchar(200) NOT NULL,
+ `DESCRIPTION` longtext NOT NULL,
+ `CREATION_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(),
+ `UPDATE_TIMESTAMP` timestamp DEFAULT current_timestamp() ON UPDATE current_timestamp(),
+ PRIMARY KEY (`ID`),
+ UNIQUE KEY `UK_processing_flags` (`FLAG`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1; \ No newline at end of file
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java
index 69a23a0eba..04161e9df9 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java
@@ -27,6 +27,7 @@ import javax.ws.rs.core.Response;
import org.json.JSONException;
import org.junit.Test;
import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
+import org.onap.so.db.catalog.beans.ProcessingFlags;
import org.onap.so.db.catalog.beans.ServiceRecipe;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;
@@ -36,6 +37,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.util.UriComponentsBuilder;
+import com.fasterxml.jackson.databind.ObjectMapper;
public class CatalogDBRestTest extends CatalogDbAdapterBaseTest {
@@ -55,6 +57,8 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest {
private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources";
+ private static final String ECOMP_MSO_CATALOG_PROCESSING_FLAGS = "ecomp/mso/catalog/v2/processingFlags";
+
TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
HttpHeaders headers = new HttpHeaders();
@@ -805,6 +809,44 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest {
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusCode().value());
}
+ @Test
+ public void testGetProcessingFlagsByFlag() throws Exception {
+ HttpEntity<String> entity = new HttpEntity<String>(null, headers);
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+
+ UriComponentsBuilder builder = UriComponentsBuilder
+ .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)).pathSegment("TESTFLAG");
+
+ ResponseEntity<String> response =
+ restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
+
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+ ObjectMapper mapper = new ObjectMapper();
+ ProcessingFlags processingFlagsResponse = mapper.readValue(response.getBody(), ProcessingFlags.class);
+
+ assertEquals(processingFlagsResponse.getFlag(), "TESTFLAG");
+ assertEquals(processingFlagsResponse.getValue(), "NO");
+ assertEquals(processingFlagsResponse.getEndpoint(), "TESTENDPOINT");
+ assertEquals(processingFlagsResponse.getDescription(), "TEST FLAG");
+ }
+
+ @Test
+ public void testSetProcessingFlagsFlagValue() throws JSONException {
+ ProcessingFlags updatedProcessingFlag = new ProcessingFlags();
+ updatedProcessingFlag.setFlag("TESTFLAG");
+ updatedProcessingFlag.setValue("YES");
+ HttpEntity<ProcessingFlags> entity = new HttpEntity<ProcessingFlags>(updatedProcessingFlag, headers);
+ headers.set("Accept", MediaType.APPLICATION_JSON);
+
+ UriComponentsBuilder builder = UriComponentsBuilder
+ .fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)).pathSegment("TESTFLAG");
+
+ ResponseEntity<String> response =
+ restTemplate.exchange(builder.toUriString(), HttpMethod.PUT, entity, String.class);
+
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+ }
+
private String createURLWithPort(String uri) {
return "http://localhost:" + port + uri;
}
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 03ef24ded0..d6f2c6dbcc 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
@@ -43,6 +43,7 @@ import org.onap.so.db.catalog.beans.InstanceGroup;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
import org.onap.so.db.catalog.beans.PnfResource;
import org.onap.so.db.catalog.beans.PnfResourceCustomization;
+import org.onap.so.db.catalog.beans.ProcessingFlags;
import org.onap.so.db.catalog.beans.ServerType;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceRecipe;
@@ -771,5 +772,12 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
}
+ @Test
+ public void testGetProcessingFlagsFromFlag() {
+ ProcessingFlags processingFlags = client.findProcessingFlagsByFlag("TESTFLAG");
+ assertNotNull(processingFlags);
+ assertEquals(processingFlags.getEndpoint(), "TESTENDPOINT");
+ }
+
}
diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql
index 8fd171bf64..31a4f126e8 100644
--- a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql
+++ b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql
@@ -253,4 +253,8 @@ insert into workflow(artifact_uuid, artifact_name, name, operation_name, version
('5b0c4322-643d-4c9f-b184-4516049e99b1', 'testingWorkflow.bpmn', 'testingWorkflow', 'create', 1, 'Test Workflow', null, 'vnf', 'sdc');
insert into vnf_resource_to_workflow(vnf_resource_model_uuid, workflow_id) values
-('ff2ae348-214a-11e7-93ae-92361f002671', '1'); \ No newline at end of file
+('ff2ae348-214a-11e7-93ae-92361f002671', '1');
+
+insert into processing_flags (flag,value,endpoint,description) values
+('TESTFLAG', 'NO', 'TESTENDPOINT', 'TEST FLAG');
+
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ProcessingFlags.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ProcessingFlags.java
new file mode 100644
index 0000000000..211da5d90b
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ProcessingFlags.java
@@ -0,0 +1,187 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 java.util.Date;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.PrePersist;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.hibernate.annotations.UpdateTimestamp;
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.openpojo.business.annotation.BusinessKey;
+import uk.co.blackpepper.bowman.annotation.RemoteResource;
+
+
+/**
+ * EntityBean class for ProcessingFlags. This bean represents a set of flags governing request processing.
+ *
+ */
+@RemoteResource("/processingFlags")
+@Entity
+@Table(name = "processing_flags")
+@JsonAutoDetect(fieldVisibility = Visibility.ANY)
+public class ProcessingFlags {
+
+ @Id
+ @Column(name = "ID", nullable = false, updatable = false)
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer id;
+
+ @JsonProperty("flag")
+ @BusinessKey
+ @Column(name = "FLAG")
+ private String flag;
+
+ @JsonProperty("value")
+ @BusinessKey
+ @Column(name = "VALUE")
+ private String value;
+
+ @JsonProperty("endpoint")
+ @BusinessKey
+ @Column(name = "ENDPOINT")
+ private String endpoint;
+
+ @JsonProperty("description")
+ @Lob
+ @Column(name = "DESCRIPTION", columnDefinition = "LONGTEXT")
+ private String description = null;
+
+ @JsonProperty("creation_timestamp")
+ @BusinessKey
+ @Column(name = "CREATION_TIMESTAMP", updatable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date created;
+
+ @JsonProperty("update_timestamp")
+ @BusinessKey
+ @Column(name = "UPDATE_TIMESTAMP")
+ @Temporal(TemporalType.TIMESTAMP)
+ @UpdateTimestamp
+ private Date updated;
+
+ public ProcessingFlags() {
+
+ }
+
+ @PrePersist
+ protected void onCreate() {
+ this.created = new Date();
+ // this.updated = new Date();
+ }
+
+ public ProcessingFlags(ProcessingFlags flags) {
+ this.flag = flags.getFlag();
+ this.value = flags.getValue();
+ this.endpoint = flags.getEndpoint();
+ this.description = flags.getDescription();
+ }
+
+ public Integer getId() {
+ return this.id;
+ }
+
+ public String getFlag() {
+ return flag;
+ }
+
+ public void setFlag(String flag) {
+ this.flag = flag;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getEndpoint() {
+ return endpoint;
+ }
+
+ public void setEndpoint(String endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public void setCreated(Date created) {
+ this.created = created;
+ }
+
+ public Date getUpdated() {
+ return updated;
+ }
+
+ public void setUpdated(Date updated) {
+ this.updated = updated;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("flag", getFlag())
+ .append("value", getValue()).append("endpoint", getEndpoint()).append("description", getDescription())
+ .toString();
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (other == null) {
+ return false;
+ }
+ if (!getClass().equals(other.getClass())) {
+ return false;
+ }
+ ProcessingFlags castOther = (ProcessingFlags) other;
+ return new EqualsBuilder().append(getFlag(), castOther.getFlag()).append(getValue(), castOther.getValue())
+ .isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(1, 31).append(getFlag()).append(getValue()).append(getEndpoint()).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 4c5bbaf7ec..a68ed44ee7 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
@@ -52,6 +52,7 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective;
import org.onap.so.db.catalog.beans.PnfResource;
import org.onap.so.db.catalog.beans.PnfResourceCustomization;
+import org.onap.so.db.catalog.beans.ProcessingFlags;
import org.onap.so.db.catalog.beans.ResourceType;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceRecipe;
@@ -121,6 +122,7 @@ public class CatalogDbClient {
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 PROCESSING_FLAGS = "/processingFlags";
private static final String SEARCH = "/search";
@@ -159,6 +161,7 @@ public class CatalogDbClient {
protected static final String ARTIFACT_UUID = "artifactUUID";
protected static final String SOURCE = "source";
protected static final String RESOURCE_TARGET = "resourceTarget";
+ protected static final String FLAG = "flag";
private static final String TARGET_ENTITY = "SO:CatalogDB";
private static final String ASTERISK = "*";
@@ -211,6 +214,7 @@ public class CatalogDbClient {
private String findBBNameSelectionReferenceByControllerActorAndScopeAndAction =
"/findBBNameSelectionReferenceByControllerActorAndScopeAndAction";
private String findWorkflowByResourceTarget = "/findByResourceTarget";
+ private String findProcessingFlagsByFlag = "/findByFlag";
private String serviceURI;
private String vfModuleURI;
@@ -285,6 +289,8 @@ public class CatalogDbClient {
private final Client<BBNameSelectionReference> bbNameSelectionReferenceClient;
+ private final Client<ProcessingFlags> processingFlagsClient;
+
@Value("${mso.catalog.db.spring.endpoint:#{null}}")
private String endpoint;
@@ -358,6 +364,8 @@ public class CatalogDbClient {
findBBNameSelectionReferenceByControllerActorAndScopeAndAction = endpoint + BB_NAME_SELECTION_REFERENCE + SEARCH
+ findBBNameSelectionReferenceByControllerActorAndScopeAndAction;
+ findProcessingFlagsByFlag = endpoint + PROCESSING_FLAGS + SEARCH + findProcessingFlagsByFlag;
+
serviceURI = endpoint + SERVICE + URI_SEPARATOR;
vfModuleURI = endpoint + VFMODULE + URI_SEPARATOR;
vnfResourceURI = endpoint + VNF_RESOURCE + URI_SEPARATOR;
@@ -425,6 +433,7 @@ public class CatalogDbClient {
pnfResourceCustomizationClient = clientFactory.create(PnfResourceCustomization.class);
workflowClient = clientFactory.create(Workflow.class);
bbNameSelectionReferenceClient = clientFactory.create(BBNameSelectionReference.class);
+ processingFlagsClient = clientFactory.create(ProcessingFlags.class);
}
@@ -477,6 +486,7 @@ public class CatalogDbClient {
pnfResourceCustomizationClient = clientFactory.create(PnfResourceCustomization.class);
workflowClient = clientFactory.create(Workflow.class);
bbNameSelectionReferenceClient = clientFactory.create(BBNameSelectionReference.class);
+ processingFlagsClient = clientFactory.create(ProcessingFlags.class);
}
public NetworkCollectionResourceCustomization getNetworkCollectionResourceCustomizationByID(
@@ -1091,6 +1101,11 @@ public class CatalogDbClient {
.queryParam(RESOURCE_TARGET, resourceTarget).build().toString()));
}
+ public ProcessingFlags findProcessingFlagsByFlag(String flag) {
+ return this.getSingleResource(processingFlagsClient,
+ getUri(UriBuilder.fromUri(findProcessingFlagsByFlag).queryParam(FLAG, flag).build().toString()));
+ }
+
public String getEndpoint() {
return endpoint;
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ProcessingFlagsRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ProcessingFlagsRepository.java
new file mode 100644
index 0000000000..b6583035df
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ProcessingFlagsRepository.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. 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.ProcessingFlags;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
+import javax.transaction.Transactional;
+
+@RepositoryRestResource(collectionResourceRel = "processingFlags", path = "processingFlags")
+@Transactional
+public interface ProcessingFlagsRepository extends JpaRepository<ProcessingFlags, String> {
+
+ ProcessingFlags findByFlag(String flag);
+}
diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/ProcessingFlagsRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/ProcessingFlagsRepositoryTest.java
new file mode 100644
index 0000000000..e8a8263d95
--- /dev/null
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/ProcessingFlagsRepositoryTest.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. 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.junit.Assert;
+import org.junit.Test;
+import org.onap.so.db.catalog.BaseTest;
+import org.onap.so.db.catalog.beans.ProcessingFlags;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class ProcessingFlagsRepositoryTest extends BaseTest {
+
+ @Autowired
+ private ProcessingFlagsRepository processingFlagsRepository;
+
+ @Test
+ public void findByFlagTest() throws Exception {
+ ProcessingFlags processingFlags = processingFlagsRepository.findByFlag("TESTFLAG");
+ Assert.assertNotNull(processingFlags);
+ Assert.assertEquals("TESTENDPOINT", processingFlags.getEndpoint());
+ }
+}
diff --git a/mso-catalog-db/src/test/resources/data.sql b/mso-catalog-db/src/test/resources/data.sql
index b38d4d9376..0913aef01b 100644
--- a/mso-catalog-db/src/test/resources/data.sql
+++ b/mso-catalog-db/src/test/resources/data.sql
@@ -962,4 +962,8 @@ 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
+('APPC', 'vnf', 'healthCheck','GenericVnfHealthCheckBB');
+
+INSERT INTO processing_flags (FLAG,VALUE,ENDPOINT,DESCRIPTION)
+VALUES
+('TESTFLAG', 'NO', 'TESTENDPOINT', 'TEST FLAG'); \ 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 0d49903e51..68f272cca0 100644
--- a/mso-catalog-db/src/test/resources/schema.sql
+++ b/mso-catalog-db/src/test/resources/schema.sql
@@ -1403,4 +1403,14 @@ CREATE TABLE IF NOT EXISTS `bbname_selection_reference` (
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-
+CREATE TABLE IF NOT EXISTS `processing_flags` (
+ `ID` INT(11) NOT NULL AUTO_INCREMENT,
+ `FLAG` varchar(200) NOT NULL,
+ `VALUE` varchar(200) NOT NULL,
+ `ENDPOINT` varchar(200) NOT NULL,
+ `DESCRIPTION` longtext NOT NULL,
+ `CREATION_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(),
+ `UPDATE_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(),
+ PRIMARY KEY (`ID`),
+ UNIQUE KEY `UK_processing_flags` (`FLAG`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;