Search in sources :

Example 1 with BwRequestStatus

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

the class BwObjectFilter method match.

/* ====================================================================
   *                   matching methods
   * ==================================================================== */
@Override
public boolean match(final Object o, final String userHref) throws WebdavException {
    ObjectFilter of = getEntity();
    Object ent = of.getEntity();
    boolean not = of.getNot();
    String val = null;
    Integer ival = null;
    if (ent instanceof BwCalendar) {
        val = ((BwCalendar) ent).getPath();
    } else if (ent instanceof String) {
        val = (String) ent;
    } else if (ent instanceof Integer) {
        ival = (Integer) ent;
    } else {
        throw new WebdavException("Unmatchable filter");
    }
    BwEvent ev = null;
    if (o instanceof BwEvent) {
        ev = (BwEvent) o;
    }
    if (of instanceof EntityTypeFilter) {
        if (ev == null) {
            return false;
        }
        if (not) {
            return ev.getEntityType() != ival;
        }
        return ev.getEntityType() == ival;
    }
    PropertyInfoIndex pii = of.getPropertyIndex();
    BwIcalPropertyInfoEntry pi = BwIcalPropertyInfo.getPinfo(pii);
    if (pi.getParam()) {
        pii = of.getParentPropertyIndex();
    }
    switch(pii) {
        case CLASS:
            if (ev.getClassification() == null) {
                return false;
            }
            return stringMatch(ev.getClassification(), val);
        case CREATED:
            return stringMatch(ev.getCreated(), val);
        case DESCRIPTION:
            for (BwLongString ls : ev.getDescriptions()) {
                if (stringMatch(ls.getValue(), val)) {
                    return true;
                }
            }
            return false;
        case DTSTAMP:
            return stringMatch(ev.getDtstamp(), val);
        case DTEND:
        /* Event only */
        case DUE:
            /* Todo only */
            return matchDateTime(pi, ev.getDtend(), val);
        case DTSTART:
            return matchDateTime(pi, ev.getDtstart(), val);
        case DURATION:
            return stringMatch(ev.getDuration(), val);
        case GEO:
            if (ev.getGeo() == null) {
                return false;
            }
            return stringMatch(ev.getGeo().toString(), val);
        case LAST_MODIFIED:
            return stringMatch(ev.getLastmod(), val);
        case LOCATION:
            if (ev.getLocation() == null) {
                return false;
            }
            return stringMatch(ev.getLocation().getAddress().getValue(), val);
        case ORGANIZER:
            if (ev.getOrganizer() == null) {
                return false;
            }
            return stringMatch(ev.getOrganizer().getOrganizerUri(), val);
        case PRIORITY:
            if (ev.getPriority() == null) {
                return false;
            }
            return stringMatch(String.valueOf(ev.getPriority()), val);
        case RECURRENCE_ID:
            if (ev.getRecurrenceId() == null) {
                return false;
            }
            return stringMatch(ev.getRecurrenceId(), val);
        case SEQUENCE:
            return stringMatch(String.valueOf(ev.getSequence()), val);
        case STATUS:
            if (ev.getStatus() == null) {
                return false;
            }
            return stringMatch(ev.getStatus(), val);
        case SUMMARY:
            for (BwString s : ev.getSummaries()) {
                if (stringMatch(s.getValue(), val)) {
                    return true;
                }
            }
            return false;
        case UID:
            return stringMatch(ev.getUid(), val);
        case URL:
            if (ev.getLink() == null) {
                return false;
            }
            return stringMatch(ev.getLink(), val);
        case TRANSP:
            try {
                if (ev.getPeruserTransparency(userHref) == null) {
                    return false;
                }
                return stringMatch(ev.getPeruserTransparency(userHref), val);
            } catch (Throwable t) {
                throw new WebdavException(t);
            }
        case COMPLETED:
            if (ev.getCompleted() == null) {
                return false;
            }
            return stringMatch(ev.getCompleted(), val);
        case PERCENT_COMPLETE:
            if (ev.getPercentComplete() == null) {
                return false;
            }
            return stringMatch(String.valueOf(ev.getPercentComplete()), val);
        case ATTACH:
            break;
        case ATTENDEE:
            break;
        case CATEGORIES:
            for (BwCategory cat : ev.getCategories()) {
                if (stringMatch(cat.getWordVal(), val)) {
                    return true;
                }
            }
            return false;
        case COMMENT:
            for (BwString s : ev.getComments()) {
                if (stringMatch(s.getValue(), val)) {
                    return true;
                }
            }
            return false;
        case CONTACT:
            for (BwContact c : ev.getContacts()) {
                if (stringMatch(c.getCn().getValue(), val)) {
                    return true;
                }
            }
            return false;
        case EXDATE:
            for (BwDateTime dt : ev.getExdates()) {
                if (stringMatch(dt.getDtval(), val)) {
                    return true;
                }
            }
            return false;
        case EXRULE:
            for (String s : ev.getExrules()) {
                if (stringMatch(s, val)) {
                    return true;
                }
            }
            return false;
        case REQUEST_STATUS:
            for (BwRequestStatus rs : ev.getRequestStatuses()) {
                if (stringMatch(rs.getCode(), val)) {
                    return true;
                }
            }
            return false;
        case RELATED_TO:
            if (ev.getRelatedTo() == null) {
                return false;
            }
            return stringMatch(ev.getRelatedTo().getValue(), val);
        case RESOURCES:
            for (BwString s : ev.getResources()) {
                if (stringMatch(s.getValue(), val)) {
                    return true;
                }
            }
            return false;
        case RDATE:
            for (BwDateTime dt : ev.getRdates()) {
                if (stringMatch(dt.getDtval(), val)) {
                    return true;
                }
            }
            return false;
        case RRULE:
            for (String s : ev.getRrules()) {
                if (stringMatch(s, val)) {
                    return true;
                }
            }
            return false;
        case FREEBUSY:
            break;
        case TZID:
            break;
        case TZNAME:
            break;
        case TZOFFSETFROM:
            break;
        case TZOFFSETTO:
            break;
        case TZURL:
            break;
        case ACTION:
            break;
        case REPEAT:
            break;
        case TRIGGER:
            break;
        case COLLECTION:
            return stringMatch(ev.getColPath(), val);
        case CREATOR:
            return stringMatch(ev.getCreatorHref(), val);
        case OWNER:
            return stringMatch(ev.getOwnerHref(), val);
        case ENTITY_TYPE:
            break;
    }
    return false;
}
Also used : BwDateTime(org.bedework.calfacade.BwDateTime) BwRequestStatus(org.bedework.calfacade.BwRequestStatus) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) BwCategory(org.bedework.calfacade.BwCategory) BwEvent(org.bedework.calfacade.BwEvent) ObjectFilter(org.bedework.caldav.util.filter.ObjectFilter) BwString(org.bedework.calfacade.BwString) BwLongString(org.bedework.calfacade.BwLongString) BwCalendar(org.bedework.calfacade.BwCalendar) BwString(org.bedework.calfacade.BwString) BwContact(org.bedework.calfacade.BwContact) EntityTypeFilter(org.bedework.caldav.util.filter.EntityTypeFilter) BwLongString(org.bedework.calfacade.BwLongString) PropertyInfoIndex(org.bedework.util.calendar.PropertyIndex.PropertyInfoIndex) BwIcalPropertyInfoEntry(org.bedework.calfacade.ical.BwIcalPropertyInfo.BwIcalPropertyInfoEntry)

