Search in sources :

Example 1 with EventInfo

use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.

the class EventFieldRule method field.

@Override
public void field(final String name) throws Exception {
    if (skippedNames.contains(name)) {
        return;
    }
    DateTimeValues dtv = null;
    if (top() instanceof DateTimeValues) {
        dtv = (DateTimeValues) pop();
    }
    EventInfo ei = (EventInfo) getTop(EventInfo.class, name);
    BwEventAnnotation ann = null;
    BwEvent e = ei.getEvent();
    if (e instanceof BwEventProxy) {
        ann = ((BwEventProxy) e).getRef();
    // e = ann;
    }
    if (shareableContainedEntityTags(e, name)) {
        return;
    }
    try {
        if (name.equals("emptyFlags")) {
            char[] flags = stringFld().toCharArray();
            for (char c : flags) {
                if ((c != 'T') && (c != 'F')) {
                    error("Bad empty flags '" + stringFld() + "' for event " + ann);
                }
            }
            ann.setEmptyFlags(new String(flags));
        /* ------------------- Start/end --------------------------- */
        } else if (name.equals("noStart")) {
            if (ann != null) {
                ann.setNoStart(booleanFld());
            } else {
                e.setNoStart(booleanFld());
            }
        } else if (name.equals("dtstart")) {
            if (ann != null) {
                ann.setDtstart(dateTimeFld(dtv));
            } else {
                e.setDtstart(dateTimeFld(dtv));
            }
        } else if (name.equals("dtend")) {
            if (ann != null) {
                ann.setDtend(dateTimeFld(dtv));
            } else {
                e.setDtend(dateTimeFld(dtv));
            }
        } else if (name.equals("duration")) {
            // XXX Fix bad duration value due to old bug
            String dur = stringFld();
            char endType = e.getEndType();
            if ("PT1S".equals(dur) && (endType == StartEndComponent.endTypeNone)) {
                dur = "PT0S";
            }
            if (ann != null) {
                ann.setDuration(dur);
            } else {
                e.setDuration(dur);
            }
        } else if (name.equals("endType")) {
            if (ann != null) {
                ann.setEndType(charFld());
            } else {
                e.setEndType(charFld());
            }
        } else if (name.equals("entityType")) {
            e.setEntityType(intFld());
        } else if (name.equals("name")) {
            if (ann != null) {
                ann.setName(stringFld());
            } else {
                e.setName(stringFld());
            }
        } else if (name.equals("uid")) {
            if (ann != null) {
                ann.setUid(stringFld());
            } else {
                e.setUid(stringFld());
            }
        } else if (name.equals("classification")) {
            e.setClassification(stringFld());
        } else if (name.equals("link")) {
            e.setLink(stringFld());
        } else if (name.equals("geo-latitude")) {
            BwGeo geo = e.getGeo();
            if (geo == null) {
                geo = new BwGeo();
                e.setGeo(geo);
            }
            // geo.setLatitude(bigDecimalFld());
            geo.setLatitude(bigDecimalFld());
        } else if (name.equals("geo-longitude")) {
            BwGeo geo = e.getGeo();
            if (geo == null) {
                geo = new BwGeo();
                e.setGeo(geo);
            }
            // geo.setLongitude(bigDecimalFld());
            geo.setLongitude(bigDecimalFld());
        } else if (name.equals("status")) {
            String status = stringFld();
            if ((status != null) && (!status.equals("F"))) {
                // 2.3.2
                e.setStatus(status);
            }
        } else if (name.equals("cost")) {
            e.setCost(stringFld());
        } else if (name.equals("deleted")) {
            e.setDeleted(booleanFld());
        } else if (name.equals("tombstoned")) {
            e.setTombstoned(booleanFld());
        } else if (name.equals("dtstamp")) {
            e.setDtstamp(stringFld());
        } else if (name.equals("lastmod")) {
            e.setLastmod(stringFld());
        } else if (name.equals("created")) {
            e.setCreated(stringFld());
        } else if (name.equals("byteSize")) {
            e.setByteSize(intFld());
        } else if (name.equals("priority")) {
            e.setPriority(integerFld());
        } else if (name.equals("transparency")) {
            e.setTransparency(stringFld());
        } else if (name.equals("relatedTo")) {
        // e.setRelatedTo(stringFld());
        } else if (name.equals("percentComplete")) {
            e.setPercentComplete(integerFld());
        } else if (name.equals("completed")) {
            e.setCompleted(stringFld());
        } else if (name.equals("ctoken")) {
            e.setCtoken(stringFld());
        /* --------------- Recurrence fields ---------------------- */
        } else if (name.equals("recurring")) {
            e.setRecurring(new Boolean(booleanFld()));
        } else if (name.equals("rrule")) {
            e.addRrule(stringFld());
        } else if (name.equals("exrule")) {
            e.addExrule(stringFld());
        } else if (name.equals("rdate")) {
            e.addRdate(dateTimeFld(dtv));
        } else if (name.equals("exdate")) {
            e.addExdate(dateTimeFld(dtv));
        } else if (name.equals("recurrenceId")) {
            e.setRecurrenceId(stringFld());
        } else if (name.equals("latestDate")) {
            e.setCtoken(stringFld());
        /* --------------- Scheduling fields ---------------------- */
        } else if (name.equals("organizer")) {
        // pre 3.5
        } else if (name.equals("sequence")) {
            e.setSequence(intFld());
        } else if (name.equals("scheduleMethod")) {
            e.setScheduleMethod(intFld());
        } else if (name.equals("originator")) {
            e.setOriginator(stringFld());
        } else if (name.equals("recipient")) {
            e.addRecipient(stringFld());
        } else if (name.equals("scheduleState")) {
            e.setScheduleState(intFld());
        } else if (name.equals("organizerSchedulingObject")) {
            e.setOrganizerSchedulingObject(booleanFld());
        } else if (name.equals("attendeeSchedulingObject")) {
            e.setAttendeeSchedulingObject(booleanFld());
        } else if (name.equals("stag")) {
            e.setStag(stringFld());
        /* ------------------- vavailability --------------------------- */
        } else if (name.equals("busyType")) {
            e.setBusyType(intFld());
        /* ------------------- vpoll --------------------------- */
        } else if (name.equals("pollCandidate")) {
            e.setPollCandidate(booleanFld());
        } else {
            unknownTag(name);
        }
    } catch (Exception ex) {
        error("Error processing event uid " + e.getUid(), ex);
        globals.entityError = true;
    }
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwEventAnnotation(org.bedework.calfacade.BwEventAnnotation) BwGeo(org.bedework.calfacade.BwGeo) BwEvent(org.bedework.calfacade.BwEvent) BwEventProxy(org.bedework.calfacade.BwEventProxy)

Example 2 with EventInfo

use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.

the class EventRule method begin.

@Override
public void begin(final String ns, final String name, final Attributes att) throws Exception {
    super.begin(ns, kind, att);
    BwEvent ev = (BwEvent) pop();
    boolean override = (kind.equals(objectOverride));
    if (ev instanceof BwEventAnnotation) {
        BwEventAnnotation ann = (BwEventAnnotation) ev;
        ann.setOverride(override);
        ev = new BwEventProxy(ann);
        if (override) {
            /* The override is embedded in the event so the top() should be the master
         * Annotations will get the master and target set later.
         */
            EventInfo mei = (EventInfo) top();
            ann.setTarget(mei.getEvent());
            ann.setMaster(mei.getEvent());
        } else {
            /* Make up empty event object for us to fill in */
            BwEvent e = new BwEventObj();
            ann.setTarget(e);
            ann.setMaster(e);
        }
    } else if (override) {
        error("Restore error - override but not annotation.");
    }
    EventInfo ei = new EventInfo(ev);
    /* Initialise fields that may be missed when restoring earlier data */
    ev.setNoStart(false);
    push(ei);
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwEventAnnotation(org.bedework.calfacade.BwEventAnnotation) BwEvent(org.bedework.calfacade.BwEvent) BwEventProxy(org.bedework.calfacade.BwEventProxy) BwEventObj(org.bedework.calfacade.BwEventObj)

Example 3 with EventInfo

use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.

the class GeoRule method end.

@Override
public void end(final String ns, final String name) throws Exception {
    BwGeo entity = (BwGeo) pop();
    if (!(top() instanceof EventInfo)) {
        warn("Expected an event info object: found " + top());
        return;
    }
    BwEvent ev = ((EventInfo) top()).getEvent();
    ev.setGeo(entity);
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwGeo(org.bedework.calfacade.BwGeo) BwEvent(org.bedework.calfacade.BwEvent)

Example 4 with EventInfo

use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.

the class LocationKeyRule method storeEntity.

@Override
public void storeEntity(final OwnerUidKey key) throws Exception {
    BwLocation ent;
    try {
        ent = globals.rintf.getLocation(key.getUid());
    } catch (Throwable t) {
        throw new Exception(t);
    }
    if (ent == null) {
        throw new Exception("Missing location with key " + key + " for " + top());
    }
    if (top() instanceof EventInfo) {
        BwEvent ev = ((EventInfo) top()).getEvent();
        ev.setLocation(ent);
        return;
    }
    throw new Exception("Unhandled class for locations " + top());
}
Also used : BwLocation(org.bedework.calfacade.BwLocation) EventInfo(org.bedework.calfacade.svc.EventInfo) BwEvent(org.bedework.calfacade.BwEvent)

Example 5 with EventInfo

use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.

the class RelatedToRule method end.

@Override
public void end(final String ns, final String name) throws Exception {
    BwRelatedTo entity = (BwRelatedTo) pop();
    if (!(top() instanceof EventInfo)) {
        warn("Expected an event info object: found " + top());
        return;
    }
    BwEvent ev = ((EventInfo) top()).getEvent();
    ev.setRelatedTo(entity);
}
Also used : BwRelatedTo(org.bedework.calfacade.BwRelatedTo) EventInfo(org.bedework.calfacade.svc.EventInfo) BwEvent(org.bedework.calfacade.BwEvent)

Aggregations

EventInfo (org.bedework.calfacade.svc.EventInfo)111 BwEvent (org.bedework.calfacade.BwEvent)80 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)37 BwCalendar (org.bedework.calfacade.BwCalendar)27 BwEventProxy (org.bedework.calfacade.BwEventProxy)24 BwAttendee (org.bedework.calfacade.BwAttendee)19 ArrayList (java.util.ArrayList)16 CoreEventInfo (org.bedework.calcorei.CoreEventInfo)15 BwEventAnnotation (org.bedework.calfacade.BwEventAnnotation)15 BwString (org.bedework.calfacade.BwString)11 BwDateTime (org.bedework.calfacade.BwDateTime)10 BwEventObj (org.bedework.calfacade.BwEventObj)10 TreeSet (java.util.TreeSet)9 BwXproperty (org.bedework.calfacade.BwXproperty)9 BwPrincipal (org.bedework.calfacade.BwPrincipal)7 CalFacadeAccessException (org.bedework.calfacade.exc.CalFacadeAccessException)7 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)7 Calendar (net.fortuna.ical4j.model.Calendar)6 Period (net.fortuna.ical4j.model.Period)6 BwOrganizer (org.bedework.calfacade.BwOrganizer)6