Revision f8009036
minor
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaVernacularExport.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
13 | 13 |
import java.io.IOException; |
14 | 14 |
import java.io.PrintWriter; |
15 | 15 |
import java.io.UnsupportedEncodingException; |
16 |
import java.util.HashSet; |
|
16 | 17 |
import java.util.List; |
17 | 18 |
import java.util.Set; |
19 |
import java.util.UUID; |
|
18 | 20 |
|
19 | 21 |
import org.apache.commons.lang.StringUtils; |
20 | 22 |
import org.apache.log4j.Logger; |
... | ... | |
26 | 28 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
27 | 29 |
import eu.etaxonomy.cdm.model.description.Feature; |
28 | 30 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
31 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
29 | 32 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
30 | 33 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
31 | 34 |
|
... | ... | |
39 | 42 |
|
40 | 43 |
private static final String ROW_TYPE = "http://rs.gbif.org/terms/1.0/VernacularName"; |
41 | 44 |
private static final String fileName = "vernacular.txt"; |
42 |
|
|
43 |
|
|
45 |
|
|
46 |
|
|
44 | 47 |
/** |
45 | 48 |
* Constructor |
46 | 49 |
*/ |
... | ... | |
52 | 55 |
/** Retrieves data from a CDM DB and serializes them CDM to XML. |
53 | 56 |
* Starts with root taxa and traverses the classification to retrieve children taxa, synonyms and relationships. |
54 | 57 |
* Taxa that are not part of the classification are not found. |
55 |
*
|
|
58 |
* |
|
56 | 59 |
* @param exImpConfig |
57 | 60 |
* @param dbname |
58 | 61 |
* @param filename |
... | ... | |
65 | 68 |
PrintWriter writer = null; |
66 | 69 |
try { |
67 | 70 |
writer = createPrintWriter(fileName, state); |
68 |
|
|
71 |
|
|
69 | 72 |
DwcaMetaDataRecord metaRecord = new DwcaMetaDataRecord(! IS_CORE, fileName, ROW_TYPE); |
70 | 73 |
state.addMetaRecord(metaRecord); |
71 |
|
|
72 |
List<TaxonNode> allNodes = getAllNodes(null); |
|
74 |
|
|
75 |
Set<UUID> classificationUuidSet = config.getClassificationUuids(); |
|
76 |
List<Classification> classificationList; |
|
77 |
if (classificationUuidSet.isEmpty()){ |
|
78 |
classificationList = getClassificationService().list(Classification.class, null, 0, null, null); |
|
79 |
}else{ |
|
80 |
classificationList = getClassificationService().find(classificationUuidSet); |
|
81 |
} |
|
82 |
|
|
83 |
Set<Classification> classificationSet = new HashSet<Classification>(); |
|
84 |
classificationSet.addAll(classificationList); |
|
85 |
List<TaxonNode> allNodes; |
|
86 |
|
|
87 |
if (state.getAllNodes().isEmpty()){ |
|
88 |
getAllNodes(state, classificationSet); |
|
89 |
} |
|
90 |
allNodes = state.getAllNodes(); |
|
73 | 91 |
for (TaxonNode node : allNodes){ |
74 | 92 |
Taxon taxon = CdmBase.deproxy(node.getTaxon(), Taxon.class); |
75 | 93 |
Set<TaxonDescription> descriptions = taxon.getDescriptions(); |
... | ... | |
92 | 110 |
} |
93 | 111 |
|
94 | 112 |
writer.flush(); |
95 |
|
|
113 |
|
|
96 | 114 |
} |
97 | 115 |
} catch (FileNotFoundException e) { |
98 | 116 |
e.printStackTrace(); |
... | ... | |
108 | 126 |
commitTransaction(txStatus); |
109 | 127 |
return; |
110 | 128 |
} |
111 |
|
|
129 |
|
|
112 | 130 |
|
113 | 131 |
|
114 | 132 |
|
... | ... | |
126 | 144 |
record.setLanguage(commonTaxonName.getLanguage()); |
127 | 145 |
// does not exist in CDM |
128 | 146 |
record.setTemporal(null); |
129 |
|
|
147 |
|
|
130 | 148 |
handleArea(record, commonTaxonName.getArea(), taxon, false); |
131 | 149 |
} |
132 | 150 |
|
... | ... | |
143 | 161 |
protected boolean isIgnore(DwcaTaxExportState state) { |
144 | 162 |
return ! state.getConfig().isDoVernacularNames(); |
145 | 163 |
} |
146 |
|
|
164 |
|
|
147 | 165 |
} |
Also available in: Unified diff