From 0bac473ab80a2f64b85df51dbaf432ecde73341e Mon Sep 17 00:00:00 2001 From: Elena Kuleshov Date: Thu, 6 Jun 2019 01:10:32 -0400 Subject: Beans fixes to workflow record creation Changes to enable cascading creates and proper id referencing Issue-ID: SO-1998 Signed-off-by: Kuleshov, Elena Change-Id: I6c08fc22fbbba1d0d2b8dc04e390cd0b3de64327 --- .../beans/ActivitySpecActivitySpecCategories.java | 3 +- .../so/db/catalog/beans/VnfResourceWorkflow.java | 32 ++------- .../so/db/catalog/beans/VnfResourceWorkflowId.java | 84 ---------------------- .../org/onap/so/db/catalog/beans/Workflow.java | 5 +- .../beans/WorkflowActivitySpecSequence.java | 31 ++++---- 5 files changed, 24 insertions(+), 131 deletions(-) delete mode 100644 mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceWorkflowId.java (limited to 'mso-catalog-db/src/main') 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; - @OneToMany(fetch = FetchType.LAZY, mappedBy = "workflow") + @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "workflow") private List 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; + } + } -- cgit 1.2.3-korg