8a1881edf39f50d36ef872b3ba97c2bd444c1fbf
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / WorkflowActivitySpecSequence.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.db.catalog.beans;
22
23 import java.io.Serializable;
24 import java.util.Date;
25
26 import javax.persistence.CascadeType;
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.FetchType;
30 import javax.persistence.GeneratedValue;
31 import javax.persistence.GenerationType;
32 import javax.persistence.Id;
33 import javax.persistence.IdClass;
34 import javax.persistence.JoinColumn;
35 import javax.persistence.ManyToOne;
36 import javax.persistence.PrePersist;
37 import javax.persistence.Table;
38 import javax.persistence.Temporal;
39 import javax.persistence.TemporalType;
40
41 import org.apache.commons.lang3.builder.EqualsBuilder;
42 import org.apache.commons.lang3.builder.HashCodeBuilder;
43 import org.apache.commons.lang3.builder.ToStringBuilder;
44
45 import com.openpojo.business.annotation.BusinessKey;
46
47 import uk.co.blackpepper.bowman.annotation.LinkedResource;
48
49 @Entity
50 @IdClass(WorkflowActivitySpecSequenceId.class)
51 @Table(name = "workflow_activity_spec_sequence")
52 public class WorkflowActivitySpecSequence implements Serializable {
53
54         private static final long serialVersionUID = -8788505759463286871L;
55
56         @Id
57         @Column(name = "ID", nullable = false, updatable = false)
58         @GeneratedValue(strategy = GenerationType.IDENTITY)
59         private Integer ID;
60
61         @BusinessKey
62         @Id
63         @Column(name = "ACTIVITY_SPEC_ID")
64         private Integer activitySpecId;
65
66         @BusinessKey
67         @Id
68         @Column(name = "WORKFLOW_ID")
69         private Integer workflowId;
70
71         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
72         @JoinColumn(name = "ACTIVITY_SPEC_ID", updatable = false, insertable = false)
73         private ActivitySpec activitySpec;
74
75         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
76         @JoinColumn(name = "WORKFLOW_ID", updatable = false, insertable = false)
77         private Workflow workflow;
78
79         @Override
80         public String toString() {
81                 return new ToStringBuilder(this).append("workflowId", workflowId)
82                                 .append("activitySpecId", activitySpecId)
83                                 .toString();
84         }
85
86         @Override
87         public boolean equals(final Object other) {
88                 if (!(other instanceof WorkflowActivitySpecSequence)) {
89                         return false;
90                 }
91                 WorkflowActivitySpecSequence castOther = (WorkflowActivitySpecSequence) other;
92                 return new EqualsBuilder().append(activitySpecId, castOther.activitySpecId)
93                                 .append(workflowId, castOther.workflowId).isEquals();
94         }
95
96         @Override
97         public int hashCode() {
98                 return new HashCodeBuilder().append(activitySpecId).append(workflowId).toHashCode();
99         }
100
101         public Integer getID() {
102                 return ID;
103         }
104
105         public Integer getActivitySpecId() {
106                 return activitySpecId;
107         }
108
109         public void setActivitySpecId(Integer activitySpecId) {
110                 this.activitySpecId = activitySpecId;
111         }
112
113         public Integer getWorkflowId() {
114                 return workflowId;
115         }
116
117         public void setWorkflowId(Integer workflowId) {
118                 this.workflowId = workflowId;
119         }
120
121         public ActivitySpec getActivitySpec() {
122                 return activitySpec;
123         }
124
125         public void setActivitySpec(ActivitySpec activitySpec) {
126                 this.activitySpec = activitySpec;
127         }
128
129         public Workflow getWorkflow() {
130                 return workflow;
131         }
132
133         public void setWorkflow(Workflow workflow) {
134                 this.workflow = workflow;
135         }
136         
137 }