Search in sources :

Example 1 with Action

use of net.fortuna.ical4j.model.property.Action in project bw-calendar-engine by Bedework.

the class VAlarmUtil method setAlarm.

private static VAlarm setAlarm(final BwEvent ev, final BwAlarm val) throws CalFacadeException {
    try {
        VAlarm alarm = new VAlarm();
        int atype = val.getAlarmType();
        String action;
        if (atype != BwAlarm.alarmTypeOther) {
            action = BwAlarm.alarmTypes[atype];
        } else {
            List<BwXproperty> xps = val.getXicalProperties("ACTION");
            action = xps.get(0).getValue();
        }
        addProperty(alarm, new Action(action));
        if (val.getTriggerDateTime()) {
            DateTime dt = new DateTime(val.getTrigger());
            addProperty(alarm, new Trigger(dt));
        } else {
            Trigger tr = new Trigger(new Dur(val.getTrigger()));
            if (!val.getTriggerStart()) {
                addParameter(tr, Related.END);
            } else {
            // Not required - it's the default - but we fail some Cyrus tests otherwise
            // Apparently Cyrus now handles the default state correctly
            // addParameter(tr, Related.START);
            }
            addProperty(alarm, tr);
        }
        if (val.getDuration() != null) {
            addProperty(alarm, new Duration(new Dur(val.getDuration())));
            addProperty(alarm, new Repeat(val.getRepeat()));
        }
        if (atype == BwAlarm.alarmTypeAudio) {
            if (val.getAttach() != null) {
                addProperty(alarm, new Attach(new URI(val.getAttach())));
            }
        } else if (atype == BwAlarm.alarmTypeDisplay) {
            // checkRequiredProperty(val.getDescription(), "alarm-description");
            if (val.getDescription() != null) {
                addProperty(alarm, new Description(val.getDescription()));
            } else {
                addProperty(alarm, new Description(ev.getSummary()));
            }
        } else if (atype == BwAlarm.alarmTypeEmail) {
            if (val.getAttach() != null) {
                addProperty(alarm, new Attach(new URI(val.getAttach())));
            }
            checkRequiredProperty(val.getDescription(), "alarm-description");
            addProperty(alarm, new Description(val.getDescription()));
            checkRequiredProperty(val.getSummary(), "alarm-summary");
            addProperty(alarm, new Summary(val.getSummary()));
            if (val.getNumAttendees() > 0) {
                for (BwAttendee att : val.getAttendees()) {
                    addProperty(alarm, setAttendee(att));
                }
            }
        } else if (atype == BwAlarm.alarmTypeProcedure) {
            checkRequiredProperty(val.getAttach(), "alarm-attach");
            addProperty(alarm, new Attach(new URI(val.getAttach())));
            if (val.getDescription() != null) {
                addProperty(alarm, new Description(val.getDescription()));
            }
        } else {
            if (val.getDescription() != null) {
                addProperty(alarm, new Description(val.getDescription()));
            }
        }
        if (val.getNumXproperties() > 0) {
            /* This event has x-props */
            IcalUtil.xpropertiesToIcal(alarm.getProperties(), val.getXproperties());
        }
        return alarm;
    } catch (CalFacadeException cfe) {
        throw cfe;
    } catch (Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : Dur(net.fortuna.ical4j.model.Dur) Action(net.fortuna.ical4j.model.property.Action) Description(net.fortuna.ical4j.model.property.Description) Attach(net.fortuna.ical4j.model.property.Attach) Duration(net.fortuna.ical4j.model.property.Duration) Repeat(net.fortuna.ical4j.model.property.Repeat) URI(java.net.URI) DateTime(net.fortuna.ical4j.model.DateTime) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) Trigger(net.fortuna.ical4j.model.property.Trigger) BwXproperty(org.bedework.calfacade.BwXproperty) Summary(net.fortuna.ical4j.model.property.Summary) VAlarm(net.fortuna.ical4j.model.component.VAlarm) BwAttendee(org.bedework.calfacade.BwAttendee)

Aggregations

URI (java.net.URI)1 DateTime (net.fortuna.ical4j.model.DateTime)1 Dur (net.fortuna.ical4j.model.Dur)1 VAlarm (net.fortuna.ical4j.model.component.VAlarm)1 Action (net.fortuna.ical4j.model.property.Action)1 Attach (net.fortuna.ical4j.model.property.Attach)1 Description (net.fortuna.ical4j.model.property.Description)1 Duration (net.fortuna.ical4j.model.property.Duration)1 Repeat (net.fortuna.ical4j.model.property.Repeat)1 Summary (net.fortuna.ical4j.model.property.Summary)1 Trigger (net.fortuna.ical4j.model.property.Trigger)1 BwAttendee (org.bedework.calfacade.BwAttendee)1 BwXproperty (org.bedework.calfacade.BwXproperty)1 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)1