aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap/vid/job/command/WatchingCommand.java
blob: 8659cfe1a140f32157caf586958a2cbb07813ebc (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
package org.onap.vid.job.command;

import org.onap.vid.job.Job;
import org.onap.vid.job.NextCommand;
import org.onap.vid.job.impl.JobSharedData;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class WatchingCommand extends BaseWatchingCommand {

    public WatchingCommand() {}

    public WatchingCommand(JobSharedData sharedData, List<String> childrenJobsIds, boolean isService) {
        super(sharedData, childrenJobsIds, isService);
    }

    protected NextCommand getNextCommand(Job.JobStatus cumulativeJobsStatus) {
        if (cumulativeJobsStatus==Job.JobStatus.IN_PROGRESS) {
            return (isService) ? new NextCommand(Job.JobStatus.IN_PROGRESS, this)
                               : new NextCommand(Job.JobStatus.RESOURCE_IN_PROGRESS, this);
        }
        if (isService) {
            asyncInstantiationBL.updateServiceInfoAndAuditStatus(getSharedData().getJobUuid(), cumulativeJobsStatus);
        }
        return new NextCommand(cumulativeJobsStatus);
    }

}