diff options
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp/sdc/be/components/property/propertytopolicydeclarators/ComponentInstancePropertyToPolicyDeclarator.java')
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/components/property/propertytopolicydeclarators/ComponentInstancePropertyToPolicyDeclarator.java | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/propertytopolicydeclarators/ComponentInstancePropertyToPolicyDeclarator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/propertytopolicydeclarators/ComponentInstancePropertyToPolicyDeclarator.java index f8e0ea0912..c07821066a 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/propertytopolicydeclarators/ComponentInstancePropertyToPolicyDeclarator.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/propertytopolicydeclarators/ComponentInstancePropertyToPolicyDeclarator.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,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdc.be.components.property.propertytopolicydeclarators; import fj.data.Either; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Optional; import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic; import org.openecomp.sdc.be.components.impl.PropertyBusinessLogic; import org.openecomp.sdc.be.components.property.DefaultPropertyDeclarator; @@ -35,22 +38,16 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.PropertyOperation; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Optional; - @org.springframework.stereotype.Component -public class ComponentInstancePropertyToPolicyDeclarator extends - DefaultPropertyDeclarator<ComponentInstance, ComponentInstanceProperty> { +public class ComponentInstancePropertyToPolicyDeclarator extends DefaultPropertyDeclarator<ComponentInstance, ComponentInstanceProperty> { - private ToscaOperationFacade toscaOperationFacade; PropertyBusinessLogic propertyBl; + private ToscaOperationFacade toscaOperationFacade; private ComponentInstanceBusinessLogic componentInstanceBl; - public ComponentInstancePropertyToPolicyDeclarator(ComponentsUtils componentsUtils, - PropertyOperation propertyOperation, ToscaOperationFacade toscaOperationFacade, - PropertyBusinessLogic propertyBl, ComponentInstanceBusinessLogic componentInstanceBl) { + public ComponentInstancePropertyToPolicyDeclarator(ComponentsUtils componentsUtils, PropertyOperation propertyOperation, + ToscaOperationFacade toscaOperationFacade, PropertyBusinessLogic propertyBl, + ComponentInstanceBusinessLogic componentInstanceBl) { super(componentsUtils, propertyOperation); this.toscaOperationFacade = toscaOperationFacade; this.propertyBl = propertyBl; @@ -64,9 +61,8 @@ public class ComponentInstancePropertyToPolicyDeclarator extends @Override protected Either<?, StorageOperationStatus> updatePropertiesValues(Component component, String componentInstanceId, - List<ComponentInstanceProperty> properties) { - Map<String, List<ComponentInstanceProperty>> - instProperties = Collections.singletonMap(componentInstanceId, properties); + List<ComponentInstanceProperty> properties) { + Map<String, List<ComponentInstanceProperty>> instProperties = Collections.singletonMap(componentInstanceId, properties); return toscaOperationFacade.addComponentInstancePropertiesToComponent(component, instProperties); } @@ -92,16 +88,10 @@ public class ComponentInstancePropertyToPolicyDeclarator extends @Override public StorageOperationStatus unDeclarePropertiesAsPolicies(Component component, PolicyDefinition policy) { - - Optional<ComponentInstanceProperty> propertyCandidate = - componentInstanceBl.getComponentInstancePropertyByPolicyId(component, policy); - - - if(propertyCandidate.isPresent()) { - return toscaOperationFacade - .updateComponentInstanceProperty(component, policy.getInstanceUniqueId(), propertyCandidate.get()); + Optional<ComponentInstanceProperty> propertyCandidate = componentInstanceBl.getComponentInstancePropertyByPolicyId(component, policy); + if (propertyCandidate.isPresent()) { + return toscaOperationFacade.updateComponentInstanceProperty(component, policy.getInstanceUniqueId(), propertyCandidate.get()); } - return StorageOperationStatus.OK; } } |