2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.db.request.beans;
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;
38 * The service operation status <br>
43 * @version ONAP Amsterdam Release 2017-08-28
46 @IdClass(OperationStatusId.class)
48 @Table(name = "operation_status")
49 public class OperationStatus implements Serializable {
54 private static final long serialVersionUID = 1L;
57 @Column(name = "SERVICE_ID")
58 private String serviceId;
60 @Column(name = "OPERATION_ID", length = 256)
61 private String operationId;
63 @Column(name = "SERVICE_NAME", length = 256)
64 private String serviceName;
66 @Column(name = "OPERATION_TYPE", length = 256)
67 private String operation;
69 @Column(name = "USER_ID", length = 256)
70 private String userId;
72 @Column(name = "RESULT", length = 256)
73 private String result;
75 @Column(name = "OPERATION_CONTENT", length = 256)
76 private String operationContent;
78 @Column(name = "PROGRESS", length = 256)
79 private String progress = "0";
81 @Column(name = "REASON", length = 256)
82 private String reason;
84 @Column(name = "OPERATE_AT", length = 256, updatable = false)
85 @Temporal(TemporalType.TIMESTAMP)
86 private Date operateAt;
88 @Column(name = "FINISHED_AT", length = 256)
89 @Temporal(TemporalType.TIMESTAMP)
90 private Date finishedAt;
92 public OperationStatus() {
96 public OperationStatus(String serviceId, String operationId) {
97 this.serviceId = serviceId;
98 this.operationId = operationId;
102 public String getServiceId() {
107 public void setServiceId(String serviceId) {
108 this.serviceId = serviceId;
112 public String getOperationId() {
117 public void setOperationId(String operationId) {
118 this.operationId = operationId;
122 public String getOperation() {
127 public void setOperation(String operation) {
128 this.operation = operation;
132 public String getServiceName() {
136 public void setServiceName(String serviceName) {
137 this.serviceName = serviceName;
140 public String getUserId() {
145 public void setUserId(String userId) {
146 this.userId = userId;
150 public String getResult() {
155 public void setResult(String result) {
156 this.result = result;
160 public String getOperationContent() {
161 return operationContent;
165 public void setOperationContent(String operationContent) {
166 this.operationContent = operationContent;
170 public String getProgress() {
175 public void setProgress(String progress) {
176 this.progress = progress;
180 public String getReason() {
185 public void setReason(String reason) {
186 this.reason = reason;
190 public Date getOperateAt() {
194 public Date getFinishedAt() {
199 protected void onCreate() {
200 this.finishedAt = this.operateAt = new Date();
204 protected void onUpdate() {
205 this.finishedAt = new Date();
209 public boolean equals(final Object other) {
213 if (!(other instanceof OperationStatus)) {
216 OperationStatus castOther = (OperationStatus) other;
217 return Objects.equals(getServiceId(), castOther.getServiceId())
218 && Objects.equals(getOperationId(), castOther.getOperationId());
222 public int hashCode() {
223 return Objects.hash(getServiceId(), getOperationId());
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())