Search in sources :

Example 16 with BwAlarm

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

the class CoreEvents method setupDependentEntities.

/* ====================================================================
   *                   Private methods
   * ==================================================================== */
private void setupDependentEntities(final BwEvent val) throws CalFacadeException {
    // Ensure collections in reasonable state.
    if (val.getAlarms() != null) {
        for (final BwAlarm alarm : val.getAlarms()) {
            alarm.setEvent(val);
            alarm.setOwnerHref(getPrincipal().getPrincipalRef());
        }
    }
}
Also used : BwAlarm(org.bedework.calfacade.BwAlarm)

Example 17 with BwAlarm

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

the class AlarmFieldRule method field.

@Override
public void field(final String name) throws Throwable {
    if (skippedNames.contains(name)) {
        return;
    }
    BwString str = null;
    if (top() instanceof BwString) {
        str = (BwString) pop();
    }
    final BwAlarm ent = (BwAlarm) top();
    if (ownedEntityTags(ent, name)) {
        return;
    }
    if (name.equals("trigger")) {
        ent.setTrigger(stringFld());
        return;
    }
    if (name.equals("duration")) {
        ent.setDuration(stringFld());
        return;
    }
    if (name.equals("repeat")) {
        ent.setRepeat(intFld());
        return;
    }
    if (name.equals("attach")) {
        ent.setAttach(stringFld());
        return;
    }
    if (name.equals("expired")) {
        ent.setExpired(booleanFld());
        return;
    }
    if (name.equals("alarmType")) {
        ent.setAlarmType(intFld());
        return;
    }
    if (name.equals("triggerStart")) {
        ent.setTriggerStart(booleanFld());
        return;
    }
    if (name.equals("triggerDateTime")) {
        ent.setTriggerDateTime(booleanFld());
        return;
    }
    if (name.equals("triggerTime")) {
        // ignore
        return;
    }
    if (name.equals("repeatCount")) {
        ent.setRepeatCount(intFld());
        return;
    }
    if (name.equals("previousTrigger")) {
        // ignore
        return;
    }
    if (name.equals("byteSize")) {
        ent.setByteSize(intFld());
        return;
    }
    unknownTag(name);
}
Also used : BwString(org.bedework.calfacade.BwString) BwAlarm(org.bedework.calfacade.BwAlarm)

Example 18 with BwAlarm

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

the class Events method setDefaultAlarms.

private void setDefaultAlarms(final EventInfo ei, final BwCalendar col) throws CalFacadeException {
    BwEvent event = ei.getEvent();
    boolean isEvent = event.getEntityType() == IcalDefs.entityTypeEvent;
    boolean isTask = event.getEntityType() == IcalDefs.entityTypeTodo;
    if (!isEvent && !isTask) {
        return;
    }
    /* This test was wrong - we need to test the alarm for compatability with
     * the task/event
     */
    // if (isTask && (event.getNoStart())) {
    // return;
    // }
    boolean isDate = event.getDtstart().getDateType();
    String al = getDefaultAlarmDef(col, isEvent, isDate);
    if (al == null) {
        // Get the user home and try that
        al = getDefaultAlarmDef(getCols().getHome(), isEvent, isDate);
    }
    if ((al == null) || (al.length() == 0)) {
        return;
    }
    Set<BwAlarm> alarms = compileAlarms(al);
    if (alarms == null) {
        return;
    }
    for (BwAlarm alarm : alarms) {
        /* XXX At this point we should test to see if this alarm can be added -
       * e.g. we should not add an alarm triggered off start to a task with no
       * start
       */
        alarm.addXproperty(new BwXproperty(BwXproperty.appleDefaultAlarm, null, "TRUE"));
        event.addAlarm(alarm);
        ei.getChangeset(getPrincipalHref()).addValue(PropertyInfoIndex.VALARM, alarm);
    }
}
Also used : BwXproperty(org.bedework.calfacade.BwXproperty) BwEvent(org.bedework.calfacade.BwEvent) BwAlarm(org.bedework.calfacade.BwAlarm)

Example 19 with BwAlarm

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

the class EventInfo method toString.

