From cd497f1f42b8e4540a4ebc0d968c1814ae73db2a Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Tue, 17 Apr 2018 15:33:35 +0000 Subject: Implement fetching default NS resource workflow Implement fetching default NS resource workflow Change-Id: I4f56198a0954d7564040e4c41009cbf651a04b2e Issue-ID: SO-422 Signed-off-by: subhash kumar singh --- .../openecomp/mso/db/catalog/CatalogDatabase.java | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java index 3fa074e8e1..27c94f0770 100644 --- a/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java +++ b/mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java @@ -94,6 +94,7 @@ public class CatalogDatabase implements Closeable { private static final String MODEL_VERSION_ID = "modelVersionId"; private static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUuid"; private static final String VF_MODULE_MODEL_UUID = "vfModuleModelUUId"; + private static final String NETWORK_SERVICE = "network service"; protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL); @@ -1202,7 +1203,7 @@ public class CatalogDatabase implements Closeable { /** * Return a Network recipe that matches a given MODEL_UUID and ACTION * - * @param modelName + * @param vnfModelUuid * @param action * @return NetworkRecipe object or null if none found */ @@ -1217,9 +1218,33 @@ public class CatalogDatabase implements Closeable { } VnfRecipe recipe = this.getVnfRecipeByNameVersion(vnfResource.getModelName(), vnfResource.getVersion(), action); + + if (recipe == null && vnfResource.getSubCategory().equalsIgnoreCase(NETWORK_SERVICE)) { + recipe = getDefaultVnfRecipe(action); + } return recipe; } + private VnfRecipe getDefaultVnfRecipe(String action) { + long startTime = System.currentTimeMillis(); + LOGGER.debug("Catalog database - get default VNF recipe with action: " + action); + + Query query = getSession().createQuery("FROM VnfRecipe WHERE vnfType = :vnfType AND action = :action "); + query.setParameter(VNF_TYPE, "NS_DEFAULT"); + query.setParameter(ACTION, action); + + @SuppressWarnings("unchecked") + List resultList = query.list(); + + if (resultList.isEmpty()) { + LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. VNF recipe not found", "CatalogDB", "getVnfRecipe", null); + return null; + } + + LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfRecipe", null); + return resultList.get(0); + } + /** * Return a VNF recipe that matches a given VF_MODULE_ID and ACTION * -- cgit 1.2.3-korg