aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db
diff options
context:
space:
mode:
authorChuanyu Chen <chenchuanyu@huawei.com>2018-03-07 01:32:28 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-07 01:32:28 +0000
commite6c32b86f5a632c43d805c78ea8ed41ae6f0b22c (patch)
treeb649685c0112d05fd66f6760c8a1af895a623b3c /mso-catalog-db
parenta591b8d2e9c4615c4c134b6079e57757c1db0fce (diff)
parent04ef8dd312938513493ccf1ca1acb8b02d1a0dca (diff)
Merge "Support query network recipe by module uuid"
Diffstat (limited to 'mso-catalog-db')
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java61
1 files changed, 61 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 46d0473746..1e045b9200 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
@@ -87,6 +87,7 @@ public class CatalogDatabase implements Closeable {
private static final String VNF_COMPONENT_TYPE = "vnfComponentType";
private static final String MODEL_ID = "modelId";
private static final String MODEL_NAME = "modelName";
+ private static final String MODEL_VERSION = "version";
private static final String TYPE = "type";
private static final String MODEL_TYPE = "modelType";
private static final String MODEL_VERSION_ID = "modelVersionId";
@@ -4425,6 +4426,26 @@ public class CatalogDatabase implements Closeable {
}
}
+ /**
+ * 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 NetworkRecipe getNetworkRecipeByModuleUuid (String networkModelUuid, String action) {
+ LOGGER.debug ("Catalog database - get network recipe with network model uuid " + networkModelUuid
+ + " and action "
+ + action
+ );
+ NetworkResource networkResource = getNetworkResourceByModelUuid(networkModelUuid);
+ if(null == networkResource){
+ return null;
+ }
+
+ NetworkRecipe recipe = getNetworkRecipeByNameVersion(networkResource.getModelName(), networkResource.getModelVersion(), action);
+ return recipe;
+ }
/**
* Return a Network recipe that matches a given MODEL_NAME and ACTION
@@ -4465,6 +4486,46 @@ public class CatalogDatabase implements Closeable {
}
/**
+ * get network recipe by module name and version and action.
+ * <br>
+ *
+ * @param modelName
+ * @param modelVersion
+ * @param action
+ * @return
+ * @since ONAP Beijing Release
+ */
+ public NetworkRecipe getNetworkRecipeByNameVersion(String modelName, String modelVersion, String action) {
+
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get network recipe with network model name " + modelName
+ +"model version " + modelVersion + " and action " + action);
+
+ try {
+ String hql = "FROM NetworkRecipe WHERE modelName = :modelName AND version=:version AND action = :action";
+
+ Query query = getSession ().createQuery (hql);
+ query.setParameter (MODEL_NAME, modelName);
+ query.setParameter (MODEL_VERSION, modelVersion);
+ query.setParameter (ACTION, action);
+
+ @SuppressWarnings("unchecked")
+ List <NetworkRecipe> resultList = query.list ();
+
+ if (resultList.isEmpty ()) {
+ return null;
+ }
+
+ Collections.sort (resultList, new MavenLikeVersioningComparator ());
+ Collections.reverse (resultList);
+
+ return resultList.get (0);
+ } finally {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getNetworkRecipe", null);
+ }
+ }
+
+ /**
* Return a Network Resource that matches the Network Customization defined by given MODEL_CUSTOMIZATION_UUID
*
* @param networkType