Project

General

Profile

Download (1.6 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
package eu.etaxonomy.cdm.remote.json.processor.bean;
10

    
11
import java.util.List;
12

    
13
import net.sf.json.JSONObject;
14
import net.sf.json.JsonConfig;
15

    
16
import org.hibernate.Hibernate;
17

    
18
import eu.etaxonomy.cdm.model.common.Language;
19
import eu.etaxonomy.cdm.model.common.LanguageString;
20
import eu.etaxonomy.cdm.model.common.MultilanguageTextHelper;
21
import eu.etaxonomy.cdm.model.description.KeyStatement;
22
import eu.etaxonomy.cdm.remote.l10n.LocaleContext;
23

    
24
/**
25
 * @author a.kohlbecker
26
 * @date 24.03.2011
27
 *
28
 */
29
public class KeyStatementBeanProcessor extends AbstractBeanProcessor<KeyStatement> {
30

    
31
    @Override
32
    public List<String> getIgnorePropNames() {
33
        return null;
34
    }
35

    
36
    /* (non-Javadoc)
37
     * @see eu.etaxonomy.cdm.remote.json.processor.bean.AbstractBeanProcessor#processBeanSecondStep(java.lang.Object, net.sf.json.JSONObject, net.sf.json.JsonConfig)
38
     */
39
    @Override
40
    public JSONObject processBeanSecondStep(KeyStatement bean, JSONObject json,	JsonConfig jsonConfig) {
41

    
42
        List<Language> languages = LocaleContext.getLanguages();
43

    
44
        if(Hibernate.isInitialized(bean.getLabel())){
45
            LanguageString label = MultilanguageTextHelper.getPreferredLanguageString(bean.getLabel(), languages);
46
            json.element("label_l10n", label.getText());
47
        }
48

    
49
        return json;
50
    }
51

    
52

    
53

    
54
}
(9-9/25)