Project

General

Profile

Download (2.06 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.log4j.Logger;
16

    
17
import eu.etaxonomy.cdm.model.name.TaxonName;
18
import net.sf.json.JSONObject;
19
import net.sf.json.JsonConfig;
20

    
21
/**
22
 * @author a.kohlbecker
23
 *
24
 */
25
public class TaxonNameBeanProcessor extends AbstractCdmBeanProcessor<TaxonName> {
26

    
27
    public static final Logger logger = Logger.getLogger(TaxonNameBeanProcessor.class);
28

    
29
    private boolean skipTaggedName = false;
30

    
31
    /**
32
     * @return the skipTaggedName
33
     */
34
    public boolean isSkipTaggedName() {
35
        return skipTaggedName;
36
    }
37

    
38
    /**
39
     * @param skipTaggedName the skipTaggedName to set
40
     */
41
    public void setSkipTaggedName(boolean skipTaggedName) {
42
        this.skipTaggedName = skipTaggedName;
43
    }
44

    
45
    @Override
46
    public List<String> getIgnorePropNames() {
47
        return Arrays.asList(new String[]{
48
                // ignore nameRelations to avoid LazyLoadingExceptions coming
49
                // from NameRelationshipBeanProcessor.secondStep() in which
50
                // the transient field fromName is added to the serialization
51
                "relationsFromThisName",
52
                "relationsToThisName",
53
                "combinationAuthorship",
54
                "basionymAuthorship",
55
                "exCombinationAuthorship",
56
                "exBasionymAuthorship"
57
        });
58
    }
59

    
60
    @Override
61
    public JSONObject processBeanSecondStep(TaxonName bean, JSONObject json, JsonConfig jsonConfig) {
62
        if(logger.isDebugEnabled()){
63
            logger.debug("processing second step" + bean);
64
        }
65
        if(!skipTaggedName){
66
            json.element("taggedName", bean.getTaggedName(), jsonConfig);
67
        }
68
        json.element("nameCache", bean.getNameCache(), jsonConfig);
69
        return json;
70
    }
71

    
72
}
(17-17/25)