Search in sources :

Example 1 with NoDump

use of org.bedework.calfacade.annotations.NoDump in project bw-calendar-engine by Bedework.

the class BwAlarm method getXicalProperties.

/**
 * Find x-properties storing the value of the named ical property
 *
 * @param val - name to match
 * @return list of matching properties - never null
 *  @throws CalFacadeException
 */
@NoProxy
@NoDump
public List<BwXproperty> getXicalProperties(final String val) throws CalFacadeException {
    List<BwXproperty> res = new ArrayList<>();
    List<BwXproperty> xs = getXproperties();
    if (xs == null) {
        return res;
    }
    for (BwXproperty x : xs) {
        if (x.getName().equals(BwXproperty.bedeworkIcalProp)) {
            List<Xpar> xpars = x.getParameters();
            Xpar xp = xpars.get(0);
            if (xp.getName().equals(val)) {
                res.add(x);
            }
        }
    }
    return res;
}
Also used : Xpar(org.bedework.calfacade.BwXproperty.Xpar) ArrayList(java.util.ArrayList) NoProxy(org.bedework.calfacade.annotations.ical.NoProxy) NoDump(org.bedework.calfacade.annotations.NoDump)

Example 2 with NoDump

use of org.bedework.calfacade.annotations.NoDump in project bw-calendar-engine by Bedework.

the class BwAlarm method getNextTriggerDate.

/* ====================================================================
   *                      Convenience methods
   * ==================================================================== */
/**
 * Get the next trigger Date value. This is the next time for the
 * alarm.
 *
 * <p>This is based on the previous time which will have been set when the
 * alarm was last triggered.
 *
 * <p>Returns null for no more triggers.
 *
 * <p>Can be called repeatedly for the same result. To move to the next
 * trigger time, update repeatCount.
 *
 * @param start for instance to base this on
 * @param previousTrigger null for first
 *  @return Date   next trigger time as a date object
 *  @throws CalFacadeException on error
 */
@NoDump
public Date getNextTriggerDate(final BwDateTime start, final Date previousTrigger) throws CalFacadeException {
    if (previousTrigger == null) {
        // First time
        triggerDate = null;
        return getTriggerDate(start);
    }
    if (repeat == 0) {
        // No next trigger
        return null;
    }
    if (repeatCount == repeat) {
        // No next trigger
        return null;
    }
    repeatCount++;
    final Dur dur = new Duration(null, duration).getDuration();
    triggerDate = dur.getTime(previousTrigger);
    return triggerDate;
}
Also used : Dur(net.fortuna.ical4j.model.Dur) Duration(net.fortuna.ical4j.model.property.Duration) NoDump(org.bedework.calfacade.annotations.NoDump)

Example 3 with NoDump

use of org.bedework.calfacade.annotations.NoDump in project bw-calendar-engine by Bedework.

the class BwAlarm method getTriggerDate.

/**
 * Get the trigger Date value. This is the earliest time for the
 * alarm.
 *
 *  @return Date   trigger time as a date object
 *  @throws CalFacadeException on error
 */
@NoDump
public Date getTriggerDate(final BwDateTime start) throws CalFacadeException {
    try {
        if (triggerDate != null) {
            return triggerDate;
        }
        final Trigger tr = new Trigger();
        tr.setValue(getTrigger());
        /* if dt is null then it's a duration????
       */
        Date dt = tr.getDateTime();
        if (dt == null) {
            final Dur dur = tr.getDuration();
            if (start == null) {
                throw new CalFacadeException("No start date for alarm " + this);
            }
            dt = dur.getTime(BwDateTimeUtil.getDate(start));
        }
        triggerDate = dt;
        return dt;
    } catch (final CalFacadeException cfe) {
        throw cfe;
    } catch (final Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : Dur(net.fortuna.ical4j.model.Dur) Trigger(net.fortuna.ical4j.model.property.Trigger) Date(java.util.Date) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) NoDump(org.bedework.calfacade.annotations.NoDump)

Example 4 with NoDump

use of org.bedework.calfacade.annotations.NoDump in project bw-calendar-engine by Bedework.

the class BwCalendar method getRestoreCallback.

@NoDump
public static FromXmlCallback getRestoreCallback() {
    if (fromXmlCb == null) {
        fromXmlCb = new FromXmlCallback() {

            @Override
            public boolean save(final Element el, final Object theObject, final Object theValue) throws Throwable {
                if ("col-lastmod".equals(el.getTagName())) {
                    ((BwCalendar) theObject).setLastmod((BwCollectionLastmod) theValue);
                    return true;
                }
                return false;
            }
        };
        fromXmlCb.addClassForName("col-lastmod", BwCollectionLastmod.class);
        fromXmlCb.addClassForName("property", BwProperty.class);
        fromXmlCb.addSkips("byteSize", "id", "seq");
        fromXmlCb.addMapField("col-lastmod", "lastmod");
        fromXmlCb.addMapField("public", "publick");
    }
    return fromXmlCb;
}
Also used : Element(org.w3c.dom.Element) FromXmlCallback(org.bedework.util.xml.FromXmlCallback) NoDump(org.bedework.calfacade.annotations.NoDump)

Example 5 with NoDump

use of org.bedework.calfacade.annotations.NoDump in project bw-calendar-engine by Bedework.

the class BwCalendar method getEventList.

/**
 * Get the event list
 *
 * @return event list - never null
 */
@NoDump
public SortedSet<EventListEntry> getEventList() {
    final Set<BwProperty> props = getProperties(eventListProperty);
    final SortedSet<EventListEntry> res = new TreeSet<>();
    if (props == null) {
        return res;
    }
    for (final BwProperty prop : props) {
        final String[] vals = prop.getValue().split("\t");
        String curPath = null;
        for (final String s : vals) {
            if (s.startsWith("/")) {
                final EventListEntry ele = new EventListEntry(s);
                curPath = ele.getPath();
                res.add(ele);
            } else {
                res.add(new EventListEntry(curPath + s));
            }
        }
    }
    return res;
}
Also used : TreeSet(java.util.TreeSet) ToString(org.bedework.util.misc.ToString) NoDump(org.bedework.calfacade.annotations.NoDump)

Aggregations

NoDump (org.bedework.calfacade.annotations.NoDump)21 ToString (org.bedework.util.misc.ToString)8 FromXmlCallback (org.bedework.util.xml.FromXmlCallback)7 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)5 TreeSet (java.util.TreeSet)4 ArrayList (java.util.ArrayList)3 NoProxy (org.bedework.calfacade.annotations.ical.NoProxy)3 Method (java.lang.reflect.Method)2 QName (javax.xml.namespace.QName)2 Dur (net.fortuna.ical4j.model.Dur)2 Xpar (org.bedework.calfacade.BwXproperty.Xpar)2 Dump (org.bedework.calfacade.annotations.Dump)2 NoWrap (org.bedework.calfacade.annotations.NoWrap)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 Blob (java.sql.Blob)1 Timestamp (java.sql.Timestamp)1 Date (java.util.Date)1 DateTime (net.fortuna.ical4j.model.DateTime)1 Period (net.fortuna.ical4j.model.Period)1