aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db
diff options
context:
space:
mode:
authorc00149107 <chenchuanyu@huawei.com>2018-03-07 09:39:58 +0800
committerc00149107 <chenchuanyu@huawei.com>2018-03-07 09:39:58 +0800
commitb5ee9a189cc001d4d1a23a2626fbe1458251b125 (patch)
tree7111d6a0fbd5547ba09f18b81a8d9cf20f76d684 /mso-catalog-db
parent04ef8dd312938513493ccf1ca1acb8b02d1a0dca (diff)
Support query vnf recipe by vnf model uuid
Support query vnf recipe by vnf model uuid Change-Id: Ie85fff28586e31bc4c5f3cc90a6360e7af3ba575 Issue-ID: SO-456 Signed-off-by: c00149107 <chenchuanyu@huawei.com>
Diffstat (limited to 'mso-catalog-db')
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java59
1 files changed, 59 insertions, 0 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 bbdb065027..a01527ed8d 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
@@ -1130,6 +1130,8 @@ public class CatalogDatabase implements Closeable {
return resultList.get(0);
}
+
+
/**
* Return a VNF recipe that matches a given VNF_TYPE and ACTION
*
@@ -1163,6 +1165,63 @@ public class CatalogDatabase implements Closeable {
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 ModelName and Modelversion and ACTION
+ *
+ * @param modelName
+ * @param modelVersion
+ * @param action
+ * @return VnfRecipe object or null if none found
+ */
+ public VnfRecipe getVnfRecipeByNameVersion(String modelName, String modelVersion, String action) {
+ StringBuilder hql = new StringBuilder("FROM VnfRecipe WHERE vnfType = :vnfType AND version= :version AND action = :action ");
+
+ long startTime = System.currentTimeMillis();
+ LOGGER.debug("Catalog database - get VNF recipe with name " + modelName
+ + " and action "
+ + action);
+
+ Query query = getSession().createQuery(hql.toString());
+ query.setParameter(VNF_TYPE, modelName);
+ query.setParameter(MODEL_VERSION, modelVersion);
+ 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;
+ }
+
+ Collections.sort(resultList, new MavenLikeVersioningComparator());
+ Collections.reverse(resultList);
+
+ LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getVnfRecipe", null);
+ return resultList.get(0);
+ }
+
+ /**
+ * Return a Network recipe that matches a given MODEL_UUID and ACTION
+ *
+ * @param modelName
+ * @param action
+ * @return NetworkRecipe object or null if none found
+ */
+ public VnfRecipe getVnfRecipeByModuleUuid (String vnfModelUuid, String action) {
+ LOGGER.debug ("Catalog database - get vnf recipe with vnf resource model uuid " + vnfModelUuid
+ + " and action "
+ + action
+ );
+ VnfResource vnfResource = getVnfResourceByModelUuid(vnfModelUuid);
+ if(null == vnfResource){
+ return null;
+ }
+
+ VnfRecipe recipe = this.getVnfRecipeByNameVersion(vnfResource.getModelName(), vnfResource.getModelVersion(), action);
+ return recipe;
+ }
/**
* Return a VNF recipe that matches a given VF_MODULE_ID and ACTION