Search in sources :

Example 46 with HibSession

use of org.bedework.calcorei.HibSession in project bw-calendar-engine by Bedework.

the class PrincipalsAndPrefsDAO method getAllAuthUsers.

@SuppressWarnings("unchecked")
public List<BwAuthUser> getAllAuthUsers() throws CalFacadeException {
    final HibSession sess = getSess();
    sess.createQuery(getAllAuthUsersQuery);
    return sess.getList();
}
Also used : HibSession(org.bedework.calcorei.HibSession)

Example 47 with HibSession

use of org.bedework.calcorei.HibSession in project bw-calendar-engine by Bedework.

the class PrincipalsAndPrefsDAO method getMembers.

@SuppressWarnings("unchecked")
public Collection<BwPrincipal> getMembers(final BwGroup group, final boolean admin) throws CalFacadeException {
    final HibSession sess = getSess();
    if (admin) {
        sess.createQuery(getAdminGroupUserMembersQuery);
    } else {
        sess.createQuery(getGroupUserMembersQuery);
    }
    sess.setEntity("gr", group);
    final Collection<BwPrincipal> ms = new TreeSet<>();
    ms.addAll(sess.getList());
    if (admin) {
        sess.createQuery(getAdminGroupGroupMembersQuery);
    } else {
        sess.createQuery(getGroupGroupMembersQuery);
    }
    sess.setEntity("gr", group);
    ms.addAll(sess.getList());
    return ms;
}
Also used : HibSession(org.bedework.calcorei.HibSession) BwPrincipal(org.bedework.calfacade.BwPrincipal) TreeSet(java.util.TreeSet)

Example 48 with HibSession

use of org.bedework.calcorei.HibSession in project bw-calendar-engine by Bedework.

the class PrincipalsAndPrefsDAO method getPrincipalHrefs.

public List<String> getPrincipalHrefs(final int start, final int count) throws CalFacadeException {
    final HibSession sess = getSess();
    sess.createQuery(getPrincipalHrefsQuery);
    sess.setFirstResult(start);
    sess.setMaxResults(count);
    @SuppressWarnings("unchecked") final List<String> res = sess.getList();
    if (Util.isEmpty(res)) {
        return null;
    }
    return res;
}
Also used : HibSession(org.bedework.calcorei.HibSession)

Example 49 with HibSession

use of org.bedework.calcorei.HibSession in project bw-calendar-engine by Bedework.

the class PrincipalsAndPrefsDAO method removeGroup.

/**
 * Delete a group
 *
 * @param  group           BwGroup group object to delete
 * @exception CalFacadeException If there's a problem
 */
public void removeGroup(final BwGroup group, final boolean admin) throws CalFacadeException {
    final HibSession sess = getSess();
    if (admin) {
        sess.createQuery(removeAllAdminGroupMemberRefsQuery);
    } else {
        sess.createQuery(removeAllGroupMembersQuery);
    }
    sess.setEntity("gr", group);
    sess.executeUpdate();
    if (admin) {
        sess.createQuery(removeFromAllAdminGroupsQuery);
    } else {
        sess.createQuery(removeFromAllGroupsQuery);
    }
    sess.setInt("mbrId", group.getId());
    /* This is what I want to do but it inserts 'true' or 'false'
    sess.setBool("isgroup", (val instanceof BwGroup));
    */
    sess.setString("isgroup", "T");
    sess.executeUpdate();
    sess.delete(group);
}
Also used : HibSession(org.bedework.calcorei.HibSession)

Example 50 with HibSession

use of org.bedework.calcorei.HibSession in project bw-calendar-engine by Bedework.

the class CoreEventPropertiesDAO method getAll.

@SuppressWarnings("unchecked")
public List<BwEventProperty> getAll(final String ownerHref) throws CalFacadeException {
    if (getAllQuery == null) {
        getAllQuery = "from " + className + " ent where " + " ent.ownerHref=:ownerHref" + " order by ent." + keyFieldName;
    }
    final HibSession sess = getSess();
    sess.createQuery(getAllQuery);
    if (debug) {
        debug("getAll: q=" + getAllQuery + " owner=" + ownerHref);
    }
    sess.setString("ownerHref", ownerHref);
    return sess.getList();
}
Also used : HibSession(org.bedework.calcorei.HibSession)

Aggregations

HibSession (org.bedework.calcorei.HibSession)60 Collection (java.util.Collection)4 BwCalendar (org.bedework.calfacade.BwCalendar)4 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)4 BwGroup (org.bedework.calfacade.BwGroup)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 TreeSet (java.util.TreeSet)2 BwEvent (org.bedework.calfacade.BwEvent)2 BwEventAnnotation (org.bedework.calfacade.BwEventAnnotation)2 BwEventProperty (org.bedework.calfacade.BwEventProperty)2 BwEventProxy (org.bedework.calfacade.BwEventProxy)2 BwPrincipal (org.bedework.calfacade.BwPrincipal)2 BwCalSuite (org.bedework.calfacade.svc.BwCalSuite)2 BwCategory (org.bedework.calfacade.BwCategory)1 BwContact (org.bedework.calfacade.BwContact)1 BwDateTime (org.bedework.calfacade.BwDateTime)1 BwFilterDef (org.bedework.calfacade.BwFilterDef)1 BwLocation (org.bedework.calfacade.BwLocation)1 BwRecurrenceInstance (org.bedework.calfacade.BwRecurrenceInstance)1