Search in sources :

Example 1 with KeyTerm_L10n

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;
}
Also used : TaxonNode(eu.etaxonomy.cdm.model.taxon.TaxonNode) JSONObject(net.sf.json.JSONObject) TaxonNodeStatus(eu.etaxonomy.cdm.model.taxon.TaxonNodeStatus) Taxon(eu.etaxonomy.cdm.model.taxon.Taxon) KeyTerm_L10n(eu.etaxonomy.cdm.api.service.l10n.KeyTerm_L10n) TaggedText(eu.etaxonomy.cdm.strategy.cache.TaggedText)

Example 2 with KeyTerm_L10n

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;
}
Also used : IKeyTerm(eu.etaxonomy.cdm.model.term.IKeyTerm) JSONObject(net.sf.json.JSONObject) IEnumTerm(eu.etaxonomy.cdm.model.term.IEnumTerm) TaxonNodeStatus(eu.etaxonomy.cdm.model.taxon.TaxonNodeStatus) KeyTerm_L10n(eu.etaxonomy.cdm.api.service.l10n.KeyTerm_L10n)

Aggregations

KeyTerm_L10n (eu.etaxonomy.cdm.api.service.l10n.KeyTerm_L10n)2 TaxonNodeStatus (eu.etaxonomy.cdm.model.taxon.TaxonNodeStatus)2 JSONObject (net.sf.json.JSONObject)2 Taxon (eu.etaxonomy.cdm.model.taxon.Taxon)1 TaxonNode (eu.etaxonomy.cdm.model.taxon.TaxonNode)1 IEnumTerm (eu.etaxonomy.cdm.model.term.IEnumTerm)1 IKeyTerm (eu.etaxonomy.cdm.model.term.IKeyTerm)1 TaggedText (eu.etaxonomy.cdm.strategy.cache.TaggedText)1