21c746158914b86512dd558868906cdd7a3ed3f4
[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.setName(property.getName());
120             propertyCopy.setValue(property.getValue());
121             propertyCopy.setUniqueId(property.getUniqueId());
122             propertyCopy.setDefaultValue(property.getDefaultValue());
123             propertyCopy.setInputId(property.getInputId());
124             propertyCopy.setGetInputValues(property.getGetInputValues());
125             this.origComponentInstanceProperties.add(propertyCopy);
126         });
127     }
128
129     List<InputDefinition> getOrigComponentInputs() {
130         return origComponentInputs;
131     }
132
133     void setOrigComponentInputs(List<InputDefinition> origComponentInputs) {
134         this.origComponentInputs = origComponentInputs;
135     }
136
137     Map<String, ArtifactDefinition> getOrigComponentDeploymentArtifactsCreatedOnTheInstance() {
138         return this.origCompInstDeploymentArtifactsCreatedOnTheInstance;
139     }
140
141     void setOrigComponentDeploymentArtifactsCreatedOnTheInstance(Map<String, ArtifactDefinition> origDeploymentArtifacts) {
142         origCompInstDeploymentArtifactsCreatedOnTheInstance = origDeploymentArtifacts;
143     }
144
145     Map<String, ArtifactDefinition> getOrigComponentInformationalArtifactsCreatedOnTheInstance() {
146         return origCompInstInformationalArtifactsCreatedOnTheInstance;
147     }
148
149     void setOrigComponentInformationalArtifactsCreatedOnTheInstance(Map<String, ArtifactDefinition> origInformationalArtifacts) {
150         origCompInstInformationalArtifactsCreatedOnTheInstance = origInformationalArtifacts;
151     }
152
153     Map<String, List<String>> getOrigCompInstExternalRefs() {
154         return origComponentInstanceExternalRefs;
155     }
156
157     void setOrigComponentInstanceExternalRefs(Map<String, List<String>> origComponentInstanceExternalRefs) {
158         this.origComponentInstanceExternalRefs = origComponentInstanceExternalRefs;
159     }
160
161     void setVfRelationsInfo(ContainerRelationsMergeInfo containerRelationsMergeInfo) {
162         this.containerRelationsMergeInfo = containerRelationsMergeInfo;
163     }
164
165     ContainerRelationsMergeInfo getContainerRelationsMergeInfo() {
166         return containerRelationsMergeInfo;
167     }
168
169     List<CapabilityDefinition> getOrigInstanceCapabilities() {
170         return origInstanceCapabilities;
171     }
172
173     void setOrigInstanceCapabilities(List<CapabilityDefinition> origInstanceCapabilities) {
174         this.origInstanceCapabilities = origInstanceCapabilities;
175     }
176
177     Component getOrigInstanceNode() {
178         return origInstanceNode;
179     }
180
181     void setOrigInstanceNode(Component origInstanceNode) {
182         this.origInstanceNode = origInstanceNode;
183     }
184
185     Component getCurrInstanceNode() {
186         return currInstanceNode;
187     }
188
189     public void setCurrInstanceNode(Component currInstanceNode) {
190         this.currInstanceNode = currInstanceNode;
191     }
192
193     public String getOrigComponentInstId() {
194         return origComponentInstId;
195     }
196
197     public void setOrigComponentInstId(String origComponentInstId) {
198         this.origComponentInstId = origComponentInstId;
199     }
200
201     public Map<String, Integer> getComponentInstanceDeploymentArtifactsTimeOut() {
202         return componentInstanceDeploymentArtifactsTimeOut;
203     }
204
205     void setComponentInstanceDeploymentArtifactsTimeOut(Map<String, Integer> componentInstancesDeploymentArtifacts) {
206         this.componentInstanceDeploymentArtifactsTimeOut = componentInstancesDeploymentArtifacts;
207     }
208
209     public List<ComponentInstanceInterface> getOrigComponentInstanceInterfaces() {
210         return origComponentInstanceInterfaces;
211     }
212
213     public void setOrigComponentInstanceInterfaces(List<ComponentInstanceInterface> origComponentInstanceInterfaces) {
214         this.origComponentInstanceInterfaces = origComponentInstanceInterfaces;
215     }
216
217     List<ComponentInstanceAttribute> getOrigComponentInstanceAttributes() {
218         return origComponentInstanceAttributes;
219     }
220
221     void setOrigComponentInstanceAttributes(List<ComponentInstanceAttribute> origComponentInstanceAttributes) {
222         Optional.ofNullable(origComponentInstanceAttributes).orElse(Collections.emptyList()).forEach(attribute -> {
223             ComponentInstanceAttribute attributeCopy = new ComponentInstanceAttribute();
224             attributeCopy.setType(attribute.getType());
225             attributeCopy.setName(attribute.getName());
226             attributeCopy.setValue(attribute.getValue());
227             attributeCopy.setUniqueId(attribute.getUniqueId());
228             attributeCopy.setDefaultValue(attribute.getDefaultValue());
229             attributeCopy.setOutputId(attribute.getOutputId());
230             attributeCopy.setGetOutputValues(attribute.getGetOutputValues());
231             attributeCopy.setOutputPath(attribute.getOutputPath());
232             this.origComponentInstanceAttributes.add(attributeCopy);
233         });
234     }
235
236     List<OutputDefinition> getOrigComponentOutputs() {
237         return origComponentOutputs;
238     }
239
240     void setOrigComponentOutputs(List<OutputDefinition> origComponentOutputs) {
241         Optional.ofNullable(origComponentOutputs).orElse(Collections.emptyList()).forEach(output -> {
242             OutputDefinition outputCopy = new OutputDefinition();
243             outputCopy.setType(output.getType());
244             outputCopy.setName(output.getName());
245             outputCopy.setValue(output.getValue());
246             outputCopy.setUniqueId(output.getUniqueId());
247             outputCopy.setDefaultValue(output.getDefaultValue());
248             outputCopy.setOutputId(output.getOutputId());
249             outputCopy.setGetOutputValues(output.getGetOutputValues());
250             outputCopy.setOutputPath(output.getOutputPath());
251             this.origComponentOutputs.add(outputCopy);
252         });
253     }
254 }