588822cce02eba56b52ad0af7398761dfafe1320
[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         
76         public OperationalEnvServiceModelStatus() {
77                 
78         }
79         
80         public OperationalEnvServiceModelStatus(String requestId, String operationalEnvId, String serviceModelVersionId) {
81                 this.requestId = requestId;
82                 this.operationalEnvId = operationalEnvId;
83                 this.serviceModelVersionId = serviceModelVersionId;
84         }
85         public String getRequestId() {
86                 return requestId;
87         }
88         
89         public void setRequestId(String requestId) {
90                 this.requestId = requestId;
91         }
92         
93         public String getOperationalEnvId() {
94                 return operationalEnvId;
95         }
96         
97         public void setOperationalEnvId(String operationalEnvId) {
98                 this.operationalEnvId = operationalEnvId;
99         }
100         
101         public String getServiceModelVersionId() {
102                 return serviceModelVersionId;
103         }
104         
105         public void setServiceModelVersionId(String serviceModelVersionId) {
106                 this.serviceModelVersionId = serviceModelVersionId;
107         }
108         
109         public String getServiceModelVersionDistrStatus() {
110                 return serviceModelVersionDistrStatus;
111         }
112         
113         public void setServiceModelVersionDistrStatus(String serviceModelVersionDistrStatus) {
114                 this.serviceModelVersionDistrStatus = serviceModelVersionDistrStatus;
115         }
116         
117         public String getRecoveryAction() {
118                 return recoveryAction;
119         }
120         
121         public void setRecoveryAction(String recoveryAction) {
122                 this.recoveryAction = recoveryAction;
123         }
124         
125         public Integer getRetryCount() {
126                 return retryCount;
127         }
128         
129         public void setRetryCount(Integer retryCount) {
130                 this.retryCount = retryCount;
131         }
132
133         public String getWorkloadContext() {
134                 return workloadContext;
135         }
136
137         public void setWorkloadContext(String workloadContext) {
138                 this.workloadContext = workloadContext;
139         }
140
141         public Date getCreateTime() {
142                 return createTime;
143         }
144
145         
146         public Date getModifyTime() {
147                 return modifyTime;
148         }
149         
150         @PrePersist
151         protected void onCreate() {
152                 this.createTime = this.modifyTime = new Date();
153         }
154
155         @PreUpdate
156         protected void onUpdate() {
157                 this.modifyTime = new Date();
158         }
159
160         @Override
161         public boolean equals(final Object other) {
162                 if (this == other) {
163                         return true;
164                 }
165                 if (!(other instanceof OperationalEnvServiceModelStatus)) {
166                         return false;
167                 }
168                 OperationalEnvServiceModelStatus castOther = (OperationalEnvServiceModelStatus) other;
169                 return Objects.equals(getRequestId(), castOther.getRequestId())
170                                 && Objects.equals(getOperationalEnvId(), castOther.getOperationalEnvId());
171         }
172
173         @Override
174         public int hashCode() {
175                 return Objects.hash(getRequestId(), getOperationalEnvId());
176         }
177
178         @Override
179         public String toString() {
180                 return new ToStringBuilder(this).append("requestId", getRequestId())
181                                 .append("operationalEnvId", getOperationalEnvId())
182                                 .append("serviceModelVersionId", getServiceModelVersionId())
183                                 .append("serviceModelVersionDistrStatus", getServiceModelVersionDistrStatus())
184                                 .append("recoveryAction", getRecoveryAction()).append("retryCount", getRetryCount())
185                                 .append("workloadContext", getWorkloadContext()).append("createTime", getCreateTime())
186                                 .append("modifyTime", getModifyTime()).toString();
187         }
188         
189
190 }