Merge "Widget MS startup fix and Onboarding changes"
[portal.git] / ecomp-portal-widget-ms / widget-ms / src / main / java / org / onap / portalapp / widget / service / impl / WidgetCatalogServiceImpl.java
index 59180d3..d71356f 100644 (file)
@@ -148,14 +148,13 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService {
        @Override
        public WidgetCatalog getWidgetCatalog(Long widgetCatalogId) {
                Session session = sessionFactory.getCurrentSession();
-               Transaction tx = session.beginTransaction();
                WidgetCatalog widget = (WidgetCatalog) session.get(WidgetCatalog.class, widgetCatalogId);
-               tx.commit();
                logger.debug("WidgetCatalogServiceImpl.getWidgetCatalog: getting widget={}", widget);
                return widget;
        }
        
        @Override
+       @Transactional
        public void deleteWidgetCatalog(long widgetCatalogId) {
                logger.debug("WidgetCatalogServiceImpl.deleteWidgetCatalog: deleting the widget with widgetId={}", widgetCatalogId);
                WidgetCatalog widget = getWidgetCatalog(widgetCatalogId);
@@ -164,7 +163,7 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService {
                        return;
                }
                Session session = sessionFactory.getCurrentSession();
-               Transaction tx = session.beginTransaction();
+               //Transaction tx = session.beginTransaction();
                Query query = session.createSQLQuery("delete from ep_pers_user_widget_sel where widget_id = :widgetId ").setParameter("widgetId", widgetCatalogId);
                query.executeUpdate();
                query = session.createSQLQuery("delete from ep_pers_user_widget_placement where widget_id = :widgetId ").setParameter("widgetId", widgetCatalogId);
@@ -174,7 +173,7 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService {
                query = session.createSQLQuery("delete from ep_widget_catalog_parameter where widget_id = :widgetId ").setParameter("widgetId", widgetCatalogId);
                query.executeUpdate();
                session.delete(widget);
-               tx.commit();
+               //tx.commit();
        }
        
        @Override
@@ -191,7 +190,7 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService {
                        Transaction tx = session.beginTransaction();            
                        session.save(newWidgetCatalog);
                        tx.commit();
-                       session.flush();
+                       //session.flush();
                        session.close();
                        updateAppId(newWidgetCatalog.getId(), newWidgetCatalog.getWidgetRoles());
                }
@@ -217,7 +216,7 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService {
                        Transaction tx = session.beginTransaction();
                        session.update(newWidgetCatalog);
                        tx.commit();
-                       session.flush();
+                       //session.flush();
                        session.close();
                        updateAppId(newWidgetCatalog.getId(), newWidgetCatalog.getWidgetRoles());
                }catch(Exception e){
@@ -268,7 +267,7 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService {
                
                List<MicroserviceData> widgets = criteria.list();
                logger.debug("WidgetCatalogServiceImpl.getWidgetIdByName: result={}", widgets);
-               session.flush();
+//             session.flush();
                session.close();
                
                return (widgets.size() > 0) ? true : false;