summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java11
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/WorkflowResourceTest.java81
-rw-r--r--asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/workflow-distribution.json2
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecActivitySpecCategories.java3
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceWorkflow.java32
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceWorkflowId.java84
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Workflow.java5
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/WorkflowActivitySpecSequence.java31
8 files changed, 84 insertions, 165 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java
index daeda2f976..a769b6a2e4 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java
@@ -122,13 +122,14 @@ public class WorkflowResource {
VnfResourceWorkflow vnfResourceWorkflow = new VnfResourceWorkflow();
vnfResourceWorkflow.setVnfResourceModelUUID(vfResourceModelUuid);
+ vnfResourceWorkflow.setWorkflow(workflow);
List<VnfResourceWorkflow> vnfResourceWorkflows = new ArrayList<VnfResourceWorkflow>();
vnfResourceWorkflows.add(vnfResourceWorkflow);
workflow.setVnfResourceWorkflow(vnfResourceWorkflows);
List<String> activityNames = getActivityNameList(artifact.getResult());
- List<WorkflowActivitySpecSequence> wfss = getWorkflowActivitySpecSequence(activityNames);
+ List<WorkflowActivitySpecSequence> wfss = getWorkflowActivitySpecSequence(activityNames, workflow);
workflow.setWorkflowActivitySpecSequence(wfss);
workflowRepo.save(workflow);
@@ -166,17 +167,21 @@ public class WorkflowResource {
return activityNameList;
}
- protected List<WorkflowActivitySpecSequence> getWorkflowActivitySpecSequence(List<String> activityNames)
- throws Exception {
+ protected List<WorkflowActivitySpecSequence> getWorkflowActivitySpecSequence(List<String> activityNames,
+ Workflow workflow) throws Exception {
if (activityNames == null || activityNames.size() == 0) {
return null;
}
List<WorkflowActivitySpecSequence> workflowActivitySpecs = new ArrayList<WorkflowActivitySpecSequence>();
+ int seqNo = 1;
for (String activityName : activityNames) {
ActivitySpec activitySpec = activityRepo.findByName(activityName);
if (activitySpec != null) {
WorkflowActivitySpecSequence workflowActivitySpec = new WorkflowActivitySpecSequence();
workflowActivitySpec.setActivitySpec(activitySpec);
+ workflowActivitySpec.setWorkflow(workflow);
+ workflowActivitySpec.setSeqNo(seqNo);
+ seqNo++;
workflowActivitySpecs.add(workflowActivitySpec);
}
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/WorkflowResourceTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/WorkflowResourceTest.java
index e655245c31..5a736217b7 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/WorkflowResourceTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/WorkflowResourceTest.java
@@ -22,45 +22,27 @@
package org.onap.so.asdc.installer.bpmn;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.*;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
import java.nio.file.Files;
-import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.ArrayList;
import java.util.List;
import javax.transaction.Transactional;
-import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.message.BasicStatusLine;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.so.asdc.BaseTest;
+import org.onap.so.db.catalog.beans.VnfResourceWorkflow;
+import org.onap.so.db.catalog.beans.Workflow;
+import org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence;
+import org.onap.so.db.catalog.data.repository.WorkflowRepository;
+import org.springframework.beans.factory.annotation.Autowired;
-@Transactional
-public class WorkflowResourceTest {
+public class WorkflowResourceTest extends BaseTest {
- private WorkflowResource workflowResource = new WorkflowResource();
+ @Autowired
+ private WorkflowResource workflowResource;
- private static final String TEST_CSAR = "src/test/resources/resource-examples/WorkflowBpmn/service-CxSvc-csar.csar";
- private Path tempDirectoryPath;
+ @Autowired
+ private WorkflowRepository workflowRepo;
@Test
public void getActivityNameList_Test() throws Exception {
@@ -106,4 +88,43 @@ public class WorkflowResourceTest {
assertTrue(workflowVersion == 1.0);
}
+ @Transactional
+ @Test
+ public void installWorkflowResource_Test() throws Exception {
+ Workflow workflow = new Workflow();
+
+ workflow.setArtifactChecksum("12345");
+ workflow.setArtifactName("myTestWorkflow1");
+ workflow.setArtifactUUID("a5c59864-8407-4175-8060-de8ff95eab41");
+ workflow.setBody("my body");
+ workflow.setDescription("testing workflow");
+ workflow.setName("myTestWorkflow1");
+ workflow.setResourceTarget("vnf");
+ workflow.setSource("sdc");
+ workflow.setTimeoutMinutes(5000);
+ workflow.setOperationName("myTestWorkflow");
+ workflow.setVersion(1.0);
+
+ VnfResourceWorkflow vnfResourceWorkflow = new VnfResourceWorkflow();
+ vnfResourceWorkflow.setVnfResourceModelUUID("ff2ae348-214a-11e7-93ae-92361f002671");
+
+ vnfResourceWorkflow.setWorkflow(workflow);
+ List<VnfResourceWorkflow> vnfResourceWorkflows = new ArrayList<VnfResourceWorkflow>();
+ vnfResourceWorkflows.add(vnfResourceWorkflow);
+
+ workflow.setVnfResourceWorkflow(vnfResourceWorkflows);
+
+ WorkflowActivitySpecSequence wfss1 = new WorkflowActivitySpecSequence();
+ wfss1.setActivitySpecId(1);
+ wfss1.setWorkflow(workflow);
+ wfss1.setSeqNo(1);
+
+ List<WorkflowActivitySpecSequence> wfss = new ArrayList<WorkflowActivitySpecSequence>();
+ wfss.add(wfss1);
+ workflow.setWorkflowActivitySpecSequence(wfss);
+
+ workflowRepo.save(workflow);
+
+ }
+
}
diff --git a/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/workflow-distribution.json b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/workflow-distribution.json
index 9f49be5bbb..85a73aa239 100644
--- a/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/workflow-distribution.json
+++ b/asdc-controller/src/test/resources/resource-examples/WorkflowBpmn/workflow-distribution.json
@@ -11,7 +11,7 @@
"resourceName": "TestVF",
"resourceVersion": "1.0",
"resoucreType": "VF",
- "resourceUUID": "5185253e-4bef-4eb4-bbf9-8c328c787ebd",
+ "resourceUUID": "ff2ae348-214a-11e7-93ae-92361f002671",
"resourceInvariantUUID": "ea8264db-3e24-4324-87cc-12c6903ed43d",
"resourceCustomizationUUID": "a959a3cb-4988-435c-9cb7-5a40ef2ef2ac",
"category": "Allotted Resource",
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecActivitySpecCategories.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecActivitySpecCategories.java
index 64c77d27db..062bdd6edc 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecActivitySpecCategories.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ActivitySpecActivitySpecCategories.java
@@ -49,12 +49,10 @@ public class ActivitySpecActivitySpecCategories implements Serializable {
private Integer ID;
@BusinessKey
- @Id
@Column(name = "ACTIVITY_SPEC_ID")
private Integer activitySpecId;
@BusinessKey
- @Id
@Column(name = "ACTIVITY_SPEC_CATEGORIES_ID")
private Integer activitySpecCategoriesId;
@@ -107,6 +105,7 @@ public class ActivitySpecActivitySpecCategories implements Serializable {
this.activitySpecCategoriesId = activitySpecCategoriesId;
}
+ @LinkedResource
public ActivitySpec getActivitySpec() {
return activitySpec;
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceWorkflow.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceWorkflow.java
index 92cc5d18f0..21549e2646 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceWorkflow.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceWorkflow.java
@@ -21,7 +21,6 @@
package org.onap.so.db.catalog.beans;
import java.io.Serializable;
-import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -29,13 +28,9 @@ import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
-import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
-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;
@@ -43,7 +38,6 @@ import com.openpojo.business.annotation.BusinessKey;
import uk.co.blackpepper.bowman.annotation.LinkedResource;
@Entity
-@IdClass(VnfResourceWorkflowId.class)
@Table(name = "vnf_resource_to_workflow")
public class VnfResourceWorkflow implements Serializable {
@@ -55,27 +49,20 @@ public class VnfResourceWorkflow implements Serializable {
private Integer ID;
@BusinessKey
- @Id
@Column(name = "VNF_RESOURCE_MODEL_UUID")
private String vnfResourceModelUUID;
- @BusinessKey
- @Id
- @Column(name = "WORKFLOW_ID")
- private Integer workflowId;
-
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "VNF_RESOURCE_MODEL_UUID", updatable = false, insertable = false)
private VnfResource vnfResource;
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
- @JoinColumn(name = "WORKFLOW_ID", updatable = false, insertable = false)
+ @JoinColumn(name = "WORKFLOW_ID")
private Workflow workflow;
@Override
public String toString() {
- return new ToStringBuilder(this).append("vnfResourceModelUUID", vnfResourceModelUUID)
- .append("workflowId", workflowId).toString();
+ return new ToStringBuilder(this).append("vnfResourceModelUUID", vnfResourceModelUUID).toString();
}
@Override
@@ -84,13 +71,12 @@ public class VnfResourceWorkflow implements Serializable {
return false;
}
VnfResourceWorkflow castOther = (VnfResourceWorkflow) other;
- return new EqualsBuilder().append(vnfResourceModelUUID, castOther.vnfResourceModelUUID)
- .append(workflowId, castOther.workflowId).isEquals();
+ return new EqualsBuilder().append(vnfResourceModelUUID, castOther.vnfResourceModelUUID).isEquals();
}
@Override
public int hashCode() {
- return new HashCodeBuilder().append(vnfResourceModelUUID).append(workflowId).toHashCode();
+ return new HashCodeBuilder().append(vnfResourceModelUUID).toHashCode();
}
public Integer getID() {
@@ -105,14 +91,7 @@ public class VnfResourceWorkflow implements Serializable {
this.vnfResourceModelUUID = vnfResourceModelUUID;
}
- public Integer getWorkflowId() {
- return workflowId;
- }
-
- public void setWorkflowId(Integer workflowId) {
- this.workflowId = workflowId;
- }
-
+ @LinkedResource
public VnfResource getVnfResource() {
return vnfResource;
}
@@ -121,6 +100,7 @@ public class VnfResourceWorkflow implements Serializable {
this.vnfResource = vnfResource;
}
+ @LinkedResource
public Workflow getWorkflow() {
return workflow;
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceWorkflowId.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceWorkflowId.java
deleted file mode 100644
index 837b9c09b2..0000000000
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceWorkflowId.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-
- * ============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.beans;
-
-import java.io.Serializable;
-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;
-
-public class VnfResourceWorkflowId implements Serializable {
-
- private static final long serialVersionUID = -594459957997483601L;
-
- private Integer ID;
-
- @BusinessKey
- private String vnfResourceModelUUID;
- @BusinessKey
- private Integer workflowId;
-
- public String getVnfResourceModelUUID() {
- return vnfResourceModelUUID;
- }
-
- public void setVnfResourceModelUUID(String vnfResourceModelUUID) {
- this.vnfResourceModelUUID = vnfResourceModelUUID;
- }
-
- public Integer getWorkflowId() {
- return workflowId;
- }
-
- public void setWorkflowId(Integer workflowId) {
- this.workflowId = workflowId;
- }
-
- public Integer getID() {
- return ID;
- }
-
- public void setID(Integer ID) {
- this.ID = ID;
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this).append("vnfResourceModelUUID", vnfResourceModelUUID)
- .append("workflowId", workflowId).toString();
- }
-
- @Override
- public boolean equals(final Object other) {
- if (!(other instanceof VnfResourceWorkflowId)) {
- return false;
- }
- VnfResourceWorkflowId castOther = (VnfResourceWorkflowId) other;
- return new EqualsBuilder().append(vnfResourceModelUUID, castOther.vnfResourceModelUUID)
- .append(workflowId, castOther.workflowId).isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder().append(vnfResourceModelUUID).append(workflowId).toHashCode();
- }
-}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Workflow.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Workflow.java
index d1e60a0f76..6bd0713085 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Workflow.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Workflow.java
@@ -3,6 +3,7 @@ package org.onap.so.db.catalog.beans;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
+import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
@@ -69,10 +70,10 @@ public class Workflow implements Serializable {
@Temporal(TemporalType.TIMESTAMP)
private Date created;
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "workflow")
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "workflow")
private List<VnfResourceWorkflow> vnfResourceWorkflow;
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "workflow")
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "workflow")
private List<WorkflowActivitySpecSequence> workflowActivitySpecSequence;
@PrePersist
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/WorkflowActivitySpecSequence.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/WorkflowActivitySpecSequence.java
index f25be45bb2..e953ff2cd4 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/WorkflowActivitySpecSequence.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/WorkflowActivitySpecSequence.java
@@ -53,22 +53,20 @@ public class WorkflowActivitySpecSequence implements Serializable {
@Column(name = "ACTIVITY_SPEC_ID")
private Integer activitySpecId;
- @BusinessKey
- @Column(name = "WORKFLOW_ID")
- private Integer workflowId;
+ @Column(name = "SEQ_NO")
+ private Integer seqNo;
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "ACTIVITY_SPEC_ID", updatable = false, insertable = false)
private ActivitySpec activitySpec;
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
- @JoinColumn(name = "WORKFLOW_ID", updatable = false, insertable = false)
+ @JoinColumn(name = "WORKFLOW_ID")
private Workflow workflow;
@Override
public String toString() {
- return new ToStringBuilder(this).append("workflowId", workflowId).append("activitySpecId", activitySpecId)
- .toString();
+ return new ToStringBuilder(this).append("activitySpecId", activitySpecId).toString();
}
@Override
@@ -77,13 +75,12 @@ public class WorkflowActivitySpecSequence implements Serializable {
return false;
}
WorkflowActivitySpecSequence castOther = (WorkflowActivitySpecSequence) other;
- return new EqualsBuilder().append(activitySpecId, castOther.activitySpecId)
- .append(workflowId, castOther.workflowId).isEquals();
+ return new EqualsBuilder().append(activitySpecId, castOther.activitySpecId).isEquals();
}
@Override
public int hashCode() {
- return new HashCodeBuilder().append(activitySpecId).append(workflowId).toHashCode();
+ return new HashCodeBuilder().append(activitySpecId).toHashCode();
}
public Integer getID() {
@@ -98,14 +95,6 @@ public class WorkflowActivitySpecSequence implements Serializable {
this.activitySpecId = activitySpecId;
}
- public Integer getWorkflowId() {
- return workflowId;
- }
-
- public void setWorkflowId(Integer workflowId) {
- this.workflowId = workflowId;
- }
-
@LinkedResource
public ActivitySpec getActivitySpec() {
return activitySpec;
@@ -124,4 +113,12 @@ public class WorkflowActivitySpecSequence implements Serializable {
this.workflow = workflow;
}
+ public Integer getSeqNo() {
+ return seqNo;
+ }
+
+ public void setSeqNo(Integer seqNo) {
+ this.seqNo = seqNo;
+ }
+
}