diff options
Diffstat (limited to 'catalog-core')
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"); |