Search in sources :

Example 6 with ArrayOfParameters

use of ietf.params.xml.ns.icalendar_2.ArrayOfParameters 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 7 with ArrayOfParameters

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

the class Xutil method uidProp.

protected static BasePropertyType uidProp(final BasePropertyType prop, final String uid) {
    if (uid == null) {
        return prop;
    }
    ArrayOfParameters pars = getAop(prop);
    XBedeworkUidParamType x = new XBedeworkUidParamType();
    x.setText(uid);
    JAXBElement<XBedeworkUidParamType> param = of.createXBedeworkUid(x);
    pars.getBaseParameter().add(param);
    return prop;
}
Also used : XBedeworkUidParamType(ietf.params.xml.ns.icalendar_2.XBedeworkUidParamType) ArrayOfParameters(ietf.params.xml.ns.icalendar_2.ArrayOfParameters)

Example 8 with ArrayOfParameters

use of ietf.params.xml.ns.icalendar_2.ArrayOfParameters 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 9 with ArrayOfParameters

use of ietf.params.xml.ns.icalendar_2.ArrayOfParameters 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 10 with ArrayOfParameters

use of ietf.params.xml.ns.icalendar_2.ArrayOfParameters 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)

Aggregations

ArrayOfParameters (ietf.params.xml.ns.icalendar_2.ArrayOfParameters)11 LanguageParamType (ietf.params.xml.ns.icalendar_2.LanguageParamType)3 BwString (org.bedework.calfacade.BwString)3 ArrayOfProperties (ietf.params.xml.ns.icalendar_2.ArrayOfProperties)2 BasePropertyType (ietf.params.xml.ns.icalendar_2.BasePropertyType)2 CnParamType (ietf.params.xml.ns.icalendar_2.CnParamType)2 DescriptionPropType (ietf.params.xml.ns.icalendar_2.DescriptionPropType)2 DirParamType (ietf.params.xml.ns.icalendar_2.DirParamType)2 DurationPropType (ietf.params.xml.ns.icalendar_2.DurationPropType)2 ScheduleStatusParamType (ietf.params.xml.ns.icalendar_2.ScheduleStatusParamType)2 SentByParamType (ietf.params.xml.ns.icalendar_2.SentByParamType)2 ActionPropType (ietf.params.xml.ns.icalendar_2.ActionPropType)1 AltrepParamType (ietf.params.xml.ns.icalendar_2.AltrepParamType)1 AttachPropType (ietf.params.xml.ns.icalendar_2.AttachPropType)1 AttendeePropType (ietf.params.xml.ns.icalendar_2.AttendeePropType)1 BaseComponentType (ietf.params.xml.ns.icalendar_2.BaseComponentType)1 CategoriesPropType (ietf.params.xml.ns.icalendar_2.CategoriesPropType)1 ClassPropType (ietf.params.xml.ns.icalendar_2.ClassPropType)1 CommentPropType (ietf.params.xml.ns.icalendar_2.CommentPropType)1 CompletedPropType (ietf.params.xml.ns.icalendar_2.CompletedPropType)1