Search in sources :

Example 1 with VToDo

use of net.fortuna.ical4j.model.component.VToDo in project bw-calendar-engine by Bedework.

the class VAlarmUtil method processComponentAlarms.

/**
 * If there are any alarms for this component add them to the events alarm
 * collection
 *
 * @param cb          IcalCallback object
 * @param val
 * @param ev
 * @param currentPrincipal - href for current authenticated user
 * @param chg
 * @throws CalFacadeException
 */
public static void processComponentAlarms(final IcalCallback cb, final Component val, final BwEvent ev, final String currentPrincipal, final ChangeTable chg) throws CalFacadeException {
    try {
        ComponentList als = null;
        if (val instanceof VEvent) {
            als = ((VEvent) val).getAlarms();
        } else if (val instanceof VToDo) {
            als = ((VToDo) val).getAlarms();
        } else if (val instanceof VPoll) {
            als = ((VPoll) val).getAlarms();
        } else {
            return;
        }
        if ((als == null) || als.isEmpty()) {
            return;
        }
        for (Object o : als) {
            if (!(o instanceof VAlarm)) {
                throw new IcalMalformedException("Invalid alarm list");
            }
            VAlarm va = (VAlarm) o;
            PropertyList pl = va.getProperties();
            if (pl == null) {
                // Empty VAlarm
                throw new IcalMalformedException("Invalid alarm list");
            }
            Property prop;
            BwAlarm al;
            /* XXX Handle mozilla alarm stuff in a way that might work better with other clients.
         *
         */
            prop = pl.getProperty("X-MOZ-LASTACK");
            boolean mozlastAck = prop != null;
            String mozSnoozeTime = null;
            if (mozlastAck) {
                prop = pl.getProperty("X-MOZ-SNOOZE-TIME");
                if (prop == null) {
                    // lastack and no snooze - presume dismiss so delete alarm
                    continue;
                }
                // UTC time
                mozSnoozeTime = prop.getValue();
            }
            // All alarm types require action and trigger
            prop = pl.getProperty(Property.ACTION);
            if (prop == null) {
                throw new IcalMalformedException("Invalid alarm");
            }
            String actionStr = prop.getValue();
            TriggerVal tr = getTrigger(pl, "NONE".equals(actionStr));
            if (mozSnoozeTime != null) {
                tr.trigger = mozSnoozeTime;
                tr.triggerDateTime = true;
                tr.triggerStart = false;
            }
            DurationRepeat dr = getDurationRepeat(pl);
            if ("EMAIL".equals(actionStr)) {
                al = BwAlarm.emailAlarm(ev, ev.getCreatorHref(), tr, dr.duration, dr.repeat, getOptStr(pl, "ATTACH"), getReqStr(pl, "DESCRIPTION"), getReqStr(pl, "SUMMARY"), null);
                Iterator<?> atts = getReqStrs(pl, "ATTENDEE");
                while (atts.hasNext()) {
                    al.addAttendee(getAttendee(cb, (Attendee) atts.next()));
                }
            } else if ("AUDIO".equals(actionStr)) {
                al = BwAlarm.audioAlarm(ev, ev.getCreatorHref(), tr, dr.duration, dr.repeat, getOptStr(pl, "ATTACH"));
            } else if ("DISPLAY".equals(actionStr)) {
                al = BwAlarm.displayAlarm(ev, ev.getCreatorHref(), tr, dr.duration, dr.repeat, getReqStr(pl, "DESCRIPTION"));
            } else if ("PROCEDURE".equals(actionStr)) {
                al = BwAlarm.procedureAlarm(ev, ev.getCreatorHref(), tr, dr.duration, dr.repeat, getReqStr(pl, "ATTACH"), getOptStr(pl, "DESCRIPTION"));
            } else if ("NONE".equals(actionStr)) {
                al = BwAlarm.noneAlarm(ev, ev.getCreatorHref(), tr, dr.duration, dr.repeat, getOptStr(pl, "DESCRIPTION"));
            } else {
                al = BwAlarm.otherAlarm(ev, ev.getCreatorHref(), actionStr, tr, dr.duration, dr.repeat, getOptStr(pl, "DESCRIPTION"));
            }
            /* Mozilla is add xprops to the containing event to set the snooze time.
         * Seems wrong - there could be multiple alarms.
         *
         * We possibly want to try this sort of trick..

        prop = pl.getProperty("X-MOZ-LASTACK");
        boolean mozlastAck = prop != null;

        String mozSnoozeTime = null;
        if (mozlastAck) {
          prop = pl.getProperty("X-MOZ-SNOOZE-TIME");

          if (prop == null) {
            // lastack and no snooze - presume dismiss so delete alarm
            continue;
          }

          mozSnoozeTime = prop.getValue(); // UTC time
        }
        ...

        TriggerVal tr = getTrigger(pl);

        if (mozSnoozeTime != null) {
          tr.trigger = mozSnoozeTime;
          tr.triggerDateTime = true;
          tr.triggerStart = false;
        }

         */
            Iterator it = pl.iterator();
            while (it.hasNext()) {
                prop = (Property) it.next();
                if (prop instanceof XProperty) {
                    /* ------------------------- x-property --------------------------- */
                    XProperty xp = (XProperty) prop;
                    al.addXproperty(new BwXproperty(xp.getName(), xp.getParameters().toString(), xp.getValue()));
                    continue;
                }
                if (prop instanceof Uid) {
                    Uid p = (Uid) prop;
                    al.addXproperty(BwXproperty.makeIcalProperty(p.getName(), p.getParameters().toString(), p.getValue()));
                    continue;
                }
            }
            al.setEvent(ev);
            al.setOwnerHref(currentPrincipal);
            chg.addValue(PropertyInfoIndex.VALARM, al);
        }
    } catch (CalFacadeException cfe) {
        throw cfe;
    } catch (Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : VEvent(net.fortuna.ical4j.model.component.VEvent) XProperty(net.fortuna.ical4j.model.property.XProperty) ComponentList(net.fortuna.ical4j.model.ComponentList) BwAlarm(org.bedework.calfacade.BwAlarm) BwAttendee(org.bedework.calfacade.BwAttendee) Attendee(net.fortuna.ical4j.model.property.Attendee) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) Uid(net.fortuna.ical4j.model.property.Uid) PropertyList(net.fortuna.ical4j.model.PropertyList) VPoll(net.fortuna.ical4j.model.component.VPoll) BwXproperty(org.bedework.calfacade.BwXproperty) Iterator(java.util.Iterator) VAlarm(net.fortuna.ical4j.model.component.VAlarm) Property(net.fortuna.ical4j.model.Property) XProperty(net.fortuna.ical4j.model.property.XProperty) TriggerVal(org.bedework.calfacade.BwAlarm.TriggerVal) VToDo(net.fortuna.ical4j.model.component.VToDo)

Example 2 with VToDo

use of net.fortuna.ical4j.model.component.VToDo in project bw-calendar-engine by Bedework.

the class VAlarmUtil method processEventAlarm.

/**
 * Process any alarms.
 *
 * @param ev
 * @param comp
 * @param currentPrincipal - href for current authenticated user
 * @throws CalFacadeException
 */
public static void processEventAlarm(final BwEvent ev, final Component comp, final String currentPrincipal) throws CalFacadeException {
    if (currentPrincipal == null) {
        // No alarms for unauthenticated users.
        return;
    }
    Collection<BwAlarm> als = ev.getAlarms();
    if ((als == null) || als.isEmpty()) {
        return;
    }
    ComponentList vals = null;
    if (comp instanceof VEvent) {
        vals = ((VEvent) comp).getAlarms();
    } else if (comp instanceof VToDo) {
        vals = ((VToDo) comp).getAlarms();
    } else {
        throw new CalFacadeException("org.bedework.invalid.component.type", comp.getName());
    }
    for (BwAlarm alarm : als) {
        /* Only add alarms for the current authenticated user */
        if (!currentPrincipal.equals(alarm.getOwnerHref())) {
            continue;
        }
        vals.add(setAlarm(ev, alarm));
    }
}
Also used : VEvent(net.fortuna.ical4j.model.component.VEvent) ComponentList(net.fortuna.ical4j.model.ComponentList) BwAlarm(org.bedework.calfacade.BwAlarm) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) VToDo(net.fortuna.ical4j.model.component.VToDo)

