Workflow Recipe Lookup
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / Workflow.java
1 package org.onap.so.db.catalog.beans;
2
3 import java.io.Serializable;
4 import java.util.ArrayList;
5 import java.util.Date;
6 import java.util.List;
7
8 import javax.persistence.Column;
9 import javax.persistence.Entity;
10 import javax.persistence.FetchType;
11 import javax.persistence.GeneratedValue;
12 import javax.persistence.GenerationType;
13 import javax.persistence.Id;
14 import javax.persistence.JoinColumn;
15 import javax.persistence.Lob;
16 import javax.persistence.ManyToOne;
17 import javax.persistence.OneToMany;
18 import javax.persistence.PrePersist;
19 import javax.persistence.Table;
20 import javax.persistence.Temporal;
21 import javax.persistence.TemporalType;
22
23 import org.apache.commons.lang3.builder.EqualsBuilder;
24 import org.apache.commons.lang3.builder.HashCodeBuilder;
25 import org.apache.commons.lang3.builder.ToStringBuilder;
26
27 import com.openpojo.business.annotation.BusinessKey;
28
29 import org.hibernate.annotations.NotFound;
30 import org.hibernate.annotations.NotFoundAction;
31 import uk.co.blackpepper.bowman.annotation.LinkedResource;
32
33 @Entity
34 @Table(name = "workflow")
35 public class Workflow implements Serializable {
36
37         private static final long serialVersionUID = 1485794141983033264L;
38
39         @Id
40         @Column(name = "ID", nullable = false, updatable = false)
41         @GeneratedValue(strategy = GenerationType.IDENTITY)
42         private Integer ID;
43         
44         @Column(name = "ARTIFACT_UUID")
45         private String artifactUUID;
46         
47         @Column(name = "ARTIFACT_NAME")
48         private String artifactName;
49         
50         @Column(name = "NAME")
51         private String name;
52         
53         @Column(name = "OPERATION_NAME")
54         private String operationName;
55         
56         @Column(name = "VERSION")
57         private Double version;
58         
59         @Column(name = "DESCRIPTION")
60         private String description;
61         
62         @Lob
63         @Column(name = "BODY", columnDefinition = "LONGTEXT")
64         private String body = null;
65         
66         @Column(name = "RESOURCE_TARGET")
67         private String resourceTarget;
68         
69         @Column(name = "SOURCE")
70         private String source;
71         
72         @Column(name = "TIMEOUT_MINUTES")
73         private Integer timeoutMinutes;
74         
75         @Column(name = "ARTIFACT_CHECKSUM")
76         private String artifactChecksum;
77         
78         @Column(name = "CREATION_TIMESTAMP", updatable = false)
79         @Temporal(TemporalType.TIMESTAMP)
80         private Date created;
81         
82         @OneToMany(fetch = FetchType.LAZY, mappedBy = "workflow")
83         private List<VnfResourceWorkflow> vnfResourceWorkflow;
84         
85         @OneToMany(fetch = FetchType.LAZY, mappedBy = "workflow")
86         private List<WorkflowActivitySpecSequence> workflowActivitySpecSequence;
87         
88         @PrePersist
89         protected void onCreate() {
90                 this.created = new Date();
91         }
92
93         public Integer getID() {
94                 return ID;
95         }
96
97         public String getArtifactUUID() {
98                 return artifactUUID;
99         }
100
101         public void setArtifactUUID(String artifactUUID) {
102                 this.artifactUUID = artifactUUID;
103         }
104
105         public String getArtifactName() {
106                 return artifactName;
107         }
108
109         public void setArtifactName(String artifactName) {
110                 this.artifactName = artifactName;
111         }
112
113         public String getName() {
114                 return name;
115         }
116
117         public void setName(String name) {
118                 this.name = name;
119         }
120
121         public String getOperationName() {
122                 return operationName;
123         }
124
125         public void setOperationName(String operationName) {
126                 this.operationName = operationName;
127         }
128
129         public Double getVersion() {
130                 return version;
131         }
132
133         public void setVersion(Double version) {
134                 this.version = version;
135         }
136
137         public String getDescription() {
138                 return description;
139         }
140
141         public void setDescription(String description) {
142                 this.description = description;
143         }
144
145         public String getBody() {
146                 return body;
147         }
148
149         public void setBody(String body) {
150                 this.body = body;
151         }
152
153         public String getResourceTarget() {
154                 return resourceTarget;
155         }
156
157         public void setResourceTarget(String resourceTarget) {
158                 this.resourceTarget = resourceTarget;
159         }
160
161         public String getSource() {
162                 return source;
163         }
164
165         public void setSource(String source) {
166                 this.source = source;
167         }
168
169         public Integer getTimeoutMinutes() {
170                 return timeoutMinutes;
171         }
172
173         public void setTimeoutMinutes(Integer timeoutMinutes) {
174                 this.timeoutMinutes = timeoutMinutes;
175         }
176
177         public String getArtifactChecksum() {
178                 return artifactChecksum;
179         }
180
181         public void setArtifactChecksum(String artifactChecksum) {
182                 this.artifactChecksum = artifactChecksum;
183         }
184
185         public Date getCreated() {
186                 return created;
187         }
188
189         public void setCreated(Date created) {
190                 this.created = created;
191         }
192
193         @LinkedResource
194         public List<VnfResourceWorkflow> getVnfResourceWorkflow() {
195                 return vnfResourceWorkflow;
196         }
197
198         public void setVnfResourceWorkflow(
199                         List<VnfResourceWorkflow> vnfResourceWorkflow) {
200                 this.vnfResourceWorkflow = vnfResourceWorkflow;
201         }
202         
203         @LinkedResource
204         public List<WorkflowActivitySpecSequence> getWorkflowActivitySpecSequence() {
205                 return workflowActivitySpecSequence;
206         }
207
208         public void setWorkflowActivitySpecSequence(
209                         List<WorkflowActivitySpecSequence> workflowActivitySpecSequence) {
210                 this.workflowActivitySpecSequence = workflowActivitySpecSequence;
211         }
212         
213         @Override
214         public String toString() {
215                 return new ToStringBuilder(this).append("ID", ID).append("artifactUUID", artifactUUID)
216                                 .append("artifactName", artifactName).append("name", name)
217                                 .append("operationName", operationName).append("version", version).append("description", description)
218                                 .append("body",body).append("resourceTarget",resourceTarget).append("source", source)
219                                 .append("timeoutMinutes", timeoutMinutes).append("artifactChecksum", artifactChecksum)
220                                 .append("created", created).append("vnfResourceWorkflow", vnfResourceWorkflow)
221                                 .append("WorkflowActivitySpecSequence",workflowActivitySpecSequence).toString();
222         }
223         @Override
224         public boolean equals(final Object other) {
225                 if (!(other instanceof Workflow)) {
226                         return false;
227                 }
228                 Workflow castOther = (Workflow) other;
229                 return new EqualsBuilder().append(ID, castOther.ID).isEquals();
230         }
231
232         @Override
233         public int hashCode() {
234                 return new HashCodeBuilder().append(ID).toHashCode();
235         }
236 }