Project

General

Profile

Download (1.69 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2009 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

    
10
package eu.etaxonomy.cdm.remote.json.processor.bean;
11

    
12
import java.util.Arrays;
13
import java.util.List;
14

    
15
import org.apache.commons.lang.StringUtils;
16
import org.apache.log4j.Logger;
17

    
18
import eu.etaxonomy.cdm.model.common.Language;
19
import eu.etaxonomy.cdm.model.term.Representation;
20
import net.sf.json.JSONObject;
21
import net.sf.json.JsonConfig;
22

    
23
/**
24
 * @author a.kohlbecker
25
 *
26
 */
27
public class RepresentationBeanProcessor extends AbstractCdmBeanProcessor<Representation> {
28

    
29
    public static final Logger logger = Logger.getLogger(RepresentationBeanProcessor.class);
30

    
31
    private static final List<String> IGNORE_LIST = Arrays.asList(new String[] {
32
//            "representations",
33
            });
34

    
35

    
36

    
37
    @Override
38
    public List<String> getIgnorePropNames() {
39
        return IGNORE_LIST;
40
    }
41

    
42
    @Override
43
    public JSONObject processBeanSecondStep(Representation representation, JSONObject json,	JsonConfig jsonConfig) {
44

    
45
        if (representation.getText() != null){
46
            json.element("description", representation.getText());
47
        }
48
        Language language = representation.getLanguage();
49
        if (language != null) {
50
            String iso = StringUtils.isEmpty(language.getIso639_2())? language.getIso639_1() : language.getIso639_2();
51
            if (iso != null){
52
                json.element("languageIso", iso);
53
            }
54
            json.element("languageUuid", language.getUuid().toString());
55
        }
56

    
57
        return json;
58
    }
59

    
60
}
(15-15/26)