diff options
author | Ubuntu <sunshine.wang@huawei.com> | 2019-12-13 12:05:20 +0800 |
---|---|---|
committer | Ubuntu <sunshine.wang@huawei.com> | 2019-12-13 12:09:18 +0800 |
commit | 2ce8c8e9e450ec1b885823c8dd3d985eaac260ac (patch) | |
tree | d3ffbfbe79d1bbc0b79e8432c358b4fd9a185234 /mso-catalog-db/src | |
parent | 02c068ce771ee4522936f2d15f41c2b631e965a8 (diff) |
add pnf_resource_to_workflow to catalogdb
bind the pnf model uuid to pnf workflow
Issue-ID: SO-2558
Signed-off-by: Yaoguang Wang <sunshine.wang@huawei.com>
Change-Id: I779ba8bef8ca3bb67ab6e9245eafec8b84571c85
Diffstat (limited to 'mso-catalog-db/src')
3 files changed, 108 insertions, 0 deletions
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceWorkflow.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceWorkflow.java new file mode 100644 index 0000000000..6e48938f19 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceWorkflow.java @@ -0,0 +1,91 @@ +package org.onap.so.db.catalog.beans; + +import java.io.Serializable; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +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; +import uk.co.blackpepper.bowman.annotation.LinkedResource; + +@Entity +@Table(name = "pnf_resource_to_workflow") +public class PnfResourceWorkflow implements Serializable { + + private static final long serialVersionUID = 4897166645148426088L; + + @Id + @Column(name = "ID", nullable = false, updatable = false) + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer ID; + + @BusinessKey + @Column(name = "PNF_RESOURCE_MODEL_UUID") + private String pnfResourceModelUUID; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "PNF_RESOURCE_MODEL_UUID", updatable = false, insertable = false) + private PnfResource pnfResource; + + @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @JoinColumn(name = "WORKFLOW_ID") + private Workflow workflow; + + @Override + public String toString() { + return new ToStringBuilder(this).append("pnfResourceModelUUID", pnfResourceModelUUID).toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof PnfResourceWorkflow)) { + return false; + } + PnfResourceWorkflow castOther = (PnfResourceWorkflow) other; + return new EqualsBuilder().append(pnfResourceModelUUID, castOther.pnfResourceModelUUID).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(pnfResourceModelUUID).toHashCode(); + } + + public Integer getID() { + return ID; + } + + public String getPnfResourceModelUUID() { + return pnfResourceModelUUID; + } + + public void setPnfResourceModelUUID(String pnfResourceModelUUID) { + this.pnfResourceModelUUID = pnfResourceModelUUID; + } + + @LinkedResource + public PnfResource getPnfResource() { + return pnfResource; + } + + public void setPnfResource(PnfResource pnfResource) { + this.pnfResource = pnfResource; + } + + @LinkedResource + public Workflow getWorkflow() { + return workflow; + } + + public void setWorkflow(Workflow workflow) { + this.workflow = workflow; + } +} diff --git a/mso-catalog-db/src/test/resources/data.sql b/mso-catalog-db/src/test/resources/data.sql index eaad15ca57..e5963c183f 100644 --- a/mso-catalog-db/src/test/resources/data.sql +++ b/mso-catalog-db/src/test/resources/data.sql @@ -768,10 +768,15 @@ insert into pnf_resource_customization_to_service(service_model_uuid, resource_m insert into workflow(artifact_uuid, artifact_name, name, operation_name, version, description, body, resource_target, source) values ('5b0c4322-643d-4c9f-b184-4516049e99b1', 'testingWorkflow.bpmn', 'testingWorkflow', 'create', 1, 'Test Workflow', null, 'vnf', 'sdc'); +insert into workflow(artifact_uuid, artifact_name, name, operation_name, version, description, body, resource_target, source) values +('b2fd5627-55e4-4f4f-8064-9e6f443e9152','DummyPnfWorkflow','Dummy Pnf Workflow','DummyPnfWorkflow',1.0,'Dummy Pnf Workflow to test custom Pnf workflow',null,'pnf','native'); insert into vnf_resource_to_workflow(vnf_resource_model_uuid, workflow_id) values ('ff2ae348-214a-11e7-93ae-92361f002671', '1'); +Insert into pnf_resource_to_workflow (`PNF_RESOURCE_MODEL_UUID`,`WORKFLOW_ID`) values +("ff2ae348-214a-11e7-93ae-92361f002680", 2); + insert into activity_spec(name, description, version) values ('testActivity1', 'Test Activity 1', 1); diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql index 67584133f8..5668ae5718 100644 --- a/mso-catalog-db/src/test/resources/schema.sql +++ b/mso-catalog-db/src/test/resources/schema.sql @@ -1241,6 +1241,18 @@ CREATE TABLE IF NOT EXISTS `vnf_resource_to_workflow` ( CONSTRAINT `fk_vnf_resource_to_workflow__workflow1` FOREIGN KEY (`WORKFLOW_ID`) REFERENCES `workflow` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +CREATE TABLE IF NOT EXISTS `pnf_resource_to_workflow` ( + `ID` int(11) NOT NULL AUTO_INCREMENT, + `PNF_RESOURCE_MODEL_UUID` varchar(200) NOT NULL, + `WORKFLOW_ID` int(11) NOT NULL, + PRIMARY KEY (`ID`), + UNIQUE KEY `UK_pnf_resource_to_workflow` (`PNF_RESOURCE_MODEL_UUID`,`WORKFLOW_ID`), + KEY `fk_pnf_resource_to_workflow__workflow1_idx` (`WORKFLOW_ID`), + KEY `fk_pnf_resource_to_workflow__pnf_res_mod_uuid_idx` (`PNF_RESOURCE_MODEL_UUID`), + CONSTRAINT `fk_pnf_resource_to_workflow__pnf_resource1` FOREIGN KEY (`PNF_RESOURCE_MODEL_UUID`) REFERENCES `pnf_resource` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_pnf_resource_to_workflow__workflow1` FOREIGN KEY (`WORKFLOW_ID`) REFERENCES `workflow` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + CREATE TABLE IF NOT EXISTS `activity_spec` ( `ID` INT(11) NOT NULL AUTO_INCREMENT, `NAME` VARCHAR(200) NOT NULL, |