2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
20 package org.onap.so.etsi.nfvo.ns.lcm.database.beans;
22 import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString;
23 import java.time.LocalDateTime;
24 import java.util.ArrayList;
25 import java.util.List;
26 import java.util.Objects;
27 import java.util.UUID;
28 import javax.persistence.CascadeType;
29 import javax.persistence.Column;
30 import javax.persistence.Entity;
31 import javax.persistence.EnumType;
32 import javax.persistence.Enumerated;
33 import javax.persistence.FetchType;
34 import javax.persistence.Id;
35 import javax.persistence.OneToMany;
36 import javax.persistence.Table;
37 import org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils;
42 public class NfvoJob {
45 @Column(name = "JOB_ID")
48 @Column(name = "JOB_TYPE")
49 private String jobType;
51 @Enumerated(EnumType.STRING)
52 @Column(name = "JOB_ACTION")
53 private JobAction jobAction;
55 @Column(name = "RESOURCE_ID")
56 private String resourceId;
58 @Column(name = "RESOURCE_NAME")
59 private String resourceName;
61 @Enumerated(EnumType.STRING)
62 @Column(name = "STATUS")
63 private JobStatusEnum status;
65 @Column(name = "START_TIME")
66 private LocalDateTime startTime;
68 @Column(name = "END_TIME")
69 private LocalDateTime endTime;
71 @Column(name = "PROGRESS")
74 @Column(name = "PROCESS_INSTANCE_ID")
75 private String processInstanceId;
77 @OneToMany(mappedBy = "nfvoJob", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
78 private List<NfvoJobStatus> nfvoJobStatuses = new ArrayList<>();
81 this.jobId = UUID.randomUUID().toString();
84 public void setJobId(final String jobId) {
88 public String getJobId() {
92 public NfvoJob jobId(final String jobId) {
97 public String getJobType() {
101 public void setJobType(final String jobType) {
102 this.jobType = jobType;
105 public NfvoJob jobType(final String jobType) {
106 this.jobType = jobType;
110 public JobAction getJobAction() {
114 public void setJobAction(final JobAction jobAction) {
115 this.jobAction = jobAction;
118 public NfvoJob jobAction(final JobAction jobAction) {
119 this.jobAction = jobAction;
123 public String getResourceId() {
127 public void setResourceId(final String resourceId) {
128 this.resourceId = resourceId;
131 public NfvoJob resourceId(final String resourceId) {
132 this.resourceId = resourceId;
136 public JobStatusEnum getStatus() {
140 public void setStatus(final JobStatusEnum status) {
141 this.status = status;
144 public NfvoJob status(final JobStatusEnum status) {
145 this.status = status;
149 public LocalDateTime getStartTime() {
153 public void setStartTime(final LocalDateTime startTime) {
154 this.startTime = startTime;
157 public NfvoJob startTime(final LocalDateTime startTime) {
158 this.startTime = startTime;
162 public LocalDateTime getEndTime() {
166 public void setEndTime(final LocalDateTime endTime) {
167 this.endTime = endTime;
170 public NfvoJob endTime(final LocalDateTime endTime) {
171 this.endTime = endTime;
175 public int getProgress() {
179 public void setProgress(final int progress) {
180 this.progress = progress;
183 public NfvoJob progress(final int progress) {
184 this.progress = progress;
188 public String getProcessInstanceId() {
189 return processInstanceId;
192 public void setProcessInstanceId(final String processInstanceId) {
193 this.processInstanceId = processInstanceId;
196 public NfvoJob processInstanceId(final String processInstanceId) {
197 this.processInstanceId = processInstanceId;
201 public String getResourceName() {
205 public void setResourceName(final String resourceName) {
206 this.resourceName = resourceName;
209 public NfvoJob resourceName(final String resourceName) {
210 this.resourceName = resourceName;
214 public List<NfvoJobStatus> getNfvoJobStatuses() {
215 return nfvoJobStatuses;
218 public void setJobStatuses(final List<NfvoJobStatus> nfvoJobStatuses) {
219 this.nfvoJobStatuses = nfvoJobStatuses;
222 public NfvoJob nfvoJobStatuses(final List<NfvoJobStatus> nfvoJobStatuses) {
223 this.nfvoJobStatuses = nfvoJobStatuses;
227 public NfvoJob nfvoJobStatus(final NfvoJobStatus nfvoJobStatus) {
228 nfvoJobStatus.setNfvoJob(this);
229 this.nfvoJobStatuses.add(nfvoJobStatus);
234 public int hashCode() {
235 return Objects.hash(jobId, processInstanceId, jobType, jobAction, startTime, endTime, status, progress,
236 resourceId, resourceName, nfvoJobStatuses);
240 public boolean equals(final Object obj) {
243 if (obj == null || getClass() != obj.getClass())
245 if (obj instanceof NfvoJob) {
246 final NfvoJob other = (NfvoJob) obj;
247 return Objects.equals(jobId, other.jobId) && Objects.equals(processInstanceId, other.processInstanceId)
248 && Objects.equals(jobType, other.jobType) && Objects.equals(jobAction, other.jobAction)
249 && Objects.equals(progress, other.progress) && Objects.equals(status, other.status)
250 && Objects.equals(startTime, other.startTime) && Objects.equals(endTime, other.endTime)
251 && Objects.equals(resourceId, other.resourceId) && Objects.equals(resourceName, other.resourceName)
252 && Utils.isEquals(nfvoJobStatuses, other.nfvoJobStatuses);
258 public String toString() {
259 final StringBuilder sb = new StringBuilder();
260 sb.append("class NfvoJob {\n");
261 sb.append(" jobId: ").append(toIndentedString(jobId)).append("\n");
262 sb.append(" processInstanceId: ").append(toIndentedString(processInstanceId)).append("\n");
263 sb.append(" jobType: ").append(toIndentedString(jobType)).append("\n");
264 sb.append(" jobAction: ").append(toIndentedString(jobAction)).append("\n");
265 sb.append(" progress: ").append(toIndentedString(progress)).append("\n");
266 sb.append(" status: ").append(toIndentedString(status)).append("\n");
267 sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n");
268 sb.append(" endTime: ").append(toIndentedString(endTime)).append("\n");
269 sb.append(" resId: ").append(toIndentedString(resourceId)).append("\n");
270 sb.append(" resName: ").append(toIndentedString(resourceName)).append("\n");
271 sb.append(" nfvoJobStatuses: ").append(toIndentedString(nfvoJobStatuses)).append("\n");
274 return sb.toString();