From 6ecc7c3e150f86528d36cdbaa94912b965619a70 Mon Sep 17 00:00:00 2001 From: aribeiro Date: Mon, 30 Aug 2021 15:18:40 +0100 Subject: Filter categories by model name Issue-ID: SDC-3706 Signed-off-by: aribeiro Change-Id: I457151f09ce0ed2edfa09340e9e08a126e114002 --- .../components/impl/CategoriesImportManager.java | 29 +++++++-------- .../import/tosca/categories/categoryTypes.yml | 41 +++++++++++++++++----- 2 files changed, 48 insertions(+), 22 deletions(-) (limited to 'catalog-be/src/main') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CategoriesImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CategoriesImportManager.java index 12eb8379b2..35502aa573 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CategoriesImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CategoriesImportManager.java @@ -55,7 +55,7 @@ public class CategoriesImportManager { @javax.annotation.Resource private ComponentsUtils componentsUtils; - public Either>, ResponseFormat> createCategories(String categoriesTypesYml) { + public Either>, ResponseFormat> createCategories(final String categoriesTypesYml) { Map> allCategories = createCategoriesFromYml(categoriesTypesYml); return createCategoriesByDao(allCategories); } @@ -72,7 +72,7 @@ public class CategoriesImportManager { nodeTypeCategory, nodeTypeSubCategory, nodeTypeGroup); List newCategoriesvalue = new ArrayList<>(); for (CategoryDefinition category : entry.getValue()) { - Either createdCategoryRes = createCategorieDeo(entry, category, nodeTypeCategory); + Either createdCategoryRes = createCategoriesDao(entry, category, nodeTypeCategory); if (createdCategoryRes.isRight()) { return Either.right(createdCategoryRes.right().value()); } @@ -99,7 +99,7 @@ public class CategoriesImportManager { NodeTypeEnum nodeTypeGroup, CategoryDefinition category, CategoryDefinition newcategory, List newsubcategories, List subcategories) { for (SubCategoryDefinition subcategory : subcategories) { - Either createdSubCategory = createSubCategorieDeo(entry, newcategory, subcategory, + Either createdSubCategory = createSubCategoriesDao(entry, newcategory, subcategory, nodeTypeSubCategory); if (createdSubCategory.isRight()) { return false; @@ -109,7 +109,7 @@ public class CategoriesImportManager { if (groupings != null) { List newgroupings = new ArrayList<>(); for (GroupingDefinition grouping : groupings) { - Either createdGrouping = createGroupingDeo(entry, grouping, subcategory, category, + Either createdGrouping = createGroupingDao(entry, grouping, subcategory, category, nodeTypeGroup); if (createdGrouping.isRight()) { return false; @@ -123,7 +123,7 @@ public class CategoriesImportManager { return true; } - private Either createGroupingDeo(Map.Entry> entry, + private Either createGroupingDao(Map.Entry> entry, GroupingDefinition grouping, SubCategoryDefinition subcategory, CategoryDefinition category, NodeTypeEnum nodeTypeGroup) { log.debug("createGroupingDeo: creating grouping {}", grouping); @@ -148,9 +148,9 @@ public class CategoriesImportManager { return Either.left(createdGrouping.left().value()); } - private Either createSubCategorieDeo(Map.Entry> entry, - CategoryDefinition newcategory, SubCategoryDefinition subcategory, - NodeTypeEnum nodeTypeSubCategory) { + private Either createSubCategoriesDao(Map.Entry> entry, + CategoryDefinition newcategory, SubCategoryDefinition subcategory, + NodeTypeEnum nodeTypeSubCategory) { log.debug("createSubCategorieDeo: creating subcategory {}", subcategory); Either createdSubCategory = elementOperation .createSubCategory(newcategory.getUniqueId(), subcategory, nodeTypeSubCategory); @@ -170,8 +170,8 @@ public class CategoriesImportManager { return Either.left(createdSubCategory.left().value()); } - private Either createCategorieDeo(Map.Entry> entry, - CategoryDefinition category, NodeTypeEnum nodeTypeCategory) { + private Either createCategoriesDao(Map.Entry> entry, + CategoryDefinition category, NodeTypeEnum nodeTypeCategory) { log.debug("createCategorieDeo: creating category {}", category); Either createdCategory = elementOperation.createCategory(category, nodeTypeCategory); if (createdCategory.isRight() && ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS == createdCategory.right().value()) { @@ -187,8 +187,8 @@ public class CategoriesImportManager { return Either.left(createdCategory.left().value()); } - private Map> createCategoriesFromYml(String categoriesTypesYml) { - Map toscaJson = (Map) new Yaml().load(categoriesTypesYml); + private Map> createCategoriesFromYml(final String categoriesTypesYml) { + Map toscaJson = new Yaml().load(categoriesTypesYml); Map> allCategories = new HashMap<>(); Iterator> categoryEntryItr = toscaJson.entrySet().iterator(); while (categoryEntryItr.hasNext()) { @@ -219,7 +219,7 @@ public class CategoriesImportManager { return allCategories; } - private List createServiceCategories(Map categories) { + private List createServiceCategories(final Map categories) { List categoriesDef = new ArrayList<>(); String catName = null; List icons = null; @@ -232,6 +232,7 @@ public class CategoriesImportManager { catDef.setIcons(icons); String normalizedName = ValidationUtils.normalizeCategoryName4Uniqueness(catName); catDef.setNormalizedName(normalizedName); + catDef.setModels((List) category.get("models")); final Object useServiceSubstitutionForNestedServicesProperty = category.get("useServiceSubstitutionForNestedServices"); final boolean useServiceSubstitutionForNestedServices = useServiceSubstitutionForNestedServicesProperty == null ? false : (Boolean) useServiceSubstitutionForNestedServicesProperty; @@ -262,7 +263,7 @@ public class CategoriesImportManager { return metadataKeyDefs; } - private List createResourceCategories(Map categoryPerType) { + private List createResourceCategories(final Map categoryPerType) { List categroiesDef = new ArrayList<>(); for (Map.Entry entry : categoryPerType.entrySet()) { Map category = (Map) entry.getValue(); diff --git a/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml b/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml index 29b8585b3d..a013264bd8 100644 --- a/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml +++ b/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml @@ -2,24 +2,45 @@ services: Mobility: name: "Mobility" icons: ['mobility'] + models: [ + "SDC AID" + ] Network_L1_3: name: "Network L1-3" icons: ['network_l_1-3'] + models: [ + "SDC AID" + ] Network_L4: name: "Network L4+" icons: ['network_l_4'] + models: [ + "SDC AID" + ] VoIP_Call_Control: name: "VoIP Call Control" icons: ['call_controll'] + models: [ + "SDC AID" + ] E2E_Service: name: "E2E Service" icons: ['network_l_1-3'] + models: [ + "SDC AID" + ] Network_Service: name: "Network Service" icons: ['network_l_1-3'] + models: [ + "SDC AID" + ] Partner_Domain_Service: name: "Partner Domain Service" icons: ['partner_domain_service'] + models: [ + "SDC AID" + ] ETSI_NFV_Network_Service: name: "ETSI NFV Network Service" icons: ['etsi_nfv_network_service'] @@ -29,10 +50,14 @@ services: validValues: [ '3.3.1', '2.7.1', '2.5.1' ] default: '2.5.1' mandatory: true + models: [ + "ETSI SOL001 v2.5.1", + "SDC AID" + ] resources: NetworkLayer23: name: "Network L2-3" - subcategories: + subcategories: Router: name: "Router" icons: ['router','vRouter'] @@ -50,13 +75,13 @@ resources: icons: ['ucpe'] NetworkLayer4: name: "Network L4+" - subcategories: + subcategories: Common_Network_Resources: name: "Common Network Resources" icons: ['network'] ApplicationLayer4: name: "Application L4+" - subcategories: + subcategories: Border_Element: name: "Border Element" icons: ['borderElement'] @@ -83,7 +108,7 @@ resources: icons: ['firewall'] Generic: name: "Generic" - subcategories: + subcategories: Infrastructure: name: "Infrastructure" icons: ['connector'] @@ -161,16 +186,16 @@ resources: icons: ['allotted_resource'] TunnelXConnect: name: "TunnelXConn" - icons: ['tunnel_x_connect'] + icons: ['tunnel_x_connect'] BRG: name: "BRG" - icons: ['brg'] + icons: ['brg'] IpMuxDemux: name: "IP Mux Demux" - icons: ['ip_mux_demux'] + icons: ['ip_mux_demux'] ServiceAdmin: name: "Service Admin" - icons: ['service_admin'] + icons: ['service_admin'] ContrailRoute: name: "Contrail Route" icons: ['contrail_route'] -- cgit 1.2.3-korg