@Override protected void doInTransactionWithoutResult(TransactionStatus status) { transactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { @Override public void afterCommit() { clearLockedPipelineStateCache(pipelineName); } }); transactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { @Override public void afterCompletion(int status) { for (AfterCompletionCallback callback : afterCompletionCallbacks) { callback.execute(status); } } }); final String cacheKey = pipelineLockStateCacheKey(pipelineName); PipelineState fromCache = pipelineStateFor(pipelineName); PipelineState toBeSaved = null; if (fromCache == null) { toBeSaved = new PipelineState(pipelineName); } else { toBeSaved = (PipelineState) sessionFactory.getCurrentSession().load(PipelineState.class, fromCache.getId()); } toBeSaved.unlock(); sessionFactory.getCurrentSession().saveOrUpdate(toBeSaved); } });
toBeSaved = new PipelineState(pipelineName); } else { toBeSaved = (PipelineState) sessionFactory.getCurrentSession().load(PipelineState.class, fromCache.getId());
@Override public Territory findById(long groupId) throws GeomajasSecurityException { return (Territory) factory.getCurrentSession().load(Territory.class, groupId); }
@Override public Territory findById(long groupId) throws GeomajasSecurityException { return (Territory) factory.getCurrentSession().load(Territory.class, groupId); }
public IVRCallSession loadIVRCallSession(long id) { return (IVRCallSession)sessionFactory.getCurrentSession().load(IVRCallSession.class, id); }
@Override public void addUserToGroup(long userId, long groupId, Role role) throws GeomajasSecurityException { User user = (User) factory.getCurrentSession().load(User.class, userId); Territory group = (Territory) factory.getCurrentSession().load(Territory.class, groupId); if (user != null && group != null) { user.addToGroupInRole(group, role); } }
@Override public void removeUserFromGroupInRole(long userId, long groupId, Role role) throws GeomajasSecurityException { User user = (User) factory.getCurrentSession().load(User.class, userId); Territory group = (Territory) factory.getCurrentSession().load(Territory.class, groupId); if (user != null && group != null) { user.removeFromGroupInRole(group, role); } }
@Override public void removeUserFromGroupInRole(long userId, long groupId, Role role) throws GeomajasSecurityException { User user = (User) factory.getCurrentSession().load(User.class, userId); Territory group = (Territory) factory.getCurrentSession().load(Territory.class, groupId); if (user != null && group != null) { user.removeFromGroupInRole(group, role); } }
@Override public void addUserToGroup(long userId, long groupId, Role role) throws GeomajasSecurityException { User user = (User) factory.getCurrentSession().load(User.class, userId); Territory group = (Territory) factory.getCurrentSession().load(Territory.class, groupId); if (user != null && group != null) { user.addToGroupInRole(group, role); } }
@Override public void setUserActive(long userId, boolean active) throws GeomajasSecurityException { User user = (User) factory.getCurrentSession().load(User.class, userId); if (user != null) { user.setActive(active); } }
@Override public void setUserActive(long userId, boolean active) throws GeomajasSecurityException { User user = (User) factory.getCurrentSession().load(User.class, userId); if (user != null) { user.setActive(active); } }
/** * {@inheritDoc} */ @Override public JCUser loadById(Long id) { return (JCUser) session().load(JCUser.class, id); }
public Object doInHibernate(Session session) throws HibernateException, SQLException { try { log.debug("Loading class: {}, id {}, method {}", new Object[] {className, id, methodName}); Object entity = sessionFactory.getCurrentSession().load(Class.forName(className), id); Object retVal = PropertyUtils.getProperty(entity, methodName); if (init) { return init(retVal); } return retVal; } catch (Exception ex) { log.error("{}", ex); throw new HibernateException(ex); } }
@Override public Territory updateGroupGeometry(long groupId, String crs, Geometry geometry) { Territory group = (Territory) factory.getCurrentSession().load(Territory.class, groupId); if (group != null) { group.setCrs(crs); group.setGeometry(geometry); } return group; }
@Override public Territory updateGroup(long groupId, String name, String key) { Territory group = (Territory) factory.getCurrentSession().load(Territory.class, groupId); if (group != null) { group.setName(name); group.setCode(key); } return group; }
@Override public Territory updateGroupGeometry(long groupId, String crs, Geometry geometry) { Territory group = (Territory) factory.getCurrentSession().load(Territory.class, groupId); if (group != null) { group.setCrs(crs); group.setGeometry(geometry); } return group; }
@Override public Territory updateGroup(long groupId, String name, String key) { Territory group = (Territory) factory.getCurrentSession().load(Territory.class, groupId); if (group != null) { group.setName(name); group.setCode(key); } return group; }
@Override public void changePassword(long userId, String newPassword) throws GeomajasSecurityException { User user = (User) factory.getCurrentSession().load(User.class, userId); if (user != null) { user.setPassword(encodePassword(user.getEmail(), newPassword)); factory.getCurrentSession().saveOrUpdate(user); } }
@Override public void changePassword(long userId, String newPassword) throws GeomajasSecurityException { User user = (User) factory.getCurrentSession().load(User.class, userId); if (user != null) { user.setPassword(encodePassword(user.getEmail(), newPassword)); factory.getCurrentSession().saveOrUpdate(user); } }
/** * {@inheritDoc} */ @Override public void updateProperties(List<PluginProperty> properties) { for (PluginProperty property: properties) { PluginProperty persistedProperty = (PluginProperty) session().load(property.getClass(), property.getId()); persistedProperty.setValue(property.getValue()); session().saveOrUpdate(persistedProperty); } session().flush(); } }