Provide user to specify the ouput name while declaring the atrributes
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / components / attribute / DefaultAttributeDeclarator.java
index 79bfcc6..e494934 100644 (file)
@@ -25,7 +25,6 @@ import com.google.gson.Gson;
 import fj.data.Either;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -120,7 +119,13 @@ public abstract class DefaultAttributeDeclarator<PROPERTYOWNER extends Propertie
             //Creating input from property create on self using add property..Do not add the prefix
             generatedInputPrefix = null;
         }
-        final String generatedOutputName = generateOutputName(generatedInputPrefix, attribOutput);
+        String generatedOutputName = null;
+        if (StringUtils.isNotEmpty(attribOutput.getOutputName())) {
+            generatedOutputName = attribOutput.getOutputName();
+        } else {
+            generatedOutputName = generateOutputName(generatedInputPrefix, attribOutput);
+        }
+
         log.debug("createInput: propOwner.uniqueId={}, attribOutput.parentUniqueId={}", propertiesOwner.getUniqueId(),
             attribOutput.getParentUniqueId());
         return createOutputFromAttribute(component.getUniqueId(), propertiesOwner, generatedOutputName, attribOutput, attributeDataDefinition);
@@ -182,7 +187,7 @@ public abstract class DefaultAttributeDeclarator<PROPERTYOWNER extends Propertie
         outputDefinition.setOutputPath(attributesName);
         outputDefinition.setInstanceUniqueId(propertiesOwner.getUniqueId());
         outputDefinition.setAttributeId(attributeOutput.getUniqueId());
-        outputDefinition.setAttributes(Arrays.asList(attributeOutput));
+        outputDefinition.setAttribute(attributeOutput);
         if (attribute instanceof IComponentInstanceConnectedElement) {
             ((IComponentInstanceConnectedElement) attribute).setComponentInstanceId(propertiesOwner.getUniqueId());
             ((IComponentInstanceConnectedElement) attribute).setComponentInstanceName(propertiesOwner.getName());
@@ -201,7 +206,7 @@ public abstract class DefaultAttributeDeclarator<PROPERTYOWNER extends Propertie
                 attributeDataDefinition.setValue(jsonObject.toJSONString());
             } else {
                 jsonObject
-                    .put(GET_ATTRIBUTE, Arrays.asList(output.getAttributes().get(0).getComponentInstanceName(), attributeDataDefinition.getName()));
+                    .put(GET_ATTRIBUTE, Arrays.asList(output.getAttribute().getComponentInstanceName(), attributeDataDefinition.getName()));
                 output.setValue(jsonObject.toJSONString());
             }
         } else {
@@ -209,7 +214,7 @@ public abstract class DefaultAttributeDeclarator<PROPERTYOWNER extends Propertie
             if (objValue instanceof Map || objValue instanceof List) {
                 if (!complexProperty) {
                     jsonObject.put(GET_ATTRIBUTE,
-                        Arrays.asList(output.getAttributes().get(0).getComponentInstanceName(), attributeDataDefinition.getName()));
+                        Arrays.asList(output.getAttribute().getComponentInstanceName(), attributeDataDefinition.getName()));
                     output.setValue(jsonObject.toJSONString());
                 } else {
                     final Map<String, Object> mappedToscaTemplate = (Map<String, Object>) objValue;
@@ -218,7 +223,7 @@ public abstract class DefaultAttributeDeclarator<PROPERTYOWNER extends Propertie
                 }
             } else {
                 jsonObject
-                    .put(GET_ATTRIBUTE, Arrays.asList(output.getAttributes().get(0).getComponentInstanceName(), attributeDataDefinition.getName()));
+                    .put(GET_ATTRIBUTE, Arrays.asList(output.getAttribute().getComponentInstanceName(), attributeDataDefinition.getName()));
                 output.setValue(jsonObject.toJSONString());
             }
         }