Project

General

Profile

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

    
12
import java.util.List;
13

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

    
17
import org.hibernate.Hibernate;
18

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

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

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

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

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

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

    
50
        return json;
51
    }
52

    
53

    
54

    
55
}
(9-9/25)