X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=catalog-be%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fsdc%2Fbe%2Ftosca%2FAttributeConverter.java;h=847947badd0e8a490f5465fe316dd096d0b6e08c;hb=5d7ca5c1e86d7633a1954ae89334df18d264f82b;hp=561480dd64eee82792d78156687f8b2f4967019a;hpb=116c4a25d915411617a3382db47e56930fb6a3ba;p=sdc.git diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java index 561480dd64..847947badd 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java @@ -16,6 +16,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ + package org.openecomp.sdc.be.tosca; import com.google.gson.JsonElement; @@ -27,6 +28,7 @@ import java.io.StringReader; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.onap.sdc.tosca.datatypes.model.EntrySchema; +import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; import org.openecomp.sdc.be.model.AttributeDefinition; import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.tosca.ToscaPropertyType; @@ -73,7 +75,14 @@ public class AttributeConverter { final ToscaAttribute toscaAttribute = new ToscaAttribute(); LOGGER.trace("Converting attribute '{}' from type '{}' with default value '{}'", attributeDefinition.getName(), attributeDefinition.getType(), attributeDefinition.getDefaultValue()); - toscaAttribute.setEntrySchema(convert(attributeDefinition.getEntry_schema())); + SchemaDefinition schema = attributeDefinition.getSchema(); + if (schema != null && schema.getProperty() != null && schema.getProperty().getType() != null + && StringUtils.isNotEmpty(schema.getProperty().getType())) { + final ToscaSchemaDefinition toscaSchemaDefinition = new ToscaSchemaDefinition(); + toscaSchemaDefinition.setType(schema.getProperty().getType()); + toscaSchemaDefinition.setDescription(schema.getProperty().getDescription()); + toscaAttribute.setEntrySchema(toscaSchemaDefinition); + } toscaAttribute.setType(attributeDefinition.getType()); toscaAttribute.setDescription(attributeDefinition.getDescription()); toscaAttribute.setStatus(attributeDefinition.getStatus()); @@ -88,16 +97,6 @@ public class AttributeConverter { return toscaAttribute; } - private ToscaSchemaDefinition convert(final EntrySchema entrySchema) { - if (entrySchema == null) { - return null; - } - final ToscaSchemaDefinition toscaSchemaDefinition = new ToscaSchemaDefinition(); - toscaSchemaDefinition.setType(entrySchema.getType()); - toscaSchemaDefinition.setDescription(entrySchema.getDescription()); - return toscaSchemaDefinition; - } - private Object convertToToscaObject(final AttributeDefinition attributeDefinition, String value, final boolean preserveEmptyValue) { @@ -140,7 +139,8 @@ public class AttributeConverter { return toscaMapValueConverter.handleComplexJsonValue(valueAsJson); } //if it is a data type - return toscaMapValueConverter.convertDataTypeToToscaObject(innerType, dataTypes, null, false, valueAsJson, preserveEmptyValue); + return toscaMapValueConverter.convertDataTypeToToscaObject(innerType, dataTypes, null, false, valueAsJson, + preserveEmptyValue, false); } catch (final JsonParseException e) { final String errorMsg = "Failed to parse json value"; LOGGER.error(EcompLoggerErrorCode.SCHEMA_ERROR, "Attribute Converter", errorMsg, e); @@ -173,8 +173,8 @@ public class AttributeConverter { public void convertAndAddValue(final Map attribs, final AttributeDefinition attribute) { - final Object convertedValue = convertToToscaObject(attribute, attribute.getDefaultValue(), false); - if (!ToscaValueBaseConverter.isEmptyObjectValue(convertedValue)) { + final Object convertedValue = convertToToscaObject(attribute, attribute.getValue(), false); + if (!ToscaValueBaseConverter.isEmptyObjectValue(convertedValue) && !attribute.isGetOutputAttribute()) { attribs.put(attribute.getName(), convertedValue); } }