Project

General

Profile

Download (1.42 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2022 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.remote.json.processor.value;
10

    
11
import java.util.Objects;
12

    
13
import eu.etaxonomy.cdm.api.service.l10n.TermRepresentation_L10n;
14
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSet;
15
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase;
16
import net.sf.json.JSONObject;
17
import net.sf.json.JsonConfig;
18
import net.sf.json.processors.JsonValueProcessor;
19

    
20
/**
21
 * @author a.mueller
22
 * @date 13.07.2022
23
 */
24
public class TypeDesignationSetValueProcessor implements JsonValueProcessor {
25

    
26
    @Override
27
    public Object processArrayValue(Object value, JsonConfig jsonConfig) {
28
        TypeDesignationSet tds = (TypeDesignationSet)value;
29
        JSONObject json = new JSONObject();
30
        for(TypeDesignationStatusBase<?> key : tds.keySet()){
31
            TermRepresentation_L10n term_L10n = new TermRepresentation_L10n(key, false);
32
            String label = Objects.toString(term_L10n.getLabel(), "NULL");
33
            json.element(label, tds.get(key), jsonConfig);
34
        }
35
        return json;
36
    }
37

    
38
    @Override
39
    public Object processObjectValue(String arg0, Object value, JsonConfig jsonConfig) {
40
        return processArrayValue(value, jsonConfig);
41
    }
42
}
(9-9/11)