Search in sources :

Example 21 with BwCategory

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

the class ProcessList method listCategories.

private boolean listCategories() throws Throwable {
    try {
        info("Categories:");
        Collection<String> vals = new ArrayList<String>();
        while (!cmdEnd()) {
            String catVal = wordOrQuotedVal();
            if (catVal == null) {
                break;
            }
            vals.add(catVal.toLowerCase());
        }
        open();
        Collection<BwCategory> cats = getSvci().getCategoriesHandler().get();
        for (BwCategory cat : cats) {
            if (vals.isEmpty()) {
                listCategory(cat);
                continue;
            }
            String lc = cat.getWordVal().toLowerCase();
            for (String s : vals) {
                if (lc.contains(s)) {
                    listCategory(cat);
                }
            }
        }
        return true;
    } finally {
        close();
    }
}
Also used : ArrayList(java.util.ArrayList) BwCategory(org.bedework.calfacade.BwCategory)

Example 22 with BwCategory

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

the class ProcessMove method getCats.

private Collection<BwCategory> getCats(final Collection<String> catVals, final String toOwner, final boolean addcats, final String fromPath) throws Throwable {
    final Collection<BwCategory> cats = new ArrayList<>();
    for (final String catVal : catVals) {
        final BwCategory cat = getCat(toOwner, catVal);
        if (cat == null) {
            if (debug) {
                debug("No cat ");
            }
            return null;
        }
        cats.add(cat);
    }
    if (addcats) {
        final String[] pathEls = fromPath.split("/");
        if (pathEls.length > 2) {
            for (int i = 2; i < pathEls.length; i++) {
                final String catVal = pathEls[i];
                final BwCategory cat = getCat(toOwner, catVal);
                if (cat == null) {
                    return null;
                }
                cats.add(cat);
            }
        }
    }
    return cats;
}
Also used : BwCategory(org.bedework.calfacade.BwCategory) ArrayList(java.util.ArrayList)

Example 23 with BwCategory

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

the class CalintfHelper method restoreCategories.

protected void restoreCategories(final CategorisedEntity ce) throws CalFacadeException {
    final Set<String> uids = ce.getCategoryUids();
    if (Util.isEmpty(uids)) {
        return;
    }
    for (final String uid : uids) {
        final BwCategory cat = cb.getCategory(uid);
        if (cat == null) {
            throw new CalFacadeException("Attempting to store null for cat uid " + uid);
        }
        ce.addCategory(cat);
    }
}
Also used : BwCategory(org.bedework.calfacade.BwCategory) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 24 with BwCategory

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

the class XbwWrapperPropUpdater method checkCategory.

/* Return true if value matches a category - which may be added as
   * a result
   */
private boolean checkCategory(final UpdateInfo ui, final BwEvent ev, final Set<BwCategory> cats, final String lang, final String val) throws CalFacadeException {
    final BwString sval = new BwString(lang, val);
    final BwCategory cat = ui.getIcalCallback().findCategory(sval);
    if (cat == null) {
        return false;
    }
    for (final BwCategory c : cats) {
        if (c.getWord().equals(sval)) {
            // Already present
            return true;
        }
    }
    ev.addCategory(cat);
    ui.getCte(PropertyIndex.PropertyInfoIndex.CATEGORIES).addValue(cat);
    return true;
}
Also used : BwCategory(org.bedework.calfacade.BwCategory) BwString(org.bedework.calfacade.BwString)

Example 25 with BwCategory

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

the class CategoryPropUpdater method removeValue.

@Override
protected boolean removeValue(final BwEvent ev, final BwString val, final UpdateInfo ui) throws WebdavException {
    if (ev.getNumCategories() == 0) {
        return false;
    }
    BwCategory cat = null;
    for (BwCategory evcat : ev.getCategories()) {
        if (evcat.getWord().equals(val)) {
            // Found the category attached to the event.
            cat = evcat;
            break;
        }
    }
    if (cat == null) {
        // Nothing to do
        return true;
    }
    ev.removeCategory(cat);
    ui.getCte().addRemovedValue(cat);
    return true;
}
Also used : BwCategory(org.bedework.calfacade.BwCategory)

Aggregations

BwCategory (org.bedework.calfacade.BwCategory)42 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)13 BwContact (org.bedework.calfacade.BwContact)11 BwString (org.bedework.calfacade.BwString)11 BwCalendar (org.bedework.calfacade.BwCalendar)10 BwEvent (org.bedework.calfacade.BwEvent)10 BwLocation (org.bedework.calfacade.BwLocation)8 BwXproperty (org.bedework.calfacade.BwXproperty)7 ArrayList (java.util.ArrayList)6 EventInfo (org.bedework.calfacade.svc.EventInfo)6 BwDateTime (org.bedework.calfacade.BwDateTime)5 TreeSet (java.util.TreeSet)4 BwAttendee (org.bedework.calfacade.BwAttendee)4 ChangeTableEntry (org.bedework.calfacade.util.ChangeTableEntry)4 PropertyInfoIndex (org.bedework.util.calendar.PropertyIndex.PropertyInfoIndex)4 Period (net.fortuna.ical4j.model.Period)3 BwEventProxy (org.bedework.calfacade.BwEventProxy)3 BwIcalPropertyInfoEntry (org.bedework.calfacade.ical.BwIcalPropertyInfo.BwIcalPropertyInfoEntry)3 FilterBase (org.bedework.caldav.util.filter.FilterBase)2 ObjectFilter (org.bedework.caldav.util.filter.ObjectFilter)2