add artifacts support in TOSCA exported yml file
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / tosca / ToscaExportHandler.java
index 0d3836b..257ea36 100644 (file)
@@ -658,6 +658,9 @@ public class ToscaExportHandler {
         Map<String, ToscaGroupTemplate> groupsMap = null;
         for (ComponentInstance componentInstance : componentInstances) {
             ToscaNodeTemplate nodeTemplate = new ToscaNodeTemplate();
+            if (MapUtils.isNotEmpty(componentInstance.getToscaArtifacts())) {
+                nodeTemplate.setArtifacts(convertToNodeTemplateArtifacts(componentInstance.getToscaArtifacts()));
+            }
             nodeTemplate.setType(componentInstance.getToscaComponentName());
             nodeTemplate.setDirectives(componentInstance.getDirectives());
             nodeTemplate.setNode_filter(convertToNodeTemplateNodeFilterComponent(componentInstance.getNodeFilter()));
@@ -1249,6 +1252,19 @@ public class ToscaExportHandler {
         return Either.left(nodeType);
     }
 
+    private Map<String, ToscaTemplateArtifact> convertToNodeTemplateArtifacts(Map<String, ToscaArtifactDataDefinition> artifacts) {
+        if (artifacts == null) {
+            return null;
+        }
+        Map<String, ToscaTemplateArtifact> arts = new HashMap<>();
+        for (Map.Entry<String, ToscaArtifactDataDefinition> entry : artifacts.entrySet()) {
+           ToscaTemplateArtifact artifact = new ToscaTemplateArtifact();
+           artifact.setFile(entry.getValue().getFile());
+           artifact.setType(entry.getValue().getType());
+           arts.put(entry.getKey(), artifact);
+        }
+        return arts;
+    }
 
     protected NodeFilter convertToNodeTemplateNodeFilterComponent(CINodeFilterDataDefinition inNodeFilter) {
         if (inNodeFilter == null){