summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.java52
1 files changed, 25 insertions, 27 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.java
index 3058835801..d8b5020046 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInputsMergeBL.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,10 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.components.merge.instance;
+import static org.openecomp.sdc.be.components.merge.resource.ResourceDataMergeBusinessLogic.ANY_ORDER_COMMAND;
+
import fj.data.Either;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
import org.openecomp.sdc.be.components.merge.VspComponentsMergeCommand;
import org.openecomp.sdc.be.components.merge.property.DataDefinitionsValuesMergingBusinessLogic;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -33,13 +38,6 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.springframework.core.annotation.Order;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import static org.openecomp.sdc.be.components.merge.resource.ResourceDataMergeBusinessLogic.ANY_ORDER_COMMAND;
-
@org.springframework.stereotype.Component
@Order(ANY_ORDER_COMMAND)
public class ComponentInstanceInputsMergeBL implements VspComponentsMergeCommand {
@@ -48,7 +46,8 @@ public class ComponentInstanceInputsMergeBL implements VspComponentsMergeCommand
private final ComponentsUtils componentsUtils;
private final DataDefinitionsValuesMergingBusinessLogic propertyValuesMergingBusinessLogic;
- public ComponentInstanceInputsMergeBL(ToscaOperationFacade toscaOperationFacade, ComponentsUtils componentsUtils, DataDefinitionsValuesMergingBusinessLogic propertyValuesMergingBusinessLogic) {
+ public ComponentInstanceInputsMergeBL(ToscaOperationFacade toscaOperationFacade, ComponentsUtils componentsUtils,
+ DataDefinitionsValuesMergingBusinessLogic propertyValuesMergingBusinessLogic) {
this.toscaOperationFacade = toscaOperationFacade;
this.componentsUtils = componentsUtils;
this.propertyValuesMergingBusinessLogic = propertyValuesMergingBusinessLogic;
@@ -60,7 +59,8 @@ public class ComponentInstanceInputsMergeBL implements VspComponentsMergeCommand
if (componentInstancesInputs == null) {
return ActionStatus.OK;
}
- componentInstancesInputs.forEach((instanceId, instInputs) -> mergeOldInstanceInputsValues(prevComponent, currentComponent, instanceId, instInputs));
+ componentInstancesInputs
+ .forEach((instanceId, instInputs) -> mergeOldInstanceInputsValues(prevComponent, currentComponent, instanceId, instInputs));
return updateComponentInstancesInputs(currentComponent, componentInstancesInputs);
}
@@ -69,31 +69,27 @@ public class ComponentInstanceInputsMergeBL implements VspComponentsMergeCommand
return "merge component instance inputs";
}
- public ActionStatus mergeComponentInstanceInputs(List<ComponentInstanceInput> oldInstProps, List<InputDefinition> oldInputs, Component newComponent, String instanceId) {
+ public ActionStatus mergeComponentInstanceInputs(List<ComponentInstanceInput> oldInstProps, List<InputDefinition> oldInputs,
+ Component newComponent, String instanceId) {
List<ComponentInstanceInput> newInstInputs = newComponent.safeGetComponentInstanceInput(instanceId);
if (newInstInputs == null) {
return ActionStatus.OK;
}
-
List<ComponentInstanceInput> oldRedeclaredInputs = findComponentInputs(oldInstProps);
- oldRedeclaredInputs.forEach(oldInput -> newInstInputs.stream()
- .filter(newInstInput -> oldInput.getName().equals(newInstInput.getName()))
- .forEach(this::switchValues));
-
+ oldRedeclaredInputs.forEach(
+ oldInput -> newInstInputs.stream().filter(newInstInput -> oldInput.getName().equals(newInstInput.getName())).forEach(this::switchValues));
propertyValuesMergingBusinessLogic.mergeInstanceDataDefinitions(oldInstProps, oldInputs, newInstInputs, newComponent.getInputs());
return updateComponentInstanceInputs(newComponent, instanceId, newInstInputs);
}
-
+
private void switchValues(ComponentInstanceInput input) {
String tempDefaultValue = input.getDefaultValue();
input.setDefaultValue(input.getValue());
input.setValue(tempDefaultValue);
}
-
+
private List<ComponentInstanceInput> findComponentInputs(List<ComponentInstanceInput> oldInstProps) {
- return oldInstProps.stream()
- .filter(ComponentInstanceInput::isGetInputProperty)
- .collect(Collectors.toList());
+ return oldInstProps.stream().filter(ComponentInstanceInput::isGetInputProperty).collect(Collectors.toList());
}
private ActionStatus updateComponentInstanceInputs(Component newComponent, String instanceId, List<ComponentInstanceInput> newInstInput) {
@@ -105,18 +101,20 @@ public class ComponentInstanceInputsMergeBL implements VspComponentsMergeCommand
}
private ActionStatus updateComponentInstancesInputs(Component component, Map<String, List<ComponentInstanceInput>> componentInstancesInputs) {
- Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus> mapStorageOperationStatusEither = toscaOperationFacade.updateComponentInstanceInputsToComponent(componentInstancesInputs, component.getUniqueId());
+ Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus> mapStorageOperationStatusEither = toscaOperationFacade
+ .updateComponentInstanceInputsToComponent(componentInstancesInputs, component.getUniqueId());
if (mapStorageOperationStatusEither.isRight()) {
return componentsUtils.convertFromStorageResponse(mapStorageOperationStatusEither.right().value());
}
return ActionStatus.OK;
}
- private void mergeOldInstanceInputsValues(Component oldComponent, Component newComponent, String instanceId, List<ComponentInstanceInput> instInputs) {
+ private void mergeOldInstanceInputsValues(Component oldComponent, Component newComponent, String instanceId,
+ List<ComponentInstanceInput> instInputs) {
ComponentInstance currentCompInstance = newComponent.getComponentInstanceById(instanceId).get();
- List<ComponentInstanceInput> oldInstInputs = oldComponent == null ? Collections.emptyList() : oldComponent.safeGetComponentInstanceInputsByName(currentCompInstance.getName());
+ List<ComponentInstanceInput> oldInstInputs =
+ oldComponent == null ? Collections.emptyList() : oldComponent.safeGetComponentInstanceInputsByName(currentCompInstance.getName());
List<InputDefinition> oldInputs = oldComponent == null ? Collections.emptyList() : oldComponent.getInputs();
propertyValuesMergingBusinessLogic.mergeInstanceDataDefinitions(oldInstInputs, oldInputs, instInputs, newComponent.getInputs());
}
-
}