Search in sources :

Example 11 with BasePropertyType

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();
}
Also used : BasePropertyType(ietf.params.xml.ns.icalendar_2.BasePropertyType) QName(javax.xml.namespace.QName) PropertySelectionType(org.oasis_open.docs.ws_calendar.ns.soap.PropertySelectionType) UpdateResult(org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)

Example 12 with BasePropertyType

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);
    }
}
Also used : SummaryPropType(ietf.params.xml.ns.icalendar_2.SummaryPropType) TriggerPropType(ietf.params.xml.ns.icalendar_2.TriggerPropType) ArrayOfParameters(ietf.params.xml.ns.icalendar_2.ArrayOfParameters) AttachPropType(ietf.params.xml.ns.icalendar_2.AttachPropType) JAXBElement(javax.xml.bind.JAXBElement) DurationPropType(ietf.params.xml.ns.icalendar_2.DurationPropType) DescriptionPropType(ietf.params.xml.ns.icalendar_2.DescriptionPropType) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) RelatedParamType(ietf.params.xml.ns.icalendar_2.RelatedParamType) ValarmType(ietf.params.xml.ns.icalendar_2.ValarmType) ArrayOfProperties(ietf.params.xml.ns.icalendar_2.ArrayOfProperties) BasePropertyType(ietf.params.xml.ns.icalendar_2.BasePropertyType) ActionPropType(ietf.params.xml.ns.icalendar_2.ActionPropType) RepeatPropType(ietf.params.xml.ns.icalendar_2.RepeatPropType) BwAttendee(org.bedework.calfacade.BwAttendee)

Example 13 with BasePropertyType

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;
}
Also used : AltrepParamType(ietf.params.xml.ns.icalendar_2.AltrepParamType) ArrayOfParameters(ietf.params.xml.ns.icalendar_2.ArrayOfParameters)

Example 14 with BasePropertyType

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;
}
Also used : LanguageParamType(ietf.params.xml.ns.icalendar_2.LanguageParamType) ArrayOfParameters(ietf.params.xml.ns.icalendar_2.ArrayOfParameters)

Example 15 with BasePropertyType

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;
    }
}
Also used : ArrayOfParameters(ietf.params.xml.ns.icalendar_2.ArrayOfParameters) TzidParamType(ietf.params.xml.ns.icalendar_2.TzidParamType)

Aggregations

ArrayOfParameters (ietf.params.xml.ns.icalendar_2.ArrayOfParameters)9 BasePropertyType (ietf.params.xml.ns.icalendar_2.BasePropertyType)5 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)5 ArrayOfProperties (ietf.params.xml.ns.icalendar_2.ArrayOfProperties)3 DescriptionPropType (ietf.params.xml.ns.icalendar_2.DescriptionPropType)3 DurationPropType (ietf.params.xml.ns.icalendar_2.DurationPropType)3 SummaryPropType (ietf.params.xml.ns.icalendar_2.SummaryPropType)3 JAXBElement (javax.xml.bind.JAXBElement)3 BwAttendee (org.bedework.calfacade.BwAttendee)3 ActionPropType (ietf.params.xml.ns.icalendar_2.ActionPropType)2 AttachPropType (ietf.params.xml.ns.icalendar_2.AttachPropType)2 BaseComponentType (ietf.params.xml.ns.icalendar_2.BaseComponentType)2 RecurrenceIdPropType (ietf.params.xml.ns.icalendar_2.RecurrenceIdPropType)2 RelatedParamType (ietf.params.xml.ns.icalendar_2.RelatedParamType)2 BwString (org.bedework.calfacade.BwString)2 AltrepParamType (ietf.params.xml.ns.icalendar_2.AltrepParamType)1 ArrayOfComponents (ietf.params.xml.ns.icalendar_2.ArrayOfComponents)1 AttendeePropType (ietf.params.xml.ns.icalendar_2.AttendeePropType)1 CategoriesPropType (ietf.params.xml.ns.icalendar_2.CategoriesPropType)1 ClassPropType (ietf.params.xml.ns.icalendar_2.ClassPropType)1