@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);
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);
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
Transaction tx = session.beginTransaction();
session.save(newWidgetCatalog);
tx.commit();
- session.flush();
+ //session.flush();
session.close();
updateAppId(newWidgetCatalog.getId(), newWidgetCatalog.getWidgetRoles());
}
Transaction tx = session.beginTransaction();
session.update(newWidgetCatalog);
tx.commit();
- session.flush();
+ //session.flush();
session.close();
updateAppId(newWidgetCatalog.getId(), newWidgetCatalog.getWidgetRoles());
}catch(Exception e){
logger.debug("WidgetCatalogServiceImpl.getWidgetCatalog: result={}", widgets);
return widgets;
}
-
-
-
-
-
+
private void updateAppId(long widgetId, Set<RoleApp> roles){
Session session = sessionFactory.openSession();
for(RoleApp role: roles){
- String sql = "UPDATE ep_widget_catalog_role SET app_id = " + role.getApp().getAppId() + " WHERE widget_id = " + widgetId + " AND ROLE_ID = " + role.getRoleId() ;
+ String sql = "UPDATE ep_widget_catalog_role SET app_id = :appId WHERE widget_id = :widgetId AND ROLE_ID = :roleId" ;
Query query = session.createSQLQuery(sql);
+ query.setParameter("appId", role.getApp().getAppId());
+ query.setParameter("widgetId", widgetId);
+ query.setParameter("roleId", role.getRoleId());
query.executeUpdate();
}
session.flush();
List<MicroserviceData> widgets = criteria.list();
logger.debug("WidgetCatalogServiceImpl.getWidgetIdByName: result={}", widgets);
- session.flush();
+// session.flush();
session.close();
return (widgets.size() > 0) ? true : false;