Search in sources :

Example 1 with HibSession

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

the class CoreCalendarsDAO method getChildCollections.

@SuppressWarnings("unchecked")
protected List getChildCollections(final String parentPath) throws CalFacadeException {
    final HibSession sess = getSess();
    if (parentPath == null) {
        sess.createQuery(getChildCollectionsQuery + " is null order by col.path");
    } else {
        sess.createQuery(getChildCollectionsQuery + "=:colPath order by col.path");
        sess.setString("colPath", parentPath);
    }
    sess.setString("tsfilter", BwCalendar.tombstonedFilter);
    return sess.getList();
}
Also used : HibSession(org.bedework.calcorei.HibSession)

Example 2 with HibSession

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

the class CoreCalendarsDAO method touchCollection.

protected void touchCollection(final BwCalendar col, final Timestamp ts) throws CalFacadeException {
    // CALWRAPPER - if we're not cloning can we avoid this?
    // val = (BwCalendar)getSess().merge(val);
    // val = (BwCalendar)getSess().merge(val);
    final BwLastMod lm = col.getLastmod();
    lm.updateLastmod(ts);
    final HibSession sess = getSess();
    sess.createQuery(touchCalendarQuery);
    sess.setString("timestamp", lm.getTimestamp());
    sess.setInt("sequence", lm.getSequence());
    sess.setString("path", col.getPath());
    sess.executeUpdate();
}
Also used : HibSession(org.bedework.calcorei.HibSession) BwLastMod(org.bedework.calfacade.base.BwLastMod)

Example 3 with HibSession

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

the class CoreCalendarsDAO method deleteCalendar.

protected void deleteCalendar(final BwCalendar val) throws CalFacadeException {
    final HibSession sess = getSess();
    sess.delete(val);
}
Also used : HibSession(org.bedework.calcorei.HibSession)

Example 4 with HibSession

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

the class CoreCalendarsDAO method getSynchInfo.

protected CollectionSynchInfo getSynchInfo(final String path, final String token) throws CalFacadeException {
    final HibSession sess = getSess();
    sess.createQuery(getSynchInfoQuery);
    sess.setString("path", path);
    sess.cacheableQuery();
    final Object[] lmfields = (Object[]) sess.getUnique();
    if (lmfields == null) {
        return null;
    }
    final CollectionSynchInfo csi = new CollectionSynchInfo();
    csi.token = BwLastMod.getTagValue((String) lmfields[0], (Integer) lmfields[1]);
    csi.changed = (token == null) || (!csi.token.equals(token));
    return csi;
}
Also used : HibSession(org.bedework.calcorei.HibSession) CollectionSynchInfo(org.bedework.calfacade.CollectionSynchInfo)

Example 5 with HibSession

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

the class CoreCalendarsDAO method collectionExists.

public boolean collectionExists(final String path) throws CalFacadeException {
    final HibSession sess = getSess();
    sess.createQuery(collectionExistsQuery);
    sess.setString("path", path);
    final Collection refs = sess.getList();
    final Object o = refs.iterator().next();
    /* Apparently some get a Long - others get Integer */
    if (o instanceof Long) {
        final Long ct = (Long) o;
        return ct > 0;
    }
    final Integer ct = (Integer) o;
    return ct > 0;
}
Also used : HibSession(org.bedework.calcorei.HibSession) Collection(java.util.Collection)

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