aboutsummaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/main/java
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2018-02-28 07:45:13 +0000
committerGerrit Code Review <gerrit@onap.org>2018-02-28 07:45:13 +0000
commit1aa00708fc21cba4de0817c07dd8f43fc0ee0a5c (patch)
tree775367dea9550aada915511fcbd75a2bc93ca277 /mso-catalog-db/src/main/java
parentd6aa2df0ed6574dbd91da24c63f66abe8f556e10 (diff)
parent7f3b9b70217a818cf940a017175d4260245ef1b5 (diff)
Merge "Support csar object query"
Diffstat (limited to 'mso-catalog-db/src/main/java')
-rw-r--r--mso-catalog-db/src/main/java/org/openecomp/mso/db/catalog/CatalogDatabase.java51
1 files changed, 51 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 2207bd7c38..534b5a38c9 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
@@ -3822,7 +3822,58 @@ public class CatalogDatabase implements Closeable {
LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getToscaCsar", null);
return resultList.get (0);
}
+
+ /**
+ * Return a specific Tosca CSAR Record resource (queried by atrifact uuid).
+ *
+ * @param toscaCsarArtifactUUID the artifact uuid of the tosca csar
+ * @return ToscaCsar object or null if none found
+ */
+ public ToscaCsar getToscaCsarByUUID(String toscaCsarArtifactUUID){
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get Tosca CSAR record with artifactUUID " + toscaCsarArtifactUUID);
+
+ String hql = "FROM ToscaCsar WHERE artifactUUID = :toscaCsarArtifactUUID";
+ Query query = getSession ().createQuery (hql);
+ query.setParameter ("toscaCsarArtifactUUID", toscaCsarArtifactUUID);
+ @SuppressWarnings("unchecked")
+ List <ToscaCsar> resultList = query.list ();
+
+ // See if something came back. Name is unique, so
+ if (resultList.isEmpty ()) {
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully. Tosca Csar not found", "CatalogDB", "getToscaCsarByUUID", null);
+ return null;
+ }
+
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getToscaCsarByUUID", null);
+ return resultList.get (0);
+ }
+
+ /**
+ * Return a specific Tosca CSAR Record resource (queried by service model uuid).
+ * <br>
+ *
+ * @param serviceModelUUID the service model uuid
+ * @return ToscaCsar object or null if none found
+ * @since ONAP Beijing Release
+ */
+ public ToscaCsar getToscaCsarByServiceModelUUID(String serviceModelUUID){
+ long startTime = System.currentTimeMillis ();
+ LOGGER.debug ("Catalog database - get Tosca CSAR record with serviceModelUUID " + serviceModelUUID);
+ Service service = getServiceByModelUUID(serviceModelUUID);
+ if(null == service){
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Service not found", "CatalogDB", "getToscaCsarByServiceModelUUID", null);
+ return null;
+ }
+ ToscaCsar csar = getToscaCsarByUUID(service.getToscaCsarArtifactUUID());
+ if(null == csar){
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Tosca csar of the service not found", "CatalogDB", "getToscaCsarByServiceModelUUID", null);
+ return null;
+ }
+ LOGGER.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "CatalogDB", "getToscaCsarByServiceModelUUID", null);
+ return csar;
+ }
public void saveTempNetworkHeatTemplateLookup (TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup) {
long startTime = System.currentTimeMillis ();