2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.vid.job.command;
23 import org.onap.vid.job.Job;
24 import org.onap.vid.job.JobType;
25 import org.onap.vid.job.NextCommand;
26 import org.onap.vid.job.command.CommandParentData.CommandDataKey;
27 import org.onap.vid.job.impl.JobSharedData;
28 import org.onap.vid.model.serviceInstantiation.VfModule;
29 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
30 import org.springframework.context.annotation.Scope;
31 import org.springframework.stereotype.Component;
33 import java.util.Arrays;
34 import java.util.List;
38 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
39 public class VolumeGroupInProgressStatusCommand extends ResourceWithChildrenInProgressCommand {
41 public VolumeGroupInProgressStatusCommand(
42 JobSharedData sharedData,
45 CommandParentData parentData) {
46 super(sharedData, requestId, instanceId, parentData);
49 public VolumeGroupInProgressStatusCommand() {
53 protected NextCommand processJobStatus(Job.JobStatus jobStatus) {
54 if (jobStatus == Job.JobStatus.FAILED) {
55 return new NextCommand(Job.JobStatus.FAILED);
57 VfModule request = (VfModule) getSharedData().getRequest();
59 if (jobStatus == Job.JobStatus.COMPLETED) {
61 Map<String, Object> dataForChild = buildDataForChild();
62 List<String> vfModuleJob = Arrays.asList(jobsBrokerService.add(
63 jobAdapter.createChildJob(JobType.VfmoduleInstantiation, Job.JobStatus.CREATING , request, getSharedData(), dataForChild)).toString());
65 return new NextCommand(Job.JobStatus.RESOURCE_IN_PROGRESS, new WatchingCommand(getSharedData(), vfModuleJob, false));
68 //in case of JobStatus.PAUSE we leave the job itself as IN_PROGRESS, for keep tracking job progress
69 if (jobStatus == Job.JobStatus.PAUSE) {
70 return new NextCommand(Job.JobStatus.RESOURCE_IN_PROGRESS, this);
72 return new NextCommand(jobStatus, this);
76 protected Map<String, Object> buildDataForChild() {
77 commandParentData.addInstanceId(CommandDataKey.VG_INSTANCE_ID, this.instanceId);
78 return super.buildDataForChild();
82 protected ExpiryChecker getExpiryChecker() {