Merge from ECOMP's repository
[vid.git] / vid-app-common / src / main / java / org / onap / vid / job / impl / JobSharedData.java
1 package org.onap.vid.job.impl;
2
3 import com.fasterxml.jackson.annotation.JsonTypeInfo;
4 import org.onap.vid.job.JobAdapter;
5
6 import java.util.Objects;
7 import java.util.UUID;
8
9 public class JobSharedData {
10
11     protected UUID jobUuid;
12     protected String userId;
13     protected Class requestType;
14     protected UUID rootJobId;
15
16     @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, property="class")
17     protected JobAdapter.AsyncJobRequest request;
18
19     public JobSharedData() {
20     }
21
22     public JobSharedData(UUID jobUuid, String userId, JobAdapter.AsyncJobRequest request) {
23         this.jobUuid = jobUuid;
24         this.userId = userId;
25         this.requestType = request.getClass();
26         this.request = request;
27         this.rootJobId = jobUuid;
28     }
29
30     public JobSharedData(UUID jobUuid, JobAdapter.AsyncJobRequest request, JobSharedData parentData) {
31         this(jobUuid, parentData.getUserId(), request);
32         rootJobId = parentData.getRootJobId() != null ? parentData.getRootJobId() : parentData.getJobUuid();
33     }
34
35
36     public UUID getJobUuid() {
37         return jobUuid;
38     }
39
40     public String getUserId() {
41         return userId;
42     }
43
44     public void setUserId(String userId) {
45         this.userId = userId;
46     }
47
48     public Class getRequestType() {
49         return requestType;
50     }
51
52     public void setRequestType(Class requestType) {
53         this.requestType = requestType;
54     }
55
56     public JobAdapter.AsyncJobRequest getRequest() {
57         return request;
58     }
59
60     public void setRequest(JobAdapter.AsyncJobRequest request) {
61         this.request = request;
62     }
63
64     public UUID getRootJobId() {
65         return rootJobId;
66     }
67
68     @Override
69     public boolean equals(Object o) {
70         if (this == o) return true;
71         if (!(o instanceof JobSharedData)) return false;
72         JobSharedData that = (JobSharedData) o;
73         return Objects.equals(getJobUuid(), that.getJobUuid()) &&
74                 Objects.equals(getUserId(), that.getUserId()) &&
75                 Objects.equals(getRequestType(), that.getRequestType()) &&
76                 Objects.equals(getRootJobId(), that.getRootJobId()) &&
77                 Objects.equals(getRequest(), that.getRequest());
78     }
79
80     @Override
81     public int hashCode() {
82         return Objects.hash(getJobUuid(), getUserId(), getRequestType(), getRootJobId(), getRequest());
83     }
84 }