Search in sources :

Example 1 with XBedeworkWrapperPropType

use of ietf.params.xml.ns.icalendar_2.XBedeworkWrapperPropType in project bw-calendar-engine by Bedework.

the class Xutil method xpropertiesToXcal.

/**
 * @param pl
 * @param xprops
 * @param pattern
 * @param masterClass
 * @param wrapXprops wrap x-properties in bedework object - allows
 *                   us to push them through soap
 * @throws Throwable
 */
@SuppressWarnings("deprecation")
public static void xpropertiesToXcal(final List<JAXBElement<? extends BasePropertyType>> pl, final List<BwXproperty> xprops, final BaseComponentType pattern, final Class masterClass, final boolean wrapXprops) throws Throwable {
    for (final BwXproperty x : xprops) {
        // Skip any timezone we saved in the event.
        final String xname = x.getName();
        final String val = x.getValue();
        if (xname.startsWith(BwXproperty.bedeworkTimezonePrefix)) {
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkExsynchEndtzid)) {
            if (!emit(pattern, masterClass, XBedeworkExsynchEndtzidPropType.class)) {
                continue;
            }
            final XBedeworkExsynchEndtzidPropType p = new XBedeworkExsynchEndtzidPropType();
            p.setText(val);
            pl.add(of.createXBedeworkExsynchEndtzid(p));
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkExsynchLastmod)) {
            if (!emit(pattern, masterClass, XBedeworkExsynchLastmodPropType.class)) {
                continue;
            }
            final XBedeworkExsynchLastmodPropType p = new XBedeworkExsynchLastmodPropType();
            p.setText(val);
            pl.add(of.createXBedeworkExsynchLastmod(p));
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkExsynchOrganizer)) {
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkExsynchStarttzid)) {
            if (!emit(pattern, masterClass, XBedeworkExsynchStarttzidPropType.class)) {
                continue;
            }
            final XBedeworkExsynchStarttzidPropType p = new XBedeworkExsynchStarttzidPropType();
            p.setText(val);
            pl.add(of.createXBedeworkExsynchStarttzid(p));
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkEventRegStart)) {
            if (!emit(pattern, masterClass, XBedeworkRegistrationStartPropType.class)) {
                continue;
            }
            final XBedeworkRegistrationStartPropType p = new XBedeworkRegistrationStartPropType();
            String tzid = null;
            for (final Xpar xp : x.getParameters()) {
                if (xp.getName().equalsIgnoreCase("TZID")) {
                    tzid = xp.getValue();
                    break;
                }
            }
            XcalUtil.initDt(p, val, tzid);
            pl.add(of.createXBedeworkRegistrationStart(p));
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkEventRegEnd)) {
            if (!emit(pattern, masterClass, XBedeworkRegistrationEndPropType.class)) {
                continue;
            }
            final XBedeworkRegistrationEndPropType p = new XBedeworkRegistrationEndPropType();
            String tzid = null;
            for (final Xpar xp : x.getParameters()) {
                if (xp.getName().equalsIgnoreCase("TZID")) {
                    tzid = xp.getValue();
                    break;
                }
            }
            XcalUtil.initDt(p, val, tzid);
            pl.add(of.createXBedeworkRegistrationEnd(p));
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkEventRegMaxTickets)) {
            if (!emit(pattern, masterClass, XBedeworkMaxTicketsPropType.class)) {
                continue;
            }
            final XBedeworkMaxTicketsPropType p = new XBedeworkMaxTicketsPropType();
            p.setInteger(BigInteger.valueOf(Long.valueOf(val)));
            pl.add(of.createXBedeworkMaxTickets(p));
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkEventRegMaxTicketsPerUser)) {
            if (!emit(pattern, masterClass, XBedeworkMaxTicketsPerUserPropType.class)) {
                continue;
            }
            final XBedeworkMaxTicketsPerUserPropType p = new XBedeworkMaxTicketsPerUserPropType();
            p.setInteger(BigInteger.valueOf(Long.valueOf(val)));
            pl.add(of.createXBedeworkMaxTicketsPerUser(p));
            continue;
        }
        if (xname.equals(BwXproperty.bedeworkEventRegWaitListLimit)) {
            if (!emit(pattern, masterClass, XBedeworkWaitListLimitPropType.class)) {
                continue;
            }
            final XBedeworkWaitListLimitPropType p = new XBedeworkWaitListLimitPropType();
            p.setText(val);
            pl.add(of.createXBedeworkWaitListLimit(p));
            continue;
        }
        if (xname.equals(BwXproperty.xBedeworkCategories)) {
            if (!emit(pattern, masterClass, XBwCategoriesPropType.class)) {
                continue;
            }
            final XBwCategoriesPropType p = new XBwCategoriesPropType();
            p.getText().add(val);
            pl.add(of.createXBedeworkCategories(p));
            continue;
        }
        if (xname.equals(BwXproperty.xBedeworkContact)) {
            if (!emit(pattern, masterClass, XBwContactPropType.class)) {
                continue;
            }
            final XBwContactPropType p = new XBwContactPropType();
            p.setText(val);
            pl.add(of.createXBedeworkContact(p));
            continue;
        }
        if (xname.equals(BwXproperty.xBedeworkLocation)) {
            if (!emit(pattern, masterClass, XBwLocationPropType.class)) {
                continue;
            }
            final XBwLocationPropType p = new XBwLocationPropType();
            p.setText(val);
            pl.add(of.createXBedeworkLocation(p));
            continue;
        }
        if (!wrapXprops) {
            if (getLog().isDebugEnabled()) {
                warn("Not handing x-property " + xname);
            }
            continue;
        }
        final XBedeworkWrapperPropType wrapper = new XBedeworkWrapperPropType();
        if (x.getParameters() != null) {
            for (final Xpar xp : x.getParameters()) {
                xparam(wrapper, xp);
            }
        }
        final XBedeworkWrappedNameParamType wnp = new XBedeworkWrappedNameParamType();
        wnp.setText(x.getName());
        if (wrapper.getParameters() == null) {
            wrapper.setParameters(new ArrayOfParameters());
        }
        wrapper.getParameters().getBaseParameter().add(of.createXBedeworkWrappedName(wnp));
        wrapper.setText(val);
        pl.add(of.createXBedeworkWrapper(wrapper));
    }
}
Also used : Xpar(org.bedework.calfacade.BwXproperty.Xpar) XBedeworkRegistrationEndPropType(ietf.params.xml.ns.icalendar_2.XBedeworkRegistrationEndPropType) XBwContactPropType(ietf.params.xml.ns.icalendar_2.XBwContactPropType) XBwCategoriesPropType(ietf.params.xml.ns.icalendar_2.XBwCategoriesPropType) XBedeworkExsynchStarttzidPropType(ietf.params.xml.ns.icalendar_2.XBedeworkExsynchStarttzidPropType) ArrayOfParameters(ietf.params.xml.ns.icalendar_2.ArrayOfParameters) XBedeworkMaxTicketsPropType(ietf.params.xml.ns.icalendar_2.XBedeworkMaxTicketsPropType) XBedeworkWaitListLimitPropType(ietf.params.xml.ns.icalendar_2.XBedeworkWaitListLimitPropType) XBedeworkExsynchEndtzidPropType(ietf.params.xml.ns.icalendar_2.XBedeworkExsynchEndtzidPropType) XBedeworkExsynchLastmodPropType(ietf.params.xml.ns.icalendar_2.XBedeworkExsynchLastmodPropType) XBwLocationPropType(ietf.params.xml.ns.icalendar_2.XBwLocationPropType) BwXproperty(org.bedework.calfacade.BwXproperty) XBedeworkMaxTicketsPerUserPropType(ietf.params.xml.ns.icalendar_2.XBedeworkMaxTicketsPerUserPropType) XBedeworkWrapperPropType(ietf.params.xml.ns.icalendar_2.XBedeworkWrapperPropType) XBedeworkRegistrationStartPropType(ietf.params.xml.ns.icalendar_2.XBedeworkRegistrationStartPropType) XBedeworkWrappedNameParamType(ietf.params.xml.ns.icalendar_2.XBedeworkWrappedNameParamType)

