79168f8f0b4394ddbc6c1be15da6e9c30bbc1e83
[so.git] / mso-api-handlers / mso-requests-db / src / main / java / org / onap / so / db / request / beans / OperationalEnvServiceModelStatus.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 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.request.beans;
22
23 import java.io.Serializable;
24 import java.util.Date;
25
26 import javax.persistence.Column;
27 import javax.persistence.Entity;
28 import javax.persistence.Id;
29 import javax.persistence.IdClass;
30 import javax.persistence.PrePersist;
31 import javax.persistence.PreUpdate;
32 import javax.persistence.Table;
33 import javax.persistence.Temporal;
34 import javax.persistence.TemporalType;
35 import java.util.Objects;
36 import org.apache.commons.lang3.builder.ToStringBuilder;
37
38 /**
39  * @author PB6115
40  *
41  */
42 @IdClass(OperationalEnvServiceModelStatusId.class)
43 @Entity
44 @Table(name = "activate_operational_env_service_model_distribution_status")
45 public class OperationalEnvServiceModelStatus implements Serializable {
46
47     /**
48          * Serialization id.
49          */
50         private static final long serialVersionUID = 8197084996598869656L;
51         
52         @Id
53         @Column(name = "REQUEST_ID", length=45)
54         private String requestId;
55         @Id
56         @Column(name = "OPERATIONAL_ENV_ID", length=45)
57         private String operationalEnvId;
58         @Id
59         @Column(name = "SERVICE_MODEL_VERSION_ID", length=45)
60         private String serviceModelVersionId;
61         @Column(name = "SERVICE_MOD_VER_FINAL_DISTR_STATUS", length=45)
62         private String serviceModelVersionDistrStatus;
63         @Column(name = "RECOVERY_ACTION", length=30)
64         private String recoveryAction;
65         @Column(name = "RETRY_COUNT_LEFT")
66         private Integer retryCount;
67         @Column(name = "WORKLOAD_CONTEXT", length=80)
68         private String workloadContext;
69         @Column(name = "CREATE_TIME", updatable=false)
70         @Temporal(TemporalType.TIMESTAMP)
71         private Date createTime;
72         @Column(name = "MODIFY_TIME")
73         @Temporal(TemporalType.TIMESTAMP)
74         private Date modifyTime;
75         @Column(name = "VNF_OPERATIONAL_ENV_ID", length=45)
76         private String vnfOperationalEnvId;     
77         
78         public OperationalEnvServiceModelStatus() {
79                 
80         }
81         
82         public OperationalEnvServiceModelStatus(String requestId, String operationalEnvId, String serviceModelVersionId) {
83                 this.requestId = requestId;
84                 this.operationalEnvId = operationalEnvId;
85                 this.serviceModelVersionId = serviceModelVersionId;
86         }
87         public String getRequestId() {
88                 return requestId;
89         }
90         
91         public void setRequestId(String requestId) {
92                 this.requestId = requestId;
93         }
94         
95         public String getOperationalEnvId() {
96                 return operationalEnvId;
97         }
98         
99         public void setOperationalEnvId(String operationalEnvId) {
100                 this.operationalEnvId = operationalEnvId;
101         }
102         
103         public String getServiceModelVersionId() {
104                 return serviceModelVersionId;
105         }
106         
107         public void setServiceModelVersionId(String serviceModelVersionId) {
108                 this.serviceModelVersionId = serviceModelVersionId;
109         }
110         
111         public String getServiceModelVersionDistrStatus() {
112                 return serviceModelVersionDistrStatus;
113         }
114         
115         public void setServiceModelVersionDistrStatus(String serviceModelVersionDistrStatus) {
116                 this.serviceModelVersionDistrStatus = serviceModelVersionDistrStatus;
117         }
118         
119         public String getRecoveryAction() {
120                 return recoveryAction;
121         }
122         
123         public void setRecoveryAction(String recoveryAction) {
124                 this.recoveryAction = recoveryAction;
125         }
126         
127         public Integer getRetryCount() {
128                 return retryCount;
129         }
130         
131         public void setRetryCount(Integer retryCount) {
132                 this.retryCount = retryCount;
133         }
134
135         public String getWorkloadContext() {
136                 return workloadContext;
137         }
138
139         public void setWorkloadContext(String workloadContext) {
140                 this.workloadContext = workloadContext;
141         }
142
143         public Date getCreateTime() {
144                 return createTime;
145         }
146
147         
148         public Date getModifyTime() {
149                 return modifyTime;
150         }
151
152         public String getVnfOperationalEnvId() {
153                 return vnfOperationalEnvId;
154         }
155         
156         public void setVnfOperationalEnvId(String vnfOperationalEnvId) {
157                 this.vnfOperationalEnvId = vnfOperationalEnvId;
158         }       
159         
160         @PrePersist
161         protected void onCreate() {
162                 this.createTime = this.modifyTime = new Date();
163         }
164
165         @PreUpdate
166         protected void onUpdate() {
167                 this.modifyTime = new Date();
168         }
169
170         @Override
171         public boolean equals(final Object other) {
172                 if (this == other) {
173                         return true;
174                 }
175                 if (!(other instanceof OperationalEnvServiceModelStatus)) {
176                         return false;
177                 }
178                 OperationalEnvServiceModelStatus castOther = (OperationalEnvServiceModelStatus) other;
179                 return Objects.equals(getRequestId(), castOther.getRequestId())
180                                 && Objects.equals(getOperationalEnvId(), castOther.getOperationalEnvId());
181         }
182
183         @Override
184         public int hashCode() {
185                 return Objects.hash(getRequestId(), getOperationalEnvId());
186         }
187
188         @Override
189         public String toString() {
190                 return new ToStringBuilder(this).append("requestId", getRequestId())
191                                 .append("operationalEnvId", getOperationalEnvId())
192                                 .append("serviceModelVersionId", getServiceModelVersionId())
193                                 .append("serviceModelVersionDistrStatus", getServiceModelVersionDistrStatus())
194                                 .append("recoveryAction", getRecoveryAction()).append("retryCount", getRetryCount())
195                                 .append("workloadContext", getWorkloadContext()).append("createTime", getCreateTime())
196                                 .append("modifyTime", getModifyTime())
197                                 .append("vnfOperationalEnvId", getVnfOperationalEnvId()).toString();
198         }
199         
200
201 }