Project

General

Profile

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

    
24

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

    
32

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

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

    
49
}
(15-15/25)