summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2018-04-17 22:50:06 +0000
committerGerrit Code Review <gerrit@onap.org>2018-04-17 22:50:06 +0000
commitb50bda5c78b1718242bb25f8638d087d340aa3b1 (patch)
treec72e3d5846b447cec9739333aea1fdb9d72314c6
parent971e9995cf63ed98d8507a1fbf2625012896acbf (diff)
parentcd497f1f42b8e4540a4ebc0d968c1814ae73db2a (diff)
Merge "Implement fetching default NS resource workflow"
-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
*