add artifacts support in TOSCA exported yml file 32/87632/32
authorLiang Ding <liang.ding@intel.com>
Mon, 15 Apr 2019 07:05:05 +0000 (00:05 -0700)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Wed, 30 Oct 2019 07:56:21 +0000 (07:56 +0000)
Change-Id: I56f8a6a1ce758876e83a7ee8318b79644ae7d5cb
Issue-ID: SDC-1952
Signed-off-by: Liang Ding <liang.ding@intel.com>
15 files changed:
catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.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/ToscaNodeTemplate.java
catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java [new file with mode: 0644]
catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadArtifactInfo.java [new file with mode: 0644]
catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadComponentInstanceInfo.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java
common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ComponentInstanceDataDefinition.java
common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaArtifactDataDefinition.java [new file with mode: 0644]
common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java

index 7b3d4fa..cff6c26 100644 (file)
@@ -467,6 +467,7 @@ public class YamlTemplateParsingHandler {
                 setToscaResourceType(createdNodesToscaResourceNames, nodeTemplateInfo, nodeTemplateJsonMap);
                 setRequirements(nodeTemplateInfo, nodeTemplateJsonMap);
                 setCapabilities(nodeTemplateInfo, nodeTemplateJsonMap);
+                setArtifacts(nodeTemplateInfo, nodeTemplateJsonMap);
                 updateProperties(nodeTemplateInfo, nodeTemplateJsonMap);
                 setDirectives(nodeTemplateInfo, nodeTemplateJsonMap);
                 setNodeFilter(nodeTemplateInfo, nodeTemplateJsonMap);
@@ -515,6 +516,15 @@ public class YamlTemplateParsingHandler {
         }
     }
 
