1
|
/**
|
2
|
* Copyright (C) 2016 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.io.caryo;
|
10
|
|
11
|
import org.apache.commons.lang3.StringUtils;
|
12
|
import org.apache.logging.log4j.LogManager;
|
13
|
import org.apache.logging.log4j.Logger;
|
14
|
|
15
|
import eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase;
|
16
|
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
|
17
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
18
|
import eu.etaxonomy.cdm.model.name.Rank;
|
19
|
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
|
20
|
|
21
|
/**
|
22
|
* @author a.mueller
|
23
|
* @since 16.06.2016
|
24
|
*/
|
25
|
public class CaryoSileneaeTransformer extends InputTransformerBase{
|
26
|
|
27
|
private static final long serialVersionUID = 4635704148993246218L;
|
28
|
|
29
|
private static final Logger logger = LogManager.getLogger();
|
30
|
|
31
|
@Override
|
32
|
public Rank getRankByKey(String key) throws UndefinedTransformerMethodException {
|
33
|
if (StringUtils.isBlank(key)){
|
34
|
return null;
|
35
|
}
|
36
|
try {
|
37
|
Rank rank = Rank.getRankByIdInVoc(key, NomenclaturalCode.ICNAFP);
|
38
|
return rank;
|
39
|
} catch (UnknownCdmTypeException e) {
|
40
|
if (key.equals("gen.")) {return Rank.GENUS();
|
41
|
} else if (key.equals("spec.")) {return Rank.SPECIES();
|
42
|
} else if (key.equals("unranked")) {return Rank.UNRANKED_INFRAGENERIC();
|
43
|
} else if (key.equals("[infrasp.unranked]")) {return Rank.UNRANKED_INFRASPECIFIC();
|
44
|
} else{
|
45
|
logger.warn("Rank not defined: " + key);
|
46
|
return null;
|
47
|
}
|
48
|
}
|
49
|
|
50
|
}
|
51
|
}
|