Example 2 with XBedeworkWrapperPropType

use of ietf.params.xml.ns.icalendar_2.XBedeworkWrapperPropType in project bw-calendar-engine by Bedework.

the class XbwWrapperPropUpdater method applyUpdate.

public UpdateResult applyUpdate(final UpdateInfo ui) throws WebdavException {
    final ChangeTableEntry cte = ui.getCte();
    final BwEvent ev = ui.getEvent();
    /* Create an x-property from the selector */
    // TODO - do parameters properly
    final XBedeworkWrapperPropType wrapper = (XBedeworkWrapperPropType) ui.getProp();
    final BwXproperty theProp = new BwXproperty(UpdaterUtil.getWrapperName(wrapper), null, wrapper.getText());
    if (ui.isRemove()) {
        ev.removeXproperty(theProp);
        cte.addRemovedValue(theProp);
        return UpdateResult.getOkResult();
    }
    if (ui.isAdd()) {
        ev.addXproperty(theProp);
        cte.addValue(theProp);
        return UpdateResult.getOkResult();
    }
    if (ui.isChange()) {
        ev.removeXproperty(theProp);
        cte.addRemovedValue(theProp);
        final BwXproperty newProp = new BwXproperty(UpdaterUtil.getWrapperName(wrapper), null, ((XBedeworkWrapperPropType) ui.getUpdprop()).getText());
        ev.addXproperty(newProp);
        cte.addValue(newProp);
        return UpdateResult.getOkResult();
    }
    return UpdateResult.getOkResult();
}
Also used : BwXproperty(org.bedework.calfacade.BwXproperty) XBedeworkWrapperPropType(ietf.params.xml.ns.icalendar_2.XBedeworkWrapperPropType) BwEvent(org.bedework.calfacade.BwEvent) ChangeTableEntry(org.bedework.calfacade.util.ChangeTableEntry)

