Support node template artifact properties 25/126625/3
authorJvD_Ericsson <jeff.van.dam@est.tech>
Tue, 18 Jan 2022 10:17:58 +0000 (10:17 +0000)
committerMichael Morris <michael.morris@est.tech>
Fri, 21 Jan 2022 22:20:14 +0000 (22:20 +0000)
Add properties variable to relevant classes and update functions to set these vaules
Added properties to an artifact in ETSI-VNF-SAMPLE.csar

Issue-ID: SDC-3847
Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
Change-Id: Id4f835826be7556cd97403da2018644c6dfea95b

catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadArtifactInfo.java
common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaArtifactDataDefinition.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/ArtifactDefinition.java
integration-tests/src/test/resources/Files/ETSI/ETSI-VNF-SAMPLE.csar

index a991f7e..3faf750 100644 (file)
@@ -832,6 +832,13 @@ public class YamlTemplateParsingHandler {
         if (nodeTemplateJsonMap.containsKey(FILE.getElementName())) {
             artifactTemplateInfo.setFile((String) nodeTemplateJsonMap.get(FILE.getElementName()));
         }
+        if (nodeTemplateJsonMap.containsKey(PROPERTIES.getElementName())) {
+            Map<String, List<UploadPropInfo>> props = buildPropModuleFromYaml(nodeTemplateJsonMap);
+            if (!props.isEmpty()) {
+                List<UploadPropInfo> properties = props.values().stream().flatMap(Collection::stream).collect(toList());
+                artifactTemplateInfo.setProperties(properties);
+            }
+        }
     }
 
     @SuppressWarnings("unchecked")
index 6665299..8c97a04 100644 (file)
@@ -3409,6 +3409,14 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
                 ToscaArtifactDataDefinition to = new ToscaArtifactDataDefinition();
                 to.setFile(entry.getValue().getFile());
                 to.setType(entry.getValue().getType());
+                if(isNotEmpty(entry.getValue().getProperties())) {
+                    Map<String, Object> newPropertiesMap = new HashMap<>();
+                    List<UploadPropInfo> artifactPropsInfo = entry.getValue().getProperties();
+                    for(UploadPropInfo propInfo: artifactPropsInfo) {
+                        newPropertiesMap.put(propInfo.getName(), propInfo.getValue());
+                    }
+                    to.setProperties(newPropertiesMap);
+                }
                 toscaArtifacts.put(entry.getKey(), to);
             }
             componentInstance.setToscaArtifacts(toscaArtifacts);
index cdd5d60..b6bd2a3 100644 (file)
@@ -1548,6 +1548,7 @@ public class ToscaExportHandler {
             ToscaTemplateArtifact artifact = new ToscaTemplateArtifact();
             artifact.setFile(entry.getValue().getFile());
             artifact.setType(entry.getValue().getType());
+            artifact.setProperties(entry.getValue().getProperties());
             arts.put(entry.getKey(), artifact);
         }
         return arts;
index 894a806..9824552 100644 (file)
@@ -22,10 +22,13 @@ package org.openecomp.sdc.be.tosca.model;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.Map;
+
 @Getter
 @Setter
 public class ToscaTemplateArtifact {
 
     private String file;
     private String type;
+    private Map<String, Object> properties;
 }
index 183f18c..33fbc4a 100644 (file)
@@ -33,4 +33,5 @@ public class UploadArtifactInfo extends UploadInfo {
     private List<String> validSourceTypes;
     private String file;
     private String type;
+    private List<UploadPropInfo> properties;
 }
index 554d37e..64c7bf0 100644 (file)
@@ -22,10 +22,13 @@ package org.openecomp.sdc.be.datatypes.elements;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.Map;
+
 @Getter
 @Setter
 public class ToscaArtifactDataDefinition {
 
     private String file;
     private String type;
+    private Map<String, Object> properties;
 }
index 90809f0..ee6bbd0 100644 (file)
@@ -22,6 +22,8 @@ package org.onap.sdc.tosca.datatypes.model;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.Map;
+
 @Getter
 @Setter
 public class ArtifactDefinition {
@@ -31,4 +33,5 @@ public class ArtifactDefinition {
     private String repository;
     private String description;
     private String deploy_path;
+    private Map<String, Object> properties;
 }
index 20ea03b..85ce2c6 100644 (file)
Binary files a/integration-tests/src/test/resources/Files/ETSI/ETSI-VNF-SAMPLE.csar and b/integration-tests/src/test/resources/Files/ETSI/ETSI-VNF-SAMPLE.csar differ