use of org.bedework.calfacade.BwAlarm in project bw-calendar-engine by Bedework.
the class AlarmRule method end.
public void end(String ns, String name) throws Exception {
BwAlarm entity = (BwAlarm) pop();
globals.counts[globals.valarms]++;
if (!(top() instanceof EventInfo)) {
warn("Expected an event info object: found " + top());
return;
}
BwEvent ev = ((EventInfo) top()).getEvent();
if (entity.getOwnerHref() == null) {
entity.setOwnerHref(ev.getOwnerHref());
}
entity.setEvent(ev);
ev.addAlarm(entity);
}
use of org.bedework.calfacade.BwAlarm in project bw-calendar-engine by Bedework.
the class BwUpdates method findSubComponent.
private Component findSubComponent(final EventInfo ei, final BaseComponentType bc) throws WebdavException {
try {
BwEvent ev = ei.getEvent();
int etype = ev.getEntityType();
if (bc instanceof ValarmType) {
if ((etype != IcalDefs.entityTypeEvent) || (etype != IcalDefs.entityTypeTodo)) {
return null;
}
/* Look for the alarm - we match on the whole component */
BwAlarm matched = null;
BwAlarm pattern = Xalarms.toBwAlarm((ValarmType) bc, false);
if ((pattern == null) || (ev.getNumAlarms() == 0)) {
return null;
}
for (BwAlarm al : ev.getAlarms()) {
if (al.matches(pattern)) {
if (matched != null) {
// Multiple matches - bad
return null;
}
matched = al;
}
}
return new PropertyUpdateComponent(ei, matched);
}
return null;
} catch (CalFacadeException cfe) {
throw new WebdavException(cfe);
}
}
use of org.bedework.calfacade.BwAlarm in project bw-calendar-engine by Bedework.
the class BwUpdates method addSubComp.
private UpdateResult addSubComp(final EventInfo ei, final ComponentReferenceType sel) throws WebdavException {
try {
BwEvent ev = ei.getEvent();
int etype = ev.getEntityType();
BaseComponentType bc = sel.getBaseComponent().getValue();
if (bc instanceof ValarmType) {
if ((etype != IcalDefs.entityTypeEvent) || (etype != IcalDefs.entityTypeTodo)) {
return new UpdateResult("Invalid entity type for alarm add");
}
BwAlarm al = Xalarms.toBwAlarm((ValarmType) bc, false);
if (al == null) {
return new UpdateResult("Invalid alarm for add");
}
ev.addAlarm(al);
return UpdateResult.getOkResult();
}
return new UpdateResult("Invalid entity type for add");
} catch (CalFacadeException cfe) {
throw new WebdavException(cfe);
}
}
use of org.bedework.calfacade.BwAlarm in project bw-calendar-engine by Bedework.
the class RepeatPropUpdater method applyUpdate.
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
BwAlarm alarm = ui.getSubComponent().getAlarm();
RepeatPropType pr = (RepeatPropType) ui.getProp();
if (ui.isRemove()) {
alarm.setRepeat(0);
flagChange(alarm, ui);
return UpdateResult.getOkResult();
}
if (ui.isAdd()) {
if (alarm.getRepeat() != 0) {
return new UpdateResult("Entity already has repeat - cannot add");
}
alarm.setRepeat(pr.getInteger().intValue());
flagChange(alarm, ui);
return UpdateResult.getOkResult();
}
if (!ui.isChange()) {
return new UpdateResult("No update specified for " + ui.getPropName());
}
/* Ensure the old value matches */
if (pr.getInteger().intValue() != alarm.getRepeat()) {
return new UpdateResult("Values don't match for update to " + ui.getPropName());
}
pr = (RepeatPropType) ui.getUpdprop();
alarm.setRepeat(pr.getInteger().intValue());
flagChange(alarm, ui);
return UpdateResult.getOkResult();
}
use of org.bedework.calfacade.BwAlarm in project bw-calendar-engine by Bedework.
the class TriggerPropUpdater method applyUpdate.
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
BwAlarm alarm = ui.getSubComponent().getAlarm();
TriggerPropType pr = (TriggerPropType) ui.getProp();
if (ui.isRemove()) {
return new UpdateResult("Cannot remove " + ui.getPropName());
}
if (ui.isAdd()) {
return new UpdateResult("Cannot add " + ui.getPropName());
}
if (!ui.isChange()) {
return new UpdateResult("No update specified for " + ui.getPropName());
}
/* Ensure the old value matches */
if (pr.getDateTime() != null) {
if (!alarm.getTriggerDateTime()) {
return new UpdateResult("Values don't match for update to " + ui.getPropName());
}
} else {
if (alarm.getTriggerDateTime()) {
return new UpdateResult("Values don't match for update to " + ui.getPropName());
}
}
pr = (TriggerPropType) ui.getUpdprop();
if (pr.getDateTime() != null) {
alarm.setTrigger(XcalUtil.getIcalFormatDateTime(pr.getDateTime()));
alarm.setTriggerDateTime(true);
} else {
alarm.setTrigger(pr.getDuration());
RelatedParamType r = (RelatedParamType) XcalUtil.findParam(pr, XcalTags.related);
alarm.setTriggerStart((r == null) || (r.getText().toUpperCase().equals("START")));
}
flagChange(alarm, ui);
return UpdateResult.getOkResult();
}
Aggregations