Search in sources :

Example 26 with HibSession

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

the class EntityDAO method getResourceContent.

public void getResourceContent(final BwResource val) throws CalFacadeException {
    final HibSession sess = getSess();
    sess.createQuery(getResourceContentQuery);
    sess.setString("path", val.getColPath());
    sess.setString("name", val.getName());
    sess.cacheableQuery();
    final BwResourceContent rc = (BwResourceContent) sess.getUnique();
    if (rc == null) {
        throw new CalFacadeException(CalFacadeException.missingResourceContent);
    }
    val.setContent(rc);
}
Also used : HibSession(org.bedework.calcorei.HibSession) BwResourceContent(org.bedework.calfacade.BwResourceContent) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 27 with HibSession

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

the class EntityDAO method getNResources.

@SuppressWarnings("unchecked")
public List<BwResource> getNResources(final String path, final int start, final int count) throws CalFacadeException {
    final HibSession sess = getSess();
    sess.createQuery(getNResourcesQuery);
    sess.setString("path", path);
    sess.setString("tsenc", BwResource.tombstoned);
    sess.setFirstResult(start);
    sess.setMaxResults(count);
    return sess.getList();
}
Also used : HibSession(org.bedework.calcorei.HibSession)

Example 28 with HibSession

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

the class EntityDAO method getEventsByAlarm.

@SuppressWarnings("unchecked")
public Collection<BwEvent> getEventsByAlarm(final BwAlarm alarm) throws CalFacadeException {
    final HibSession sess = getSess();
    sess.createQuery(eventByAlarmQuery);
    sess.setInt("alarmId", alarm.getId());
    return sess.getList();
}
Also used : HibSession(org.bedework.calcorei.HibSession)

Example 29 with HibSession

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

the class PrincipalsAndPrefsDAO method findGroup.

public BwGroup findGroup(final String account, final boolean admin) throws CalFacadeException {
    final HibSession sess = getSess();
    if (admin) {
        sess.createQuery(getAdminGroupQuery);
    } else {
        sess.createQuery(getGroupQuery);
    }
    sess.setString("account", account);
    return (BwGroup) sess.getUnique();
}
Also used : HibSession(org.bedework.calcorei.HibSession) BwGroup(org.bedework.calfacade.BwGroup)

Example 30 with HibSession

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

the class PrincipalsAndPrefsDAO method getGroups.

@SuppressWarnings("unchecked")
public Collection<BwGroup> getGroups(final BwPrincipal val, final boolean admin) throws CalFacadeException {
    final HibSession sess = getSess();
    if (admin) {
        sess.createQuery(getAdminGroupsQuery);
    } else {
        sess.createQuery(getGroupsQuery);
    }
    sess.setInt("entId", val.getId());
    /* This is what I want to do but it inserts 'true' or 'false'
    sess.setBool("isgroup", (val instanceof BwGroup));
    */
    if (val.getKind() == WhoDefs.whoTypeGroup) {
        sess.setString("isgroup", "T");
    } else {
        sess.setString("isgroup", "F");
    }
    final Set<BwGroup> gs = new TreeSet<>(sess.getList());
    if (admin && (val.getKind() == WhoDefs.whoTypeUser)) {
        /* Event owner for group is implicit member of group. */
        sess.createQuery(getAdminGroupsByEventOwnerQuery);
        sess.setString("ownerHref", val.getPrincipalRef());
        gs.addAll(sess.getList());
    }
    return gs;
}
Also used : HibSession(org.bedework.calcorei.HibSession) BwGroup(org.bedework.calfacade.BwGroup) TreeSet(java.util.TreeSet)

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