use of net.fortuna.ical4j.model.property.Repeat 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);
}
}
Aggregations