aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuanHu <yuan.hu1@zte.com.cn>2016-10-27 09:55:42 +0800
committerYuanHu <yuan.hu1@zte.com.cn>2016-10-27 09:55:42 +0800
commitffdc1048604d09d1438b6ae723b0c2fa003497ef (patch)
treee825ddf6c3fb4686467a1f75944e9f013f289213
parent5e21de34c68f18c7d78899df5622c2bf755d5b8b (diff)
Add 'id' property to service template.
Change-Id: I03a861f3b30efec1b79156f271dbadc00a10ffc9 Issue-id: TOSCA-148 Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/TemplateDataHelper.java2
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/entity/ServiceTemplate.java2
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java4
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java1
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java5
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/wrapper/ServiceTemplateWrapper.java13
-rw-r--r--catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/ServiceTemplateWrapperTest.java1
7 files changed, 21 insertions, 7 deletions
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/TemplateDataHelper.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/TemplateDataHelper.java
index b03946c4..6c591f1c 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/TemplateDataHelper.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/TemplateDataHelper.java
@@ -146,7 +146,7 @@ public class TemplateDataHelper {
ToolUtil.fromJson(std.getOperations(), ServiceTemplateOperation[].class);
String downloadUri = buildSTDownloadUri(std.getCsarId(), std.getDownloadUri());
- return new ServiceTemplate(std.getServiceTemplateId(), std.getTemplateName(), std.getVendor(),
+ return new ServiceTemplate(std.getServiceTemplateId(), std.getTemplateName(), std.getTemplateName(), std.getVendor(),
std.getVersion(), std.getCsarId(), std.getType(), downloadUri,
parameters.getInputs(), parameters.getOutputs(), operations);
}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/entity/ServiceTemplate.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/entity/ServiceTemplate.java
index 064940da..cbc75667 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/entity/ServiceTemplate.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/entity/ServiceTemplate.java
@@ -26,6 +26,8 @@ public class ServiceTemplate {
private String serviceTemplateId;
+ private String id;
+
private String templateName;
private String vendor;
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java
index 5b777f9d..fb556543 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java
@@ -219,8 +219,8 @@ public abstract class AbstractModelParser {
* @return
*/
public String parserServiceTemplateName(Map<String, String> metadata) {
- if (metadata.containsKey("name")) {
- return metadata.get("name");
+ if (metadata.containsKey("id")) {
+ return metadata.get("id");
}
return metadata.get("template_name");
}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java
index bfebe15d..fd2b3507 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java
@@ -243,6 +243,7 @@ public class AriaModelParser extends AbstractModelParser {
ServiceTemplate st = new ServiceTemplate();
st.setServiceTemplateId(ToolUtil.generateId());
+ st.setId(parserServiceTemplateName(result.getInstance().getMetadata())); // TODO
st.setTemplateName(parserServiceTemplateName(result.getInstance().getMetadata()));
st.setVendor(parserServiceTemplateVendor(result.getInstance().getMetadata()));
st.setVersion(parserServiceTemplateVersion(result.getInstance().getMetadata()));
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java
index 7f57075b..4a50b02d 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/zte/ToscaYamlModelParser.java
@@ -50,7 +50,7 @@ public class ToscaYamlModelParser extends AbstractModelParser {
// service template
ServiceTemplate st = parseServiceTemplate(
- packageId, result, parseServiceTemplateFileName(packageId, fileLocation));
+ result, packageId, parseServiceTemplateFileName(packageId, fileLocation));
// workflow
ServiceTemplateOperation[] operations = parseOperations(fileLocation);
st.setOperations(operations);
@@ -103,11 +103,12 @@ public class ToscaYamlModelParser extends AbstractModelParser {
stm.getCapabilityList());
}
- private ServiceTemplate parseServiceTemplate(String packageId, ParseYamlResult result,
+ private ServiceTemplate parseServiceTemplate(ParseYamlResult result, String packageId,
String stDownloadUri) {
ServiceTemplate st = new ServiceTemplate();
st.setServiceTemplateId(ToolUtil.generateId());
+ st.setId(parserServiceTemplateName(result.getMetadata())); // TODO
st.setTemplateName(parserServiceTemplateName(result.getMetadata()));
st.setVendor(parserServiceTemplateVendor(result.getMetadata()));
st.setVersion(parserServiceTemplateVersion(result.getMetadata()));
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/wrapper/ServiceTemplateWrapper.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/wrapper/ServiceTemplateWrapper.java
index c381c8aa..e9cec9d2 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/wrapper/ServiceTemplateWrapper.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/wrapper/ServiceTemplateWrapper.java
@@ -112,14 +112,23 @@ public class ServiceTemplateWrapper {
SubstitutionMapping stm = getSubstitutionMappingsByNodeTypeId(nodeTypeIds[i]);
if (stm == null) {
sts[i] = null;
- } else {
- sts[i] = getServiceTemplateById(stm.getServiceTemplateId());
+ continue;
}
+ sts[i] = getServiceTemplate(stm, nodeTypeIds[i]);
}
return sts;
}
+ private ServiceTemplate getServiceTemplate(SubstitutionMapping stm, String nodeTypeId) {
+ try {
+ return getServiceTemplateById(stm.getServiceTemplateId());
+ } catch (CatalogResourceException e) {
+ logger.warn("Get Nesting ServiceTemplate Failed. NodeTypeIds = " + nodeTypeId, e);
+ return null;
+ }
+ }
+
/**
* get substitution mappings by nodeTpe id.
* @param nodeTypeId nodeType id
diff --git a/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/ServiceTemplateWrapperTest.java b/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/ServiceTemplateWrapperTest.java
index 7087b220..8a9bf745 100644
--- a/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/ServiceTemplateWrapperTest.java
+++ b/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/ServiceTemplateWrapperTest.java
@@ -370,6 +370,7 @@ public class ServiceTemplateWrapperTest {
OutputParameter[] outputs = getOutputs();
serviceTemplate.setOutputs(outputs);
serviceTemplate.setServiceTemplateId("serviceTemplateId");
+ serviceTemplate.setId("templateName");
serviceTemplate.setTemplateName("templateName");
serviceTemplate.setType("NS");
serviceTemplate.setVendor("ZTE");