Example 3 with VToDo

use of net.fortuna.ical4j.model.component.VToDo in project bw-calendar-engine by Bedework.

the class VEventUtil method toIcalComponent.

/**
 * Make an Icalendar component from a BwEvent object. This may produce a
 * VEvent, VTodo, VJournal or VPoll.
 *
 * @param ei the event
 * @param isOverride - true if event object is an override
 * @param tzreg - timezone registry
 * @param currentPrincipal - href for current authenticated user
 * @return Component
 * @throws CalFacadeException
 */
public static Component toIcalComponent(final EventInfo ei, final boolean isOverride, final TimeZoneRegistry tzreg, final String currentPrincipal) throws CalFacadeException {
    if ((ei == null) || (ei.getEvent() == null)) {
        return null;
    }
    final BwEvent val = ei.getEvent();
    boolean isInstance = false;
    try {
        Component xcomp = null;
        Calendar cal = null;
        final List<BwXproperty> xcompProps = val.getXproperties(BwXproperty.bedeworkIcal);
        if (!Util.isEmpty(xcompProps)) {
            final BwXproperty xcompProp = xcompProps.get(0);
            final String xcompPropVal = xcompProp.getValue();
            if (xcompPropVal != null) {
                final StringBuilder sb = new StringBuilder();
                final Icalendar ic = new Icalendar();
                try {
                    sb.append("BEGIN:VCALENDAR\n");
                    sb.append(Version.VERSION_2_0.toString());
                    sb.append("\n");
                    sb.append(xcompPropVal);
                    if (!xcompPropVal.endsWith("\n")) {
                        sb.append("\n");
                    }
                    sb.append("END:VCALENDAR\n");
                    CalendarBuilder bldr = new CalendarBuilder(new CalendarParserImpl(), ic);
                    UnfoldingReader ufrdr = new UnfoldingReader(new StringReader(sb.toString()), true);
                    cal = bldr.build(ufrdr);
                } catch (Throwable t) {
                    error(t);
                    error("Trying to parse:\n" + xcompPropVal);
                }
            }
        }
        Component comp;
        PropertyList pl = new PropertyList();
        boolean freeBusy = false;
        boolean vavail = false;
        boolean todo = false;
        boolean vpoll = false;
        int entityType = val.getEntityType();
        if (entityType == IcalDefs.entityTypeEvent) {
            comp = new VEvent(pl);
        } else if (entityType == IcalDefs.entityTypeTodo) {
            comp = new VToDo(pl);
            todo = true;
        } else if (entityType == IcalDefs.entityTypeJournal) {
            comp = new VJournal(pl);
        } else if (entityType == IcalDefs.entityTypeFreeAndBusy) {
            comp = new VFreeBusy(pl);
            freeBusy = true;
        } else if (entityType == IcalDefs.entityTypeVavailability) {
            comp = new VAvailability(pl);
            vavail = true;
        } else if (entityType == IcalDefs.entityTypeAvailable) {
            comp = new Available(pl);
        } else if (entityType == IcalDefs.entityTypeVpoll) {
            comp = new VPoll(pl);
            vpoll = true;
        } else {
            throw new CalFacadeException("org.bedework.invalid.entity.type", String.valueOf(entityType));
        }
        if (cal != null) {
            xcomp = cal.getComponent(comp.getName());
        }
        Property prop;
        /* ------------------- RecurrenceID --------------------
       * Done early so we know if this is an instance.
       */
        String strval = val.getRecurrenceId();
        if ((strval != null) && (strval.length() > 0)) {
            isInstance = true;
            pl.add(new RecurrenceId(makeZonedDt(val, strval)));
        }
        /* ------------------- Alarms -------------------- */
        VAlarmUtil.processEventAlarm(val, comp, currentPrincipal);
        /* ------------------- Attachments -------------------- */
        if (val.getNumAttachments() > 0) {
            for (BwAttachment att : val.getAttachments()) {
                pl.add(setAttachment(att));
            }
        }
        /* ------------------- Attendees -------------------- */
        if (!vpoll && (val.getNumAttendees() > 0)) {
            for (BwAttendee att : val.getAttendees()) {
                prop = setAttendee(att);
                mergeXparams(prop, xcomp);
                pl.add(prop);
            }
        }
        if (val.getNumCategories() > 0) {
            // LANG - filter on language - group language in one cat list?
            for (BwCategory cat : val.getCategories()) {
                prop = new Categories();
                TextList cl = ((Categories) prop).getCategories();
                cl.add(cat.getWord().getValue());
                pl.add(langProp(prop, cat.getWord()));
            }
        }
        /* ------------------- Class -------------------- */
        final String pval = val.getClassification();
        if (pval != null) {
            pl.add(new Clazz(pval));
        }
        if (val.getNumComments() > 0) {
            for (final BwString str : val.getComments()) {
                pl.add(langProp(new Comment(str.getValue()), str));
            }
        }
        if ((todo || vpoll) && (val.getCompleted() != null)) {
            prop = new Completed(new DateTime(val.getCompleted()));
            pl.add(prop);
        }
        if (val.getNumContacts() > 0) {
            for (final BwContact c : val.getContacts()) {
                // LANG
                prop = new Contact(c.getCn().getValue());
                final String l = c.getLink();
                if (l != null) {
                    prop.getParameters().add(new AltRep(l));
                }
                pl.add(langProp(uidProp(prop, c.getUid()), c.getCn()));
            }
        }
        if (val.getCost() != null) {
            IcalUtil.addXproperty(pl, BwXproperty.bedeworkCost, null, val.getCost());
        }
        /* ------------------- Created -------------------- */
        prop = new Created(val.getCreated());
        // if (pars.includeDateTimeProperty) {
        // prop.getParameters().add(Value.DATE_TIME);
        // }
        pl.add(prop);
        if (val.getDeleted()) {
            IcalUtil.addXproperty(pl, BwXproperty.bedeworkDeleted, null, String.valueOf(val.getDeleted()));
        }
        /* ------------------- Description -------------------- */
        BwStringBase bwstr = val.findDescription(null);
        if (bwstr != null) {
            pl.add(langProp(new Description(bwstr.getValue()), bwstr));
        }
        if (val.getEndType() == StartEndComponent.endTypeDate) {
            if (todo) {
                Due due = val.getDtend().makeDue(tzreg);
                if (freeBusy | val.getForceUTC()) {
                    due.setUtc(true);
                }
                pl.add(due);
            } else {
                DtEnd dtend = val.getDtend().makeDtEnd(tzreg);
                if (freeBusy | val.getForceUTC()) {
                    dtend.setUtc(true);
                }
                pl.add(dtend);
            }
        } else if (val.getEndType() == StartEndComponent.endTypeDuration) {
            addProperty(comp, new Duration(new Dur(val.getDuration())));
        }
        /* ------------------- DtStamp -------------------- */
        prop = new DtStamp(new DateTime(val.getDtstamp()));
        // if (pars.includeDateTimeProperty) {
        // prop.getParameters().add(Value.DATE_TIME);
        // }
        pl.add(prop);
        if (!val.getNoStart()) {
            DtStart dtstart = val.getDtstart().makeDtStart(tzreg);
            if (freeBusy | val.getForceUTC()) {
                dtstart.setUtc(true);
            }
            pl.add(dtstart);
        }
        if (freeBusy) {
            Collection<BwFreeBusyComponent> fbps = val.getFreeBusyPeriods();
            if (fbps != null) {
                for (BwFreeBusyComponent fbc : fbps) {
                    FreeBusy fb = new FreeBusy();
                    int type = fbc.getType();
                    if (type == BwFreeBusyComponent.typeBusy) {
                        addParameter(fb, FbType.BUSY);
                    } else if (type == BwFreeBusyComponent.typeFree) {
                        addParameter(fb, FbType.FREE);
                    } else if (type == BwFreeBusyComponent.typeBusyUnavailable) {
                        addParameter(fb, FbType.BUSY_UNAVAILABLE);
                    } else if (type == BwFreeBusyComponent.typeBusyTentative) {
                        addParameter(fb, FbType.BUSY_TENTATIVE);
                    } else {
                        throw new CalFacadeException("Bad free-busy type " + type);
                    }
                    PeriodList pdl = fb.getPeriods();
                    for (Period p : fbc.getPeriods()) {
                        // XXX inverse.ca plugin cannot handle durations.
                        Period np = new Period(p.getStart(), p.getEnd());
                        pdl.add(np);
                    }
                    pl.add(fb);
                }
            }
        }
        if (!vpoll) {
            BwGeo bwgeo = val.getGeo();
            if (bwgeo != null) {
                Geo geo = new Geo(bwgeo.getLatitude(), bwgeo.getLongitude());
                pl.add(geo);
            }
        }
        /* ------------------- LastModified -------------------- */
        prop = new LastModified(new DateTime(val.getLastmod()));
        // if (pars.includeDateTimeProperty) {
        // prop.getParameters().add(Value.DATE_TIME);
        // }
        pl.add(prop);
        if (!vpoll) {
            final BwLocation loc = val.getLocation();
            if (loc != null) {
                prop = new Location(loc.getCombinedValues());
                pl.add(langProp(uidProp(prop, loc.getUid()), loc.getAddress()));
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationAddr, null, loc.getAddressField());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationRoom, null, loc.getRoomField());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationAccessible, null, String.valueOf(loc.getAccessible()));
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationSfield1, null, loc.getSubField1());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationSfield2, null, loc.getSubField2());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationGeo, null, loc.getGeouri());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationStreet, null, loc.getStreet());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationCity, null, loc.getCity());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationState, null, loc.getState());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationZip, null, loc.getZip());
                IcalUtil.addXproperty(pl, BwXproperty.xBedeworkLocationLink, null, loc.getLink());
            }
        }
        /* ------------------- Organizer -------------------- */
        BwOrganizer org = val.getOrganizer();
        if (org != null) {
            prop = setOrganizer(org);
            mergeXparams(prop, xcomp);
            pl.add(prop);
        }
        if (todo) {
            Integer pc = val.getPercentComplete();
            if (pc != null) {
                pl.add(new PercentComplete(pc.intValue()));
            }
        }
        /* ------------------- Priority -------------------- */
        Integer prio = val.getPriority();
        if (prio != null) {
            pl.add(new Priority(prio.intValue()));
        }
        /* ------------------- RDate -below------------------- */
        /* ------------------- RelatedTo -------------------- */
        /* We encode related to (maybe) as triples - reltype, value-type, value */
        String[] info = null;
        BwRelatedTo relto = val.getRelatedTo();
        if (relto != null) {
            info = new String[3];
            info[0] = relto.getRelType();
            // default
            info[1] = "";
            info[2] = relto.getValue();
        } else {
            String relx = val.getXproperty(BwXproperty.bedeworkRelatedTo);
            if (relx != null) {
                info = Util.decodeArray(relx);
            }
        }
        if (info != null) {
            int i = 0;
            while (i < info.length) {
                RelatedTo irelto;
                String reltype = info[i];
                String valtype = info[i + 1];
                String relval = info[i + 2];
                ParameterList rtpl = null;
                if (reltype.length() > 0) {
                    rtpl = new ParameterList();
                    rtpl.add(new RelType(reltype));
                }
                if (valtype.length() > 0) {
                    if (rtpl == null) {
                        rtpl = new ParameterList();
                    }
                    rtpl.add(new Value(valtype));
                }
                if (rtpl != null) {
                    irelto = new RelatedTo(rtpl, relval);
                } else {
                    irelto = new RelatedTo(relval);
                }
                pl.add(irelto);
                i += 3;
            }
        }
        if (val.getNumResources() > 0) {
            /* This event has a resource */
            prop = new Resources();
            TextList rl = ((Resources) prop).getResources();
            for (BwString str : val.getResources()) {
                // LANG
                rl.add(str.getValue());
            }
            pl.add(prop);
        }
        if (val.getSequence() > 0) {
            pl.add(new Sequence(val.getSequence()));
        }
        /* ------------------- Status -------------------- */
        String status = val.getStatus();
        if ((status != null) && !status.equals(BwEvent.statusMasterSuppressed)) {
            pl.add(new Status(status));
        }
        /* ------------------- Summary -------------------- */
        bwstr = val.findSummary(null);
        if (bwstr != null) {
            pl.add(langProp(new Summary(bwstr.getValue()), bwstr));
        }
        if (!todo && !vpoll) {
            strval = val.getPeruserTransparency(currentPrincipal);
            if ((strval != null) && (strval.length() > 0)) {
                pl.add(new Transp(strval));
            }
        }
        /* ------------------- Uid -------------------- */
        pl.add(new Uid(val.getUid()));
        /* ------------------- Url -------------------- */
        strval = val.getLink();
        if (strval != null) {
            // Possibly drop this if we do it on input and check all data
            strval = strval.trim();
        }
        if ((strval != null) && (strval.length() > 0)) {
            URI uri = Util.validURI(strval);
            if (uri != null) {
                pl.add(new Url(uri));
            }
        }
        if (val.getNumXproperties() > 0) {
            try {
                IcalUtil.xpropertiesToIcal(pl, val.getXproperties());
            } catch (Throwable t) {
                // XXX For the moment swallow these.
                error(t);
            }
        }
        if (!vpoll && !isInstance && !isOverride && val.testRecurring()) {
            doRecurring(val, pl);
        }
        if (vavail) {
            if (ei.getNumContainedItems() > 0) {
                final VAvailability va = (VAvailability) comp;
                for (final EventInfo aei : ei.getContainedItems()) {
                    va.getAvailable().add((Available) toIcalComponent(aei, false, tzreg, currentPrincipal));
                }
            }
            /* ----------- Vavailability - busyType ----------------- */
            String s = val.getBusyTypeString();
            if (s != null) {
                pl.add(new BusyType(s));
            }
        }
        if (vpoll) {
            final Integer ival = val.getPollWinner();
            if (ival != null) {
                pl.add(new PollWinner(ival));
            }
            strval = val.getPollAcceptResponse();
            if ((strval != null) && (strval.length() > 0)) {
                pl.add(new AcceptResponse(strval));
            }
            strval = val.getPollMode();
            if ((strval != null) && (strval.length() > 0)) {
                pl.add(new PollMode(strval));
            }
            strval = val.getPollProperties();
            if ((strval != null) && (strval.length() > 0)) {
                pl.add(new PollProperties(strval));
            }
            final Map<String, VVoter> vvoters = parseVpollVvoters(val);
            for (final VVoter vv : vvoters.values()) {
                ((VPoll) comp).getVoters().add(vv);
            }
            final Map<Integer, Component> comps = parseVpollCandidates(val);
            for (final Component candidate : comps.values()) {
                ((VPoll) comp).getCandidates().add(candidate);
            }
        }
        return comp;
    } catch (final CalFacadeException cfe) {
        throw cfe;
    } catch (final Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : FreeBusy(net.fortuna.ical4j.model.property.FreeBusy) VFreeBusy(net.fortuna.ical4j.model.component.VFreeBusy) BwRelatedTo(org.bedework.calfacade.BwRelatedTo) EventInfo(org.bedework.calfacade.svc.EventInfo) BwCategory(org.bedework.calfacade.BwCategory) BwString(org.bedework.calfacade.BwString) VAvailability(net.fortuna.ical4j.model.component.VAvailability) DateTime(net.fortuna.ical4j.model.DateTime) BwDateTime(org.bedework.calfacade.BwDateTime) TextList(net.fortuna.ical4j.model.TextList) LastModified(net.fortuna.ical4j.model.property.LastModified) DtStamp(net.fortuna.ical4j.model.property.DtStamp) AcceptResponse(net.fortuna.ical4j.model.property.AcceptResponse) Available(net.fortuna.ical4j.model.component.Available) BwAttachment(org.bedework.calfacade.BwAttachment) RelatedTo(net.fortuna.ical4j.model.property.RelatedTo) BwRelatedTo(org.bedework.calfacade.BwRelatedTo) VEvent(net.fortuna.ical4j.model.component.VEvent) Status(net.fortuna.ical4j.model.property.Status) BwFreeBusyComponent(org.bedework.calfacade.BwFreeBusyComponent) BwLocation(org.bedework.calfacade.BwLocation) VVoter(net.fortuna.ical4j.model.component.VVoter) Transp(net.fortuna.ical4j.model.property.Transp) Categories(net.fortuna.ical4j.model.property.Categories) Priority(net.fortuna.ical4j.model.property.Priority) BusyType(net.fortuna.ical4j.model.property.BusyType) PeriodList(net.fortuna.ical4j.model.PeriodList) Period(net.fortuna.ical4j.model.Period) Duration(net.fortuna.ical4j.model.property.Duration) BwString(org.bedework.calfacade.BwString) BwContact(org.bedework.calfacade.BwContact) Sequence(net.fortuna.ical4j.model.property.Sequence) Geo(net.fortuna.ical4j.model.property.Geo) BwGeo(org.bedework.calfacade.BwGeo) Uid(net.fortuna.ical4j.model.property.Uid) PollMode(net.fortuna.ical4j.model.property.PollMode) BwXproperty(org.bedework.calfacade.BwXproperty) Value(net.fortuna.ical4j.model.parameter.Value) ParameterList(net.fortuna.ical4j.model.ParameterList) RecurrenceId(net.fortuna.ical4j.model.property.RecurrenceId) Resources(net.fortuna.ical4j.model.property.Resources) BwAttendee(org.bedework.calfacade.BwAttendee) VToDo(net.fortuna.ical4j.model.component.VToDo) CalendarParserImpl(net.fortuna.ical4j.data.CalendarParserImpl) VJournal(net.fortuna.ical4j.model.component.VJournal) Description(net.fortuna.ical4j.model.property.Description) BwGeo(org.bedework.calfacade.BwGeo) AltRep(net.fortuna.ical4j.model.parameter.AltRep) BwEvent(org.bedework.calfacade.BwEvent) URI(java.net.URI) Url(net.fortuna.ical4j.model.property.Url) PollWinner(net.fortuna.ical4j.model.property.PollWinner) Created(net.fortuna.ical4j.model.property.Created) VPoll(net.fortuna.ical4j.model.component.VPoll) Due(net.fortuna.ical4j.model.property.Due) StringReader(java.io.StringReader) PollProperties(net.fortuna.ical4j.model.property.PollProperties) Clazz(net.fortuna.ical4j.model.property.Clazz) StartEndComponent(org.bedework.calfacade.base.StartEndComponent) Component(net.fortuna.ical4j.model.Component) BwFreeBusyComponent(org.bedework.calfacade.BwFreeBusyComponent) DateListProperty(net.fortuna.ical4j.model.property.DateListProperty) Property(net.fortuna.ical4j.model.Property) BwOrganizer(org.bedework.calfacade.BwOrganizer) Dur(net.fortuna.ical4j.model.Dur) Comment(net.fortuna.ical4j.model.property.Comment) RelType(net.fortuna.ical4j.model.parameter.RelType) VFreeBusy(net.fortuna.ical4j.model.component.VFreeBusy) Calendar(net.fortuna.ical4j.model.Calendar) UnfoldingReader(net.fortuna.ical4j.data.UnfoldingReader) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) Contact(net.fortuna.ical4j.model.property.Contact) BwContact(org.bedework.calfacade.BwContact) PropertyList(net.fortuna.ical4j.model.PropertyList) DtStart(net.fortuna.ical4j.model.property.DtStart) BwStringBase(org.bedework.calfacade.base.BwStringBase) PercentComplete(net.fortuna.ical4j.model.property.PercentComplete) Completed(net.fortuna.ical4j.model.property.Completed) Summary(net.fortuna.ical4j.model.property.Summary) DtEnd(net.fortuna.ical4j.model.property.DtEnd) BwLocation(org.bedework.calfacade.BwLocation) Location(net.fortuna.ical4j.model.property.Location)

