public void toJson(final JsonGenerator jgen) throws CalFacadeException { try { jgen.writeStartObject(); outJsonField("name", getName(), jgen); outJsonField("href", getHref(), jgen); outJsonField("colPath", getColPath(), jgen); outJsonField("uid", getUid(), jgen); outJsonBwString("word", getWord(), jgen); outJsonBwString("description", getDescription(), jgen); jgen.writeEndObject(); // category } catch (final Throwable t) { throw new CalFacadeException(t); } }
@Override public Object clone() { final BwCategory cat = new BwCategory(); super.copyTo(cat); cat.setWord((BwString)getWord().clone()); if (getDescription() != null) { cat.setDescription((BwString)getDescription().clone()); } cat.setName(getName()); return cat; } }
/** Delete the category's keyword - this must be called rather than setting * the value to null. * */ public void deleteWord() { addDeletedEntity(getWord()); setWord(null); }
@Override public void afterDeletion() { addDeletedEntity(getWord()); addDeletedEntity(getDescription()); }
/** Delete the category's description - this must be called rather than setting * the value to null. * */ public void deleteDescription() { addDeletedEntity(getDescription()); setDescription(null); }
@Override public void fixNames(final BasicSystemProperties props, final BwPrincipal principal) { if (getHref() != null) { return; } String extra = getWordVal(); final String name; final int pos = extra.lastIndexOf("/"); if (pos < 0) { name = extra; extra = ""; } else { name = extra.substring(pos + 1); extra = extra.substring(0, pos); } setName(name); setColPath(props, principal, "categories", extra); setHref(Util.buildPath(false, getColPath(), getName())); }
/** * * @param cat the other one * @return true if anything changed */ public boolean updateFrom(final BwCategory cat) { boolean changed = false; if (!getWord().equals(cat.getWord())) { setWord(cat.getWord()); changed = true; } if (Util.cmpObjval(getDescription(), cat.getDescription()) != 0) { setDescription(cat.getDescription()); changed = true; } return changed; }
@Override @NoDump public BwString getFinderKeyValue() { return getWord(); }
/** Size to use for quotas. * * @return int */ @Override public int length() { return super.length() + getWord().length() + getDescription().length(); }
@Override public String toString() { final ToString ts = new ToString(this); toStringSegment(ts); ts.append("word", getWord()); return ts.toString(); }
cat = BwCategory.makeCategory(); cat.setWord(key);
/** * @return category with uid filled in. */ public static BwCategory makeCategory() { return (BwCategory)new BwCategory().initUid(); }
public void setStatus(final String val) { if (getDescription() == null) { setDescription(new BwString(val, null)); } else { getDescription().setLang(val); } }
/** * @return String */ public String getStatus() { final BwString s = getDescription(); if (s == null) { return null; } return s.getLang(); }
@Override public Set<BwCategory> cloneCategories() { if (getNumCategories() == 0) { return null; } TreeSet<BwCategory> ts = new TreeSet<BwCategory>(); for (BwCategory cat: getCategories()) { ts.add((BwCategory)cat.clone()); } return ts; }
@Override public int compare(final BwCategory o1, final BwCategory o2) { return o1.compareTo(o2); }
@Override @NoDump public String getCollateValue() { return getWord().getValue(); }
/** * @param val new description value */ public void setDescriptionVal(final String val) { BwString s = getDescription(); if (val == null) { if (s != null) { addDeletedEntity(s); setDescription(null); } return; } if (s == null) { s = new BwString(); setDescription(s); } s.setValue(val); }
/** Size to use for quotas. * * @return int */ @Override @NoDump public int getSize() { return super.length() + QuotaUtil.size(getWord()) + QuotaUtil.size(getDescription()); }
/** * @return String */ @NoDump public String getDescriptionVal() { final BwString s = getDescription(); if (s == null) { return null; } return s.getValue(); }