From fe4afd47955705bb377583649cb53e2cf4508493 Mon Sep 17 00:00:00 2001 From: talio Date: Sun, 14 Apr 2019 15:37:20 +0300 Subject: Declare properties as policies Change-Id: I54dc7b444e08117097c314cf5f51bd356ac5287d Issue-ID: SDC-2240 Signed-off-by: talio --- catalog-model/pom.xml | 13 +- .../java/org/openecomp/sdc/be/model/Component.java | 82 +++++--- .../sdc/be/model/ComponentInstInputsMap.java | 56 ++---- .../sdc/be/model/ComponentParametersView.java | 208 ++++++++++++--------- .../openecomp/sdc/be/model/PolicyDefinition.java | 11 +- .../sdc/be/model/tosca/ToscaFunctions.java | 3 +- .../openecomp/sdc/be/model/tosca/ToscaType.java | 4 +- .../be/model/tosca/constraints/ConstraintUtil.java | 4 +- .../converters/DataTypePropertyConverter.java | 9 +- .../tosca/converters/ToscaConverterUtils.java | 6 + .../tosca/converters/ToscaMapValueConverter.java | 24 ++- .../sdc/be/model/ComponentInstInputsMapTest.java | 4 +- 12 files changed, 234 insertions(+), 190 deletions(-) (limited to 'catalog-model') diff --git a/catalog-model/pom.xml b/catalog-model/pom.xml index 994b2f7960..06b65915be 100644 --- a/catalog-model/pom.xml +++ b/catalog-model/pom.xml @@ -281,12 +281,17 @@ netty-handler - org.apache.commons - commons-collections4 - 4.1 + org.projectlombok + lombok + ${lombok.version} + + + joda-time + joda-time + ${joda.time.version} - + diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java index e33ded2fb4..65ad149a89 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java @@ -39,28 +39,18 @@ import java.util.stream.Collectors; import org.apache.commons.collections.MapUtils; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.utils.MapUtil; -import org.openecomp.sdc.be.datatypes.elements.*; +import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.PolicyTargetType; +import org.openecomp.sdc.be.datatypes.elements.PropertiesOwner; +import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.model.category.CategoryDefinition; import org.openecomp.sdc.be.model.category.SubCategoryDefinition; import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElementTypeEnum; import org.openecomp.sdc.common.api.ArtifactTypeEnum; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import static java.util.Collections.emptyList; -import static java.util.Collections.emptyMap; -import static java.util.stream.Collectors.toMap; -import static org.apache.commons.collections.CollectionUtils.isEmpty; -import static org.apache.commons.collections.MapUtils.isEmpty; - public abstract class Component implements PropertiesOwner { private ComponentMetadataDefinition componentMetadataDefinition; @@ -83,9 +73,11 @@ public abstract class Component implements PropertiesOwner { private String derivedFromGenericVersion; private String toscaType; protected List additionalInformation; + private Map nodeFilterComponents; + private Map> nodeFilters; + private Map> serviceFilters; protected List properties; private Map interfaces; - private Map nodeFilterComponents; public Map getInterfaces() { return interfaces; @@ -567,6 +559,42 @@ public abstract class Component implements PropertiesOwner { this.policies = policies; } + public void addPolicy(PolicyDefinition policyDefinition) { + if(MapUtils.isEmpty(this.policies)) { + this.policies = new HashMap<>(); + } + + this.policies.put(policyDefinition.getUniqueId(), policyDefinition); + } + + public Map getNodeFilterComponents() { + return nodeFilterComponents; + } + + public void setNodeFilterComponents(Map nodeFilter) { + this.nodeFilterComponents = nodeFilter; + } + + + + public Map> getNodeFilters() { + return nodeFilters; + } + + public void setNodeFilters( + Map> nodeFilters) { + this.nodeFilters = nodeFilters; + } + + public Map> getServiceFilters() { + return serviceFilters; + } + + public void setServiceFilters( + Map> serviceFilters) { + this.serviceFilters = serviceFilters; + } + public List getProperties() { return properties; } @@ -575,6 +603,14 @@ public abstract class Component implements PropertiesOwner { this.properties = properties; } + public void addProperty(PropertyDefinition propertyDefinition) { + if(org.apache.commons.collections.CollectionUtils.isEmpty(this.properties)) { + this.properties = new ArrayList<>(); + } + + this.properties.add(propertyDefinition);; + } + @Override public int hashCode() { final int prime = 31; @@ -582,11 +618,7 @@ public abstract class Component implements PropertiesOwner { result = prime * result + ((artifacts == null) ? 0 : artifacts.hashCode()); result = prime * result + ((categories == null) ? 0 : categories.hashCode()); result = prime * result + ((componentMetadataDefinition == null) ? 0 : componentMetadataDefinition.hashCode()); -// result = prime * result + ((creatorUserId == null) ? 0 : creatorUserId.hashCode()); -// result = prime * result + ((creatorFullName == null) ? 0 : creatorFullName.hashCode()); result = prime * result + ((deploymentArtifacts == null) ? 0 : deploymentArtifacts.hashCode()); -// result = prime * result + ((lastUpdaterUserId == null) ? 0 : lastUpdaterUserId.hashCode()); -// result = prime * result + ((lastUpdaterFullName == null) ? 0 : lastUpdaterFullName.hashCode()); result = prime * result + ((capabilities == null) ? 0 : capabilities.hashCode()); result = prime * result + ((requirements == null) ? 0 : requirements.hashCode()); result = prime * result + ((componentInstances == null) ? 0 : componentInstances.hashCode()); @@ -604,14 +636,6 @@ public abstract class Component implements PropertiesOwner { return result; } - public Map getNodeFilterComponents() { - return nodeFilterComponents; - } - - public void setNodeFilterComponents(Map nodeFilterComponents) { - this.nodeFilterComponents = nodeFilterComponents; - } - @Override public boolean equals(Object obj) { if (this == obj) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstInputsMap.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstInputsMap.java index 9d0877d8f9..a7903b3f30 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstInputsMap.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstInputsMap.java @@ -20,6 +20,8 @@ package org.openecomp.sdc.be.model; +import lombok.Getter; +import lombok.Setter; import org.apache.commons.lang3.tuple.Pair; import java.util.List; @@ -27,6 +29,8 @@ import java.util.Map; import static org.apache.commons.collections.MapUtils.isNotEmpty; +@Getter +@Setter public class ComponentInstInputsMap { private Map> componentInstanceInputsMap; @@ -34,6 +38,8 @@ public class ComponentInstInputsMap { private Map> serviceProperties; private Map> policyProperties; private Map> groupProperties; + private Map> componentPropertiesToPolicies; + private Map> componentInstancePropertiesToPolicies; public Pair> resolvePropertiesToDeclare() { if (isNotEmpty(componentInstanceInputsMap)) { @@ -51,6 +57,12 @@ public class ComponentInstInputsMap { if (isNotEmpty(groupProperties)) { return singleMapEntry(groupProperties); } + if(isNotEmpty(componentPropertiesToPolicies)) { + return singleMapEntry(componentPropertiesToPolicies); + } + if (isNotEmpty(componentInstancePropertiesToPolicies)) { + return singleMapEntry(componentInstancePropertiesToPolicies); + } throw new IllegalStateException("there are no properties selected for declaration"); } @@ -58,48 +70,4 @@ public class ComponentInstInputsMap { Map.Entry> singleEntry = propertiesMap.entrySet().iterator().next(); return Pair.of(singleEntry.getKey(), singleEntry.getValue()); } - - public Map> getComponentInstanceInputsMap() { - return componentInstanceInputsMap; - } - - public void setComponentInstanceInputsMap(Map> componentInstanceInputsMap) { - this.componentInstanceInputsMap = componentInstanceInputsMap; - } - - public Map> getComponentInstanceProperties() { - return componentInstanceProperties; - } - - public void setComponentInstancePropInput(Map> componentInstanceProperties) { - this.componentInstanceProperties = componentInstanceProperties; - } - - public Map> getPolicyProperties() { - return policyProperties; - } - - public void setPolicyProperties(Map> policyProperties) { - this.policyProperties = policyProperties; - } - - public Map> getServiceProperties() { - return serviceProperties; - } - - public void setServiceProperties( - Map> serviceProperties) { - this.serviceProperties = serviceProperties; - } - - public Map> getGroupProperties() { - return groupProperties; - } - - public void setGroupProperties(Map> groupProperties) { - this.groupProperties = groupProperties; - } - - - } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java index 35b4a865a1..05d9a572a3 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java @@ -20,12 +20,11 @@ package org.openecomp.sdc.be.model; +import java.util.List; import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum; import org.openecomp.sdc.be.datatypes.enums.ComponentFieldsEnum; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -import java.util.List; - public class ComponentParametersView { private boolean ignoreUsers = false; @@ -40,6 +39,7 @@ public class ComponentParametersView { private boolean ignoreAdditionalInformation = false; private boolean ignoreArtifacts = false; private boolean ignoreInterfaces = false; + private boolean ignoreInterfaceInstances = false; private boolean ignoreComponentInstancesInterfaces = false; private boolean ignoreDerivedFrom = false; private boolean ignoreAttributesFrom = false; @@ -49,6 +49,7 @@ public class ComponentParametersView { private boolean ignoreCapabiltyProperties = true; private boolean ignoreServicePath = true; private boolean ignorePolicies = false; + private boolean ignoreNodeFilterRequirements = false; private boolean ignoreNodeFilter = false; public ComponentParametersView() { @@ -146,6 +147,7 @@ public class ComponentParametersView { this.setIgnorePolicies(false); break; case NODE_FILTER: + this.setIgnoreNodeFilterRequirements(false); this.setIgnoreNodeFilter(false); break; case COMPONENT_INSTANCES_INTERFACES: @@ -165,96 +167,120 @@ public class ComponentParametersView { public Component filter(Component component, ComponentTypeEnum componentType) { - if (ignoreUsers) { - component.setCreatorUserId(null); - component.setCreatorFullName(null); - component.setLastUpdaterUserId(null); - component.setLastUpdaterFullName(null); - } - if (ignoreGroups) { - component.setGroups(null); - } - if (ignoreComponentInstances) { - component.setComponentInstances(null); - component.setComponentInstancesRelations(null); - } - if (ignoreComponentInstancesProperties) { - component.setComponentInstancesProperties(null); - } - if (ignoreProperties && componentType == ComponentTypeEnum.RESOURCE) { - ((Resource) component).setProperties(null); - } - if (ignoreCapabilities) { - component.setCapabilities(null); - } - if (ignoreRequirements) { - component.setRequirements(null); - } - if (ignoreCategories) { - component.setCategories(null); - } - if (ignoreAllVersions) { - component.setAllVersions(null); - } - if (ignoreAdditionalInformation && componentType == ComponentTypeEnum.RESOURCE) { - ((Resource) component).setAdditionalInformation(null); - } - if (ignoreArtifacts) { - component.setArtifacts(null); - component.setSpecificComponetTypeArtifacts(null); - component.setDeploymentArtifacts(null); - component.setToscaArtifacts(null); - } - if (ignoreInterfaces && componentType == ComponentTypeEnum.RESOURCE) { - ((Resource) component).setInterfaces(null); - } - if (ignoreDerivedFrom && componentType == ComponentTypeEnum.RESOURCE) { - ((Resource) component).setDerivedFrom(null); - } - if (ignoreAttributesFrom && componentType == ComponentTypeEnum.RESOURCE) { - ((Resource) component).setAttributes(null); - } - if (ignoreComponentInstancesAttributesFrom) { - component.setComponentInstancesAttributes(null); - } - if (ignoreInputs) { - component.setInputs(null); - } - if (ignoreComponentInstancesInputs) { - component.setComponentInstancesInputs(null); - } - if (ignoreServicePath && componentType == ComponentTypeEnum.SERVICE) { - ((Service) component).setForwardingPaths(null); - } - if (ignoreNodeFilter){ - component.setNodeFilterComponents(null); - } - return component; - } - - public void disableAll() { - ignoreUsers = true; - ignoreGroups = true; - ignorePolicies = true; - ignoreComponentInstances = true; - ignoreComponentInstancesProperties = true; - ignoreProperties = true; - ignoreCapabilities = true; - ignoreRequirements = true; - ignoreCategories = true; - ignoreAllVersions = true; - ignoreAdditionalInformation = true; - ignoreArtifacts = true; - ignoreInterfaces = true; - ignoreDerivedFrom = true; - ignoreAttributesFrom = true; - ignoreInputs = true; - ignoreComponentInstancesAttributesFrom = true; - ignoreComponentInstancesInputs = true; - ignoreCapabiltyProperties = true; - ignoreServicePath = true; + if (ignoreUsers) { + component.setCreatorUserId(null); + component.setCreatorFullName(null); + component.setLastUpdaterUserId(null); + component.setLastUpdaterFullName(null); + } + + if (ignoreGroups) { + component.setGroups(null); + } + + if (ignoreComponentInstances) { + component.setComponentInstances(null); + component.setComponentInstancesRelations(null); + } + + if (ignoreComponentInstancesProperties) { + component.setComponentInstancesProperties(null); + } + + if (ignoreProperties && componentType == ComponentTypeEnum.RESOURCE) { + ((Resource) component).setProperties(null); + } + + if (ignoreCapabilities) { + component.setCapabilities(null); + } + + if (ignoreRequirements) { + component.setRequirements(null); + } + + if (ignoreCategories) { + component.setCategories(null); + } + + if (ignoreAllVersions) { + component.setAllVersions(null); + } + if (ignoreAdditionalInformation && componentType == ComponentTypeEnum.RESOURCE) { + ((Resource) component).setAdditionalInformation(null); + } + + if (ignoreArtifacts) { + component.setArtifacts(null); + component.setSpecificComponetTypeArtifacts(null); + component.setDeploymentArtifacts(null); + component.setToscaArtifacts(null); + } + if (ignoreNodeFilterRequirements){ + component.setNodeFilterComponents(null); + } + if (ignoreInterfaces && ignoreInterfaceInstances && + componentType == ComponentTypeEnum.RESOURCE) { + component.setInterfaces(null); + } + if (ignoreDerivedFrom && componentType == ComponentTypeEnum.RESOURCE) { + ((Resource) component).setDerivedFrom(null); + } + if (ignoreAttributesFrom && componentType == ComponentTypeEnum.RESOURCE) { + ((Resource) component).setAttributes(null); + } + if (ignoreComponentInstancesAttributesFrom) { + component.setComponentInstancesAttributes(null); + } + if (ignoreInputs) { + component.setInputs(null); + } + if (ignoreComponentInstancesInputs) { + component.setComponentInstancesInputs(null); + } + if (ignoreServicePath && componentType == ComponentTypeEnum.SERVICE) { + ((Service) component).setForwardingPaths(null); + } + if (ignoreNodeFilter){ + component.setNodeFilterComponents(null); + } + return component; + + } + + public boolean isIgnoreNodeFilterRequirements() { + return ignoreNodeFilterRequirements; + } + + public void setIgnoreNodeFilterRequirements(boolean ignoreNodeFilter) { + this.ignoreNodeFilterRequirements = ignoreNodeFilter; + } + + public void disableAll() { + ignoreUsers = true; + ignoreGroups = true; + ignorePolicies = true; + ignoreComponentInstances = true; + ignoreComponentInstancesProperties = true; + ignoreProperties = true; + ignoreCapabilities = true; + ignoreRequirements = true; + ignoreCategories = true; + ignoreAllVersions = true; + ignoreAdditionalInformation = true; + ignoreArtifacts = true; + ignoreInterfaces = true; + ignoreInterfaceInstances = true; + ignoreDerivedFrom = true; + ignoreAttributesFrom = true; + ignoreInputs = true; + ignoreComponentInstancesAttributesFrom = true; + ignoreComponentInstancesInputs = true; + ignoreCapabiltyProperties = true; + ignoreServicePath = true; + ignoreNodeFilterRequirements = true; ignoreNodeFilter = true; - } + } public boolean isIgnoreGroups() { return ignoreGroups; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/PolicyDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/PolicyDefinition.java index 17e422bc5b..e69bf3f16b 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/PolicyDefinition.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/PolicyDefinition.java @@ -1,12 +1,11 @@ package org.openecomp.sdc.be.model; -import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.PropertiesOwner; -import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; - import java.util.HashMap; import java.util.Map; import java.util.stream.Collectors; +import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.PropertiesOwner; +import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; /** * public class representing the component policy */ @@ -19,6 +18,10 @@ public class PolicyDefinition extends PolicyDataDefinition implements Properties super(); } + public PolicyDefinition(PropertyDataDefinition propertyDataDefinition) { + super(propertyDataDefinition); + } + /** * public constructor from superclass * @param policy diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaFunctions.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaFunctions.java index 1f55fecc86..6e52976a42 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaFunctions.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaFunctions.java @@ -7,7 +7,8 @@ public enum ToscaFunctions { GET_INPUT("get_input"), GET_PROPERTY("get_property"), - GET_OPERATION_OUTPUT("get_operation_output"); + GET_OPERATION_OUTPUT("get_operation_output"), + GET_POLICY("get_policy"); private String functionName; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaType.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaType.java index 6384146df9..04b6874f93 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaType.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaType.java @@ -20,6 +20,8 @@ package org.openecomp.sdc.be.model.tosca; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.text.DateFormat; import java.text.ParseException; @@ -27,8 +29,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.type.TypeReference; import org.openecomp.sdc.be.model.tosca.constraints.ConstraintUtil; import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java index 0bbc0f755f..188ad1b5c7 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/constraints/ConstraintUtil.java @@ -20,14 +20,14 @@ package org.openecomp.sdc.be.model.tosca.constraints; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.io.IOException; import java.lang.reflect.InvocationTargetException; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.type.TypeReference; import org.openecomp.sdc.be.model.tosca.ToscaType; import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException; import org.slf4j.Logger; diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/DataTypePropertyConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/DataTypePropertyConverter.java index f3b842e0cf..7f11330bdf 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/DataTypePropertyConverter.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/DataTypePropertyConverter.java @@ -5,14 +5,13 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.stream.JsonReader; -import org.openecomp.sdc.be.model.DataTypeDefinition; -import org.openecomp.sdc.be.model.PropertyDefinition; -import org.openecomp.sdc.common.util.JsonUtils; - import java.io.StringReader; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.openecomp.sdc.be.model.DataTypeDefinition; +import org.openecomp.sdc.be.model.PropertyDefinition; +import org.openecomp.sdc.common.util.JsonUtils; public class DataTypePropertyConverter { @@ -52,7 +51,7 @@ public class DataTypePropertyConverter { } private void mergeDefaultValuesRec(JsonObject defaultValue, JsonObject value) { - if (ToscaConverterUtils.isGetInputValue(value)) { + if (ToscaConverterUtils.isGetInputValue(value) || ToscaConverterUtils.isGetPolicyValue(value)) { return; } for (Map.Entry defVal : defaultValue.entrySet()) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaConverterUtils.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaConverterUtils.java index 941535a09d..5848abfc49 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaConverterUtils.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaConverterUtils.java @@ -5,8 +5,14 @@ import org.openecomp.sdc.be.model.tosca.ToscaFunctions; public class ToscaConverterUtils { + private ToscaConverterUtils() {} + public static boolean isGetInputValue(JsonObject value) { return value.get(ToscaFunctions.GET_INPUT.getFunctionName()) != null; } + public static boolean isGetPolicyValue(JsonObject value) { + return value.get(ToscaFunctions.GET_POLICY.getFunctionName()) != null; + } + } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java index 04636d87e0..f0b3ca25b9 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java @@ -20,18 +20,27 @@ package org.openecomp.sdc.be.model.tosca.converters; -import com.google.gson.*; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; import com.google.gson.stream.JsonReader; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; +import org.openecomp.sdc.be.model.tosca.ToscaFunctions; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; import org.openecomp.sdc.common.log.wrappers.Logger; -import java.io.StringReader; -import java.util.*; -import java.util.Map.Entry; - public class ToscaMapValueConverter extends ToscaValueBaseConverter implements ToscaValueConverter { private static ToscaMapValueConverter mapConverter = new ToscaMapValueConverter(); @@ -230,7 +239,7 @@ public class ToscaMapValueConverter extends ToscaValueBaseConverter implements T convValue = handleComplexJsonValue(elementValue); } } - if(preserveEmptyValue || !isEmptyObjectValue(convValue)){ + if(preserveEmptyValue || !isEmptyObjectValue(convValue) || isGetPolicyValue(propName)){ toscaObjectPresentation.put(propName, convValue); } } @@ -238,4 +247,7 @@ public class ToscaMapValueConverter extends ToscaValueBaseConverter implements T return convertedValue; } + private boolean isGetPolicyValue(String key) { + return key.equals(ToscaFunctions.GET_POLICY.getFunctionName()); + } } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstInputsMapTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstInputsMapTest.java index 95247c7cd4..43f7f0c1cb 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstInputsMapTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstInputsMapTest.java @@ -51,7 +51,7 @@ public class ComponentInstInputsMapTest { // default test testSubject = createTestSubject(); - testSubject.setComponentInstancePropInput(componentInstanceProperties); + testSubject.setComponentInstanceProperties(componentInstanceProperties); } @Test @@ -80,7 +80,7 @@ public class ComponentInstInputsMapTest { testSubject.setComponentInstanceInputsMap(inputs); testSubject.resolvePropertiesToDeclare(); testSubject = createTestSubject(); - testSubject.setComponentInstancePropInput(inputs); + testSubject.setComponentInstanceProperties(inputs); testSubject.resolvePropertiesToDeclare(); testSubject = createTestSubject(); testSubject.setPolicyProperties(inputs); -- cgit 1.2.3-korg