aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap/vid/job/impl/JobSharedData.java
blob: 8f1e457364861b2e8191f5b985641f46afbea8c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package org.onap.vid.job.impl;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.onap.vid.job.JobAdapter;

import java.util.Objects;
import java.util.UUID;

public class JobSharedData {

    protected UUID jobUuid;
    protected String userId;
    protected Class requestType;
    protected UUID rootJobId;

    @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, property="class")
    protected JobAdapter.AsyncJobRequest request;

    public JobSharedData() {
    }

    public JobSharedData(UUID jobUuid, String userId, JobAdapter.AsyncJobRequest request) {
        this.jobUuid = jobUuid;
        this.userId = userId;
        this.requestType = request.getClass();
        this.request = request;
        this.rootJobId = jobUuid;
    }

    public JobSharedData(UUID jobUuid, JobAdapter.AsyncJobRequest request, JobSharedData parentData) {
        this(jobUuid, parentData.getUserId(), request);
        rootJobId = parentData.getRootJobId() != null ? parentData.getRootJobId() : parentData.getJobUuid();
    }


    public UUID getJobUuid() {
        return jobUuid;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public Class getRequestType() {
        return requestType;
    }

    public void setRequestType(Class requestType) {
        this.requestType = requestType;
    }

    public JobAdapter.AsyncJobRequest getRequest() {
        return request;
    }

    public void setRequest(JobAdapter.AsyncJobRequest request) {
        this.request = request;
    }

    public UUID getRootJobId() {
        return rootJobId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof JobSharedData)) return false;
        JobSharedData that = (JobSharedData) o;
        return Objects.equals(getJobUuid(), that.getJobUuid()) &&
                Objects.equals(getUserId(), that.getUserId()) &&
                Objects.equals(getRequestType(), that.getRequestType()) &&
                Objects.equals(getRootJobId(), that.getRootJobId()) &&
                Objects.equals(getRequest(), that.getRequest());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getJobUuid(), getUserId(), getRequestType(), getRootJobId(), getRequest());
    }
}