Move pauseInstantiation from VfModule to BaseResource
[vid.git] / vid-app-common / src / main / java / org / onap / vid / model / serviceInstantiation / VfModule.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 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
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
21 package org.onap.vid.model.serviceInstantiation;
22
23 import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
24
25 import com.fasterxml.jackson.annotation.JsonAlias;
26 import com.fasterxml.jackson.annotation.JsonInclude;
27 import com.fasterxml.jackson.annotation.JsonProperty;
28 import java.util.Collection;
29 import java.util.Collections;
30 import java.util.List;
31 import java.util.Map;
32 import javax.annotation.Nullable;
33 import org.onap.vid.job.JobAdapter;
34 import org.onap.vid.job.JobType;
35 import org.onap.vid.mso.model.ModelInfo;
36 import org.onap.vid.mso.model.ServiceInstantiationRequestDetails.UserParamNameAndValue;
37
38 /**
39  * The Class VfModule.
40  */
41 @JsonInclude(NON_NULL)
42 public class VfModule extends BaseResource implements JobAdapter.AsyncJobRequest {
43
44         @JsonInclude(NON_NULL) @JsonProperty("volumeGroupName") private final String volumeGroupInstanceName;
45         @JsonInclude(NON_NULL) @JsonProperty("sdncPreLoad") private Boolean usePreload;
46         private List<UserParamNameAndValue> supplementaryParams;
47
48         @JsonInclude(NON_NULL)
49         private final Boolean retainVolumeGroups;
50
51         @JsonInclude(NON_NULL)
52         private Boolean retainAssignments;
53
54         public VfModule(@JsonProperty("modelInfo") ModelInfo modelInfo,
55                 @JsonProperty("instanceName") String instanceName,
56                 @JsonProperty("volumeGroupName") @JsonAlias("volumeGroupInstanceName") String volumeGroupInstanceName,
57                 @JsonProperty("action") String action,
58                 @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
59                 @JsonProperty("legacyRegion") String legacyRegion,
60                 @JsonProperty("tenantId") String tenantId,
61                 @JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
62                 @JsonProperty("supplementaryFileContent") List<UserParamNameAndValue> supplementaryParams,
63                 @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
64                 @JsonProperty("sdncPreLoad") @JsonAlias("usePreload") Boolean usePreload,
65                 @JsonProperty("instanceId") String instanceId,
66                 @JsonProperty("trackById") String trackById,
67                 @JsonProperty("isFailed") Boolean isFailed,
68                 @JsonProperty("statusMessage") String statusMessage,
69                 @Nullable @JsonProperty("retainAssignments") Boolean retainAssignments,
70                 @Nullable @JsonProperty("retainVolumeGroups") Boolean retainVolumeGroups,
71                 @JsonProperty("position") Integer position,
72                 @JsonProperty("pauseInstantiation") PauseInstantiation pauseInstantiation,
73                 @JsonProperty("originalName") String originalName) {
74                 super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage,
75                         position, pauseInstantiation, originalName);
76                 this.volumeGroupInstanceName = volumeGroupInstanceName;
77                 this.usePreload = usePreload;
78                 this.supplementaryParams = supplementaryParams;
79                 this.retainAssignments = retainAssignments;
80                 this.retainVolumeGroups = retainVolumeGroups;
81         }
82
83         public String getVolumeGroupInstanceName() {
84                 return volumeGroupInstanceName;
85         }
86
87         public Boolean isUsePreload() {
88
89                 return usePreload;
90         }
91
92         public List<UserParamNameAndValue> getSupplementaryParams() {
93                 return supplementaryParams;
94         }
95
96         @Override
97         protected String getModelType() {
98                 return "vfModule";
99         }
100
101         @Override
102         public Collection<BaseResource> getChildren() {
103                 return Collections.emptyList();
104         }
105
106         @Override
107         public JobType getJobType() {
108                 return JobType.VfmoduleInstantiation;
109         }
110
111         @Nullable
112         public Boolean isRetainAssignments() {
113                 return retainAssignments;
114         }
115
116         @Nullable
117         public Boolean isRetainVolumeGroups() {
118                 return retainVolumeGroups;
119         }
120
121         public VfModule cloneWith(ModelInfo modelInfo) {
122                 return new VfModule(
123                                 modelInfo,
124                                 this.getInstanceName(),
125                                 this.getVolumeGroupInstanceName(),
126                                 this.getAction().toString(),
127                                 this.getLcpCloudRegionId(),
128                                 this.getLcpCloudRegionId(),
129                                 this.getTenantId(),
130                                 this.getInstanceParams(),
131                                 this.getSupplementaryParams(),
132                                 this.isRollbackOnFailure(),
133                                 this.isUsePreload(),
134                                 this.getInstanceId(),
135                                 this.getTrackById(),
136                                 this.getIsFailed(),
137                                 this.getStatusMessage(),
138                                 this.isRetainAssignments(),
139                                 this.isRetainVolumeGroups(),
140                                 this.getPosition(),
141                             this.getPauseInstantiation(),
142                             this.getOriginalName()
143                 );
144         }
145
146         public VfModule cloneWith(String lcpCloudRegionId, String tenantId) {
147                 return new VfModule(
148                         this.getModelInfo(),
149                         this.getInstanceName(),
150                         this.getVolumeGroupInstanceName(),
151                         this.getAction().toString(),
152                         lcpCloudRegionId,
153                         lcpCloudRegionId,
154                         tenantId,
155                         this.getInstanceParams(),
156                         this.getSupplementaryParams(),
157                         this.isRollbackOnFailure(),
158                         this.isUsePreload(),
159                         this.getInstanceId(),
160                         this.getTrackById(),
161                         this.getIsFailed(),
162                         this.getStatusMessage(),
163                         this.isRetainAssignments(),
164                         this.isRetainVolumeGroups(),
165                         this.getPosition(),
166                         this.getPauseInstantiation(),
167                         this.getOriginalName()
168                 );
169         }
170 }