2 * ============LICENSE_START=======================================================
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
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=========================================================
20 package org.openecomp.sdc.be.components.merge.instance;
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.HashMap;
25 import java.util.List;
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;
39 * Created by chaya on 9/7/2017.
41 public class DataForMergeHolder {
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;
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<>();
73 List<ArtifactDefinition> getOrigComponentInstanceHeatEnvArtifacts() {
74 return origComponentInstanceHeatEnvArtifacts;
77 void setOrigComponentInstanceHeatEnvArtifacts(List<ArtifactDefinition> origComponentInstanceHeatEnvArtifacts) {
78 this.origComponentInstanceHeatEnvArtifacts = origComponentInstanceHeatEnvArtifacts;
81 List<ComponentInstanceInput> getOrigComponentInstanceInputs() {
82 return origComponentInstanceInputs;
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);
111 List<ComponentInstanceProperty> getOrigComponentInstanceProperties() {
112 return origComponentInstanceProperties;
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 propertyCopy.setToscaFunction(property.getToscaFunction());
126 this.origComponentInstanceProperties.add(propertyCopy);
130 List<InputDefinition> getOrigComponentInputs() {
131 return origComponentInputs;
134 void setOrigComponentInputs(List<InputDefinition> origComponentInputs) {
135 this.origComponentInputs = origComponentInputs;
138 Map<String, ArtifactDefinition> getOrigComponentDeploymentArtifactsCreatedOnTheInstance() {
139 return this.origCompInstDeploymentArtifactsCreatedOnTheInstance;
142 void setOrigComponentDeploymentArtifactsCreatedOnTheInstance(Map<String, ArtifactDefinition> origDeploymentArtifacts) {
143 origCompInstDeploymentArtifactsCreatedOnTheInstance = origDeploymentArtifacts;
146 Map<String, ArtifactDefinition> getOrigComponentInformationalArtifactsCreatedOnTheInstance() {
147 return origCompInstInformationalArtifactsCreatedOnTheInstance;
150 void setOrigComponentInformationalArtifactsCreatedOnTheInstance(Map<String, ArtifactDefinition> origInformationalArtifacts) {
151 origCompInstInformationalArtifactsCreatedOnTheInstance = origInformationalArtifacts;
154 Map<String, List<String>> getOrigCompInstExternalRefs() {
155 return origComponentInstanceExternalRefs;
158 void setOrigComponentInstanceExternalRefs(Map<String, List<String>> origComponentInstanceExternalRefs) {
159 this.origComponentInstanceExternalRefs = origComponentInstanceExternalRefs;
162 void setVfRelationsInfo(ContainerRelationsMergeInfo containerRelationsMergeInfo) {
163 this.containerRelationsMergeInfo = containerRelationsMergeInfo;
166 ContainerRelationsMergeInfo getContainerRelationsMergeInfo() {
167 return containerRelationsMergeInfo;
170 List<CapabilityDefinition> getOrigInstanceCapabilities() {
171 return origInstanceCapabilities;
174 void setOrigInstanceCapabilities(List<CapabilityDefinition> origInstanceCapabilities) {
175 this.origInstanceCapabilities = origInstanceCapabilities;
178 Component getOrigInstanceNode() {
179 return origInstanceNode;
182 void setOrigInstanceNode(Component origInstanceNode) {
183 this.origInstanceNode = origInstanceNode;
186 Component getCurrInstanceNode() {
187 return currInstanceNode;
190 public void setCurrInstanceNode(Component currInstanceNode) {
191 this.currInstanceNode = currInstanceNode;
194 public String getOrigComponentInstId() {
195 return origComponentInstId;
198 public void setOrigComponentInstId(String origComponentInstId) {
199 this.origComponentInstId = origComponentInstId;
202 public Map<String, Integer> getComponentInstanceDeploymentArtifactsTimeOut() {
203 return componentInstanceDeploymentArtifactsTimeOut;
206 void setComponentInstanceDeploymentArtifactsTimeOut(Map<String, Integer> componentInstancesDeploymentArtifacts) {
207 this.componentInstanceDeploymentArtifactsTimeOut = componentInstancesDeploymentArtifacts;
210 public List<ComponentInstanceInterface> getOrigComponentInstanceInterfaces() {
211 return origComponentInstanceInterfaces;
214 public void setOrigComponentInstanceInterfaces(List<ComponentInstanceInterface> origComponentInstanceInterfaces) {
215 this.origComponentInstanceInterfaces = origComponentInstanceInterfaces;
218 List<ComponentInstanceAttribute> getOrigComponentInstanceAttributes() {
219 return origComponentInstanceAttributes;
222 void setOrigComponentInstanceAttributes(List<ComponentInstanceAttribute> origComponentInstanceAttributes) {
223 Optional.ofNullable(origComponentInstanceAttributes).orElse(Collections.emptyList()).forEach(attribute -> {
224 ComponentInstanceAttribute attributeCopy = new ComponentInstanceAttribute();
225 attributeCopy.setType(attribute.getType());
226 attributeCopy.setName(attribute.getName());
227 attributeCopy.setValue(attribute.getValue());
228 attributeCopy.setUniqueId(attribute.getUniqueId());
229 attributeCopy.setDefaultValue(attribute.getDefaultValue());
230 attributeCopy.setOutputId(attribute.getOutputId());
231 attributeCopy.setGetOutputValues(attribute.getGetOutputValues());
232 attributeCopy.setOutputPath(attribute.getOutputPath());
233 this.origComponentInstanceAttributes.add(attributeCopy);
237 List<OutputDefinition> getOrigComponentOutputs() {
238 return origComponentOutputs;
241 void setOrigComponentOutputs(List<OutputDefinition> origComponentOutputs) {
242 Optional.ofNullable(origComponentOutputs).orElse(Collections.emptyList()).forEach(output -> {
243 OutputDefinition outputCopy = new OutputDefinition();
244 outputCopy.setType(output.getType());
245 outputCopy.setName(output.getName());
246 outputCopy.setValue(output.getValue());
247 outputCopy.setUniqueId(output.getUniqueId());
248 outputCopy.setDefaultValue(output.getDefaultValue());
249 outputCopy.setOutputId(output.getOutputId());
250 outputCopy.setGetOutputValues(output.getGetOutputValues());
251 outputCopy.setOutputPath(output.getOutputPath());
252 this.origComponentOutputs.add(outputCopy);