Example 4 with VToDo

use of net.fortuna.ical4j.model.component.VToDo in project bw-calendar-engine by Bedework.

the class IcalTranslator method xmlComponent.

private void xmlComponent(final XmlEmit xml, final Component val) throws CalFacadeException {
    try {
        QName tag = openTag(xml, val.getName());
        PropertyList pl = val.getProperties();
        if (pl.size() > 0) {
            xml.openTag(XcalTags.properties);
            for (Object po : pl) {
                xmlProperty(xml, (Property) po);
            }
            xml.closeTag(XcalTags.properties);
        }
        ComponentList cl = null;
        if (val instanceof VTimeZone) {
            cl = ((VTimeZone) val).getObservances();
        } else if (val instanceof VEvent) {
            cl = ((VEvent) val).getAlarms();
        } else if (val instanceof VToDo) {
            cl = ((VToDo) val).getAlarms();
        }
        if ((cl != null) && (cl.size() > 0)) {
            xml.openTag(XcalTags.components);
            for (Object o : cl) {
                xmlComponent(xml, (Component) o);
            }
            xml.closeTag(XcalTags.components);
        }
        xml.closeTag(tag);
    } catch (CalFacadeException cfe) {
        throw cfe;
    } catch (Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : VEvent(net.fortuna.ical4j.model.component.VEvent) PropertyList(net.fortuna.ical4j.model.PropertyList) QName(javax.xml.namespace.QName) VTimeZone(net.fortuna.ical4j.model.component.VTimeZone) ComponentList(net.fortuna.ical4j.model.ComponentList) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) VToDo(net.fortuna.ical4j.model.component.VToDo)

Example 5 with VToDo

use of net.fortuna.ical4j.model.component.VToDo in project bw-calendar-engine by Bedework.

the class JcalHandler method outComp.

private static void outComp(final JsonGenerator jgen, final Component comp) throws CalFacadeException {
    try {
        jgen.writeStartArray();
        jgen.writeString(comp.getName().toLowerCase());
        jgen.writeStartArray();
        for (final Object o : comp.getProperties()) {
            JsonProperty.addFields(jgen, (Property) o);
        }
        // End event properties
        jgen.writeEndArray();
        /* Output subcomponents
       */
        jgen.writeStartArray();
        ComponentList cl = null;
        if (comp instanceof VEvent) {
            cl = ((VEvent) comp).getAlarms();
        } else if (comp instanceof VToDo) {
            cl = ((VToDo) comp).getAlarms();
        // } else if (comp instanceof VJournal) {
        // } else if (comp instanceof VFreeBusy) {
        } else if (comp instanceof VAvailability) {
            cl = ((VAvailability) comp).getAvailable();
        // } else if (comp instanceof Available) {
        } else if (comp instanceof VPoll) {
            cl = ((VPoll) comp).getVoters();
        } else if (comp instanceof VVoter) {
            cl = ((VVoter) comp).getVotes();
        }
        if (cl != null) {
            for (final Object o : cl) {
                outComp(jgen, (Component) o);
            }
            if (comp instanceof VPoll) {
                for (final Object o : ((VPoll) comp).getCandidates()) {
                    outComp(jgen, (Component) o);
                }
            }
        }
        // end subcomponents
        jgen.writeEndArray();
        // end event
        jgen.writeEndArray();
    } catch (Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : VEvent(net.fortuna.ical4j.model.component.VEvent) VVoter(net.fortuna.ical4j.model.component.VVoter) VPoll(net.fortuna.ical4j.model.component.VPoll) ComponentList(net.fortuna.ical4j.model.ComponentList) VAvailability(net.fortuna.ical4j.model.component.VAvailability) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) VToDo(net.fortuna.ical4j.model.component.VToDo)

Aggregations

VEvent (net.fortuna.ical4j.model.component.VEvent)8 VToDo (net.fortuna.ical4j.model.component.VToDo)8 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)7 PropertyList (net.fortuna.ical4j.model.PropertyList)6 ComponentList (net.fortuna.ical4j.model.ComponentList)5 Property (net.fortuna.ical4j.model.Property)5 VPoll (net.fortuna.ical4j.model.component.VPoll)5 VAvailability (net.fortuna.ical4j.model.component.VAvailability)4 Component (net.fortuna.ical4j.model.Component)3 VFreeBusy (net.fortuna.ical4j.model.component.VFreeBusy)3 Iterator (java.util.Iterator)2 Period (net.fortuna.ical4j.model.Period)2 PeriodList (net.fortuna.ical4j.model.PeriodList)2 TextList (net.fortuna.ical4j.model.TextList)2 Available (net.fortuna.ical4j.model.component.Available)2 VJournal (net.fortuna.ical4j.model.component.VJournal)2 VTimeZone (net.fortuna.ical4j.model.component.VTimeZone)2 VVoter (net.fortuna.ical4j.model.component.VVoter)2 Value (net.fortuna.ical4j.model.parameter.Value)2 AcceptResponse (net.fortuna.ical4j.model.property.AcceptResponse)2