summaryrefslogtreecommitdiffstats
path: root/mso-catalog-db
diff options
context:
space:
mode:
Diffstat (limited to 'mso-catalog-db')
-rw-r--r--mso-catalog-db/pom.xml2
-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/beans/Service.java14
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceArtifact.java168
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceInfo.java106
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java40
-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/main/java/org/onap/so/db/catalog/data/repository/ServiceInfoRepository.java33
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java10
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/rest/beans/ServiceMacroHolder.java49
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java16
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java13
-rw-r--r--mso-catalog-db/src/test/resources/data.sql6
-rw-r--r--mso-catalog-db/src/test/resources/schema.sql12
14 files changed, 600 insertions, 20 deletions
diff --git a/mso-catalog-db/pom.xml b/mso-catalog-db/pom.xml
index 6a4a6774e6..7444866315 100644
--- a/mso-catalog-db/pom.xml
+++ b/mso-catalog-db/pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.onap.so</groupId>
<artifactId>so</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<artifactId>mso-catalog-db</artifactId>
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/beans/Service.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java
index ab40cefb4e..0d7a6dbd1f 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java
@@ -136,6 +136,9 @@ public class Service implements Serializable {
@JoinColumn(name = "TOSCA_CSAR_ARTIFACT_UUID")
private ToscaCsar csar;
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "service")
+ private List<ServiceArtifact> serviceArtifactList;
+
@Column(name = "NAMING_POLICY")
private String namingPolicy;
@@ -371,6 +374,17 @@ public class Service implements Serializable {
this.csar = csar;
}
+ public List<ServiceArtifact> getServiceArtifactList() {
+ if (serviceArtifactList == null) {
+ serviceArtifactList = new ArrayList<>();
+ }
+ return serviceArtifactList;
+ }
+
+ public void setServiceArtifactList(List<ServiceArtifact> serviceArtifactList) {
+ this.serviceArtifactList = serviceArtifactList;
+ }
+
public String getWorkloadContext() {
return this.workloadContext;
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceArtifact.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceArtifact.java
new file mode 100644
index 0000000000..a8884a81bb
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceArtifact.java
@@ -0,0 +1,168 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ * ================================================================================
+ * 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 com.fasterxml.jackson.annotation.JsonFormat;
+import com.openpojo.business.annotation.BusinessKey;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Objects;
+
+@Entity
+@Table(name = "service_artifact")
+public class ServiceArtifact implements Serializable {
+
+ private static final long serialVersionUID = 768026109321305392L;
+
+ @BusinessKey
+ @Id
+ @Column(name = "ARTIFACT_UUID")
+ private String artifactUUID;
+
+ @Column(name = "TYPE")
+ private String type;
+
+ @Column(name = "NAME")
+ private String name;
+
+ @Column(name = "VERSION")
+ private String version;
+
+ @Column(name = "DESCRIPTION")
+ private String description;
+
+ @Column(name = "CONTENT", columnDefinition = "LONGTEXT")
+ private String content;
+
+ @Column(name = "CHECKSUM")
+ private String checksum;
+
+ @Column(name = "CREATION_TIMESTAMP", updatable = false)
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date creationTimestamp;
+
+ @ManyToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "SERVICE_MODEL_UUID")
+ private Service service;
+
+ @PrePersist
+ protected void onCreate() {
+ this.creationTimestamp = new Date();
+ }
+
+ public String getArtifactUUID() {
+ return artifactUUID;
+ }
+
+ public void setArtifactUUID(String artifactUUID) {
+ this.artifactUUID = artifactUUID;
+ }
+
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public String getChecksum() {
+ return checksum;
+ }
+
+ public void setChecksum(String checksum) {
+ this.checksum = checksum;
+ }
+
+ public Date getCreationTimestamp() {
+ return creationTimestamp;
+ }
+
+ public void setCreationTimestamp(Date creationTimestamp) {
+ this.creationTimestamp = creationTimestamp;
+ }
+
+ public Service getService() {
+ return service;
+ }
+
+ public void setService(Service service) {
+ this.service = service;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("artifactUUID", artifactUUID).append("type", type).append("name", name)
+ .append("version", version).append("description", description).append("content", content)
+ .append("checksum", checksum).append("creationTimestamp", creationTimestamp).toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ ServiceArtifact that = (ServiceArtifact) o;
+ return artifactUUID.equals(that.artifactUUID);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(artifactUUID);
+ }
+}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceInfo.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceInfo.java
new file mode 100644
index 0000000000..f9c95767f6
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceInfo.java
@@ -0,0 +1,106 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ * ================================================================================
+ * 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 com.openpojo.business.annotation.BusinessKey;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import uk.co.blackpepper.bowman.annotation.LinkedResource;
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Objects;
+
+@Entity
+@Table(name = "service_info")
+public class ServiceInfo implements Serializable {
+
+ private static final long serialVersionUID = 768026109321305392L;
+
+ @Id
+ @BusinessKey
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "ID")
+ private Integer id;
+
+ @Column(name = "SERVICE_INPUT")
+ private String serviceInput;
+
+ @Column(name = "SERVICE_PROPERTIES")
+ private String serviceProperties;
+
+ @OneToOne(cascade = CascadeType.ALL)
+ @JoinTable(name = "service_to_service_info", joinColumns = @JoinColumn(name = "SERVICE_INFO_ID"),
+ inverseJoinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"))
+ private Service service;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer serviceInfoId) {
+ this.id = serviceInfoId;
+ }
+
+ public String getServiceInput() {
+ return serviceInput;
+ }
+
+ public void setServiceInput(String serviceInput) {
+ this.serviceInput = serviceInput;
+ }
+
+ public String getServiceProperties() {
+ return serviceProperties;
+ }
+
+ public void setServiceProperties(String serviceProperties) {
+ this.serviceProperties = serviceProperties;
+ }
+
+ @LinkedResource
+ public Service getService() {
+ return service;
+ }
+
+ public void setService(Service service) {
+ this.service = service;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("id", id).append("serviceProperties", serviceProperties)
+ .append("serviceInput", serviceInput).toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ ServiceInfo that = (ServiceInfo) o;
+ return id.equals(that.id);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+}
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..26c33941ed 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
@@ -7,9 +7,9 @@
* 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.
@@ -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";
@@ -156,6 +158,7 @@ public class CatalogDbClient {
protected static final String HOMING_INSTANCE = "/homingInstance";
protected static final String ARTIFACT_UUID = "artifactUUID";
protected static final String SOURCE = "source";
+ protected static final String RESOURCE_TARGET = "resource_target";
private static final String TARGET_ENTITY = "SO:CatalogDB";
private static final String ASTERISK = "*";
@@ -201,10 +204,13 @@ public class CatalogDbClient {
private String findServiceByServiceInstanceId = "/findServiceByServiceInstanceId";
private String findPnfResourceCustomizationByModelUuid = "/findPnfResourceCustomizationByModelUuid";
private String findWorkflowByArtifactUUID = "/findByArtifactUUID";
- private String findWorkflowByModelUUID = "/findWorkflowByModelUUID";
+ private String findWorkflowByVnfModelUUID = "/findWorkflowByVnfModelUUID";
private String findWorkflowByPnfModelUUID = "/findWorkflowByPnfModelUUID";
private String findWorkflowBySource = "/findBySource";
private String findVnfResourceCustomizationByModelUuid = "/findVnfResourceCustomizationByModelUuid";
+ private String findBBNameSelectionReferenceByControllerActorAndScopeAndAction =
+ "/findBBNameSelectionReferenceByControllerActorAndScopeAndAction";
+ private String findWorkflowByResourceTarget = "/findByResourceTarget";
private String serviceURI;
private String vfModuleURI;
@@ -277,6 +283,8 @@ public class CatalogDbClient {
private final Client<Workflow> workflowClient;
+ private final Client<BBNameSelectionReference> bbNameSelectionReferenceClient;
+
@Value("${mso.catalog.db.spring.endpoint:#{null}}")
private String endpoint;
@@ -339,13 +347,17 @@ public class CatalogDbClient {
endpoint + PNF_RESOURCE_CUSTOMIZATION + SEARCH + findPnfResourceCustomizationByModelUuid;
findWorkflowByArtifactUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByArtifactUUID;
- findWorkflowByModelUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByModelUUID;
+ findWorkflowByVnfModelUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByVnfModelUUID;
findWorkflowByPnfModelUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByPnfModelUUID;
findWorkflowBySource = endpoint + WORKFLOW + SEARCH + findWorkflowBySource;
+ findWorkflowByResourceTarget = endpoint + WORKFLOW + SEARCH + findWorkflowByResourceTarget;
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 +424,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 +476,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 +704,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)
@@ -1049,8 +1072,8 @@ public class CatalogDbClient {
.queryParam(ARTIFACT_UUID, artifactUUID).build().toString()));
}
- public List<Workflow> findWorkflowByModelUUID(String vnfResourceModelUUID) {
- return this.getMultipleResources(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByModelUUID)
+ public List<Workflow> findWorkflowByVnfModelUUID(String vnfResourceModelUUID) {
+ return this.getMultipleResources(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByVnfModelUUID)
.queryParam(VNF_RESOURCE_MODEL_UUID, vnfResourceModelUUID).build().toString()));
}
@@ -1064,6 +1087,11 @@ public class CatalogDbClient {
getUri(UriBuilder.fromUri(findWorkflowBySource).queryParam(SOURCE, source).build().toString()));
}
+ public List<Workflow> findWorkflowByResourceTarget(String resourceTarget) {
+ return this.getMultipleResources(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByResourceTarget)
+ .queryParam(RESOURCE_TARGET, resourceTarget).build().toString()));
+ }
+
public String getEndpoint() {
return endpoint;
}
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/main/java/org/onap/so/db/catalog/data/repository/ServiceInfoRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceInfoRepository.java
new file mode 100644
index 0000000000..e3a4ca264e
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/ServiceInfoRepository.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ * ================================================================================
+ * 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.Service;
+import org.onap.so.db.catalog.beans.ServiceInfo;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
+
+@RepositoryRestResource(collectionResourceRel = "serviceInfo", path = "serviceInfo")
+public interface ServiceInfoRepository extends JpaRepository<ServiceInfo, Integer> {
+
+ ServiceInfo findByService(Service service);
+
+}
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 f1b399325e..93ec54a2eb 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
@@ -7,9 +7,9 @@
* 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.
@@ -33,18 +33,20 @@ public interface WorkflowRepository extends JpaRepository<Workflow, Integer> {
List<Workflow> findBySource(String source);
+ List<Workflow> findByResourceTarget(String resourceTarget);
+
/**
* Used to fetch the @{link Workflow} by the Model UUID.
*
* This operation is required by {@link org.onap.so.db.catalog.client.CatalogDbClient} to provide Workflow based on
- * model UUID without projection.
+ * vnf model UUID without projection.
*
* @param vnfResourceModelUUID UUID
* @return List of Workflow
*/
@Query(value = "select b.* from vnf_resource_to_workflow a join workflow b where a.WORKFLOW_ID = b.ID and a.VNF_RESOURCE_MODEL_UUID = ?1",
nativeQuery = true)
- List<Workflow> findWorkflowByModelUUID(String vnfResourceModelUUID);
+ List<Workflow> findWorkflowByVnfModelUUID(String vnfResourceModelUUID);
/**
* Used to fetch the @{link Workflow} by the Pnf Model UUID.
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/rest/beans/ServiceMacroHolder.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/rest/beans/ServiceMacroHolder.java
index f9cbb0d462..ec4e922c8f 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/rest/beans/ServiceMacroHolder.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/rest/beans/ServiceMacroHolder.java
@@ -20,14 +20,10 @@
package org.onap.so.db.catalog.rest.beans;
+import com.openpojo.business.annotation.BusinessKey;
+import org.onap.so.db.catalog.beans.*;
import java.io.Serializable;
import java.util.ArrayList;
-import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
-import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
-import org.onap.so.db.catalog.beans.Service;
-import org.onap.so.db.catalog.beans.VnfResource;
-import org.onap.so.db.catalog.beans.VnfResourceCustomization;
-import com.openpojo.business.annotation.BusinessKey;
/*
* A simple holder for Service and its associated elements: VnfResource, 1-n VfModule, Network TBD
@@ -42,6 +38,8 @@ public class ServiceMacroHolder implements Serializable {
private ArrayList<NetworkResourceCustomization> networkResourceCustomizations;
private ArrayList<AllottedResourceCustomization> allottedResourceCustomizations;
private ArrayList<VnfResourceCustomization> vnfResourceCustomizations;
+ private ArrayList<ServiceProxyResourceCustomization> serviceProxyResourceCustomizations;
+ private ServiceInfo serviceInfo;
public ServiceMacroHolder() {
@@ -51,6 +49,8 @@ public class ServiceMacroHolder implements Serializable {
this.networkResourceCustomizations = new ArrayList<>();
this.allottedResourceCustomizations = new ArrayList<>();
this.vnfResourceCustomizations = new ArrayList<>();
+ this.serviceProxyResourceCustomizations = new ArrayList<>();
+ this.serviceInfo = null;
}
public ServiceMacroHolder(Service service) {
@@ -66,6 +66,14 @@ public class ServiceMacroHolder implements Serializable {
this.service = service;
}
+ public ServiceInfo getServiceInfo() {
+ return serviceInfo;
+ }
+
+ public void setServiceInfo(ServiceInfo serviceInfo) {
+ this.serviceInfo = serviceInfo;
+ }
+
public void setVnfResources(ArrayList<VnfResource> vnfResources) {
this.vnfResources = vnfResources;
}
@@ -139,6 +147,15 @@ public class ServiceMacroHolder implements Serializable {
}
}
+ public void addServiceProxyResourceCustomization(ServiceProxyResourceCustomization sprc) {
+ if (this.serviceProxyResourceCustomizations != null) {
+ this.serviceProxyResourceCustomizations.add(sprc);
+ } else {
+ this.serviceProxyResourceCustomizations = new ArrayList<>();
+ this.serviceProxyResourceCustomizations.add(sprc);
+ }
+ }
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -148,6 +165,11 @@ public class ServiceMacroHolder implements Serializable {
} else {
sb.append("service: null");
}
+ if (this.serviceInfo != null) {
+ sb.append("serviceInfo: " + this.serviceInfo.toString());
+ } else {
+ sb.append("serviceInfo: null");
+ }
if (this.vnfResourceCustomizations != null && this.vnfResourceCustomizations.size() > 0) {
int i = 0;
sb.append("VnfResources: ");
@@ -180,6 +202,13 @@ public class ServiceMacroHolder implements Serializable {
sb.append("ARC[" + i++ + "]: " + arc.toString());
}
}
+ if (this.serviceProxyResourceCustomizations != null && this.serviceProxyResourceCustomizations.size() > 0) {
+ int i = 0;
+ sb.append("ServiceProxyResourceCustomizations:");
+ for (ServiceProxyResourceCustomization sprc : this.serviceProxyResourceCustomizations) {
+ sb.append("SPRC[" + i++ + "]: " + sprc.toString());
+ }
+ }
return sb.toString();
}
@@ -202,6 +231,12 @@ public class ServiceMacroHolder implements Serializable {
this.allottedResourceCustomizations = allottedResourceCustomizations;
}
+ public ArrayList<ServiceProxyResourceCustomization> getServiceProxyResourceCustomizations() {
+ return serviceProxyResourceCustomizations;
+ }
-
+ public void setServiceProxyResourceCustomizations(
+ ArrayList<ServiceProxyResourceCustomization> serviceProxyResourceCustomizations) {
+ this.serviceProxyResourceCustomizations = serviceProxyResourceCustomizations;
+ }
}
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 66fc0f5dc5..79e3cbcc08 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
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 Nordix
+ * ================================================================================
* 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
@@ -179,7 +181,7 @@ public class CatalogDbClientTest {
}
@Test
- public final void testFindWorkflowByPnfModelUUID() throws Exception {
+ public final void testFindWorkflowByPnfModelUUID() {
String pnfResourceModelUUID = "f2d1f2b2-88bb-49da-b716-36ae420ccbff";
doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any());
@@ -190,4 +192,16 @@ public class CatalogDbClientTest {
}
+ @Test
+ public final void testFindWorkflowByResourceTarget() {
+ // when
+ final String pnf_resource = "pnf";
+ doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any());
+ catalogDbClient.findWorkflowByResourceTarget(pnf_resource);
+
+ // verify
+ verify(catalogDbClient).getMultipleResources(any(Client.class), eq(UriBuilder.fromUri("/findByResourceTarget")
+ .queryParam(CatalogDbClient.RESOURCE_TARGET, pnf_resource).build()));
+ }
+
}
diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java
index 7d1b8d0d96..e47c61d8b4 100644
--- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java
@@ -36,7 +36,8 @@ public class WorkflowRepositoryTest extends BaseTest {
@Test
public void findByVnfResourceModelUUIDTest() throws Exception {
- List<Workflow> workflows = workflowRepository.findWorkflowByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
+ List<Workflow> workflows =
+ workflowRepository.findWorkflowByVnfModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
Assert.assertTrue(workflows != null);
Assert.assertTrue(workflows.size() != 0);
@@ -54,4 +55,14 @@ public class WorkflowRepositoryTest extends BaseTest {
Assert.assertTrue("testingWorkflow.bpmn".equals(workflows.get(0).getArtifactName()));
}
+ @Test
+ public void findByResourceTargetTest() {
+ List<Workflow> workflows = workflowRepository.findByResourceTarget("pnf");
+
+ Assert.assertTrue(workflows != null);
+ Assert.assertTrue(workflows.size() == 1);
+
+ Assert.assertTrue("DummyPnfWorkflow".equals(workflows.get(0).getArtifactName()));
+ }
+
}
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;