Search in sources :

Example 1 with ExRule

use of net.fortuna.ical4j.model.property.ExRule in project bw-calendar-engine by Bedework.

the class VEventUtil method doRecurring.

/**
 * Build recurring properties from event.
 *
 * @param val
 * @param pl
 * @throws CalFacadeException
 */
public static void doRecurring(final BwEvent val, final PropertyList pl) throws CalFacadeException {
    try {
        if (val.hasRrules()) {
            for (String s : val.getRrules()) {
                RRule rule = new RRule();
                rule.setValue(s);
                pl.add(rule);
            }
        }
        if (val.hasExrules()) {
            for (String s : val.getExrules()) {
                ExRule rule = new ExRule();
                rule.setValue(s);
                pl.add(rule);
            }
        }
        makeDlp(val, false, val.getRdates(), pl);
        makeDlp(val, true, val.getExdates(), pl);
    } catch (CalFacadeException cfe) {
        throw cfe;
    } catch (Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : RRule(net.fortuna.ical4j.model.property.RRule) BwString(org.bedework.calfacade.BwString) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) ExRule(net.fortuna.ical4j.model.property.ExRule)

Example 2 with ExRule

use of net.fortuna.ical4j.model.property.ExRule in project bw-calendar-engine by Bedework.

the class IcalTranslator method xmlProperty.

private void xmlProperty(final XmlEmit xml, final Property val) throws CalFacadeException {
    try {
        QName tag = openTag(xml, val.getName());
        ParameterList pl = val.getParameters();
        if (pl.size() > 0) {
            xml.openTag(XcalTags.parameters);
            Iterator pli = pl.iterator();
            while (pli.hasNext()) {
                xmlParameter(xml, (Parameter) pli.next());
            }
            xml.closeTag(XcalTags.parameters);
        }
        PropertyInfoIndex pii = PropertyInfoIndex.fromName(val.getName());
        QName ptype = XcalTags.textVal;
        if (pii != null) {
            DataType dtype = pii.getPtype();
            if (dtype != null) {
                ptype = dtype.getXcalType();
            }
        }
        if (ptype == null) {
            // Special processing I haven't done
            warn("Unimplemented value type for " + val.getName());
            ptype = XcalTags.textVal;
        }
        if (ptype.equals(XcalTags.recurVal)) {
            // Emit individual parts of recur rule
            xml.openTag(ptype);
            Recur r;
            if (val instanceof ExRule) {
                r = ((ExRule) val).getRecur();
            } else {
                r = ((RRule) val).getRecur();
            }
            xml.property(XcalTags.freq, r.getFrequency());
            xmlProp(xml, XcalTags.wkst, r.getWeekStartDay().name());
            if (r.getUntil() != null) {
                xmlProp(xml, XcalTags.until, r.getUntil().toString());
            }
            xmlProp(xml, XcalTags.count, String.valueOf(r.getCount()));
            xmlProp(xml, XcalTags.interval, String.valueOf(r.getInterval()));
            xmlProp(xml, XcalTags.bymonth, r.getMonthList());
            xmlProp(xml, XcalTags.byweekno, r.getWeekNoList());
            xmlProp(xml, XcalTags.byyearday, r.getYearDayList());
            xmlProp(xml, XcalTags.bymonthday, r.getMonthDayList());
            xmlProp(xml, XcalTags.byday, r.getDayList());
            xmlProp(xml, XcalTags.byhour, r.getHourList());
            xmlProp(xml, XcalTags.byminute, r.getMinuteList());
            xmlProp(xml, XcalTags.bysecond, r.getSecondList());
            xmlProp(xml, XcalTags.bysetpos, r.getSetPosList());
            xml.closeTag(ptype);
        } else {
            xml.property(ptype, val.getValue());
        }
        xml.closeTag(tag);
    } catch (CalFacadeException cfe) {
        throw cfe;
    } catch (Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : PropertyInfoIndex(org.bedework.util.calendar.PropertyIndex.PropertyInfoIndex) QName(javax.xml.namespace.QName) Iterator(java.util.Iterator) ParameterList(net.fortuna.ical4j.model.ParameterList) DataType(org.bedework.util.calendar.PropertyIndex.DataType) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) Recur(net.fortuna.ical4j.model.Recur) ExRule(net.fortuna.ical4j.model.property.ExRule)

Example 3 with ExRule

use of net.fortuna.ical4j.model.property.ExRule in project ofbiz-framework by apache.

the class ICalRecurConverter method visit.

@Override
public void visit(Intersection expr) {
    this.stateStack.push(this.state);
    VisitorState newState = new VisitorState();
    newState.isExcluded = this.state.isExcluded;
    newState.isIntersection = true;
    this.state = newState;
    for (TemporalExpression childExpr : expr.getExpressionSet()) {
        childExpr.accept(this);
    }
    this.state = this.stateStack.pop();
    if (newState.inclRecurList.size() > 0) {
        this.incRuleList.add(new RRule(this.consolidateRecurs(newState.inclRecurList)));
    }
    if (newState.exRecurList.size() > 0) {
        this.exRuleList.add(new ExRule(this.consolidateRecurs(newState.exRecurList)));
    }
}
Also used : TemporalExpression(org.apache.ofbiz.service.calendar.TemporalExpression) RRule(net.fortuna.ical4j.model.property.RRule) ExRule(net.fortuna.ical4j.model.property.ExRule)

Aggregations

ExRule (net.fortuna.ical4j.model.property.ExRule)3 RRule (net.fortuna.ical4j.model.property.RRule)2 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)2 Iterator (java.util.Iterator)1 QName (javax.xml.namespace.QName)1 ParameterList (net.fortuna.ical4j.model.ParameterList)1 Recur (net.fortuna.ical4j.model.Recur)1 TemporalExpression (org.apache.ofbiz.service.calendar.TemporalExpression)1 BwString (org.bedework.calfacade.BwString)1 DataType (org.bedework.util.calendar.PropertyIndex.DataType)1 PropertyInfoIndex (org.bedework.util.calendar.PropertyIndex.PropertyInfoIndex)1