Replaced all tabs with spaces in java and pom.xml
[so.git] / mso-api-handlers / mso-requests-db / src / main / java / org / onap / so / db / request / beans / OperationStatus.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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 import javax.persistence.Column;
26 import javax.persistence.Entity;
27 import javax.persistence.Id;
28 import javax.persistence.IdClass;
29 import javax.persistence.PrePersist;
30 import javax.persistence.PreUpdate;
31 import javax.persistence.Table;
32 import javax.persistence.Temporal;
33 import javax.persistence.TemporalType;
34 import java.util.Objects;
35 import org.apache.commons.lang3.builder.ToStringBuilder;
36
37 /**
38  * The service operation status <br>
39  * <p>
40  * </p>
41  * 
42  * @author
43  * @version ONAP Amsterdam Release 2017-08-28
44  */
45
46 @IdClass(OperationStatusId.class)
47 @Entity
48 @Table(name = "operation_status")
49 public class OperationStatus implements Serializable {
50
51     /**
52      * 
53      */
54     private static final long serialVersionUID = 1L;
55
56     @Id
57     @Column(name = "SERVICE_ID")
58     private String serviceId;
59     @Id
60     @Column(name = "OPERATION_ID", length = 256)
61     private String operationId;
62
63     @Column(name = "SERVICE_NAME", length = 256)
64     private String serviceName;
65
66     @Column(name = "OPERATION_TYPE", length = 256)
67     private String operation;
68
69     @Column(name = "USER_ID", length = 256)
70     private String userId;
71
72     @Column(name = "RESULT", length = 256)
73     private String result;
74
75     @Column(name = "OPERATION_CONTENT", length = 256)
76     private String operationContent;
77
78     @Column(name = "PROGRESS", length = 256)
79     private String progress = "0";
80
81     @Column(name = "REASON", length = 256)
82     private String reason;
83
84     @Column(name = "OPERATE_AT", length = 256, updatable = false)
85     @Temporal(TemporalType.TIMESTAMP)
86     private Date operateAt;
87
88     @Column(name = "FINISHED_AT", length = 256)
89     @Temporal(TemporalType.TIMESTAMP)
90     private Date finishedAt;
91
92     public OperationStatus() {
93
94     }
95
96     public OperationStatus(String serviceId, String operationId) {
97         this.serviceId = serviceId;
98         this.operationId = operationId;
99     }
100
101
102     public String getServiceId() {
103         return serviceId;
104     }
105
106
107     public void setServiceId(String serviceId) {
108         this.serviceId = serviceId;
109     }
110
111
112     public String getOperationId() {
113         return operationId;
114     }
115
116
117     public void setOperationId(String operationId) {
118         this.operationId = operationId;
119     }
120
121
122     public String getOperation() {
123         return operation;
124     }
125
126
127     public void setOperation(String operation) {
128         this.operation = operation;
129     }
130
131
132     public String getServiceName() {
133         return serviceName;
134     }
135
136     public void setServiceName(String serviceName) {
137         this.serviceName = serviceName;
138     }
139
140     public String getUserId() {
141         return userId;
142     }
143
144
145     public void setUserId(String userId) {
146         this.userId = userId;
147     }
148
149
150     public String getResult() {
151         return result;
152     }
153
154
155     public void setResult(String result) {
156         this.result = result;
157     }
158
159
160     public String getOperationContent() {
161         return operationContent;
162     }
163
164
165     public void setOperationContent(String operationContent) {
166         this.operationContent = operationContent;
167     }
168
169
170     public String getProgress() {
171         return progress;
172     }
173
174
175     public void setProgress(String progress) {
176         this.progress = progress;
177     }
178
179
180     public String getReason() {
181         return reason;
182     }
183
184
185     public void setReason(String reason) {
186         this.reason = reason;
187     }
188
189
190     public Date getOperateAt() {
191         return operateAt;
192     }
193
194     public Date getFinishedAt() {
195         return finishedAt;
196     }
197
198     @PrePersist
199     protected void onCreate() {
200         this.finishedAt = this.operateAt = new Date();
201     }
202
203     @PreUpdate
204     protected void onUpdate() {
205         this.finishedAt = new Date();
206     }
207
208     @Override
209     public boolean equals(final Object other) {
210         if (this == other) {
211             return true;
212         }
213         if (!(other instanceof OperationStatus)) {
214             return false;
215         }
216         OperationStatus castOther = (OperationStatus) other;
217         return Objects.equals(getServiceId(), castOther.getServiceId())
218                 && Objects.equals(getOperationId(), castOther.getOperationId());
219     }
220
221     @Override
222     public int hashCode() {
223         return Objects.hash(getServiceId(), getOperationId());
224     }
225
226     @Override
227     public String toString() {
228         return new ToStringBuilder(this).append("serviceId", getServiceId()).append("operationId", getOperationId())
229                 .append("operation", getOperation()).append("userId", getUserId()).append("result", getResult())
230                 .append("operationContent", getOperationContent()).append("progress", getProgress())
231                 .append("reason", getReason()).append("operateAt", getOperateAt()).append("finishedAt", getFinishedAt())
232                 .toString();
233     }
234
235
236
237 }