Fix 'Changing VFC version wipes List type property values'-bug
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / components / merge / instance / DataForMergeHolder.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 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
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.openecomp.sdc.be.components.merge.instance;
21
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.HashMap;
25 import java.util.List;
26 import java.util.Map;
27 import java.util.Optional;
28 import org.openecomp.sdc.be.model.ArtifactDefinition;
29 import org.openecomp.sdc.be.model.CapabilityDefinition;
30 import org.openecomp.sdc.be.model.Component;
31 import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
32 import org.openecomp.sdc.be.model.ComponentInstanceInput;
33 import org.openecomp.sdc.be.model.ComponentInstanceInterface;
34 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
35 import org.openecomp.sdc.be.model.InputDefinition;
36 import org.openecomp.sdc.be.model.OutputDefinition;
37
38 /**
39  * Created by chaya on 9/7/2017.
40  */
41 public class DataForMergeHolder {
42
43     private List<ComponentInstanceInput> origComponentInstanceInputs;
44     private List<ComponentInstanceProperty> origComponentInstanceProperties;
45     private List<InputDefinition> origComponentInputs;
46     private Map<String, ArtifactDefinition> origCompInstDeploymentArtifactsCreatedOnTheInstance;
47     private Map<String, ArtifactDefinition> origCompInstInformationalArtifactsCreatedOnTheInstance;
48     private Map<String, List<String>> origComponentInstanceExternalRefs;
49     private List<ArtifactDefinition> origComponentInstanceHeatEnvArtifacts;
50     private ContainerRelationsMergeInfo containerRelationsMergeInfo;
51     private List<CapabilityDefinition> origInstanceCapabilities;
52     private Component origInstanceNode;
53     private Component currInstanceNode;
54     private String origComponentInstId;
55     private List<ComponentInstanceInterface> origComponentInstanceInterfaces;
56     private Map<String, Integer> componentInstanceDeploymentArtifactsTimeOut;
57     private final List<ComponentInstanceAttribute> origComponentInstanceAttributes;
58     private final List<OutputDefinition> origComponentOutputs;
59
60     public DataForMergeHolder() {
61         origComponentInstanceInputs = new ArrayList<>();
62         origComponentInstanceProperties = new ArrayList<>();
63         origComponentInstanceAttributes = new ArrayList<>();
64         origComponentOutputs = new ArrayList<>();
65         origComponentInputs = new ArrayList<>();
66         origCompInstDeploymentArtifactsCreatedOnTheInstance = new HashMap<>();
67         origCompInstDeploymentArtifactsCreatedOnTheInstance = new HashMap<>();
68         origInstanceCapabilities = new ArrayList<>();
69         origComponentInstanceInterfaces = new ArrayList<>();
70         componentInstanceDeploymentArtifactsTimeOut = new HashMap<>();
71     }
72
73     List<ArtifactDefinition> getOrigComponentInstanceHeatEnvArtifacts() {
74         return origComponentInstanceHeatEnvArtifacts;
75     }
76
77     void setOrigComponentInstanceHeatEnvArtifacts(List<ArtifactDefinition> origComponentInstanceHeatEnvArtifacts) {
78         this.origComponentInstanceHeatEnvArtifacts = origComponentInstanceHeatEnvArtifacts;
79     }
80
81     List<ComponentInstanceInput> getOrigComponentInstanceInputs() {
82         return origComponentInstanceInputs;
83     }
84
85     void setOrigComponentInstanceInputs(List<ComponentInstanceInput> origComponentInstanceInputs) {
86         Optional.ofNullable(origComponentInstanceInputs).orElse(Collections.emptyList()).forEach(input -> {
87             ComponentInstanceInput copyInput = new ComponentInstanceInput();
88             copyInput.setType(input.getType());
89             copyInput.setPath(input.getPath());
90             copyInput.setRules(input.getRules());
91             copyInput.setValueUniqueUid(input.getValueUniqueUid());
92             copyInput.setDefaultValue(input.getDefaultValue());
93             copyInput.setDescription(input.getDescription());
94             copyInput.setGetInputValues(input.getGetInputValues());
95             copyInput.setInputId(input.getInputId());
96             copyInput.setInputPath(input.getInputPath());
97             copyInput.setInputs(input.getInputs());
98             copyInput.setLabel(input.getLabel());
99             copyInput.setName(input.getName());
100             copyInput.setParentUniqueId(input.getParentUniqueId());
101             copyInput.setProperties(input.getProperties());
102             copyInput.setPropertyId(input.getPropertyId());
103             copyInput.setSchema(input.getSchema());
104             copyInput.setStatus(input.getStatus());
105             copyInput.setDefaultValue(input.getDefaultValue());
106             copyInput.setValue(input.getValue());
107             this.origComponentInstanceInputs.add(copyInput);
108         });
109     }
110
111     List<ComponentInstanceProperty> getOrigComponentInstanceProperties() {
112         return origComponentInstanceProperties;
113     }
114
115     void setOrigComponentInstanceProperties(List<ComponentInstanceProperty> origComponentInstanceProperties) {
116         Optional.ofNullable(origComponentInstanceProperties).orElse(Collections.emptyList()).forEach(property -> {
117             ComponentInstanceProperty propertyCopy = new ComponentInstanceProperty();
118             propertyCopy.setType(property.getType());
119             propertyCopy.setSchema(property.getSchema());
120             propertyCopy.setName(property.getName());
121             propertyCopy.setValue(property.getValue());
122             propertyCopy.setUniqueId(property.getUniqueId());
123             propertyCopy.setDefaultValue(property.getDefaultValue());
124             propertyCopy.setInputId(property.getInputId());
125             propertyCopy.setGetInputValues(property.getGetInputValues());
126             propertyCopy.setToscaFunction(property.getToscaFunction());
127             this.origComponentInstanceProperties.add(propertyCopy);
128         });
129     }
130
131     List<InputDefinition> getOrigComponentInputs() {
132         return origComponentInputs;
133     }
134
135     void setOrigComponentInputs(List<InputDefinition> origComponentInputs) {
136         this.origComponentInputs = origComponentInputs;
137     }
138
139     Map<String, ArtifactDefinition> getOrigComponentDeploymentArtifactsCreatedOnTheInstance() {
140         return this.origCompInstDeploymentArtifactsCreatedOnTheInstance;
141     }
142
143     void setOrigComponentDeploymentArtifactsCreatedOnTheInstance(Map<String, ArtifactDefinition> origDeploymentArtifacts) {
144         origCompInstDeploymentArtifactsCreatedOnTheInstance = origDeploymentArtifacts;
145     }
146
147     Map<String, ArtifactDefinition> getOrigComponentInformationalArtifactsCreatedOnTheInstance() {
148         return origCompInstInformationalArtifactsCreatedOnTheInstance;
149     }
150
151     void setOrigComponentInformationalArtifactsCreatedOnTheInstance(Map<String, ArtifactDefinition> origInformationalArtifacts) {
152         origCompInstInformationalArtifactsCreatedOnTheInstance = origInformationalArtifacts;
153     }
154
155     Map<String, List<String>> getOrigCompInstExternalRefs() {
156         return origComponentInstanceExternalRefs;
157     }
158
159     void setOrigComponentInstanceExternalRefs(Map<String, List<String>> origComponentInstanceExternalRefs) {
160         this.origComponentInstanceExternalRefs = origComponentInstanceExternalRefs;
161     }
162
163     void setVfRelationsInfo(ContainerRelationsMergeInfo containerRelationsMergeInfo) {
164         this.containerRelationsMergeInfo = containerRelationsMergeInfo;
165     }
166
167     ContainerRelationsMergeInfo getContainerRelationsMergeInfo() {
168         return containerRelationsMergeInfo;
169     }
170
171     List<CapabilityDefinition> getOrigInstanceCapabilities() {
172         return origInstanceCapabilities;
173     }
174
175     void setOrigInstanceCapabilities(List<CapabilityDefinition> origInstanceCapabilities) {
176         this.origInstanceCapabilities = origInstanceCapabilities;
177     }
178
179     Component getOrigInstanceNode() {
180         return origInstanceNode;
181     }
182
183     void setOrigInstanceNode(Component origInstanceNode) {
184         this.origInstanceNode = origInstanceNode;
185     }
186
187     Component getCurrInstanceNode() {
188         return currInstanceNode;
189     }
190
191     public void setCurrInstanceNode(Component currInstanceNode) {
192         this.currInstanceNode = currInstanceNode;
193     }
194
195     public String getOrigComponentInstId() {
196         return origComponentInstId;
197     }
198
199     public void setOrigComponentInstId(String origComponentInstId) {
200         this.origComponentInstId = origComponentInstId;
201     }
202
203     public Map<String, Integer> getComponentInstanceDeploymentArtifactsTimeOut() {
204         return componentInstanceDeploymentArtifactsTimeOut;
205     }
206
207     void setComponentInstanceDeploymentArtifactsTimeOut(Map<String, Integer> componentInstancesDeploymentArtifacts) {
208         this.componentInstanceDeploymentArtifactsTimeOut = componentInstancesDeploymentArtifacts;
209     }
210
211     public List<ComponentInstanceInterface> getOrigComponentInstanceInterfaces() {
212         return origComponentInstanceInterfaces;
213     }
214
215     public void setOrigComponentInstanceInterfaces(List<ComponentInstanceInterface> origComponentInstanceInterfaces) {
216         this.origComponentInstanceInterfaces = origComponentInstanceInterfaces;
217     }
218
219     List<ComponentInstanceAttribute> getOrigComponentInstanceAttributes() {
220         return origComponentInstanceAttributes;
221     }
222
223     void setOrigComponentInstanceAttributes(List<ComponentInstanceAttribute> origComponentInstanceAttributes) {
224         Optional.ofNullable(origComponentInstanceAttributes).orElse(Collections.emptyList()).forEach(attribute -> {
225             ComponentInstanceAttribute attributeCopy = new ComponentInstanceAttribute();
226             attributeCopy.setType(attribute.getType());
227             attributeCopy.setName(attribute.getName());
228             attributeCopy.setValue(attribute.getValue());
229             attributeCopy.setUniqueId(attribute.getUniqueId());
230             attributeCopy.setDefaultValue(attribute.getDefaultValue());
231             attributeCopy.setOutputId(attribute.getOutputId());
232             attributeCopy.setGetOutputValues(attribute.getGetOutputValues());
233             attributeCopy.setOutputPath(attribute.getOutputPath());
234             this.origComponentInstanceAttributes.add(attributeCopy);
235         });
236     }
237
238     List<OutputDefinition> getOrigComponentOutputs() {
239         return origComponentOutputs;
240     }
241
242     void setOrigComponentOutputs(List<OutputDefinition> origComponentOutputs) {
243         Optional.ofNullable(origComponentOutputs).orElse(Collections.emptyList()).forEach(output -> {
244             OutputDefinition outputCopy = new OutputDefinition();
245             outputCopy.setType(output.getType());
246             outputCopy.setName(output.getName());
247             outputCopy.setValue(output.getValue());
248             outputCopy.setUniqueId(output.getUniqueId());
249             outputCopy.setDefaultValue(output.getDefaultValue());
250             outputCopy.setOutputId(output.getOutputId());
251             outputCopy.setGetOutputValues(output.getGetOutputValues());
252             outputCopy.setOutputPath(output.getOutputPath());
253             this.origComponentOutputs.add(outputCopy);
254         });
255     }
256 }