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());
}
}
}
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);
}
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);
}
}
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();
}
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;
}
Aggregations