diff options
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/input/InputsMergeCommand.java')
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/input/InputsMergeCommand.java | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/input/InputsMergeCommand.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/input/InputsMergeCommand.java index 0f6c89a592..ba3e600e18 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/input/InputsMergeCommand.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/input/InputsMergeCommand.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,14 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.be.components.merge.input; +import static java.util.Collections.emptyList; +import static org.apache.commons.collections.CollectionUtils.isEmpty; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.impl.ComponentsUtils; @@ -28,23 +33,16 @@ import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; import org.openecomp.sdc.common.log.wrappers.Logger; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static java.util.Collections.emptyList; -import static org.apache.commons.collections.CollectionUtils.isEmpty; - public abstract class InputsMergeCommand { private static final Logger log = Logger.getLogger(InputsMergeCommand.class); - private InputsValuesMergingBusinessLogic inputsValuesMergingBusinessLogic; private DeclaredInputsResolver declaredInputsResolver; private ToscaOperationFacade toscaOperationFacade; private ComponentsUtils componentsUtils; - public InputsMergeCommand(InputsValuesMergingBusinessLogic inputsValuesMergingBusinessLogic, DeclaredInputsResolver declaredInputsResolver, ToscaOperationFacade toscaOperationFacade, ComponentsUtils componentsUtils) { + public InputsMergeCommand(InputsValuesMergingBusinessLogic inputsValuesMergingBusinessLogic, DeclaredInputsResolver declaredInputsResolver, + ToscaOperationFacade toscaOperationFacade, ComponentsUtils componentsUtils) { this.inputsValuesMergingBusinessLogic = inputsValuesMergingBusinessLogic; this.declaredInputsResolver = declaredInputsResolver; this.toscaOperationFacade = toscaOperationFacade; @@ -65,26 +63,26 @@ public abstract class InputsMergeCommand { return updateInputs(currComponent.getUniqueId(), mergedInputs); } - - private List<InputDefinition> mergeInputsValues(Component prevComponent, Component currComponent) { - log.debug("#mergeInputsValues - merge inputs values from previous component {} to current component {}", prevComponent.getUniqueId(), currComponent.getUniqueId()); + log.debug("#mergeInputsValues - merge inputs values from previous component {} to current component {}", prevComponent.getUniqueId(), + currComponent.getUniqueId()); List<InputDefinition> inputsToMerge = getInputsToMerge(currComponent); List<InputDefinition> prevInputs = prevComponent.safeGetInputs(); inputsValuesMergingBusinessLogic.mergeComponentInputs(prevInputs, inputsToMerge); return inputsToMerge; } - private List<InputDefinition> getUniquePreviouslyDeclaredInputsToMerge(Component prevComponent, Component currComponent, List<InputDefinition> mergedInputs) { + private List<InputDefinition> getUniquePreviouslyDeclaredInputsToMerge(Component prevComponent, Component currComponent, + List<InputDefinition> mergedInputs) { List<InputDefinition> previouslyDeclaredInputsToMerge = getPreviouslyDeclaredInputsToMerge(prevComponent, currComponent); return previouslyDeclaredInputsToMerge.stream() - .filter(prev -> mergedInputs.stream() - .noneMatch(merged -> merged.getName().equals(prev.getName()))).collect(Collectors.toList()); + .filter(prev -> mergedInputs.stream().noneMatch(merged -> merged.getName().equals(prev.getName()))).collect(Collectors.toList()); } - private List<InputDefinition> getPreviouslyDeclaredInputsToMerge(Component prevComponent, Component currComponent) { - log.debug("#getPreviouslyDeclaredInputsToMerge - getting inputs that were previously declared from previous component {} and setting on current component {}", prevComponent.getUniqueId(), currComponent.getUniqueId()); + log.debug( + "#getPreviouslyDeclaredInputsToMerge - getting inputs that were previously declared from previous component {} and setting on current component {}", + prevComponent.getUniqueId(), currComponent.getUniqueId()); if (isEmpty(prevComponent.getInputs())) { return emptyList(); } @@ -95,8 +93,6 @@ public abstract class InputsMergeCommand { private ActionStatus updateInputs(String containerId, List<InputDefinition> inputsToUpdate) { log.debug("#updateInputs - updating inputs for container {}", containerId); return toscaOperationFacade.updateInputsToComponent(inputsToUpdate, containerId) - .either(updatedInputs -> ActionStatus.OK, - componentsUtils::convertFromStorageResponse); + .either(updatedInputs -> ActionStatus.OK, componentsUtils::convertFromStorageResponse); } - } |