summaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/main/java
diff options
context:
space:
mode:
authorChuanyu Chen <chenchuanyu@huawei.com>2018-03-07 03:56:56 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-07 03:56:56 +0000
commitd9134ec971e925bc03069666c1511146d2df50e7 (patch)
treefb07ad5d2f4b1fd8067e97b2ab9d0fa160a600a6 /mso-catalog-db/src/main/java
parente6c32b86f5a632c43d805c78ea8ed41ae6f0b22c (diff)
parentb5ee9a189cc001d4d1a23a2626fbe1458251b125 (diff)
Merge "Support query vnf recipe by vnf model uuid"
Diffstat (limited to 'mso-catalog-db/src/main/java')
-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 1e045b9200..6083f1bd9f 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
*
@@ -1162,6 +1164,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