use of org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult in project bw-calendar-engine by Bedework.
the class PercentCompletePropUpdater method applyUpdate.
@Override
public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
BwEvent ev = ui.getEvent();
PercentCompletePropType pr = (PercentCompletePropType) ui.getProp();
ChangeTableEntry cte = ui.getCte();
BigInteger val = pr.getInteger();
BigInteger evVal = null;
if (ev.getPercentComplete() != null) {
evVal = BigInteger.valueOf(ev.getPercentComplete());
}
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 = ((PercentCompletePropType) ui.getUpdprop()).getInteger();
}
if (Util.cmpObjval(val, evVal) != 0) {
cte.setChanged(evVal, val);
ev.setPercentComplete(val.intValue());
}
return UpdateResult.getOkResult();
}
Aggregations