Merge from ECOMP's repository
[vid.git] / vid-app-common / src / main / java / org / onap / vid / job / command / ResourceWithChildrenInProgressCommand.java
1 package org.onap.vid.job.command;
2
3 import org.onap.vid.job.Job;
4 import org.onap.vid.job.NextCommand;
5 import org.onap.vid.job.impl.JobSharedData;
6
7 import java.util.HashMap;
8 import java.util.Map;
9
10
11 public class ResourceWithChildrenInProgressCommand extends BaseInProgressStatusCommand {
12
13     public ResourceWithChildrenInProgressCommand() {
14     }
15
16     public ResourceWithChildrenInProgressCommand(JobSharedData sharedData,
17                                                  String requestId,
18                                                  String instanceId,
19                                                  CommandParentData commandParentData) {
20         init(sharedData, requestId, instanceId, commandParentData);
21     }
22
23     protected BaseInProgressStatusCommand init(JobSharedData sharedData,
24                                                String requestId,
25                                                String instanceId,
26                                                CommandParentData commandParentData) {
27         init(sharedData, requestId, instanceId);
28         this.commandParentData= commandParentData;
29         return this;
30     }
31
32
33     @Override
34     public Map<String, Object> getData() {
35         Map<String, Object> data = new HashMap<>(super.getData());
36         data.putAll(buildDataForChild());
37         return data;
38     }
39
40     @Override
41     public BaseInProgressStatusCommand init(JobSharedData sharedData, Map<String, Object> commandData) {
42         return init(
43                 sharedData,
44                 (String) commandData.get("requestId"),
45                 (String) commandData.get("instanceId"),
46                 commandParentData.initParentData(commandData));
47     }
48
49     protected Map<String, Object> buildDataForChild() {
50        return commandParentData.getParentData();
51     }
52
53
54
55     @Override
56     protected NextCommand processJobStatus(Job.JobStatus jobStatus) {
57         return new NextCommand(jobStatus, this);
58     }
59
60     @Override
61     protected ExpiryChecker getExpiryChecker() {
62         return x->false;
63     }
64
65 }