386daa6dbb79923d6a31517ecee6871541480636
[so.git] / mso-api-handlers / mso-requests-db / src / main / java / org / onap / so / db / request / beans / ResourceOperationStatus.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
25 import javax.persistence.Column;
26 import javax.persistence.Entity;
27 import javax.persistence.Id;
28 import javax.persistence.IdClass;
29 import javax.persistence.Table;
30 import java.util.Objects;
31 import org.apache.commons.lang3.builder.ToStringBuilder;
32
33 /**
34  * The Resource operation status
35  * <br>
36  * <p>
37  * </p>
38  * 
39  * @author
40  * @version     ONAP Amsterdam Release  2017-08-28
41  */
42
43 @IdClass(ResourceOperationStatusId.class)
44 @Entity
45 @Table(name = "resource_operation_status")
46 public class ResourceOperationStatus implements Serializable{
47
48     /**
49      * 
50      */
51     private static final long serialVersionUID = 1L;
52
53     @Id
54         @Column(name = "SERVICE_ID")
55     private String serviceId;
56     @Id
57         @Column(name = "OPERATION_ID", length=256)
58     private String operationId;
59     @Id
60         @Column(name = "RESOURCE_TEMPLATE_UUID")
61     private String resourceTemplateUUID;
62         
63     @Column(name = "OPER_TYPE", length=256)
64     private String operType;
65     
66     @Column(name = "RESOURCE_INSTANCE_ID", length=256)
67     private String resourceInstanceID;
68     
69     @Column(name = "JOB_ID", length=256)
70     private String jobId;
71     
72     @Column(name = "STATUS", length=256)
73     private String status;
74     
75     @Column(name = "PROGRESS", length=256)
76     private String progress = "0";
77     
78     @Column(name = "ERROR_CODE", length=256)
79     private String errorCode;
80     
81     @Column(name = "STATUS_DESCRIPOTION", length=256)
82     private String statusDescription;
83
84     public ResourceOperationStatus(){
85         
86     }
87     
88     public ResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID)
89     {
90         this.serviceId = serviceId;
91         this.operationId = operationId;
92         this.resourceTemplateUUID = resourceTemplateUUID;
93     }
94     
95     public String getServiceId() {
96         return serviceId;
97     }
98
99     
100     public void setServiceId(String serviceId) {
101         this.serviceId = serviceId;
102     }
103
104     
105     public String getOperationId() {
106         return operationId;
107     }
108
109     
110     public void setOperationId(String operationId) {
111         this.operationId = operationId;
112     }
113
114     
115     public String getResourceTemplateUUID() {
116         return resourceTemplateUUID;
117     }
118
119     
120     public void setResourceTemplateUUID(String resourceTemplateUUId) {
121         this.resourceTemplateUUID = resourceTemplateUUId;
122     }
123
124     
125     public String getJobId() {
126         return jobId;
127     }
128
129     
130     public void setJobId(String jobId) {
131         this.jobId = jobId;
132     }
133
134     
135     public String getStatus() {
136         return status;
137     }
138
139     
140     public void setStatus(String status) {
141         this.status = status;
142     }
143
144     
145     public String getProgress() {
146         return progress;
147     }
148
149     
150     public void setProgress(String progress) {
151         this.progress = progress;
152     }
153
154     
155     public String getErrorCode() {
156         return errorCode;
157     }
158
159     
160     public void setErrorCode(String errorCode) {
161         this.errorCode = errorCode;
162     }
163
164     
165     public String getStatusDescription() {
166         return statusDescription;
167     }
168
169     
170     public void setStatusDescription(String statusDescription) {
171         this.statusDescription = statusDescription;
172     }
173
174
175     
176     public String getResourceInstanceID() {
177         return resourceInstanceID;
178     }
179
180
181     
182     public void setResourceInstanceID(String resourceInstanceID) {
183         this.resourceInstanceID = resourceInstanceID;
184     }
185
186     
187     public String getOperType() {
188         return operType;
189     }
190
191     
192     public void setOperType(String operType) {
193         this.operType = operType;
194     }
195
196         @Override
197         public boolean equals(final Object other) {
198                 if (this == other) {
199                         return true;
200                 }
201                 if (!(other instanceof ResourceOperationStatus)) {
202                         return false;
203                 }
204                 ResourceOperationStatus castOther = (ResourceOperationStatus) other;
205                 return Objects.equals(getServiceId(), castOther.getServiceId())
206                                 && Objects.equals(getOperationId(), castOther.getOperationId())
207                                 && Objects.equals(getResourceTemplateUUID(), castOther.getResourceTemplateUUID());
208         }
209
210         @Override
211         public int hashCode() {
212                 return Objects.hash(getServiceId(), getOperationId(), getResourceTemplateUUID());
213         }
214
215         @Override
216         public String toString() {
217                 return new ToStringBuilder(this).append("serviceId", getServiceId()).append("operationId", getOperationId())
218                                 .append("resourceTemplateUUID", getResourceTemplateUUID()).append("operType", getOperType())
219                                 .append("resourceInstanceID", getResourceInstanceID()).append("jobId", getJobId())
220                                 .append("status", getStatus()).append("progress", getProgress()).append("errorCode", getErrorCode())
221                                 .append("statusDescription", getStatusDescription()).toString();
222         }
223 }