Search in sources :

Example 31 with HibSession

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

the class PrincipalsAndPrefsDAO method removeMember.

public void removeMember(final BwGroup group, final BwPrincipal val, final boolean admin) throws CalFacadeException {
    final HibSession sess = getSess();
    if (admin) {
        sess.createQuery(findAdminGroupEntryQuery);
    } else {
        sess.createQuery(findGroupEntryQuery);
    }
    sess.setEntity("grp", group);
    sess.setInt("mbrId", val.getId());
    /* This is what I want to do but it inserts 'true' or 'false'
    sess.setBool("isgroup", (val instanceof BwGroup));
    */
    if (val instanceof BwGroup) {
        sess.setString("isgroup", "T");
    } else {
        sess.setString("isgroup", "F");
    }
    final Object ent = sess.getUnique();
    if (ent == null) {
        return;
    }
    sess.delete(ent);
}
Also used : HibSession(org.bedework.calcorei.HibSession) BwGroup(org.bedework.calfacade.BwGroup)

Example 32 with HibSession

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

the class PrincipalsAndPrefsDAO method findGroupParents.

/**
 * @param group the group
 * @param admin          true for an admin group
 * @return Collection
 * @throws CalFacadeException on error
 */
@SuppressWarnings("unchecked")
public Collection<BwGroup> findGroupParents(final BwGroup group, final boolean admin) throws CalFacadeException {
    final HibSession sess = getSess();
    if (admin) {
        sess.createQuery(getAdminGroupParentsQuery);
    } else {
        sess.createQuery(getGroupParentsQuery);
    }
    sess.setInt("grpid", group.getId());
    return sess.getList();
}
Also used : HibSession(org.bedework.calcorei.HibSession)

Example 33 with HibSession

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

the class CoreCalendarsDAO method getChildrenCollections.

public List getChildrenCollections(final String parentPath, final int start, final int count) throws CalFacadeException {
    final HibSession sess = getSess();
    if (parentPath == null) {
        sess.createQuery(getChildCollectionPathsQuery + " is null order by col.path");
    } else {
        sess.createQuery(getChildCollectionPathsQuery + "=:colPath order by col.path");
        sess.setString("colPath", parentPath);
    }
    sess.setString("tsfilter", BwCalendar.tombstonedFilter);
    if (start >= 0) {
        sess.setFirstResult(start);
        sess.setMaxResults(count);
    }
    final List res = sess.getList();
    if (Util.isEmpty(res)) {
        return null;
    }
    return res;
}
Also used : HibSession(org.bedework.calcorei.HibSession) ArrayList(java.util.ArrayList) List(java.util.List)

Example 34 with HibSession

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

the class CoreCalendarsDAO method getCollections.

protected List getCollections(final List<String> paths) throws CalFacadeException {
    final HibSession sess = getSess();
    sess.createQuery(getCollectionsQuery);
    sess.setParameterList("paths", paths);
    return sess.getList();
}
Also used : HibSession(org.bedework.calcorei.HibSession)

Example 35 with HibSession

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

the class CoreCalendarsDAO method getCollection.

public BwCalendar getCollection(final String path) throws CalFacadeException {
    final HibSession sess = getSess();
    sess.createQuery(getCalendarByPathQuery);
    sess.setString("path", path);
    sess.cacheableQuery();
    return (BwCalendar) sess.getUnique();
}
Also used : HibSession(org.bedework.calcorei.HibSession) BwCalendar(org.bedework.calfacade.BwCalendar)

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