Aggregations

XBedeworkWrapperPropType (ietf.params.xml.ns.icalendar_2.XBedeworkWrapperPropType)2 BwXproperty (org.bedework.calfacade.BwXproperty)2 ArrayOfParameters (ietf.params.xml.ns.icalendar_2.ArrayOfParameters)1 XBedeworkExsynchEndtzidPropType (ietf.params.xml.ns.icalendar_2.XBedeworkExsynchEndtzidPropType)1 XBedeworkExsynchLastmodPropType (ietf.params.xml.ns.icalendar_2.XBedeworkExsynchLastmodPropType)1 XBedeworkExsynchStarttzidPropType (ietf.params.xml.ns.icalendar_2.XBedeworkExsynchStarttzidPropType)1 XBedeworkMaxTicketsPerUserPropType (ietf.params.xml.ns.icalendar_2.XBedeworkMaxTicketsPerUserPropType)1 XBedeworkMaxTicketsPropType (ietf.params.xml.ns.icalendar_2.XBedeworkMaxTicketsPropType)1 XBedeworkRegistrationEndPropType (ietf.params.xml.ns.icalendar_2.XBedeworkRegistrationEndPropType)1 XBedeworkRegistrationStartPropType (ietf.params.xml.ns.icalendar_2.XBedeworkRegistrationStartPropType)1 XBedeworkWaitListLimitPropType (ietf.params.xml.ns.icalendar_2.XBedeworkWaitListLimitPropType)1 XBedeworkWrappedNameParamType (ietf.params.xml.ns.icalendar_2.XBedeworkWrappedNameParamType)1 XBwCategoriesPropType (ietf.params.xml.ns.icalendar_2.XBwCategoriesPropType)1 XBwContactPropType (ietf.params.xml.ns.icalendar_2.XBwContactPropType)1 XBwLocationPropType (ietf.params.xml.ns.icalendar_2.XBwLocationPropType)1 BwEvent (org.bedework.calfacade.BwEvent)1 Xpar (org.bedework.calfacade.BwXproperty.Xpar)1 ChangeTableEntry (org.bedework.calfacade.util.ChangeTableEntry)1