aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/main/java/org
diff options
context:
space:
mode:
authorc00149107 <chenchuanyu@huawei.com>2018-03-06 18:07:14 +0800
committerc00149107 <chenchuanyu@huawei.com>2018-03-06 18:07:14 +0800
commit04ef8dd312938513493ccf1ca1acb8b02d1a0dca (patch)
treee6aeb64bf6dd20d5357a9e4d20bd38b91d974132 /mso-catalog-db/src/main/java/org
parentb8566c560b21c595525e5bcba855c8632a8cd9db (diff)
Support query network recipe by module uuid
Support query network recipe by module uuid Change-Id: I8b49babf73f98c5e9ffe27463bd8227274440390 Issue-ID: SO-456 Signed-off-by: c00149107 <chenchuanyu@huawei.com>
Diffstat (limited to 'mso-catalog-db/src/main/java/org')
-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 f59c09a418..bbdb065027 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";
@@ -4443,6 +4444,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
@@ -4483,6 +4504,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