aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/main
diff options
context:
space:
mode:
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>2018-04-17 15:33:35 +0000
committersubhash kumar singh <subhash.kumar.singh@huawei.com>2018-04-17 15:33:35 +0000
commitcd497f1f42b8e4540a4ebc0d968c1814ae73db2a (patch)
tree67f194c66711c5dda8ca97742bc348d6eef279a0 /mso-catalog-db/src/main
parent635e3ec4166a91871fd47f146f1b039c5be90a93 (diff)
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 <subhash.kumar.singh@huawei.com>
Diffstat (limited to 'mso-catalog-db/src/main')
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java27
1 files changed, 26 insertions, 1 deletions
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 <VnfRecipe> 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
*