1 |
179b9191
|
Andreas Müller
|
/**
|
2 |
|
|
* Copyright (C) 2007 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.io.dwca.out;
|
11 |
|
|
|
12 |
|
|
import java.io.FileNotFoundException;
|
13 |
|
|
import java.io.IOException;
|
14 |
|
|
import java.io.PrintWriter;
|
15 |
|
|
import java.io.UnsupportedEncodingException;
|
16 |
|
|
import java.util.List;
|
17 |
|
|
import java.util.Set;
|
18 |
|
|
|
19 |
|
|
import org.apache.commons.lang.StringUtils;
|
20 |
|
|
import org.apache.log4j.Logger;
|
21 |
|
|
import org.springframework.stereotype.Component;
|
22 |
|
|
import org.springframework.transaction.TransactionStatus;
|
23 |
|
|
|
24 |
2890acf5
|
Andreas Müller
|
import eu.etaxonomy.cdm.common.CdmUtils;
|
25 |
|
|
import eu.etaxonomy.cdm.model.common.Annotation;
|
26 |
|
|
import eu.etaxonomy.cdm.model.common.AnnotationType;
|
27 |
179b9191
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
28 |
|
|
import eu.etaxonomy.cdm.model.common.RelationshipTermBase;
|
29 |
|
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
|
30 |
|
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
31 |
|
|
import eu.etaxonomy.cdm.model.name.Rank;
|
32 |
|
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
33 |
2ae594e7
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
34 |
|
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
35 |
179b9191
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
36 |
|
|
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
|
37 |
|
|
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
|
38 |
|
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
39 |
|
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
40 |
|
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
41 |
|
|
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
|
42 |
|
|
|
43 |
|
|
/**
|
44 |
|
|
* @author a.mueller
|
45 |
|
|
* @created 18.04.2011
|
46 |
|
|
*/
|
47 |
|
|
@Component
|
48 |
2907e2c8
|
Andreas Müller
|
public class DwcaTaxExport extends DwcaExportBase {
|
49 |
179b9191
|
Andreas Müller
|
private static final Logger logger = Logger.getLogger(DwcaTaxExport.class);
|
50 |
|
|
|
51 |
17b23836
|
Andreas Müller
|
private static final String ROW_TYPE = "http://rs.tdwg.org/dwc/terms/Taxon";
|
52 |
0cf40899
|
Andreas Müller
|
private static final String fileName = "coreTax.txt";
|
53 |
17b23836
|
Andreas Müller
|
|
54 |
179b9191
|
Andreas Müller
|
/**
|
55 |
|
|
*
|
56 |
|
|
*/
|
57 |
|
|
public DwcaTaxExport() {
|
58 |
|
|
super();
|
59 |
|
|
this.ioName = this.getClass().getSimpleName();
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
/** Retrieves data from a CDM DB and serializes them CDM to XML.
|
63 |
|
|
* Starts with root taxa and traverses the classification to retrieve children taxa, synonyms and relationships.
|
64 |
|
|
* Taxa that are not part of the classification are not found.
|
65 |
|
|
*
|
66 |
|
|
* @param exImpConfig
|
67 |
|
|
* @param dbname
|
68 |
|
|
* @param filename
|
69 |
|
|
*/
|
70 |
|
|
@Override
|
71 |
51171c9d
|
Andreas Müller
|
protected void doInvoke(DwcaTaxExportState state){
|
72 |
179b9191
|
Andreas Müller
|
DwcaTaxExportConfigurator config = state.getConfig();
|
73 |
|
|
TransactionStatus txStatus = startTransaction(true);
|
74 |
17b23836
|
Andreas Müller
|
|
75 |
0cf40899
|
Andreas Müller
|
DwcaMetaDataRecord metaRecord = new DwcaMetaDataRecord(true, fileName, ROW_TYPE);
|
76 |
17b23836
|
Andreas Müller
|
state.addMetaRecord(metaRecord);
|
77 |
0cf40899
|
Andreas Müller
|
|
78 |
bd669c71
|
Andreas Müller
|
PrintWriter writer = null;
|
79 |
179b9191
|
Andreas Müller
|
try {
|
80 |
|
|
|
81 |
bd669c71
|
Andreas Müller
|
writer = createPrintWriter(fileName, state);
|
82 |
17b23836
|
Andreas Müller
|
|
83 |
2ae594e7
|
Andreas Müller
|
List<TaxonNode> allNodes = getAllNodes(null);
|
84 |
2890acf5
|
Andreas Müller
|
int i = 0;
|
85 |
179b9191
|
Andreas Müller
|
for (TaxonNode node : allNodes){
|
86 |
2890acf5
|
Andreas Müller
|
i++;
|
87 |
179b9191
|
Andreas Müller
|
Taxon taxon = CdmBase.deproxy(node.getTaxon(), Taxon.class);
|
88 |
0cf40899
|
Andreas Müller
|
DwcaTaxRecord record = new DwcaTaxRecord(metaRecord, config);
|
89 |
2ae594e7
|
Andreas Müller
|
|
90 |
179b9191
|
Andreas Müller
|
NonViralName<?> name = CdmBase.deproxy(taxon.getName(), NonViralName.class);
|
91 |
|
|
Taxon parent = node.getParent() == null ? null : node.getParent().getTaxon();
|
92 |
|
|
TaxonNameBase<?, ?> basionym = name.getBasionym();
|
93 |
2ae594e7
|
Andreas Müller
|
Classification classification = node.getClassification();
|
94 |
d5fe8657
|
Andreas Müller
|
if (! this.recordExists(taxon)){
|
95 |
7518fc67
|
Andreas Müller
|
handleTaxonBase(record, taxon, name, taxon, parent, basionym, classification, null, false, false, config);
|
96 |
d5fe8657
|
Andreas Müller
|
record.write(writer);
|
97 |
|
|
this.addExistingRecord(taxon);
|
98 |
|
|
}
|
99 |
179b9191
|
Andreas Müller
|
|
100 |
|
|
node.getClassification().getName();
|
101 |
|
|
//synonyms
|
102 |
0cf40899
|
Andreas Müller
|
handleSynonyms(taxon, writer, classification, metaRecord, config);
|
103 |
179b9191
|
Andreas Müller
|
|
104 |
|
|
//misapplied names
|
105 |
0cf40899
|
Andreas Müller
|
handleMisapplication(taxon, writer, classification, metaRecord, config);
|
106 |
179b9191
|
Andreas Müller
|
|
107 |
|
|
writer.flush();
|
108 |
|
|
|
109 |
|
|
}
|
110 |
|
|
} catch (FileNotFoundException e) {
|
111 |
|
|
e.printStackTrace();
|
112 |
|
|
} catch (UnsupportedEncodingException e) {
|
113 |
|
|
e.printStackTrace();
|
114 |
|
|
} catch (ClassCastException e) {
|
115 |
|
|
e.printStackTrace();
|
116 |
|
|
} catch (IOException e) {
|
117 |
|
|
e.printStackTrace();
|
118 |
|
|
}
|
119 |
bd669c71
|
Andreas Müller
|
finally{
|
120 |
|
|
closeWriter(writer, state);
|
121 |
|
|
}
|
122 |
179b9191
|
Andreas Müller
|
commitTransaction(txStatus);
|
123 |
51171c9d
|
Andreas Müller
|
return;
|
124 |
17b23836
|
Andreas Müller
|
|
125 |
179b9191
|
Andreas Müller
|
}
|
126 |
2ae594e7
|
Andreas Müller
|
|
127 |
0cf40899
|
Andreas Müller
|
private void handleSynonyms(Taxon taxon, PrintWriter writer, Classification classification, DwcaMetaDataRecord metaRecord, DwcaTaxExportConfigurator config) {
|
128 |
179b9191
|
Andreas Müller
|
Set<SynonymRelationship> synRels = taxon.getSynonymRelations();
|
129 |
|
|
for (SynonymRelationship synRel :synRels ){
|
130 |
0cf40899
|
Andreas Müller
|
DwcaTaxRecord record = new DwcaTaxRecord(metaRecord, config);
|
131 |
179b9191
|
Andreas Müller
|
Synonym synonym = synRel.getSynonym();
|
132 |
|
|
SynonymRelationshipType type = synRel.getType();
|
133 |
80cc3771
|
Andreas Müller
|
boolean isProParte = synRel.isProParte();
|
134 |
|
|
boolean isPartial = synRel.isPartial();
|
135 |
179b9191
|
Andreas Müller
|
if (type == null){ // should not happen
|
136 |
|
|
type = SynonymRelationshipType.SYNONYM_OF();
|
137 |
|
|
}
|
138 |
|
|
NonViralName<?> name = CdmBase.deproxy(synonym.getName(), NonViralName.class);
|
139 |
|
|
//????
|
140 |
|
|
Taxon parent = null;
|
141 |
|
|
TaxonNameBase<?, ?> basionym = name.getBasionym();
|
142 |
|
|
|
143 |
d5fe8657
|
Andreas Müller
|
if (! this.recordExists(synonym)){
|
144 |
7518fc67
|
Andreas Müller
|
handleTaxonBase(record, synonym, name, taxon, parent, basionym, classification, type, isProParte, isPartial, config);
|
145 |
d5fe8657
|
Andreas Müller
|
record.write(writer);
|
146 |
|
|
this.addExistingRecord(synonym);
|
147 |
|
|
}
|
148 |
179b9191
|
Andreas Müller
|
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
}
|
152 |
|
|
|
153 |
|
|
|
154 |
0cf40899
|
Andreas Müller
|
private void handleMisapplication(Taxon taxon, PrintWriter writer, Classification classification, DwcaMetaDataRecord metaRecord, DwcaTaxExportConfigurator config) {
|
155 |
179b9191
|
Andreas Müller
|
Set<Taxon> misappliedNames = taxon.getMisappliedNames();
|
156 |
|
|
for (Taxon misappliedName : misappliedNames ){
|
157 |
0cf40899
|
Andreas Müller
|
DwcaTaxRecord record = new DwcaTaxRecord(metaRecord, config);
|
158 |
2ae594e7
|
Andreas Müller
|
TaxonRelationshipType relType = TaxonRelationshipType.MISAPPLIED_NAME_FOR();
|
159 |
179b9191
|
Andreas Müller
|
NonViralName<?> name = CdmBase.deproxy(misappliedName.getName(), NonViralName.class);
|
160 |
|
|
//????
|
161 |
|
|
Taxon parent = null;
|
162 |
|
|
TaxonNameBase<?, ?> basionym = name.getBasionym();
|
163 |
|
|
|
164 |
d5fe8657
|
Andreas Müller
|
if (! this.recordExists(misappliedName)){
|
165 |
7518fc67
|
Andreas Müller
|
handleTaxonBase(record, misappliedName, name, taxon, parent, basionym, classification, relType, false, false, config);
|
166 |
d5fe8657
|
Andreas Müller
|
record.write(writer);
|
167 |
|
|
this.addExistingRecord(misappliedName);
|
168 |
|
|
}
|
169 |
2ae594e7
|
Andreas Müller
|
}
|
170 |
179b9191
|
Andreas Müller
|
}
|
171 |
|
|
|
172 |
2ae594e7
|
Andreas Müller
|
/**
|
173 |
|
|
* @param record
|
174 |
|
|
* @param taxonBase
|
175 |
|
|
* @param name
|
176 |
|
|
* @param acceptedTaxon
|
177 |
|
|
* @param parent
|
178 |
|
|
* @param basionym
|
179 |
80cc3771
|
Andreas Müller
|
* @param isPartial
|
180 |
|
|
* @param isProParte
|
181 |
0cf40899
|
Andreas Müller
|
* @param config
|
182 |
2ae594e7
|
Andreas Müller
|
* @param type
|
183 |
|
|
*/
|
184 |
0cf40899
|
Andreas Müller
|
private void handleTaxonBase(DwcaTaxRecord record, TaxonBase<?> taxonBase, NonViralName<?> name,
|
185 |
2ae594e7
|
Andreas Müller
|
Taxon acceptedTaxon, Taxon parent, TaxonNameBase<?, ?> basionym, Classification classification,
|
186 |
7518fc67
|
Andreas Müller
|
RelationshipTermBase<?> relType, boolean isProParte, boolean isPartial, DwcaTaxExportConfigurator config) {
|
187 |
179b9191
|
Andreas Müller
|
record.setId(taxonBase.getId());
|
188 |
0cf40899
|
Andreas Müller
|
record.setUuid(taxonBase.getUuid());
|
189 |
|
|
|
190 |
2890acf5
|
Andreas Müller
|
//maybe wrong as according to the DwC-A documentation only resolvable ids are allowed, this differs from DwC documentation
|
191 |
0cf40899
|
Andreas Müller
|
record.setScientificNameId(name);
|
192 |
2890acf5
|
Andreas Müller
|
record.setScientificName(name.getTitleCache());
|
193 |
0cf40899
|
Andreas Müller
|
|
194 |
|
|
record.setAcceptedNameUsageId(acceptedTaxon.getUuid());
|
195 |
2890acf5
|
Andreas Müller
|
record.setAcceptedNameUsage(acceptedTaxon.getName() == null? acceptedTaxon.getTitleCache() : acceptedTaxon.getName().getTitleCache());
|
196 |
|
|
|
197 |
|
|
//parentNameUsage
|
198 |
|
|
if (parent != null){
|
199 |
|
|
record.setParentNameUsageId(parent.getUuid());
|
200 |
|
|
record.setParentNameUsage(parent.getTitleCache());
|
201 |
|
|
}
|
202 |
|
|
|
203 |
|
|
//originalNameUsage
|
204 |
179b9191
|
Andreas Müller
|
// ??? - is not a name usage (concept)
|
205 |
2890acf5
|
Andreas Müller
|
if (basionym != null){
|
206 |
1ad8b3ae
|
Andreas Müller
|
//FIXME needs to be a coreID otherwise use string only
|
207 |
|
|
// record.setOriginalNameUsageId(basionym.getUuid());
|
208 |
|
|
record.setOriginalNameUsageId(null);
|
209 |
2890acf5
|
Andreas Müller
|
record.setOriginalNameUsage(basionym.getTitleCache());
|
210 |
|
|
}
|
211 |
|
|
|
212 |
|
|
//nameAccordingTo
|
213 |
0cf40899
|
Andreas Müller
|
Reference<?> sec = taxonBase.getSec();
|
214 |
2ae594e7
|
Andreas Müller
|
if (sec == null){
|
215 |
|
|
String message = "There is a taxon without sec " + taxonBase.getTitleCache() + "( " + taxonBase.getId() + ")";
|
216 |
|
|
logger.warn(message);
|
217 |
|
|
}else{
|
218 |
0cf40899
|
Andreas Müller
|
record.setNameAccordingToId(taxonBase.getSec().getUuid());
|
219 |
2ae594e7
|
Andreas Müller
|
record.setNameAccordingTo(taxonBase.getSec().getTitleCache());
|
220 |
|
|
}
|
221 |
179b9191
|
Andreas Müller
|
|
222 |
2890acf5
|
Andreas Müller
|
//namePublishedIn
|
223 |
179b9191
|
Andreas Müller
|
// ??? is not a nameUsage (concept)
|
224 |
2890acf5
|
Andreas Müller
|
if (name.getNomenclaturalReference() != null){
|
225 |
|
|
record.setNamePublishedInId(name.getNomenclaturalReference().getUuid());
|
226 |
|
|
record.setNamePublishedIn(name.getNomenclaturalReference() == null ? null : name.getNomenclaturalReference().getTitleCache());
|
227 |
|
|
}
|
228 |
|
|
|
229 |
|
|
// what is the exact difference to id and acceptedNameUsageId
|
230 |
|
|
record.setTaxonConceptId(taxonBase.getUuid());
|
231 |
179b9191
|
Andreas Müller
|
|
232 |
2890acf5
|
Andreas Müller
|
//Classification
|
233 |
7518fc67
|
Andreas Müller
|
if (config.isWithHigherClassification()){
|
234 |
|
|
//FIXME all classification and rank specific fields are meant to represent the classification
|
235 |
|
|
//currently the information is only compiled for the exact same range but it should be compiled
|
236 |
|
|
//for all ranks above the rank of this taxon
|
237 |
|
|
//TODO we do not support this yet
|
238 |
|
|
record.setHigherClassification(null);
|
239 |
|
|
//... higher ranks
|
240 |
|
|
handleUninomialOrGenus(record, name);
|
241 |
|
|
if (name.getRank() != null && name.getRank().equals(Rank.SUBGENUS())){
|
242 |
|
|
record.setSubgenus(name.getNameCache());
|
243 |
|
|
}
|
244 |
|
|
//record.setSubgenus(name.getInfraGenericEpithet());
|
245 |
2890acf5
|
Andreas Müller
|
}
|
246 |
7518fc67
|
Andreas Müller
|
if (name.getRank() != null && (name.getRank().isSupraGeneric() || name.getRank().isGenus())){
|
247 |
|
|
record.setUninomial(name.getGenusOrUninomial());
|
248 |
|
|
}else{
|
249 |
8d5fb727
|
Andreas Müller
|
record.setGenusPart(name.getGenusOrUninomial());
|
250 |
7518fc67
|
Andreas Müller
|
}
|
251 |
|
|
record.setInfraGenericEpithet(name.getInfraGenericEpithet());
|
252 |
179b9191
|
Andreas Müller
|
|
253 |
|
|
record.setSpecificEpithet(name.getSpecificEpithet());
|
254 |
|
|
record.setInfraspecificEpithet(name.getInfraSpecificEpithet());
|
255 |
|
|
|
256 |
|
|
record.setTaxonRank(name.getRank());
|
257 |
2ae594e7
|
Andreas Müller
|
if (name.getRank() != null){
|
258 |
2890acf5
|
Andreas Müller
|
record.setVerbatimTaxonRank(name.getRank().getAbbreviation());
|
259 |
2ae594e7
|
Andreas Müller
|
}else{
|
260 |
|
|
String message = "No rank available for " + name.getTitleCache() + "(" + name.getId() + ")";
|
261 |
|
|
logger.warn(message);
|
262 |
|
|
}
|
263 |
2890acf5
|
Andreas Müller
|
|
264 |
179b9191
|
Andreas Müller
|
record.setScientificNameAuthorship(name.getAuthorshipCache());
|
265 |
|
|
|
266 |
2890acf5
|
Andreas Müller
|
// ??? - use for TextData common names?
|
267 |
179b9191
|
Andreas Müller
|
record.setVernacularName(null);
|
268 |
|
|
|
269 |
|
|
record.setNomenclaturalCode(name.getNomenclaturalCode());
|
270 |
|
|
// ??? TODO Misapplied Names, inferred synonyms
|
271 |
80cc3771
|
Andreas Müller
|
handleTaxonomicStatus(record, name, relType, isProParte, isPartial);
|
272 |
179b9191
|
Andreas Müller
|
handleNomStatus(record, taxonBase, name);
|
273 |
2890acf5
|
Andreas Müller
|
|
274 |
|
|
// TODO we need to differentiate technical
|
275 |
|
|
String taxonRemarks = "";
|
276 |
|
|
for (Annotation annotation : taxonBase.getAnnotations()){
|
277 |
|
|
if (AnnotationType.EDITORIAL().equals(annotation.getAnnotationType())){
|
278 |
|
|
taxonRemarks += CdmUtils.Nz(annotation.getText());
|
279 |
|
|
}
|
280 |
|
|
}
|
281 |
|
|
for (Annotation annotation : name.getAnnotations()){
|
282 |
|
|
if (AnnotationType.EDITORIAL().equals(annotation.getAnnotationType())){
|
283 |
|
|
taxonRemarks += CdmUtils.Nz(annotation.getText());
|
284 |
|
|
}
|
285 |
|
|
}
|
286 |
|
|
if (StringUtils.isNotBlank(taxonRemarks)){
|
287 |
|
|
record.setTaxonRemarks(taxonRemarks);
|
288 |
|
|
}
|
289 |
|
|
|
290 |
|
|
// TODO which date is needed here (taxon, name, sec, ... ?)
|
291 |
179b9191
|
Andreas Müller
|
record.setModified(taxonBase.getUpdated());
|
292 |
2890acf5
|
Andreas Müller
|
|
293 |
179b9191
|
Andreas Müller
|
// ???
|
294 |
|
|
record.setLanguage(null);
|
295 |
|
|
|
296 |
54649625
|
Andreas Müller
|
record.setRights(taxonBase.getRights());
|
297 |
|
|
|
298 |
2ae594e7
|
Andreas Müller
|
//TODO
|
299 |
|
|
record.setRightsHolder(null);
|
300 |
|
|
record.setAccessRights(null);
|
301 |
2890acf5
|
Andreas Müller
|
|
302 |
|
|
//TODO currently only via default value
|
303 |
2ae594e7
|
Andreas Müller
|
record.setBibliographicCitation(null);
|
304 |
|
|
record.setInformationWithheld(null);
|
305 |
|
|
|
306 |
0cf40899
|
Andreas Müller
|
record.setDatasetId(classification);
|
307 |
2ae594e7
|
Andreas Müller
|
record.setDatasetName(classification.getTitleCache());
|
308 |
|
|
|
309 |
2890acf5
|
Andreas Müller
|
//TODO
|
310 |
2ae594e7
|
Andreas Müller
|
record.setSource(null);
|
311 |
179b9191
|
Andreas Müller
|
|
312 |
|
|
return;
|
313 |
|
|
}
|
314 |
|
|
|
315 |
|
|
/**
|
316 |
|
|
* @param record
|
317 |
|
|
* @param name
|
318 |
|
|
* @param type
|
319 |
80cc3771
|
Andreas Müller
|
* @param isPartial
|
320 |
|
|
* @param isProParte
|
321 |
179b9191
|
Andreas Müller
|
*/
|
322 |
|
|
private void handleTaxonomicStatus(DwcaTaxRecord record,
|
323 |
80cc3771
|
Andreas Müller
|
NonViralName<?> name, RelationshipTermBase<?> type, boolean isProParte, boolean isPartial) {
|
324 |
179b9191
|
Andreas Müller
|
if (type == null){
|
325 |
|
|
record.setTaxonomicStatus(name.getNomenclaturalCode().acceptedTaxonStatusLabel());
|
326 |
|
|
}else{
|
327 |
|
|
String status = name.getNomenclaturalCode().synonymStatusLabel();
|
328 |
|
|
if (type.equals(SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF())){
|
329 |
80cc3771
|
Andreas Müller
|
status = "heterotypicSynonym";
|
330 |
179b9191
|
Andreas Müller
|
}else if(type.equals(SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF())){
|
331 |
80cc3771
|
Andreas Müller
|
status = "homotypicSynonym";
|
332 |
179b9191
|
Andreas Müller
|
}else if(type.equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
|
333 |
|
|
status = "misapplied";
|
334 |
|
|
}
|
335 |
80cc3771
|
Andreas Müller
|
if (isProParte){
|
336 |
|
|
status = "proParteSynonym";
|
337 |
|
|
}else if (isPartial){
|
338 |
|
|
String message = "Partial synonym is not part of the gbif toxonomic status vocabulary";
|
339 |
|
|
logger.warn(message);
|
340 |
|
|
status = "partialSynonym";
|
341 |
|
|
}
|
342 |
|
|
|
343 |
179b9191
|
Andreas Müller
|
record.setTaxonomicStatus(status);
|
344 |
|
|
}
|
345 |
|
|
}
|
346 |
|
|
|
347 |
|
|
/**
|
348 |
|
|
* @param record
|
349 |
|
|
* @param name
|
350 |
|
|
*/
|
351 |
|
|
private void handleUninomialOrGenus(DwcaTaxRecord record, NonViralName<?> name) {
|
352 |
|
|
//epethita
|
353 |
|
|
String firstEpi = name.getGenusOrUninomial();
|
354 |
|
|
if (!StringUtils.isBlank(firstEpi)){
|
355 |
|
|
Rank rank = name.getRank();
|
356 |
|
|
if (rank != null){
|
357 |
|
|
if (rank.isLower(Rank.GENUS())){
|
358 |
|
|
record.setGenus(firstEpi);
|
359 |
|
|
}else if (rank.equals(Rank.GENUS())){
|
360 |
|
|
record.setGenus(firstEpi);
|
361 |
|
|
}else if (rank.equals(Rank.KINGDOM())){
|
362 |
|
|
record.setKingdom(firstEpi);
|
363 |
|
|
}else if (rank.equals(Rank.PHYLUM())){
|
364 |
|
|
record.setPhylum(firstEpi);
|
365 |
|
|
}else if (rank.equals(Rank.CLASS())){
|
366 |
|
|
record.setClazz(firstEpi);
|
367 |
|
|
}else if (rank.equals(Rank.ORDER())){
|
368 |
|
|
record.setOrder(firstEpi);
|
369 |
|
|
}else if (rank.equals(Rank.FAMILY())){
|
370 |
|
|
record.setFamily(firstEpi);
|
371 |
|
|
}else{
|
372 |
|
|
// !!!
|
373 |
|
|
String message = "Rank not covered. Set uninomial as genus instead: " + rank.getLabel();
|
374 |
|
|
logger.warn(message);
|
375 |
|
|
// record.setGenus(firstEpi);
|
376 |
|
|
}
|
377 |
|
|
|
378 |
|
|
}
|
379 |
|
|
}
|
380 |
|
|
}
|
381 |
|
|
|
382 |
|
|
|
383 |
|
|
/**
|
384 |
|
|
* @param record
|
385 |
|
|
* @param taxon
|
386 |
|
|
* @param name
|
387 |
|
|
*/
|
388 |
0cf40899
|
Andreas Müller
|
private void handleNomStatus(DwcaTaxRecord record, TaxonBase<?> taxon,
|
389 |
179b9191
|
Andreas Müller
|
NonViralName<?> name) {
|
390 |
|
|
int nStatus = name.getStatus().size();
|
391 |
|
|
if (nStatus > 0){
|
392 |
|
|
if (name.getStatus().size()> 1){
|
393 |
|
|
String warning = "There is more than 1 nomenclatural status ( " + name.getStatus().size()+ "): " + taxon.getTitleCache();
|
394 |
|
|
logger.warn(warning);
|
395 |
|
|
}
|
396 |
|
|
NomenclaturalStatusType status = name.getStatus().iterator().next().getType();
|
397 |
|
|
record.setNomenclaturalStatus(status);
|
398 |
|
|
}else{
|
399 |
|
|
record.setNomenclaturalStatus(null);
|
400 |
|
|
}
|
401 |
|
|
}
|
402 |
|
|
|
403 |
|
|
|
404 |
|
|
@Override
|
405 |
|
|
protected boolean doCheck(DwcaTaxExportState state) {
|
406 |
|
|
boolean result = true;
|
407 |
2ae594e7
|
Andreas Müller
|
logger.warn("No check implemented for " + this.ioName);
|
408 |
179b9191
|
Andreas Müller
|
return result;
|
409 |
|
|
}
|
410 |
|
|
|
411 |
|
|
|
412 |
|
|
@Override
|
413 |
|
|
protected boolean isIgnore(DwcaTaxExportState state) {
|
414 |
2ae594e7
|
Andreas Müller
|
return ! state.getConfig().isDoTaxa();
|
415 |
179b9191
|
Andreas Müller
|
}
|
416 |
|
|
|
417 |
|
|
}
|