use of org.bedework.calfacade.util.ChangeTableEntry in project bw-calendar-engine by Bedework.
the class PriorityPropUpdater method applyUpdate.
@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
BwEvent ev = ui.getEvent();
PriorityPropType pr = (PriorityPropType) ui.getProp();
ChangeTableEntry cte = ui.getCte();
BigInteger val = pr.getInteger();
BigInteger evVal = null;
if (ev.getPriority() != null) {
evVal = BigInteger.valueOf(ev.getPriority());
}
if (ui.isRemove()) {
if (evVal == null) {
return new UpdateResult("Entity has no " + ui.getPropName() + " property - cannot remove");
}
val = null;
} else if (ui.isAdd()) {
if (evVal != null) {
return new UpdateResult("Entity already has " + ui.getPropName() + " property - cannot add");
}
} else if (!ui.isChange()) {
return new UpdateResult("No update specified for " + ui.getPropName());
} else {
if (!val.equals(evVal)) {
return new UpdateResult("Values don't match for update to " + ui.getPropName());
}
val = ((PriorityPropType) ui.getUpdprop()).getInteger();
}
if (val != null) {
int ival = val.intValue();
if ((ival < 0) || (ival > 9)) {
return new UpdateResult("Value for " + ui.getPropName() + " must be >= 0 and <= 9 ");
}
}
if (Util.cmpObjval(val, evVal) != 0) {
cte.setChanged(evVal, val);
ev.setPriority(val.intValue());
}
return UpdateResult.getOkResult();
}
use of org.bedework.calfacade.util.ChangeTableEntry in project bw-calendar-engine by Bedework.
the class RdatePropUpdater method applyUpdate.
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
try {
BwEvent ev = ui.getEvent();
ChangeTableEntry cte = ui.getCte();
Set<BwDateTime> evDts = ev.getRdates();
DateDatetimePropertyType dt = (DateDatetimePropertyType) ui.getProp();
String dtUTC = XcalUtil.getUTC(dt, ui.getTzs());
if (ui.isRemove()) {
removeDt(dtUTC, evDts, cte);
return UpdateResult.getOkResult();
}
BwDateTime prdt = BwDateTime.makeBwDateTime(dt);
if (ui.isAdd()) {
addDt(prdt, evDts, cte);
return UpdateResult.getOkResult();
}
/* Changing rdate maybe just changing the parameters (UTC unchanged) or
* an actual value change. Second case is really a remove and add
*/
BwDateTime newdt = BwDateTime.makeBwDateTime((DateDatetimePropertyType) ui.getUpdprop());
if (prdt.getDate().equals(newdt.getDate())) {
// tzid or date only?
if (prdt.getTzid().equals(newdt.getTzid()) && (prdt.getDateType() == newdt.getDateType())) {
// Unchanged
return UpdateResult.getOkResult();
} else {
evDts.remove(prdt);
evDts.add(newdt);
cte.addChangedValue(newdt);
}
}
/* Do remove then add */
removeDt(prdt.getDate(), evDts, cte);
addDt(newdt, evDts, cte);
return UpdateResult.getOkResult();
} catch (WebdavException we) {
throw we;
} catch (Throwable t) {
throw new WebdavException(t);
}
}
use of org.bedework.calfacade.util.ChangeTableEntry in project bw-calendar-engine by Bedework.
the class AlarmPropUpdater method flagChange.
protected void flagChange(final BwAlarm val, final UpdateInfo ui) {
ChangeTableEntry cte = ui.getCte();
if (cte != null) {
cte.setChanged(null, null);
}
ChangeTable ct = ui.getEi().getChangeset(ui.getUserHref());
cte = ct.getEntry(PropertyInfoIndex.VALARM);
if (cte != null) {
cte.setChanged(null, val);
}
getAS(ui).add(val);
}
use of org.bedework.calfacade.util.ChangeTableEntry in project bw-calendar-engine by Bedework.
the class CompletedPropUpdater method applyUpdate.
@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
BwEvent ev = ui.getEvent();
CompletedPropType pr = (CompletedPropType) ui.getProp();
ChangeTableEntry cte = ui.getCte();
String val = XcalUtil.getIcalFormatDateTime(pr.getUtcDateTime());
String evVal = null;
if (ev.getCompleted() != null) {
evVal = ev.getCompleted();
}
if (ui.isRemove()) {
if (evVal == null) {
return new UpdateResult("Entity has no " + ui.getPropName() + " property - cannot remove");
}
val = null;
} else if (ui.isAdd()) {
if (evVal != null) {
return new UpdateResult("Entity already has " + ui.getPropName() + " property - cannot add");
}
} else if (!ui.isChange()) {
return new UpdateResult("No update specified for " + ui.getPropName());
} else {
if (!val.equals(evVal)) {
return new UpdateResult("Values don't match for update to " + ui.getPropName());
}
val = XcalUtil.getIcalFormatDateTime(((CompletedPropType) ui.getUpdprop()).getUtcDateTime());
}
if (Util.cmpObjval(val, evVal) != 0) {
cte.setChanged(evVal, val);
ev.setCompleted(val);
}
return UpdateResult.getOkResult();
}
use of org.bedework.calfacade.util.ChangeTableEntry in project bw-calendar-engine by Bedework.
the class DtEndDuePropUpdater method applyUpdate.
@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
/* For start, end and duration we have to finish up at the end after all
* changes are made.
*/
try {
BwEvent ev = ui.getEvent();
DateDatetimePropertyType dt = (DateDatetimePropertyType) ui.getProp();
if (dt instanceof DuePropType) {
if (ev.getEntityType() != IcalDefs.entityTypeTodo) {
return new UpdateResult("DUE only valid for tasks");
}
} else {
if (ev.getEntityType() == IcalDefs.entityTypeTodo) {
return new UpdateResult("DUE required for tasks");
}
}
DatesState ds = (DatesState) ui.getState(DatesState.stateName);
if (ds == null) {
ds = new DatesState(ev);
ui.saveState(DatesState.stateName, ds);
}
ChangeTableEntry cte = ui.getCte();
if (ui.isRemove()) {
if (ev.getEndType() != StartEndComponent.endTypeDate) {
return new UpdateResult("Entity has no end date - cannot remove");
}
cte.setDeleted(ev.getDtend());
ds.end = null;
return UpdateResult.getOkResult();
}
if (ui.isAdd()) {
if (ev.getEndType() == StartEndComponent.endTypeDate) {
return new UpdateResult("Entity already has end date - cannot add");
}
ds.end = BwDateTime.makeBwDateTime(dt);
cte.setAdded(ds.end);
return UpdateResult.getOkResult();
}
/* Changing dtend - either value or parameters */
if (ev.getEndType() != StartEndComponent.endTypeDate) {
return new UpdateResult("Entity has no end date - cannot change");
}
Holder<BwDateTime> resdt = new Holder<BwDateTime>();
UpdateResult ur = makeDt(ev.getDtend(), resdt, ui);
if (!ur.getOk()) {
return ur;
}
if (resdt.value != null) {
cte.setChanged(ev.getDtend(), resdt.value);
ds.end = resdt.value;
}
return UpdateResult.getOkResult();
} catch (CalFacadeException cfe) {
throw new WebdavException(cfe);
}
}
Aggregations