Example 2 with BwRequestStatus

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

the class BwStringRule method end.

@Override
public void end(final String ns, final String name) throws Exception {
    if (name.equals("bwstring")) {
        // 3.5 onwards we wrapped with a tag. Do nothing
        return;
    }
    BwString entity = (BwString) pop();
    if (top() instanceof BwRequestStatus) {
        BwRequestStatus rs = (BwRequestStatus) top();
        rs.setDescription(entity);
        return;
    }
    if (top() instanceof BwCategory) {
        BwCategory cat = (BwCategory) top();
        if (name.equals("keyword")) {
            cat.setWord(entity);
        } else if (name.equals("desc")) {
            cat.setDescription(entity);
        } else {
            unknownTag(name);
        }
        return;
    }
    if (top() instanceof BwContact) {
        BwContact ent = (BwContact) top();
        if (name.equals("value")) {
            ent.setCn(entity);
        } else {
            unknownTag(name);
        }
        return;
    }
    if (top() instanceof BwLocation) {
        BwLocation loc = (BwLocation) top();
        if (name.equals("addr")) {
            loc.setAddress(entity);
        } else if (name.equals("subaddr")) {
            loc.setSubaddress(entity);
        } else {
            unknownTag(name);
        }
        return;
    }
    if (top() instanceof BwFilterDef) {
        BwFilterDef f = (BwFilterDef) top();
        if (name.equals("display-name")) {
            f.addDisplayName(entity);
        } else if (name.equals("subaddr")) {
            f.addDescription(new BwLongString(entity.getLang(), entity.getValue()));
        } else {
            unknownTag(name);
        }
        return;
    }
    if (top() instanceof BwAlarm) {
        BwAlarm a = (BwAlarm) top();
        if (name.equals("description")) {
            a.addDescription(entity);
            if (entity.getLang() != null) {
                a.addXproperty(new BwXproperty(entity.getLang(), null, entity.getValue()));
            } else {
                a.addDescription(entity);
            }
            return;
        }
        if (name.equals("summary")) {
            a.addSummary(entity);
        } else {
            unknownTag(name);
        }
        return;
    }
    EventInfo ei = (EventInfo) top();
    BwEvent e = ei.getEvent();
    if (e instanceof BwEventProxy) {
        e = ((BwEventProxy) e).getRef();
    }
    if (name.equals("comment")) {
        e.addComment(entity);
    } else if (name.equals("description")) {
        e.addDescription(new BwLongString(entity.getLang(), entity.getValue()));
    } else if (name.equals("resource")) {
        e.addResource(entity);
    } else if (name.equals("summary")) {
        e.addSummary(entity);
    } else {
        unknownTag(name);
    }
}
Also used : BwLongString(org.bedework.calfacade.BwLongString) BwLocation(org.bedework.calfacade.BwLocation) BwRequestStatus(org.bedework.calfacade.BwRequestStatus) EventInfo(org.bedework.calfacade.svc.EventInfo) BwXproperty(org.bedework.calfacade.BwXproperty) BwCategory(org.bedework.calfacade.BwCategory) BwFilterDef(org.bedework.calfacade.BwFilterDef) BwEvent(org.bedework.calfacade.BwEvent) BwString(org.bedework.calfacade.BwString) BwContact(org.bedework.calfacade.BwContact) BwEventProxy(org.bedework.calfacade.BwEventProxy) BwAlarm(org.bedework.calfacade.BwAlarm)