@Override
public String toString() {
    ToString ts = new ToString(this);
    if (getEvent() == null) {
        ts.append("eventId", (Integer) null);
    } else {
        ts.append("eventId", getEvent().getId());
    }
    ts.append("editable", getEditable());
    ts.append("kind", kindStr[getKind()]);
    if (getAlarms() != null) {
        for (BwAlarm alarm : getAlarms()) {
            ts.append("alarm", alarm.toString());
        }
    }
    ts.append("recurrenceId", getEvent().getRecurrenceId());
    return ts.toString();
}
Also used : ToString(org.bedework.util.misc.ToString) BwAlarm(org.bedework.calfacade.BwAlarm)

Example 20 with BwAlarm

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

the class EventInfo method getDeletedOverrideProxies.

/**
 * @param userHref
 * @return Collection of deleted override proxy events or null
 * @throws CalFacadeException
 */
public Collection<BwEventProxy> getDeletedOverrideProxies(final String userHref) throws CalFacadeException {
    TreeSet<BwEventProxy> proxies = new TreeSet<>();
    if ((retrievedOverrides == null) || instanceOnly) {
        return proxies;
    }
    for (EventOverride eo : retrievedOverrides) {
        if (overrides.contains(eo)) {
            continue;
        }
        BwEventProxy proxy = (BwEventProxy) eo.getEvent();
        if (proxy.getRef().unsaved()) {
            throw new RuntimeException("Unsaved override in delete list");
        }
        if (proxy.getXproperty(BwXproperty.peruserInstance) == null) {
            /* Not peruser - remove it. */
            proxies.add(proxy);
            continue;
        }
        BwXproperty pu = proxy.findPeruserXprop(userHref, BwXproperty.peruserPropTransp);
        if (pu != null) {
            /* remove it */
            proxy.removeXproperty(pu);
        }
        /* Remove any alarm(s) */
        List<BwAlarm> toRemove = new ArrayList<>();
        for (BwAlarm a : proxy.getAlarms()) {
            if (a.getOwnerHref().equals(userHref)) {
                toRemove.add(a);
            }
        }
        for (BwAlarm a : toRemove) {
            proxy.removeAlarm(a);
        }
        if (Util.isEmpty(proxy.getXproperties(BwXproperty.peruserPropTransp)) && Util.isEmpty(proxy.getAlarms())) {
            /* No more peruser data - add to remove list */
            proxies.add(proxy);
        }
        /* Update the changes */
        ChangeTable chg = getChangeset(userHref);
        if (pu != null) {
            chg.addValue(PropertyInfoIndex.XPROP, pu);
        }
        if (!Util.isEmpty(toRemove)) {
            for (BwAlarm a : toRemove) {
                chg.addValue(PropertyInfoIndex.VALARM, a);
            }
        }
    }
    return proxies;
}
Also used : BwXproperty(org.bedework.calfacade.BwXproperty) TreeSet(java.util.TreeSet) ChangeTable(org.bedework.calfacade.util.ChangeTable) ArrayList(java.util.ArrayList) BwEventProxy(org.bedework.calfacade.BwEventProxy) BwAlarm(org.bedework.calfacade.BwAlarm)

Aggregations

BwAlarm (org.bedework.calfacade.BwAlarm)20 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)8 BwEvent (org.bedework.calfacade.BwEvent)6 BwXproperty (org.bedework.calfacade.BwXproperty)5 UpdateResult (org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)4 ValarmType (ietf.params.xml.ns.icalendar_2.ValarmType)3 TreeSet (java.util.TreeSet)3 BwString (org.bedework.calfacade.BwString)3 EventInfo (org.bedework.calfacade.svc.EventInfo)3 DurationPropType (ietf.params.xml.ns.icalendar_2.DurationPropType)2 RelatedParamType (ietf.params.xml.ns.icalendar_2.RelatedParamType)2 RepeatPropType (ietf.params.xml.ns.icalendar_2.RepeatPropType)2 TriggerPropType (ietf.params.xml.ns.icalendar_2.TriggerPropType)2 ComponentList (net.fortuna.ical4j.model.ComponentList)2 VEvent (net.fortuna.ical4j.model.component.VEvent)2 VToDo (net.fortuna.ical4j.model.component.VToDo)2 BwAttendee (org.bedework.calfacade.BwAttendee)2 BwLongString (org.bedework.calfacade.BwLongString)2 IndexException (org.bedework.util.indexing.IndexException)2 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)2