use of ietf.params.xml.ns.icalendar_2.BasePropertyType in project bw-calendar-engine by Bedework.
the class BwUpdates method updateEventProperties.
/**
* The current selector is for the event properties.
*
* <p>We might have one or more updates - add or remove
*
* <p>We might also have one or more selects which allow for change of values
*
* @param ei
* @param subComponent - non null if this is a sub-component update
* @param sel - matching the "properties" element
* @return true for updated OK
* @throws WebdavException
*/
private UpdateResult updateEventProperties(final EventInfo ei, final Component subComponent, final PropertiesSelectionType sel) throws WebdavException {
for (final PropertySelectionType psel : sel.getProperty()) {
/* psel represents a selection on a property which must exist and for
* which we must have an updater.
*
* We may be applying changes to the property with a change update and/or
* updating the parameters through one or more a selections on the
* parameters.
*/
final BasePropertyType bprop;
final QName pname;
if (psel.getBaseProperty() == null) {
return new UpdateResult("No selection property supplied");
}
bprop = psel.getBaseProperty().getValue();
pname = psel.getBaseProperty().getName();
final PropertyUpdater pu = getUpdater(bprop);
if (pu == null) {
return new UpdateResult("No updater for property: " + pname);
}
PropertyUpdateInfo ui = new PropertyUpdateInfo(bprop, pname, cb, ei, subComponent, state, userHref);
UpdateResult ur = null;
/* There is possibly no change - for example we are changing the tzid for
* the dtstart
*/
if (psel.getChange() != null) {
ur = ui.setChange(psel.getChange());
if (ur != null) {
return ur;
}
}
/* Look for updates to property parameters and add them to the property
* updater info.
*/
if (psel.getParameters() != null) {
ui.setParameterUpdates(psel.getParameters());
}
// There may be no change
ur = pu.applyUpdate(ui);
if (!ur.getOk()) {
return ur;
}
}
/* Next adds
*/
UpdateResult ur = addRemove(ei, subComponent, true, sel.getAdd(), cb);
if (!ur.getOk()) {
return ur;
}
/* Next removes
*/
ur = addRemove(ei, subComponent, false, sel.getRemove(), cb);
if (!ur.getOk()) {
return ur;
}
/* We now need to validate the result to ensure the changes leave a
* consistent entity. Date/time changes in particular can have a number
* of side effects.
*/
ur = validateDates(ei);
if (!ur.getOk()) {
return ur;
}
if (debug) {
ei.getChangeset(userHref).dumpEntries();
}
return UpdateResult.getOkResult();
}
use of ietf.params.xml.ns.icalendar_2.BasePropertyType in project bw-calendar-engine by Bedework.
the class Xalarms method toXAlarm.
/**
* @param ev
* @param val
* @param pattern
* @param masterClass
* @return ValarmType
* @throws CalFacadeException
*/
public static ValarmType toXAlarm(final BwEvent ev, final BwAlarm val, final BaseComponentType pattern, final Class masterClass) throws CalFacadeException {
try {
ValarmType alarm = new ValarmType();
int atype = val.getAlarmType();
alarm.setProperties(new ArrayOfProperties());
List<JAXBElement<? extends BasePropertyType>> pl = alarm.getProperties().getBasePropertyOrTzid();
if (emit(pattern, masterClass, ValarmType.class, ActionPropType.class)) {
ActionPropType a = new ActionPropType();
a.setText(BwAlarm.alarmTypes[val.getAlarmType()]);
pl.add(of.createAction(a));
}
if (emit(pattern, masterClass, ValarmType.class, TriggerPropType.class)) {
TriggerPropType t = new TriggerPropType();
if (val.getTriggerDateTime()) {
// t.setDateTime(val.getTrigger());
t.setDateTime(XcalUtil.getXMlUTCCal(val.getTrigger()));
} else {
t.setDuration(val.getTrigger());
if (!val.getTriggerStart()) {
ArrayOfParameters pars = getAop(t);
RelatedParamType r = new RelatedParamType();
r.setText(IcalDefs.alarmTriggerRelatedEnd);
JAXBElement<RelatedParamType> param = of.createRelated(r);
pars.getBaseParameter().add(param);
}
}
pl.add(of.createTrigger(t));
}
if (emit(pattern, masterClass, ValarmType.class, DurationPropType.class)) {
if (val.getDuration() != null) {
DurationPropType dur = new DurationPropType();
dur.setDuration(val.getDuration());
pl.add(of.createDuration(dur));
RepeatPropType rep = new RepeatPropType();
rep.setInteger(BigInteger.valueOf(val.getRepeat()));
pl.add(of.createRepeat(rep));
}
}
/* Description */
if ((atype == BwAlarm.alarmTypeDisplay) || (atype == BwAlarm.alarmTypeEmail) || (atype == BwAlarm.alarmTypeProcedure)) {
// Both require description
String desc = val.getDescription();
if (desc == null) {
if (ev != null) {
if (ev.getDescription() != null) {
desc = ev.getDescription();
} else {
desc = ev.getSummary();
}
}
}
if (desc == null) {
desc = " ";
}
DescriptionPropType d = new DescriptionPropType();
d.setText(desc);
pl.add(of.createDescription(d));
}
/* Summary */
if (atype == BwAlarm.alarmTypeEmail) {
SummaryPropType s = new SummaryPropType();
s.setText(val.getSummary());
pl.add(of.createSummary(s));
}
if ((atype == BwAlarm.alarmTypeAudio) || (atype == BwAlarm.alarmTypeEmail) || (atype == BwAlarm.alarmTypeProcedure)) {
if (val.getAttach() != null) {
AttachPropType a = new AttachPropType();
a.setUri(val.getAttach());
pl.add(of.createAttach(a));
}
}
/* Attendees */
if (atype == BwAlarm.alarmTypeEmail) {
if (val.getNumAttendees() > 0) {
for (BwAttendee att : val.getAttendees()) {
pl.add(of.createAttendee(ToXEvent.makeAttendee(att)));
}
}
}
if (val.getNumXproperties() > 0) {
/* This alarm has x-props */
}
return alarm;
} catch (Throwable t) {
throw new CalFacadeException(t);
}
}
use of ietf.params.xml.ns.icalendar_2.BasePropertyType in project bw-calendar-engine by Bedework.
the class Xutil method altrepProp.
protected static BasePropertyType altrepProp(final BasePropertyType prop, final String val) {
if (val == null) {
return prop;
}
final ArrayOfParameters pars = getAop(prop);
final AltrepParamType a = new AltrepParamType();
a.setUri(val);
final JAXBElement<AltrepParamType> param = of.createAltrep(a);
pars.getBaseParameter().add(param);
return prop;
}
use of ietf.params.xml.ns.icalendar_2.BasePropertyType in project bw-calendar-engine by Bedework.
the class Xutil method langProp.
protected static BasePropertyType langProp(final BasePropertyType prop, final BwStringBase s) {
String lang = s.getLang();
if (lang == null) {
return prop;
}
ArrayOfParameters pars = getAop(prop);
LanguageParamType l = new LanguageParamType();
l.setText(lang);
JAXBElement<LanguageParamType> param = of.createLanguage(l);
pars.getBaseParameter().add(param);
return prop;
}
use of ietf.params.xml.ns.icalendar_2.BasePropertyType in project bw-calendar-engine by Bedework.
the class Xutil method xparam.
/**
* Convert a parameter
* @param prop - parameters go here
* @param xp - a parameter
* @throws Throwable
*/
protected static void xparam(final BasePropertyType prop, final Xpar xp) throws Throwable {
ArrayOfParameters aop = prop.getParameters();
if (aop == null) {
aop = new ArrayOfParameters();
prop.setParameters(aop);
}
if (xp.getName().equalsIgnoreCase("tzid")) {
final TzidParamType tz = new TzidParamType();
tz.setText(xp.getValue());
aop.getBaseParameter().add(of.createTzid(tz));
return;
}
}
Aggregations