[MSO-8] Update the maven dependency
[so.git] / mso-api-handlers / mso-requests-db / src / main / java / org / openecomp / mso / requestsdb / RequestsDatabase.java
index fda4461..e32c456 100644 (file)
@@ -35,13 +35,17 @@ import org.hibernate.criterion.Criterion;
 import org.hibernate.criterion.Order;
 import org.hibernate.criterion.Restrictions;
 import org.hibernate.persister.entity.AbstractEntityPersister;
-
+import org.openecomp.mso.db.HibernateUtils;
+import org.openecomp.mso.requestsdb.HibernateUtilsRequestsDb;
 import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.logger.MessageEnum;
 
 public class RequestsDatabase {
 
+    protected static HibernateUtils hibernateUtils = new HibernateUtilsRequestsDb ();
+    
     protected static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
-
+    
     protected static final String         SOURCE                     = "source";
     protected static final String         START_TIME                 = "startTime";
     protected static final String         REQUEST_TYPE               = "requestType";
@@ -70,7 +74,7 @@ public class RequestsDatabase {
     }
 
     public static boolean healthCheck () {
-        Session session = HibernateUtil.getSessionFactory ().openSession ();
+        Session session = hibernateUtils.getSessionFactory ().openSession ();
         try {
             Query query = session.createSQLQuery (" show tables ");
 
@@ -88,7 +92,7 @@ public class RequestsDatabase {
     public static int updateInfraStatus (String requestId, String requestStatus, String lastModifiedBy) {
         long startTime = System.currentTimeMillis ();
         msoLogger.debug ("Update infra request record " + requestId + " with status " + requestStatus);
-        Session session = HibernateUtil.getSessionFactory ().openSession ();
+        Session session = hibernateUtils.getSessionFactory ().openSession ();
 
         int result = 0;
         try {
@@ -113,7 +117,7 @@ public class RequestsDatabase {
     public static int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) {
         long startTime = System.currentTimeMillis ();
         msoLogger.debug ("Update infra request record " + requestId + " with status " + requestStatus);
-        Session session = HibernateUtil.getSessionFactory ().openSession ();
+        Session session = hibernateUtils.getSessionFactory ().openSession ();
 
         int result = 0;
         try {
@@ -139,7 +143,7 @@ public class RequestsDatabase {
     public static int updateInfraFinalStatus (String requestId, String requestStatus, String statusMessage, long progress, String responseBody, String lastModifiedBy) {
         long startTime = System.currentTimeMillis ();
         msoLogger.debug ("Update infra request record " + requestId + " with status " + requestStatus);
-        Session session = HibernateUtil.getSessionFactory ().openSession ();
+        Session session = hibernateUtils.getSessionFactory ().openSession ();
 
         int result = 0;
         try {
@@ -172,7 +176,7 @@ public class RequestsDatabase {
         
         List <InfraActiveRequests> results = new ArrayList<InfraActiveRequests>();
 
-        Session session = HibernateUtil.getSessionFactory ().openSession ();
+        Session session = hibernateUtils.getSessionFactory ().openSession ();
         try {
             session.beginTransaction ();
             Criteria crit = session.createCriteria (InfraActiveRequests.class);
@@ -197,7 +201,7 @@ public class RequestsDatabase {
         long startTime = System.currentTimeMillis ();
         msoLogger.debug ("Get request " + requestId + " from InfraActiveRequests DB");
 
-        Session session = HibernateUtil.getSessionFactory ().openSession ();
+        Session session = hibernateUtils.getSessionFactory ().openSession ();
         InfraActiveRequests ar = null;
         try {
             session.beginTransaction ();
@@ -314,7 +318,7 @@ public class RequestsDatabase {
         long startTime = System.currentTimeMillis ();
         msoLogger.debug ("Get list of infra requests from DB with " + queryAttributeName + " = " + queryValue);
 
-        Session session = HibernateUtil.getSessionFactory ().openSession ();
+        Session session = hibernateUtils.getSessionFactory ().openSession ();
         try {
             session.beginTransaction ();
             Criteria crit = session.createCriteria (InfraActiveRequests.class)
@@ -342,7 +346,7 @@ public class RequestsDatabase {
         long startTime = System.currentTimeMillis ();
         msoLogger.debug ("Get infra request from DB with id " + requestId);
 
-        Session session = HibernateUtil.getSessionFactory ().openSession ();
+        Session session = hibernateUtils.getSessionFactory ().openSession ();
         InfraActiveRequests ar = null;
         try {
             session.beginTransaction ();
@@ -366,7 +370,7 @@ public class RequestsDatabase {
         msoLogger.debug ("Get infra request from DB for VNF " + vnfName + " and action " + action + " and requestType " + requestType);
 
         InfraActiveRequests ar = null;
-        Session session = HibernateUtil.getSessionFactory ().openSession ();
+        Session session = hibernateUtils.getSessionFactory ().openSession ();
 
         try {
             session.beginTransaction ();
@@ -395,7 +399,7 @@ public class RequestsDatabase {
         msoLogger.debug ("Get list of infra requests from DB for VNF " + vnfId + " and action " + action);
 
         InfraActiveRequests ar = null;
-        Session session = HibernateUtil.getSessionFactory ().openSession ();
+        Session session = hibernateUtils.getSessionFactory ().openSession ();
 
         try {
             session.beginTransaction ();
@@ -429,7 +433,7 @@ public class RequestsDatabase {
      * @return SiteStatus object or null if none found
      */
     public static SiteStatus getSiteStatus (String siteName) {
-        Session session = HibernateUtil.getSessionFactory ().openSession ();
+        Session session = hibernateUtils.getSessionFactory ().openSession ();
 
         long startTime = System.currentTimeMillis ();
         SiteStatus siteStatus = null;
@@ -456,7 +460,7 @@ public class RequestsDatabase {
      * @param status The updated status of the Site
      */
     public static void updateSiteStatus (String siteName, boolean status) {
-        Session session = HibernateUtil.getSessionFactory ().openSession ();
+        Session session = hibernateUtils.getSessionFactory ().openSession ();
         session.beginTransaction ();
 
         long startTime = System.currentTimeMillis ();