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=========================================================
21 package org.openecomp.sdc.be.components.merge.input;
23 import org.openecomp.sdc.be.components.merge.VspComponentsMergeCommand;
24 import org.openecomp.sdc.be.dao.api.ActionStatus;
25 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
26 import org.openecomp.sdc.be.impl.ComponentsUtils;
27 import org.openecomp.sdc.be.model.Component;
28 import org.openecomp.sdc.be.model.InputDefinition;
29 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
30 import org.springframework.core.annotation.Order;
32 import java.util.List;
34 import java.util.Map.Entry;
35 import java.util.stream.Stream;
37 import static java.util.stream.Collectors.toMap;
38 import static org.openecomp.sdc.be.components.merge.resource.ResourceDataMergeBusinessLogic.PENULTIMATE_COMMAND;
39 import static org.openecomp.sdc.be.utils.PropertyDefinitionUtils.convertListOfProperties;
41 @org.springframework.stereotype.Component
42 @Order(PENULTIMATE_COMMAND)//must run after all properties values were merged but before component instance relations merge
43 public class ComponentInputsMergeBL extends InputsMergeCommand implements VspComponentsMergeCommand {
45 public ComponentInputsMergeBL(InputsValuesMergingBusinessLogic inputsValuesMergingBusinessLogic, DeclaredInputsResolver declaredInputsResolver, ToscaOperationFacade toscaOperationFacade, ComponentsUtils componentsUtils) {
46 super(inputsValuesMergingBusinessLogic, declaredInputsResolver, toscaOperationFacade, componentsUtils);
50 public ActionStatus mergeComponents(Component prevComponent, Component currentComponent) {
51 return super.redeclareAndMergeInputsValues(prevComponent, currentComponent);
55 public String description() {
56 return "merge component inputs";
60 List<InputDefinition> getInputsToMerge(Component component) {
61 return component.safeGetInputs();
65 Map<String, List<PropertyDataDefinition>> getProperties(Component component) {
66 return Stream.of(component.safeGetComponentInstancesProperties(),
67 component.safeGetComponentInstancesInputs(),
68 component.safeGetGroupsProperties(),
69 component.safeGetPolicyProperties())
70 .flatMap(map -> map.entrySet().stream())
71 .collect(toMap(Entry::getKey, entry -> convertListOfProperties(entry.getValue())));