use of eu.etaxonomy.cdm.api.service.l10n.KeyTerm_L10n in project cdmlib by cybertaxonomy.
the class TaxonNode2DtoBeanProcessor method processBean.
@Override
public JSONObject processBean(Object bean, JsonConfig jsonConfig) {
TaxonNode node = (TaxonNode) bean;
JSONObject json = new JSONObject();
json.element("class", "TaxonNodeDto");
json.element("uuid", node.getUuid(), jsonConfig);
json.element("taxonomicChildrenCount", node.getCountChildren(), jsonConfig);
// json.element("classificationUuid", node.getClassification().getUuid(), jsonConfig);
json.element("doubtful", node.isDoubtful());
json.element("unplaced", node.isUnplaced());
json.element("excluded", node.isExcluded());
if (node.getStatus() != null) {
json.element("status", node.getStatus());
json.element("status_symbol", node.getStatus().getSymbol());
KeyTerm_L10n<TaxonNodeStatus> status_L10n = new KeyTerm_L10n<TaxonNodeStatus>(node.getStatus());
json.element("status_message_L10n", status_L10n.localizedLabel());
}
Taxon taxon = node.getTaxon();
if (taxon != null) {
json.element("titleCache", taxon.getName().getTitleCache(), jsonConfig);
List<TaggedText> taggedTitle = taxon.getName().getTaggedName();
json.element("taggedTitle", taggedTitle, jsonConfig);
json.element("taxonUuid", taxon.getUuid(), jsonConfig);
// comparation made for avoiding view exceptions
if (taxon.getSec() == null) {
json.element("secUuid", "null");
} else {
json.element("secUuid", taxon.getSec().getUuid(), jsonConfig);
}
String ranklabel = null;
if (taxon.getName().getRank() != null) {
ranklabel = taxon.getName().getRank().getLabel();
}
json.element("rankLabel", ranklabel, jsonConfig);
}
return json;
}
use of eu.etaxonomy.cdm.api.service.l10n.KeyTerm_L10n in project cdmlib by cybertaxonomy.
the class KeyTermValueProcessor method processObjectValue.
@Override
public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
if (value == null) {
return JSONNull.getInstance();
}
IKeyTerm term = (IKeyTerm) value;
JSONObject json = new JSONObject();
if (term.getClass().isEnum()) {
// will be serialized as enum.name()
json.element("name", term);
}
KeyTerm_L10n<?> keyTerm_L10n = new KeyTerm_L10n<>(term);
json.element("representation_L10n", keyTerm_L10n.localizedLabel());
if (IEnumTerm.class.isAssignableFrom(term.getClass())) {
json.element("uuid", ((IEnumTerm) term).getUuid().toString());
}
if (term instanceof TaxonNodeStatus) {
json.element("symbol", ((TaxonNodeStatus) term).getSymbol());
}
return json;
}
Aggregations