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;
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;
39 * The service operation status
45 * @version ONAP Amsterdam Release 2017-08-28
48 @IdClass(OperationStatusId.class)
50 @Table(name = "operation_status")
51 public class OperationStatus implements Serializable{
56 private static final long serialVersionUID = 1L;
59 @Column(name = "SERVICE_ID")
60 private String serviceId;
62 @Column(name = "OPERATION_ID", length=256)
63 private String operationId;
65 @Column(name = "SERVICE_NAME", length=256)
66 private String serviceName;
68 @Column(name = "OPERATION_TYPE", length=256)
69 private String operation;
71 @Column(name = "USER_ID", length=256)
72 private String userId;
74 @Column(name = "RESULT", length=256)
75 private String result;
77 @Column(name = "OPERATION_CONTENT", length=256)
78 private String operationContent;
80 @Column(name = "PROGRESS", length=256)
81 private String progress = "0";
83 @Column(name = "REASON", length=256)
84 private String reason;
86 @Column(name = "OPERATE_AT", length=256, updatable=false)
87 @Temporal(TemporalType.TIMESTAMP)
88 private Date operateAt;
90 @Column(name = "FINISHED_AT", length=256)
91 @Temporal(TemporalType.TIMESTAMP)
92 private Date finishedAt;
94 public OperationStatus() {
98 public OperationStatus(String serviceId, String operationId) {
99 this.serviceId = serviceId;
100 this.operationId = operationId;
104 public String getServiceId() {
109 public void setServiceId(String serviceId) {
110 this.serviceId = serviceId;
114 public String getOperationId() {
119 public void setOperationId(String operationId) {
120 this.operationId = operationId;
124 public String getOperation() {
129 public void setOperation(String operation) {
130 this.operation = operation;
134 public String getServiceName() {
138 public void setServiceName(String serviceName) {
139 this.serviceName = serviceName;
142 public String getUserId() {
147 public void setUserId(String userId) {
148 this.userId = userId;
152 public String getResult() {
157 public void setResult(String result) {
158 this.result = result;
162 public String getOperationContent() {
163 return operationContent;
167 public void setOperationContent(String operationContent) {
168 this.operationContent = operationContent;
172 public String getProgress() {
177 public void setProgress(String progress) {
178 this.progress = progress;
182 public String getReason() {
187 public void setReason(String reason) {
188 this.reason = reason;
192 public Date getOperateAt() {
196 public Date getFinishedAt() {
201 protected void onCreate() {
202 this.finishedAt = this.operateAt = new Date();
206 protected void onUpdate() {
207 this.finishedAt = new Date();
211 public boolean equals(final Object other) {
215 if (!(other instanceof OperationStatus)) {
218 OperationStatus castOther = (OperationStatus) other;
219 return Objects.equals(getServiceId(), castOther.getServiceId())
220 && Objects.equals(getOperationId(), castOther.getOperationId());
224 public int hashCode() {
225 return Objects.hash(getServiceId(), getOperationId());
229 public String toString() {
230 return new ToStringBuilder(this).append("serviceId", getServiceId()).append("operationId", getOperationId())
231 .append("operation", getOperation()).append("userId", getUserId()).append("result", getResult())
232 .append("operationContent", getOperationContent()).append("progress", getProgress())
233 .append("reason", getReason()).append("operateAt", getOperateAt()).append("finishedAt", getFinishedAt())