+    private void setArtifacts(UploadComponentInstanceInfo nodeTemplateInfo, Map<String, Object> nodeTemplateJsonMap) {
+        if (nodeTemplateJsonMap.containsKey(ARTIFACTS.getElementName())) {
+            Map<String, Map<String, UploadArtifactInfo>> eitherArtifactsRes = createArtifactsModuleFromYaml(nodeTemplateJsonMap);
+            if (!eitherArtifactsRes.isEmpty()) {
+                nodeTemplateInfo.setArtifacts(eitherArtifactsRes);
+            }
+        }
+    }
+
     private void setRequirements(UploadComponentInstanceInfo nodeTemplateInfo, Map<String, Object> nodeTemplateJsonMap) {
         if (nodeTemplateJsonMap.containsKey(REQUIREMENTS.getElementName())) {
             Map<String, List<UploadReqInfo>> regResponse = createReqModuleFromYaml(nodeTemplateJsonMap);
@@ -590,6 +600,63 @@ public class YamlTemplateParsingHandler {
         }
     }
 
+    @SuppressWarnings("unchecked")
+    private Map<String, Map<String, UploadArtifactInfo>> createArtifactsModuleFromYaml(Map<String, Object> nodeTemplateJsonMap) {
+        Map<String, Map<String, UploadArtifactInfo>> moduleArtifacts = new HashMap<>();
+        Either<List<Object>, ResultStatusEnum> ArtifactsListRes =
+                findFirstToscaListElement(nodeTemplateJsonMap, ARTIFACTS);
+        if (ArtifactsListRes.isLeft()) {
+            for (Object jsonArtifactObj : ArtifactsListRes.left().value()) {
+                String key = ((Map<String, Object>) jsonArtifactObj).keySet().iterator().next();
+                Object artifactJson = ((Map<String, Object>) jsonArtifactObj).get(key);
+                addModuleNodeTemplateArtifacts(moduleArtifacts, artifactJson, key);
+            }
+        } else {
+            Either<Map<String, Map<String, Object>>, ResultStatusEnum> ArtifactsMapRes =
+                    findFirstToscaMapElement(nodeTemplateJsonMap, ARTIFACTS);
+            if (ArtifactsMapRes.isLeft()) {
+                for (Map.Entry<String, Map<String, Object>> entry : ArtifactsMapRes.left().value().entrySet()) {
+                    String artifactName = entry.getKey();
+                    Object artifactJson = entry.getValue();
+                    addModuleNodeTemplateArtifacts(moduleArtifacts, artifactJson, artifactName);
+                }
+            }
+        }
+        return moduleArtifacts;
+    }
+
+    private void addModuleNodeTemplateArtifacts(Map<String, Map<String, UploadArtifactInfo>> moduleArtifacts, Object artifactJson, String artifactName) {
+
+        UploadArtifactInfo artifact = buildModuleNodeTemplateArtifact(artifactJson);
+        artifact.setName(artifactName);
+        if (moduleArtifacts.containsKey(ARTIFACTS.getElementName())) {
+            moduleArtifacts.get(ARTIFACTS.getElementName()).put(artifactName, artifact);
+        } else {
+            Map<String, UploadArtifactInfo> map = new HashMap<>();
+            map.put(artifactName, artifact);
+            moduleArtifacts.put(ARTIFACTS.getElementName(), map);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private UploadArtifactInfo buildModuleNodeTemplateArtifact(Object artifactObject) {
+        UploadArtifactInfo artifactTemplateInfo = new UploadArtifactInfo();
+        if (artifactObject instanceof Map) {
+            fillArtifact(artifactTemplateInfo, (Map<String, Object>) artifactObject);
+        }
+        return artifactTemplateInfo;
+    }
+
+    private void fillArtifact(UploadArtifactInfo artifactTemplateInfo, Map<String, Object> nodeTemplateJsonMap) {
+        if (nodeTemplateJsonMap.containsKey(TYPE.getElementName())) {
+            artifactTemplateInfo.setType((String) nodeTemplateJsonMap.get(TYPE.getElementName()));
+        }
+        if (nodeTemplateJsonMap.containsKey(FILE.getElementName())) {
+            artifactTemplateInfo.setFile((String) nodeTemplateJsonMap.get(FILE.getElementName()));
+        }
+    }
+
+
     @SuppressWarnings("unchecked")
     private Map<String, List<UploadCapInfo>> createCapModuleFromYaml(Map<String, Object> nodeTemplateJsonMap) {
         Map<String, List<UploadCapInfo>> moduleCap = new HashMap<>();
index 3d149f7..9eae363 100644 (file)
@@ -52,6 +52,7 @@ import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ToscaArtifactDataDefinition;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
@@ -388,8 +389,10 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
                 .equals(ArtifactTypeEnum.TOSCA_CSAR.getType()) && StringUtils.isEmpty(artifactInfo.getArtifactChecksum());
     }
 
-    public Either<Either<ArtifactDefinition, Operation>, ResponseFormat> generateAndSaveToscaArtifact(ArtifactDefinition artifactDefinition, org.openecomp.sdc.be.model.Component component, User user, boolean isInCertificationRequest,
-                                                                                                      boolean shouldLock, boolean inTransaction, boolean fetchTemplatesFromDB) {
+    public Either<Either<ArtifactDefinition, Operation>, ResponseFormat> generateAndSaveToscaArtifact(
+        ArtifactDefinition artifactDefinition, org.openecomp.sdc.be.model.Component component,
+        User user, boolean isInCertificationRequest, boolean shouldLock, boolean inTransaction,
+        boolean fetchTemplatesFromDB) {
 
         Either<Either<ArtifactDefinition, Operation>, ResponseFormat> generated = generateToscaArtifact(component, artifactDefinition, isInCertificationRequest, fetchTemplatesFromDB);
         if (generated.isRight()) {
index 5a99720..12345e7 100644 (file)
@@ -47,6 +47,7 @@ import java.util.Optional;
 import java.util.Set;
 import java.util.function.Function;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 import fj.data.Either;
 import org.apache.commons.codec.binary.Base64;
@@ -83,6 +84,7 @@ import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ToscaArtifactDataDefinition;
 import org.openecomp.sdc.be.datatypes.enums.ComponentFieldsEnum;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.CreatedFrom;
@@ -115,6 +117,7 @@ import org.openecomp.sdc.be.model.RelationshipInfo;
 import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
 import org.openecomp.sdc.be.model.RequirementDefinition;
 import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.UploadArtifactInfo;
 import org.openecomp.sdc.be.model.UploadCapInfo;
 import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
 import org.openecomp.sdc.be.model.UploadInfo;
@@ -3113,6 +3116,23 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
                     uploadComponentInstanceInfo.getCapabilities());
             componentInstance.setCapabilities(validComponentInstanceCapabilities);
         }
+
+        if (isNotEmpty(uploadComponentInstanceInfo.getArtifacts())) {
+            Map<String, Map<String, UploadArtifactInfo>> artifacts = uploadComponentInstanceInfo.getArtifacts();
+            Map<String, ToscaArtifactDataDefinition> toscaArtifacts = new HashMap<>();
+            Map<String, Map<String, UploadArtifactInfo>> arts = artifacts.entrySet().stream()
+                                       .filter(e -> e.getKey().contains(TypeUtils.ToscaTagNamesEnum.ARTIFACTS.getElementName()))
+                                        .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
+            Map<String, UploadArtifactInfo> artifact = arts.get(TypeUtils.ToscaTagNamesEnum.ARTIFACTS.getElementName());
+            for (Map.Entry<String, UploadArtifactInfo> entry : artifact.entrySet()) {
+                ToscaArtifactDataDefinition to = new ToscaArtifactDataDefinition();
+                to.setFile(entry.getValue().getFile());
+                to.setType(entry.getValue().getType());
+                toscaArtifacts.put(entry.getKey(), to);
+            }
+            componentInstance.setToscaArtifacts(toscaArtifacts);
+        }
+
         if (!existingnodeTypeMap.containsKey(uploadComponentInstanceInfo.getType())) {
             log.debug(
                     "createResourceInstances - not found lates version for resource instance with name {} and type ",
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){
index b17dc3a..d757cec 100644 (file)
@@ -27,6 +27,11 @@ import java.util.List;
 import java.util.Map;
 import org.apache.commons.collections.CollectionUtils;
 
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
 public class ToscaNodeTemplate {
 
     private String type;
@@ -36,61 +41,10 @@ public class ToscaNodeTemplate {
     private Map<String, Object> properties;
     private List<Map<String, ToscaTemplateRequirement>> requirements;
     private Map<String, ToscaTemplateCapability> capabilities;
+    private Map<String, ToscaTemplateArtifact> artifacts;
     private NodeFilter node_filter;
     private Map<String, Object> interfaces;
 
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public Map<String, Object> getProperties() {
-        return properties;
-    }
-
-    public void setProperties(Map<String, Object> properties) {
-        this.properties = properties;
-    }
-
-    public List<Map<String, ToscaTemplateRequirement>> getRequirements() {
-        return requirements;
-    }
-
-    public void setRequirements(List<Map<String, ToscaTemplateRequirement>> requirements) {
-        this.requirements = requirements;
-    }
-
-    public Map<String, ToscaTemplateCapability> getCapabilities() {
-        return capabilities;
-    }
-
-    public void setCapabilities(Map<String, ToscaTemplateCapability> capabilities) {
-        this.capabilities = capabilities;
-    }
-
-    public ToscaMetadata getMetadata() {
-        return metadata;
-    }
-
-    public void setMetadata(ToscaMetadata metadata) {
-        this.metadata = metadata;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public List<String> getDirectives() {
-        return directives;
-    }
-
     public void setDirectives(List<String> directives) {
         if (CollectionUtils.isEmpty(directives)) {
             this.directives = null;
@@ -99,19 +53,6 @@ public class ToscaNodeTemplate {
         this.directives = directives;
     }
 
-    public NodeFilter getNode_filter() {
-        return node_filter;
-    }
-
-    public void setNode_filter(NodeFilter node_filter) {
-        this.node_filter = node_filter;
-    }
-
-    public void setInterfaces(
-            Map<String, Object> interfaces) {
-        this.interfaces = interfaces;
-    }
-
     public void addInterface(String interfaceName, Object interfaceDataDefinition) {
         if (MapUtils.isEmpty(this.interfaces)) {
             this.interfaces = new HashMap<>();
@@ -120,3 +61,4 @@ public class ToscaNodeTemplate {
         this.interfaces.put(interfaceName, interfaceDataDefinition);
     }
 }
+
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java
new file mode 100644 (file)
index 0000000..58432ba
--- /dev/null
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.tosca.model;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class ToscaTemplateArtifact {
+
+    private String file;
+    private String type;
+
+}
index 347c952..19d1a17 100644 (file)
@@ -20,6 +20,8 @@
 
 package org.openecomp.sdc.be.components.impl.utils;
 
+import mockit.Deencapsulation;
+import org.apache.commons.collections.MapUtils;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertNotNull;
 import static org.mockito.ArgumentMatchers.eq;
@@ -31,10 +33,12 @@ import java.util.*;
 import java.util.stream.Collectors;
 
 import org.assertj.core.util.Lists;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 
@@ -49,6 +53,14 @@ import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
 import org.openecomp.sdc.be.model.*;
 import org.openecomp.sdc.be.model.operations.impl.AnnotationTypeOperations;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.*;
 @RunWith(MockitoJUnitRunner.class)
 public class YamlTemplateParsingHandlerTest {
 
@@ -87,6 +99,9 @@ public class YamlTemplateParsingHandlerTest {
     private static final String MAIN_GROUP_NAME = "x_group";
     private static final String NESTED_GROUP_NAME = "nested_mg_vepdg_group";
 
+    @InjectMocks
+    YamlTemplateParsingHandler testSubject;
+
     @BeforeClass()
     public static void prepareData() throws IOException, URISyntaxException {
         csar = ZipUtil.readData(CSAR_FILE_PATH);
@@ -249,4 +264,69 @@ public class YamlTemplateParsingHandlerTest {
 
         return property;
     }
+    @Test
+    public void testSetArtifacts() throws Exception {
+        UploadComponentInstanceInfo nodeTemplateInfo = new UploadComponentInstanceInfo();
+        Map<String, Object> nodeTemplateJsonMap = new HashMap<>();
+        Map<String, String> nodeMap = new HashMap<>();
+        nodeMap.put("name","test_name");
+        nodeMap.put("type","test_type");
+        nodeTemplateJsonMap.put(ARTIFACTS.getElementName(), nodeMap);
+        Deencapsulation.invoke(testSubject, "setArtifacts", nodeTemplateInfo, nodeTemplateJsonMap);
+        Assert.assertTrue(nodeTemplateInfo.getArtifacts() != null);
+    }
+
+    @Test
+    public void testCreateArtifactsModuleFromYaml() throws Exception {
+        Map<String, Map<String, Map<String, String>>> nodeTemplateJsonMap = new HashMap<>();
+        Map<String, Map<String,String>> map0 = new HashMap<>();
+        Map<String, String> map1 = new HashMap<>();
+        map1.put("file", "test_file");
+        map1.put("type", "test_type");
+        map0.put("test_art", map1);
+        nodeTemplateJsonMap.put(ARTIFACTS.getElementName(), map0);
+        Map<String, Map<String, UploadArtifactInfo>> result;
+        result = Deencapsulation.invoke(testSubject, "createArtifactsModuleFromYaml", nodeTemplateJsonMap);
+        Assert.assertTrue(MapUtils.isNotEmpty(result));
+        Assert.assertTrue(MapUtils.isNotEmpty(result.get(ARTIFACTS.getElementName())));
+        Assert.assertTrue(result.get(ARTIFACTS.getElementName()).get("test_art").getFile().equals("test_file"));
+        Assert.assertTrue(result.get(ARTIFACTS.getElementName()).get("test_art").getType().equals("test_type"));
+    }
+
+    @Test
+    public void testAddModuleNodeTemplateArtifacts() throws Exception {
+        Map<String, Map<String, UploadArtifactInfo>> result = new HashMap<>();
+        Map<String, String> map1 = new HashMap<>();
+        map1.put("file", "test_file");
+        map1.put("type", "test_type");
+        Deencapsulation.invoke(testSubject, "addModuleNodeTemplateArtifacts", result, map1, "test_art");
+        Assert.assertTrue(MapUtils.isNotEmpty(result));
+        Assert.assertTrue(MapUtils.isNotEmpty(result.get(ARTIFACTS.getElementName())));
+        Assert.assertTrue(result.get(ARTIFACTS.getElementName()).get("test_art").getFile().equals("test_file"));
+        Assert.assertTrue(result.get(ARTIFACTS.getElementName()).get("test_art").getType().equals("test_type"));
+    }
+
+    @Test
+    public void testBuildModuleNodeTemplateArtifact() throws Exception {
+        Map<String, String> map1 = new HashMap<>();
+        map1.put("file", "test_file");
+        map1.put("type", "test_type");
+        UploadArtifactInfo result;
+        result = Deencapsulation.invoke(testSubject, "buildModuleNodeTemplateArtifact", map1);
+        Assert.assertTrue(result != null);
+        Assert.assertTrue(result.getFile().equals("test_file"));
+        Assert.assertTrue(result.getType().equals("test_type"));
+    }
+
+    @Test
+    public void testFillArtifact() throws Exception {
+        Map<String, String> map1 = new HashMap<>();
+        map1.put("file", "test_file");
+        map1.put("type", "test_type");
+        UploadArtifactInfo result = new UploadArtifactInfo();
+        Deencapsulation.invoke(testSubject, "fillArtifact", result, map1);
+        Assert.assertTrue(result != null);
+        Assert.assertTrue(result.getFile().equals("test_file"));
+        Assert.assertTrue(result.getType().equals("test_type"));
+    }
 }
index f319643..5521f86 100644 (file)
@@ -29,6 +29,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 import mockit.Deencapsulation;
+import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Triple;
 import org.junit.Assert;
@@ -47,6 +48,7 @@ import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefiniti
 import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ToscaArtifactDataDefinition;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
 import org.openecomp.sdc.be.model.ArtifactDefinition;
@@ -81,6 +83,7 @@ import org.openecomp.sdc.be.tosca.model.ToscaNodeTemplate;
 import org.openecomp.sdc.be.tosca.model.ToscaNodeType;
 import org.openecomp.sdc.be.tosca.model.ToscaProperty;
 import org.openecomp.sdc.be.tosca.model.ToscaTemplate;
+import org.openecomp.sdc.be.tosca.model.ToscaTemplateArtifact;
 import org.openecomp.sdc.be.tosca.model.ToscaTemplateRequirement;
 import org.openecomp.sdc.be.tosca.model.ToscaTopolgyTemplate;
 import org.openecomp.sdc.be.tosca.utils.InputConverter;
@@ -1349,4 +1352,18 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
                // default test
                result = Deencapsulation.invoke(testSubject, "convertCapabilities", component, nodeType, dataTypes);
        }
+
+        @Test
+        public void testConvertToNodeTemplateArtifacts() throws Exception {
+                Map<String, ToscaArtifactDataDefinition> container = new HashMap<>();
+                ToscaArtifactDataDefinition art = new ToscaArtifactDataDefinition();
+                art.setFile("test_file");
+                art.setType("test_type");
+                Map<String, ToscaTemplateArtifact> result;
+                container.put("test_art", art);
+                result = Deencapsulation.invoke(testSubject, "convertToNodeTemplateArtifacts", container);
+                Assert.assertTrue(MapUtils.isNotEmpty(result));
+                Assert.assertTrue(result.get("test_art").getFile().equals("test_file"));
+                Assert.assertTrue(result.get("test_art").getType().equals("test_type"));
+        }
 }
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadArtifactInfo.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadArtifactInfo.java
new file mode 100644 (file)
index 0000000..7f74225
--- /dev/null
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.model;
+
+import java.util.List;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class UploadArtifactInfo extends UploadInfo {
+    /**
+     * specify the node type(Optional by tosca)
+     */
+    private List<String> validSourceTypes;
+
+    private String file;
+    private String type;
+
+}
index 7b672ac..8daf492 100644 (file)
@@ -24,86 +24,21 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
 public class UploadComponentInstanceInfo {
     private String name;
     private String type;
     private Map<String, List<UploadCapInfo>> capabilities;
     private Map<String, List<UploadReqInfo>> requirements;
+    private Map<String, Map<String, UploadArtifactInfo>> artifacts;
     private Map<String, List<UploadPropInfo>> properties;
     private Map<String, String> capabilitiesNamesToUpdate;
     private Map<String, String> requirementsNamesToUpdate;
     private Collection<String> directives;
     private UploadNodeFilterInfo uploadNodeFilterInfo;
 
-    public Map<String, List<UploadPropInfo>> getProperties() {
-        return properties;
-    }
-
-    public void setProperties(Map<String, List<UploadPropInfo>> properties) {
-        this.properties = properties;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public Map<String, List<UploadCapInfo>> getCapabilities() {
-        return capabilities;
-    }
-
-    public void setCapabilities(Map<String, List<UploadCapInfo>> capabilities) {
-        this.capabilities = capabilities;
-    }
-
-    public Map<String, List<UploadReqInfo>> getRequirements() {
-        return requirements;
-    }
-
-    public void setRequirements(Map<String, List<UploadReqInfo>> requirements) {
-        this.requirements = requirements;
-    }
-
-    public Map<String, String> getCapabilitiesNamesToUpdate() {
-        return capabilitiesNamesToUpdate;
-    }
-
-    public void setCapabilitiesNamesToUpdate(Map<String, String> capabilitiesNamesToUpdate) {
-        this.capabilitiesNamesToUpdate = capabilitiesNamesToUpdate;
-    }
-
-    public Map<String, String> getRequirementsNamesToUpdate() {
-        return requirementsNamesToUpdate;
-    }
-
-    public void setRequirementsNamesToUpdate(Map<String, String> requirementsNamesToUpdate) {
-        this.requirementsNamesToUpdate = requirementsNamesToUpdate;
-    }
-
-    public Collection<String> getDirectives() {
-        return directives;
-    }
-
-    public void setDirectives(Collection<String> directives) {
-        this.directives = directives;
-    }
-
-    public UploadNodeFilterInfo getUploadNodeFilterInfo() {
-        return uploadNodeFilterInfo;
-    }
-
-    public void setUploadNodeFilterInfo(UploadNodeFilterInfo uploadNodeFilterInfo) {
-        this.uploadNodeFilterInfo = uploadNodeFilterInfo;
-    }
 }
index ecbbc69..72fa713 100644 (file)
@@ -263,9 +263,7 @@ public class ArtifactsOperations extends BaseOperation {
         foundArtifact = getArtifactByLabel(parentId, null, EdgeLabelEnum.TOSCA_ARTIFACTS);
         if (foundArtifact.isLeft()) {
             resMap.putAll(foundArtifact.left().value());
-
         }
-
         return Either.left(resMap);
 
     }
index d701b0f..3790849 100644 (file)
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.datatypes.elements;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
-import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
-import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-import org.openecomp.sdc.common.util.ValidationUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class ComponentInstanceDataDefinition extends ToscaDataDefinition {
-
-    public ComponentInstanceDataDefinition() {
-        setPropertyValueCounter(1);
-        setAttributeValueCounter(1);
-        setInputValueCounter(1);
-        setIsProxy(false);
-    }
-
-    public ComponentInstanceDataDefinition(ComponentInstanceDataDefinition dataDefinition) {
-        setIcon(dataDefinition.getIcon());
-        setUniqueId(dataDefinition.getUniqueId());
-        setName(dataDefinition.getName());
-        setComponentUid(dataDefinition.getComponentUid());
-        setCreationTime(dataDefinition.getCreationTime());
-        setModificationTime(dataDefinition.getModificationTime());
-        setDescription(dataDefinition.getDescription());
-        setPosX(dataDefinition.getPosX());
-        setPosY(dataDefinition.getPosY());
-        setPropertyValueCounter(dataDefinition.getPropertyValueCounter());
-        setNormalizedName(dataDefinition.getNormalizedName());
-        setOriginType(dataDefinition.getOriginType());
-        setCustomizationUUID(dataDefinition.getCustomizationUUID());
-        setComponentName(dataDefinition.getComponentName());
-        setComponentVersion(dataDefinition.getComponentVersion());
-        setToscaComponentName(dataDefinition.getToscaComponentName());
-        setInvariantName(dataDefinition.getInvariantName());
-        setSourceModelInvariant(dataDefinition.getSourceModelInvariant());
-        setSourceModelName(dataDefinition.getSourceModelName());
-        setSourceModelUuid(dataDefinition.getSourceModelUuid());
-        setSourceModelUid(dataDefinition.getSourceModelUid());
-        setIsProxy(dataDefinition.getIsProxy());
-        setDirectives(dataDefinition.getDirectives());
-        setOriginArchived(dataDefinition.isOriginArchived());
-    }
-
-    public String getIcon() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.CI_ICON);
-    }
-
-    public void setIcon(String icon) {
-        setToscaPresentationValue(JsonPresentationFields.CI_ICON, icon);
-    }
-
-    public String getUniqueId() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.UNIQUE_ID);
-    }
-
-    public void setUniqueId(String uniqueId) {
-        setToscaPresentationValue(JsonPresentationFields.UNIQUE_ID, uniqueId);
-    }
-
-    public Long getCreationTime() {
-        return (Long) getToscaPresentationValue(JsonPresentationFields.CREATION_TIME);
-    }
-
-    public void setCreationTime(Long creationTime) {
-        setToscaPresentationValue(JsonPresentationFields.CREATION_TIME, creationTime);
-    }
-
-    public Long getModificationTime() {
-        return (Long) getToscaPresentationValue(JsonPresentationFields.MODIFICATION_TIME);
-    }
-
-    public void setModificationTime(Long modificationTime) {
-        setToscaPresentationValue(JsonPresentationFields.MODIFICATION_TIME, modificationTime);
-    }
-
-    public String getDescription() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.DESCRIPTION);
-    }
-
-    public void setDescription(String description) {
-        setToscaPresentationValue(JsonPresentationFields.DESCRIPTION, description);
-    }
-
-    public String getPosX() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.CI_POS_X);
-    }
-
-    public void setPosX(String posX) {
-        setToscaPresentationValue(JsonPresentationFields.CI_POS_X, posX);
-    }
-
-    public String getPosY() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.CI_POS_Y);
-    }
-
-    public void setPosY(String posY) {
-        setToscaPresentationValue(JsonPresentationFields.CI_POS_Y, posY);
-    }
-
-    public String getComponentUid() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_UID);
-    }
-
-    public void setComponentUid(String resourceUid) {
-        setToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_UID, resourceUid);
-    }
-
-    public String getName() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.NAME);
-    }
-
-    public void setName(String name) {
-        if (this.getInvariantName() == null && name != null) {
-            this.setInvariantName(ValidationUtils.normalizeComponentInstanceName(name));
-        }
-        setToscaPresentationValue(JsonPresentationFields.NAME, name);
-    }
-
-    public String getInvariantName() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.CI_INVARIANT_NAME);
-    }
-
-    public void setInvariantName(String invariantName) {
-        setToscaPresentationValue(JsonPresentationFields.CI_INVARIANT_NAME, invariantName);
-    }
-
-    public Integer getPropertyValueCounter() {
-        return (Integer) getToscaPresentationValue(JsonPresentationFields.CI_PROP_VALUE_COUNTER);
-    }
-
-    public void setPropertyValueCounter(Integer propertyValueCounter) {
-        setToscaPresentationValue(JsonPresentationFields.CI_PROP_VALUE_COUNTER, propertyValueCounter);
-    }
-
-    public String getNormalizedName() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.NORMALIZED_NAME);
-    }
-
-    public void setNormalizedName(String normalizedName) {
-        setToscaPresentationValue(JsonPresentationFields.NORMALIZED_NAME, normalizedName);
-    }
-
-    public OriginTypeEnum getOriginType() {
-        OriginTypeEnum originType = null;
-        String origType = (String) getToscaPresentationValue(JsonPresentationFields.CI_ORIGIN_TYPE);
-        if (origType != null && !origType.isEmpty()) {
-
-            originType = OriginTypeEnum.findByValue(origType);
-        }
-        return originType;
-    }
-
-    public void setOriginType(OriginTypeEnum originType) {
-        if (originType != null) {
-            setToscaPresentationValue(JsonPresentationFields.CI_ORIGIN_TYPE, originType.getValue());
-        }
-    }
-
-    public Integer getAttributeValueCounter() {
-        return (Integer) getToscaPresentationValue(JsonPresentationFields.CI_ATTR_VALUE_COUNTER);
-    }
-
-    public void setAttributeValueCounter(Integer attributeValueCounter) {
-        setToscaPresentationValue(JsonPresentationFields.CI_ATTR_VALUE_COUNTER, attributeValueCounter);
-    }
-
-    public Integer getInputValueCounter() {
-        return (Integer) getToscaPresentationValue(JsonPresentationFields.CI_INPUT_VALUE_COUNTER);
-    }
-
-    public void setInputValueCounter(Integer inputValueCounter) {
-        setToscaPresentationValue(JsonPresentationFields.CI_INPUT_VALUE_COUNTER, inputValueCounter);
-    }
-
-    public String getCustomizationUUID() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.CUSTOMIZATION_UUID);
-    }
-
-    public void setCustomizationUUID(String customizationUUID) {
-        setToscaPresentationValue(JsonPresentationFields.CUSTOMIZATION_UUID, customizationUUID);
-    }
-
-    public String getComponentName() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_NAME);
-    }
-
-    public void setComponentName(String resourceName) {
-        setToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_NAME, resourceName);
-    }
-
-    public String getComponentVersion() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_VERSION);
-    }
-
-    public String getToscaComponentName() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.CI_TOSCA_COMPONENT_NAME);
-    }
-
-    public void setToscaComponentName(String toscaComponentName) {
-        setToscaPresentationValue(JsonPresentationFields.CI_TOSCA_COMPONENT_NAME, toscaComponentName);
-    }
-
-    public void setComponentVersion(String resourceVersion) {
-        setToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_VERSION, resourceVersion);
-    }
-
-    public void setSourceModelUuid(String targetModelUuid) {
-        setToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_UUID, targetModelUuid);
-    }
-
-    public void setSourceModelUid(String targetModelUid) {
-        setToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_UID, targetModelUid);
-    }
-
-    public void setSourceModelName(String targetModelName) {
-        setToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_NAME, targetModelName);
-    }
-
-    public void setSourceModelInvariant(String targetModelInvariant) {
-        setToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_INVARIANT, targetModelInvariant);
-    }
-
-    public String getSourceModelUuid() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_UUID);
-    }
-
-    public String getSourceModelUid() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_UID);
-    }
-
-    public String getSourceModelName() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_NAME);
-    }
-
-    public String getSourceModelInvariant() {
-        return (String) getToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_INVARIANT);
-    }
-
-    public void setIsProxy(Boolean isProxy) {
-        if (isProxy == null) {
-            setToscaPresentationValue(JsonPresentationFields.CI_IS_PROXY, false);
-        } else {
-            setToscaPresentationValue(JsonPresentationFields.CI_IS_PROXY, isProxy);
-        }
-    }
-
-    public Boolean getIsProxy() {
-        Boolean isProxy = (Boolean) getToscaPresentationValue(JsonPresentationFields.CI_IS_PROXY);
-        return (isProxy != null) ? isProxy : false;
-    }
-
-    public void setOriginArchived(Boolean originArchived) {
-        if (originArchived == null) {
-            setToscaPresentationValue(JsonPresentationFields.CI_IS_ORIGIN_ARCHIVED, false);
-        } else {
-            setToscaPresentationValue(JsonPresentationFields.CI_IS_ORIGIN_ARCHIVED, originArchived);
-        }
-    }
-
-    public List<String> getDirectives() {
-        return (List<String>) getToscaPresentationValue(JsonPresentationFields.CI_DIRECTIVES);
-    }
-
-    public void setDirectives(List<String> directives) {
-        if (directives == null) {
-            directives = new ArrayList<>();
-        }
-        setToscaPresentationValue(JsonPresentationFields.CI_DIRECTIVES, directives);
-    }
-
-    public Boolean isOriginArchived() {
-        Boolean originArchived = (Boolean) getToscaPresentationValue(JsonPresentationFields.CI_IS_ORIGIN_ARCHIVED);
-        return (originArchived != null) ? originArchived : false;
-    }
-
-    private String getDirectivesString() {
-        if (CollectionUtils.isEmpty(getDirectives())) {
-            return "";
-        }
-        return getDirectives().stream().collect(Collectors.joining(","));
-    }
-
-    @Override
-    public String toString() {
-        return "ComponentInstanceDataDefinition [icon=" + getIcon() + ", uniqueId=" + getUniqueId() + ", name="
-                + getName() + ", normalizedName=" + getNormalizedName() + ", componentUid=" + getComponentUid()
-                + ", creationTime=" + getCreationTime() + ", modificationTime=" + getModificationTime()
-                + ", description=" + getDescription() + ", posX=" + getPosX() + ", posY=" + getPosY()
-                + ", propertyValueCounter=" + getPropertyValueCounter() + ", attributeValueCounter="
-                + getAttributeValueCounter() + ", inputValueCounter=" + getInputValueCounter() + ", originType="
-                + getOriginType() + ", customizationUUID=" + getCustomizationUUID() + ", componentName="
-                + getComponentName() + ", componentVersion=" + getComponentVersion() + ", toscaComponentName="
-                + getToscaComponentName() + ", directives =" + getDirectivesString() + "]";
-    }
-
-}
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * SDC\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.sdc.be.datatypes.elements;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.HashMap;\r
+import java.util.stream.Collectors;\r
+import org.apache.commons.collections.CollectionUtils;\r
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;\r
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;\r
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;\r
+import org.openecomp.sdc.common.util.ValidationUtils;\r
+\r
+public class ComponentInstanceDataDefinition extends ToscaDataDefinition {\r
+\r
+    public ComponentInstanceDataDefinition() {\r
+        setPropertyValueCounter(1);\r
+        setAttributeValueCounter(1);\r
+        setInputValueCounter(1);\r
+        setIsProxy(false);\r
+    }\r
+\r
+    public ComponentInstanceDataDefinition(ComponentInstanceDataDefinition dataDefinition) {\r
+        setIcon(dataDefinition.getIcon());\r
+        setUniqueId(dataDefinition.getUniqueId());\r
+        setName(dataDefinition.getName());\r
+        setComponentUid(dataDefinition.getComponentUid());\r
+        setCreationTime(dataDefinition.getCreationTime());\r
+        setModificationTime(dataDefinition.getModificationTime());\r
+        setDescription(dataDefinition.getDescription());\r
+        setPosX(dataDefinition.getPosX());\r
+        setPosY(dataDefinition.getPosY());\r
+        setPropertyValueCounter(dataDefinition.getPropertyValueCounter());\r
+        setNormalizedName(dataDefinition.getNormalizedName());\r
+        setOriginType(dataDefinition.getOriginType());\r
+        setCustomizationUUID(dataDefinition.getCustomizationUUID());\r
+        setComponentName(dataDefinition.getComponentName());\r
+        setComponentVersion(dataDefinition.getComponentVersion());\r
+        setToscaComponentName(dataDefinition.getToscaComponentName());\r
+        setInvariantName(dataDefinition.getInvariantName());\r
+        setSourceModelInvariant(dataDefinition.getSourceModelInvariant());\r
+        setSourceModelName(dataDefinition.getSourceModelName());\r
+        setSourceModelUuid(dataDefinition.getSourceModelUuid());\r
+        setSourceModelUid(dataDefinition.getSourceModelUid());\r
+        setIsProxy(dataDefinition.getIsProxy());\r
+        setDirectives(dataDefinition.getDirectives());\r
+        setOriginArchived(dataDefinition.isOriginArchived());\r
+        setToscaArtifacts(dataDefinition.getToscaArtifacts());\r
+    }\r
+\r
+    public String getIcon() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.CI_ICON);\r
+    }\r
+\r
+    public void setIcon(String icon) {\r
+        setToscaPresentationValue(JsonPresentationFields.CI_ICON, icon);\r
+    }\r
+\r
+    public String getUniqueId() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.UNIQUE_ID);\r
+    }\r
+\r
+    public void setUniqueId(String uniqueId) {\r
+        setToscaPresentationValue(JsonPresentationFields.UNIQUE_ID, uniqueId);\r
+    }\r
+\r
+    public Long getCreationTime() {\r
+        return (Long) getToscaPresentationValue(JsonPresentationFields.CREATION_TIME);\r
+    }\r
+\r
+    public void setCreationTime(Long creationTime) {\r
+        setToscaPresentationValue(JsonPresentationFields.CREATION_TIME, creationTime);\r
+    }\r
+\r
+    public Long getModificationTime() {\r
+        return (Long) getToscaPresentationValue(JsonPresentationFields.MODIFICATION_TIME);\r
+    }\r
+\r
+    public void setModificationTime(Long modificationTime) {\r
+        setToscaPresentationValue(JsonPresentationFields.MODIFICATION_TIME, modificationTime);\r
+    }\r
+\r
+    public String getDescription() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.DESCRIPTION);\r
+    }\r
+\r
+    public void setDescription(String description) {\r
+        setToscaPresentationValue(JsonPresentationFields.DESCRIPTION, description);\r
+    }\r
+\r
+    public String getPosX() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.CI_POS_X);\r
+    }\r
+\r
+    public void setPosX(String posX) {\r
+        setToscaPresentationValue(JsonPresentationFields.CI_POS_X, posX);\r
+    }\r
+\r
+    public String getPosY() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.CI_POS_Y);\r
+    }\r
+\r
+    public void setPosY(String posY) {\r
+        setToscaPresentationValue(JsonPresentationFields.CI_POS_Y, posY);\r
+    }\r
+\r
+    public String getComponentUid() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_UID);\r
+    }\r
+\r
+    public void setComponentUid(String resourceUid) {\r
+        setToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_UID, resourceUid);\r
+    }\r
+\r
+    public String getName() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.NAME);\r
+    }\r
+\r
+    public void setName(String name) {\r
+        if (this.getInvariantName() == null && name != null) {\r
+            this.setInvariantName(ValidationUtils.normalizeComponentInstanceName(name));\r
+        }\r
+        setToscaPresentationValue(JsonPresentationFields.NAME, name);\r
+    }\r
+\r
+    public String getInvariantName() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.CI_INVARIANT_NAME);\r
+    }\r
+\r
+    public void setInvariantName(String invariantName) {\r
+        setToscaPresentationValue(JsonPresentationFields.CI_INVARIANT_NAME, invariantName);\r
+    }\r
+\r
+    public Integer getPropertyValueCounter() {\r
+        return (Integer) getToscaPresentationValue(JsonPresentationFields.CI_PROP_VALUE_COUNTER);\r
+    }\r
+\r
+    public void setPropertyValueCounter(Integer propertyValueCounter) {\r
+        setToscaPresentationValue(JsonPresentationFields.CI_PROP_VALUE_COUNTER, propertyValueCounter);\r
+    }\r
+\r
+    public String getNormalizedName() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.NORMALIZED_NAME);\r
+    }\r
+\r
+    public void setNormalizedName(String normalizedName) {\r
+        setToscaPresentationValue(JsonPresentationFields.NORMALIZED_NAME, normalizedName);\r
+    }\r
+\r
+    public OriginTypeEnum getOriginType() {\r
+        OriginTypeEnum originType = null;\r
+        String origType = (String) getToscaPresentationValue(JsonPresentationFields.CI_ORIGIN_TYPE);\r
+        if (origType != null && !origType.isEmpty()) {\r
+\r
+            originType = OriginTypeEnum.findByValue(origType);\r
+        }\r
+        return originType;\r
+    }\r
+\r
+    public void setOriginType(OriginTypeEnum originType) {\r
+        if (originType != null) {\r
+            setToscaPresentationValue(JsonPresentationFields.CI_ORIGIN_TYPE, originType.getValue());\r
+        }\r
+    }\r
+\r
+    public Integer getAttributeValueCounter() {\r
+        return (Integer) getToscaPresentationValue(JsonPresentationFields.CI_ATTR_VALUE_COUNTER);\r
+    }\r
+\r
+    public void setAttributeValueCounter(Integer attributeValueCounter) {\r
+        setToscaPresentationValue(JsonPresentationFields.CI_ATTR_VALUE_COUNTER, attributeValueCounter);\r
+    }\r
+\r
+    public Integer getInputValueCounter() {\r
+        return (Integer) getToscaPresentationValue(JsonPresentationFields.CI_INPUT_VALUE_COUNTER);\r
+    }\r
+\r
+    public void setInputValueCounter(Integer inputValueCounter) {\r
+        setToscaPresentationValue(JsonPresentationFields.CI_INPUT_VALUE_COUNTER, inputValueCounter);\r
+    }\r
+\r
+    public String getCustomizationUUID() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.CUSTOMIZATION_UUID);\r
+    }\r
+\r
+    public void setCustomizationUUID(String customizationUUID) {\r
+        setToscaPresentationValue(JsonPresentationFields.CUSTOMIZATION_UUID, customizationUUID);\r
+    }\r
+\r
+    public String getComponentName() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_NAME);\r
+    }\r
+\r
+    public void setComponentName(String resourceName) {\r
+        setToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_NAME, resourceName);\r
+    }\r
+\r
+    public String getComponentVersion() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_VERSION);\r
+    }\r
+\r
+    public String getToscaComponentName() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.CI_TOSCA_COMPONENT_NAME);\r
+    }\r
+\r
+    public void setToscaComponentName(String toscaComponentName) {\r
+        setToscaPresentationValue(JsonPresentationFields.CI_TOSCA_COMPONENT_NAME, toscaComponentName);\r
+    }\r
+\r
+    public void setComponentVersion(String resourceVersion) {\r
+        setToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_VERSION, resourceVersion);\r
+    }\r
+\r
+    public void setSourceModelUuid(String targetModelUuid) {\r
+        setToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_UUID, targetModelUuid);\r
+    }\r
+\r
+    public void setSourceModelUid(String targetModelUid) {\r
+        setToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_UID, targetModelUid);\r
+    }\r
+\r
+    public void setSourceModelName(String targetModelName) {\r
+        setToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_NAME, targetModelName);\r
+    }\r
+\r
+    public void setSourceModelInvariant(String targetModelInvariant) {\r
+        setToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_INVARIANT, targetModelInvariant);\r
+    }\r
+\r
+    public String getSourceModelUuid() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_UUID);\r
+    }\r
+\r
+    public String getSourceModelUid() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_UID);\r
+    }\r
+\r
+    public String getSourceModelName() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_NAME);\r
+    }\r
+\r
+    public String getSourceModelInvariant() {\r
+        return (String) getToscaPresentationValue(JsonPresentationFields.CI_SOURCE_MODEL_INVARIANT);\r
+    }\r
+\r
+    public void setIsProxy(Boolean isProxy) {\r
+        if (isProxy == null) {\r
+            setToscaPresentationValue(JsonPresentationFields.CI_IS_PROXY, false);\r
+        } else {\r
+            setToscaPresentationValue(JsonPresentationFields.CI_IS_PROXY, isProxy);\r
+        }\r
+    }\r
+\r
+    public Boolean getIsProxy() {\r
+        Boolean isProxy = (Boolean) getToscaPresentationValue(JsonPresentationFields.CI_IS_PROXY);\r
+        return (isProxy != null) ? isProxy : false;\r
+    }\r
+\r
+    public void setOriginArchived(Boolean originArchived) {\r
+        if (originArchived == null) {\r
+            setToscaPresentationValue(JsonPresentationFields.CI_IS_ORIGIN_ARCHIVED, false);\r
+        } else {\r
+            setToscaPresentationValue(JsonPresentationFields.CI_IS_ORIGIN_ARCHIVED, originArchived);\r
+        }\r
+    }\r
+\r
+    public List<String> getDirectives() {\r
+        return (List<String>) getToscaPresentationValue(JsonPresentationFields.CI_DIRECTIVES);\r
+    }\r
+\r
+    public void setDirectives(List<String> directives) {\r
+        if (directives == null) {\r
+            directives = new ArrayList<>();\r
+        }\r
+        setToscaPresentationValue(JsonPresentationFields.CI_DIRECTIVES, directives);\r
+    }\r
+\r
+    public  Map<String, ToscaArtifactDataDefinition> getToscaArtifacts() {\r
+        return ( Map<String, ToscaArtifactDataDefinition>) getToscaPresentationValue(JsonPresentationFields.CI_ARTIFACTS);\r
+    }\r
+\r
+    public  void setToscaArtifacts(Map<String, ToscaArtifactDataDefinition> artifacts) {\r
+        if (artifacts == null){\r
+            artifacts = new HashMap<>();\r
+        }\r
+        setToscaPresentationValue(JsonPresentationFields.CI_ARTIFACTS, artifacts);\r
+    }\r
+\r
+    public Boolean isOriginArchived() {\r
+        Boolean originArchived = (Boolean) getToscaPresentationValue(JsonPresentationFields.CI_IS_ORIGIN_ARCHIVED);\r
+        return (originArchived != null) ? originArchived : false;\r
+    }\r
+\r
+    private String getDirectivesString() {\r
+        if (CollectionUtils.isEmpty(getDirectives())) {\r
+            return "";\r
+        }\r
+        return getDirectives().stream().collect(Collectors.joining(","));\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        return "ComponentInstanceDataDefinition [icon=" + getIcon() + ", uniqueId=" + getUniqueId() + ", name="\r
+                + getName() + ", normalizedName=" + getNormalizedName() + ", componentUid=" + getComponentUid()\r
+                + ", creationTime=" + getCreationTime() + ", modificationTime=" + getModificationTime()\r
+                + ", description=" + getDescription() + ", posX=" + getPosX() + ", posY=" + getPosY()\r
+                + ", propertyValueCounter=" + getPropertyValueCounter() + ", attributeValueCounter="\r
+                + getAttributeValueCounter() + ", inputValueCounter=" + getInputValueCounter() + ", originType="\r
+                + getOriginType() + ", customizationUUID=" + getCustomizationUUID() + ", componentName="\r
+                + getComponentName() + ", componentVersion=" + getComponentVersion() + ", toscaComponentName="\r
+                + getToscaComponentName() + ", directives =" + getDirectivesString() + "]";\r
+    }\r
+\r
+}\r
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaArtifactDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaArtifactDataDefinition.java
new file mode 100644 (file)
index 0000000..607292f
--- /dev/null
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.datatypes.elements;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class ToscaArtifactDataDefinition {
+
+    private String file;
+    private String type;
+}
index 0adf681..3a824d5 100644 (file)
@@ -192,6 +192,7 @@ public enum JsonPresentationFields {
     CI_SOURCE_MODEL_NAME("sourceModelName", null),
     CI_IS_PROXY("isProxy", null),
     CI_DIRECTIVES("directives", null),
+    CI_ARTIFACTS("artifacts", null),
 
     //path
     FORWARDING_PATH("forwardingPath", null),
index 408fb50..f68f217 100644 (file)
@@ -52,6 +52,8 @@ public class TypeUtils {
         // Requirements
         REQUIREMENTS("requirements"), NODE("node"), RELATIONSHIP("relationship"), CAPABILITY("capability"), INTERFACES("interfaces"),
         NODE_FILTER("node_filter"), TOSCA_ID("tosca_id"),
+        // Artifacts
+        ARTIFACTS("artifacts"), FILE("file"),
         // Heat env Validation
         PARAMETERS("parameters"),
         // Import Validations