Example 3 with BwRequestStatus

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

the class InReply method getRstat.

private String getRstat(final BwEvent ev) {
    String rstat = null;
    for (final BwRequestStatus bwrstat : ev.getRequestStatuses()) {
        if (rstat != null) {
            rstat += ",";
            rstat += bwrstat.getCode();
        } else {
            rstat = bwrstat.getCode();
        }
    }
    if (rstat == null) {
        rstat = IcalDefs.deliveryStatusSuccess;
    }
    return rstat;
}
Also used : BwRequestStatus(org.bedework.calfacade.BwRequestStatus)

Example 4 with BwRequestStatus

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

the class DocBuilder method indexReqStat.

private void indexReqStat(final Set<BwRequestStatus> val) throws CalFacadeException {
    try {
        if (Util.isEmpty(val)) {
            return;
        }
        startArray(getJname(PropertyInfoIndex.REQUEST_STATUS));
        for (final BwRequestStatus rs : val) {
            value(rs.strVal());
        }
        endArray();
    } catch (final IndexException e) {
        throw new CalFacadeException(e);
    }
}
Also used : BwRequestStatus(org.bedework.calfacade.BwRequestStatus) IndexException(org.bedework.util.indexing.IndexException) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 5 with BwRequestStatus

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

the class EventBwRequestStatusRule method end.

public void end(String ns, String name) throws Exception {
    BwRequestStatus entity = (BwRequestStatus) pop();
    EventInfo ei = (EventInfo) top();
    BwEvent e = ei.getEvent();
    if (e instanceof BwEventProxy) {
        e = ((BwEventProxy) e).getRef();
    }
    e.addRequestStatus(entity);
}
Also used : BwRequestStatus(org.bedework.calfacade.BwRequestStatus) EventInfo(org.bedework.calfacade.svc.EventInfo) BwEvent(org.bedework.calfacade.BwEvent) BwEventProxy(org.bedework.calfacade.BwEventProxy)

Aggregations

BwRequestStatus (org.bedework.calfacade.BwRequestStatus)9 BwEvent (org.bedework.calfacade.BwEvent)7 EventInfo (org.bedework.calfacade.svc.EventInfo)6 BwString (org.bedework.calfacade.BwString)5 BwAttendee (org.bedework.calfacade.BwAttendee)4 ScheduleResult (org.bedework.calfacade.ScheduleResult)3 BwCategory (org.bedework.calfacade.BwCategory)2 BwContact (org.bedework.calfacade.BwContact)2 BwLongString (org.bedework.calfacade.BwLongString)2 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)2 Iterator (java.util.Iterator)1 Holder (javax.xml.ws.Holder)1 Component (net.fortuna.ical4j.model.Component)1 Date (net.fortuna.ical4j.model.Date)1 Parameter (net.fortuna.ical4j.model.Parameter)1 Period (net.fortuna.ical4j.model.Period)1 PeriodList (net.fortuna.ical4j.model.PeriodList)1 Property (net.fortuna.ical4j.model.Property)1 PropertyList (net.fortuna.ical4j.model.PropertyList)1 TextList (net.fortuna.ical4j.model.TextList)1