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.NonViralName;
|
18
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
19
|
import net.sf.json.JSONObject;
|
20
|
import net.sf.json.JsonConfig;
|
21
|
|
22
|
/**
|
23
|
* @author a.kohlbecker
|
24
|
*
|
25
|
*/
|
26
|
public class TaxonNameBaseBeanProcessor extends AbstractCdmBeanProcessor<TaxonNameBase> {
|
27
|
|
28
|
public static final Logger logger = Logger.getLogger(TaxonNameBaseBeanProcessor.class);
|
29
|
|
30
|
private boolean skipTaggedName = false;
|
31
|
|
32
|
/**
|
33
|
* @return the skipTaggedName
|
34
|
*/
|
35
|
public boolean isSkipTaggedName() {
|
36
|
return skipTaggedName;
|
37
|
}
|
38
|
|
39
|
/**
|
40
|
* @param skipTaggedName the skipTaggedName to set
|
41
|
*/
|
42
|
public void setSkipTaggedName(boolean skipTaggedName) {
|
43
|
this.skipTaggedName = skipTaggedName;
|
44
|
}
|
45
|
|
46
|
@Override
|
47
|
public List<String> getIgnorePropNames() {
|
48
|
return Arrays.asList(new String[]{
|
49
|
// ignore nameRelations to avoid LazyLoadingExceptions coming
|
50
|
// from NameRelationshipBeanProcessor.secondStep() in which
|
51
|
// the transient field fromName is added to the serialization
|
52
|
"relationsFromThisName",
|
53
|
"relationsToThisName",
|
54
|
"combinationAuthorship",
|
55
|
"basionymAuthorship",
|
56
|
"exCombinationAuthorship",
|
57
|
"exBasionymAuthorship"
|
58
|
});
|
59
|
}
|
60
|
|
61
|
@Override
|
62
|
public JSONObject processBeanSecondStep(TaxonNameBase bean, JSONObject json, JsonConfig jsonConfig) {
|
63
|
if(logger.isDebugEnabled()){
|
64
|
logger.debug("processing second step" + bean);
|
65
|
}
|
66
|
if(!skipTaggedName){
|
67
|
json.element("taggedName", bean.getTaggedName(), jsonConfig);
|
68
|
}
|
69
|
if(bean instanceof NonViralName){
|
70
|
json.element("nameCache", ((NonViralName) bean).getNameCache(), jsonConfig);
|
71
|
}
|
72
|
return json;
|
73
|
}
|
74
|
|
75
|
}
|