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();
}
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations