Project

General

Profile

Download (1.57 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2013 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.StateData;
23
import eu.etaxonomy.cdm.remote.l10n.LocaleContext;
24

    
25

    
26
/**
27
 * @author a.kohlbecker
28
 * @date Dec 4, 2013
29
 *
30
 */
31
public class StateDataBeanProcessor extends AbstractModifiableThingBeanProcessor<StateData> implements IMultilanguageTextBeanProcessor {
32

    
33

    
34
    @Override
35
    public JSONObject processBeanSecondStep(StateData bean, JSONObject json, JsonConfig jsonConfig) {
36
        List<Language> languages = LocaleContext.getLanguages();
37

    
38
        if(Hibernate.isInitialized(bean.getModifyingText())){
39
            LanguageString modifyingText = MultilanguageTextHelper.getPreferredLanguageString(bean.getModifyingText(), languages);
40
            if(modifyingText != null){
41
                json.element("modifyingText_l10n", modifyingText.getText());
42
            }
43
            if(!isReplaceMultilanguageText()){
44
                json.element("modifyingText", bean.getModifyingText().values(), jsonConfig);
45
            }
46
        }
47
        return json;
48
    }
49

    
50
}
(15-15/25)