Aharoni, Pavel (pa0916) | 8c70f07 | 2018-11-18 00:07:12 +0200 | [diff] [blame^] | 1 | /*-
|
| 2 | * ============LICENSE_START=======================================================
|
| 3 | * OSAM
|
| 4 | * ================================================================================
|
| 5 | * Copyright (C) 2018 AT&T
|
| 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 | package org.onap.osam.job.impl;
|
| 21 |
|
| 22 | import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
| 23 | import org.onap.osam.job.IJobFactory;
|
| 24 |
|
| 25 | import java.util.Objects;
|
| 26 | import java.util.UUID;
|
| 27 |
|
| 28 | public class JobSharedData {
|
| 29 |
|
| 30 | protected UUID jobUuid;
|
| 31 | protected String userId;
|
| 32 | protected Class requestType;
|
| 33 | protected UUID rootJobId;
|
| 34 |
|
| 35 | @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, property="class")
|
| 36 | protected IJobFactory.AsyncJobRequest request;
|
| 37 |
|
| 38 | public JobSharedData() {
|
| 39 | }
|
| 40 |
|
| 41 | public JobSharedData(UUID jobUuid, String userId, IJobFactory.AsyncJobRequest request) {
|
| 42 | this.jobUuid = jobUuid;
|
| 43 | this.userId = userId;
|
| 44 | this.requestType = request.getClass();
|
| 45 | this.request = request;
|
| 46 | this.rootJobId = jobUuid;
|
| 47 | }
|
| 48 |
|
| 49 | public JobSharedData(UUID jobUuid, IJobFactory.AsyncJobRequest request, JobSharedData parentData) {
|
| 50 | this(jobUuid, parentData.getUserId(), request);
|
| 51 | rootJobId = parentData.getRootJobId() != null ? parentData.getRootJobId() : parentData.getJobUuid();
|
| 52 | }
|
| 53 |
|
| 54 |
|
| 55 | public UUID getJobUuid() {
|
| 56 | return jobUuid;
|
| 57 | }
|
| 58 |
|
| 59 | public String getUserId() {
|
| 60 | return userId;
|
| 61 | }
|
| 62 |
|
| 63 | public void setUserId(String userId) {
|
| 64 | this.userId = userId;
|
| 65 | }
|
| 66 |
|
| 67 | public Class getRequestType() {
|
| 68 | return requestType;
|
| 69 | }
|
| 70 |
|
| 71 | public void setRequestType(Class requestType) {
|
| 72 | this.requestType = requestType;
|
| 73 | }
|
| 74 |
|
| 75 | public IJobFactory.AsyncJobRequest getRequest() {
|
| 76 | return request;
|
| 77 | }
|
| 78 |
|
| 79 | public void setRequest(IJobFactory.AsyncJobRequest request) {
|
| 80 | this.request = request;
|
| 81 | }
|
| 82 |
|
| 83 | public UUID getRootJobId() {
|
| 84 | return rootJobId;
|
| 85 | }
|
| 86 |
|
| 87 | @Override
|
| 88 | public boolean equals(Object o) {
|
| 89 | if (this == o) return true;
|
| 90 | if (!(o instanceof JobSharedData)) return false;
|
| 91 | JobSharedData that = (JobSharedData) o;
|
| 92 | return Objects.equals(getJobUuid(), that.getJobUuid()) &&
|
| 93 | Objects.equals(getUserId(), that.getUserId()) &&
|
| 94 | Objects.equals(getRequestType(), that.getRequestType()) &&
|
| 95 | Objects.equals(getRootJobId(), that.getRootJobId()) &&
|
| 96 | Objects.equals(getRequest(), that.getRequest());
|
| 97 | }
|
| 98 |
|
| 99 | @Override
|
| 100 | public int hashCode() {
|
| 101 | return Objects.hash(getJobUuid(), getUserId(), getRequestType(), getRootJobId(), getRequest());
|
| 102 | }
|
| 103 | }
|