summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java67
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java7
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java20
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java16
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java72
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java33
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java80
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java17
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadArtifactInfo.java39
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadComponentInstanceInfo.java77
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java2
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ComponentInstanceDataDefinition.java655
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaArtifactDataDefinition.java32
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java1
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java2
15 files changed, 659 insertions, 461 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
index 7b3d4fac25..cff6c26e58 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
@@ -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);
@@ -591,6 +601,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<>();
Either<List<Object>, ResultStatusEnum> capabilitiesListRes =
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
index 3d149f79e6..9eae363afb 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
@@ -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()) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 5a997205ea..12345e7802 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -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 ",
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 0d3836b1c9..257ea3675d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -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){
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java
index b17dc3a43f..d757cec36c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java
@@ -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
index 0000000000..58432ba29b
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaTemplateArtifact.java
@@ -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;
+
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java
index 347c95217d..19d1a17e84 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/utils/YamlTemplateParsingHandlerTest.java
@@ -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"));
+ }
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
index f319643fd6..5521f8683b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
@@ -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
index 0000000000..7f742258cb
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadArtifactInfo.java
@@ -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;
+
+}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadComponentInstanceInfo.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadComponentInstanceInfo.java
index 7b672acc97..8daf492a62 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadComponentInstanceInfo.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadComponentInstanceInfo.java
@@ -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;
- }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java
index ecbbc69e5e..72fa71356e 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ArtifactsOperations.java
@@ -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);
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ComponentInstanceDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ComponentInstanceDataDefinition.java
index d701b0f6ca..3790849ecf 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ComponentInstanceDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ComponentInstanceDataDefinition.java
@@ -1,321 +1,334 @@
-/*-
- * ============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() + "]";
- }
-
-}
+/*-
+ * ============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 java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.stream.Collectors;
+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;
+
+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());
+ setToscaArtifacts(dataDefinition.getToscaArtifacts());
+ }
+
+ 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 Map<String, ToscaArtifactDataDefinition> getToscaArtifacts() {
+ return ( Map<String, ToscaArtifactDataDefinition>) getToscaPresentationValue(JsonPresentationFields.CI_ARTIFACTS);
+ }
+
+ public void setToscaArtifacts(Map<String, ToscaArtifactDataDefinition> artifacts) {
+ if (artifacts == null){
+ artifacts = new HashMap<>();
+ }
+ setToscaPresentationValue(JsonPresentationFields.CI_ARTIFACTS, artifacts);
+ }
+
+ 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() + "]";
+ }
+
+}
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
index 0000000000..607292f7eb
--- /dev/null
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/ToscaArtifactDataDefinition.java
@@ -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;
+}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
index 0adf681d7c..3a824d52f8 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/JsonPresentationFields.java
@@ -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),
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java b/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java
index 408fb5042a..f68f217014 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/utils/TypeUtils.java
@@ -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