Revision 2890acf5
Added by Andreas Müller about 13 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/out/DwcaTaxExport.java | ||
---|---|---|
21 | 21 |
import org.springframework.stereotype.Component; |
22 | 22 |
import org.springframework.transaction.TransactionStatus; |
23 | 23 |
|
24 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
25 |
import eu.etaxonomy.cdm.model.common.Annotation; |
|
26 |
import eu.etaxonomy.cdm.model.common.AnnotationType; |
|
24 | 27 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
25 | 28 |
import eu.etaxonomy.cdm.model.common.RelationshipTermBase; |
26 | 29 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType; |
... | ... | |
78 | 81 |
writer = createPrintWriter(fileName, state); |
79 | 82 |
|
80 | 83 |
List<TaxonNode> allNodes = getAllNodes(null); |
84 |
int i = 0; |
|
81 | 85 |
for (TaxonNode node : allNodes){ |
86 |
i++; |
|
82 | 87 |
Taxon taxon = CdmBase.deproxy(node.getTaxon(), Taxon.class); |
83 | 88 |
DwcaTaxRecord record = new DwcaTaxRecord(metaRecord, config); |
84 | 89 |
|
... | ... | |
164 | 169 |
} |
165 | 170 |
} |
166 | 171 |
|
167 |
/** |
|
168 |
* @param record |
|
169 |
* @param taxon |
|
170 |
* @param name |
|
171 |
* @param parent |
|
172 |
* @param basionym |
|
173 |
* @param type |
|
174 |
* @return |
|
175 |
*/ |
|
176 | 172 |
/** |
177 | 173 |
* @param record |
178 | 174 |
* @param taxonBase |
... | ... | |
191 | 187 |
record.setId(taxonBase.getId()); |
192 | 188 |
record.setUuid(taxonBase.getUuid()); |
193 | 189 |
|
190 |
//maybe wrong as according to the DwC-A documentation only resolvable ids are allowed, this differs from DwC documentation |
|
194 | 191 |
record.setScientificNameId(name); |
192 |
record.setScientificName(name.getTitleCache()); |
|
195 | 193 |
|
196 | 194 |
record.setAcceptedNameUsageId(acceptedTaxon.getUuid()); |
197 |
record.setParentNameUsageId(parent == null ? null : parent.getUuid()); |
|
195 |
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 |
|
198 | 204 |
// ??? - is not a name usage (concept) |
199 |
// record.setOriginalNameUsageId(basionym.getId()); |
|
205 |
if (basionym != null){ |
|
206 |
record.setOriginalNameUsageId(basionym.getUuid()); |
|
207 |
record.setOriginalNameUsage(basionym.getTitleCache()); |
|
208 |
} |
|
209 |
|
|
210 |
//nameAccordingTo |
|
200 | 211 |
Reference<?> sec = taxonBase.getSec(); |
201 | 212 |
if (sec == null){ |
202 | 213 |
String message = "There is a taxon without sec " + taxonBase.getTitleCache() + "( " + taxonBase.getId() + ")"; |
... | ... | |
205 | 216 |
record.setNameAccordingToId(taxonBase.getSec().getUuid()); |
206 | 217 |
record.setNameAccordingTo(taxonBase.getSec().getTitleCache()); |
207 | 218 |
} |
208 |
record.setNamePublishedInId(name.getNomenclaturalReference() == null ? null : name.getNomenclaturalReference().getUuid()); |
|
209 |
// what is the difference to id |
|
210 |
record.setTaxonConceptId(taxonBase.getUuid()); |
|
211 | 219 |
|
212 |
record.setScientificName(name.getTitleCache()); |
|
213 |
// ??? |
|
214 |
record.setAcceptedNameUsage(acceptedTaxon.getTitleCache()); |
|
215 |
record.setParentNameUsage(parent == null ? null : parent.getTitleCache()); |
|
220 |
//namePublishedIn |
|
216 | 221 |
// ??? is not a nameUsage (concept) |
217 |
record.setOriginalNameUsage(basionym == null ? null : basionym.getTitleCache()); |
|
218 |
record.setNamePublishedIn(name.getNomenclaturalReference() == null ? null : name.getNomenclaturalReference().getTitleCache()); |
|
222 |
if (name.getNomenclaturalReference() != null){ |
|
223 |
record.setNamePublishedInId(name.getNomenclaturalReference().getUuid()); |
|
224 |
record.setNamePublishedIn(name.getNomenclaturalReference() == null ? null : name.getNomenclaturalReference().getTitleCache()); |
|
225 |
} |
|
226 |
|
|
227 |
// what is the exact difference to id and acceptedNameUsageId |
|
228 |
record.setTaxonConceptId(taxonBase.getUuid()); |
|
219 | 229 |
|
220 |
//??? |
|
230 |
//Classification |
|
231 |
//FIXME all classification and rank specific fields are meant to represent the classification |
|
232 |
//currently the information is only compiled for the exact same range but it should be compiled |
|
233 |
//for all ranks above the rank of this taxon |
|
234 |
//TODO we do not support this yet |
|
221 | 235 |
record.setHigherClassification(null); |
222 |
|
|
223 | 236 |
//... higher ranks |
224 | 237 |
handleUninomialOrGenus(record, name); |
238 |
if (name.getRank() != null && name.getRank().equals(Rank.SUBGENUS())){ |
|
239 |
record.setSubgenus(name.getNameCache()); |
|
240 |
} |
|
241 |
//record.setSubgenus(name.getInfraGenericEpithet()); |
|
242 |
|
|
225 | 243 |
|
226 |
//TODO other subgneric ranks ?? |
|
227 |
record.setSubgenus(name.getInfraGenericEpithet()); |
|
228 | 244 |
record.setSpecificEpithet(name.getSpecificEpithet()); |
229 | 245 |
record.setInfraspecificEpithet(name.getInfraSpecificEpithet()); |
230 | 246 |
|
231 | 247 |
record.setTaxonRank(name.getRank()); |
232 | 248 |
if (name.getRank() != null){ |
233 |
record.setVerbatimTaxonRank(name.getRank().getTitleCache());
|
|
249 |
record.setVerbatimTaxonRank(name.getRank().getAbbreviation());
|
|
234 | 250 |
}else{ |
235 | 251 |
String message = "No rank available for " + name.getTitleCache() + "(" + name.getId() + ")"; |
236 | 252 |
logger.warn(message); |
237 | 253 |
} |
254 |
|
|
238 | 255 |
record.setScientificNameAuthorship(name.getAuthorshipCache()); |
239 | 256 |
|
240 |
// ??? - use for TextData names? |
|
257 |
// ??? - use for TextData common names?
|
|
241 | 258 |
record.setVernacularName(null); |
242 | 259 |
|
243 | 260 |
record.setNomenclaturalCode(name.getNomenclaturalCode()); |
244 | 261 |
// ??? TODO Misapplied Names, inferred synonyms |
245 | 262 |
handleTaxonomicStatus(record, name, relType, isProParte, isPartial); |
246 | 263 |
handleNomStatus(record, taxonBase, name); |
247 |
// ??? |
|
248 |
record.setTaxonRemarks(null); |
|
249 |
// ??? which date is needed here (taxon, name, sec, ... ?) |
|
264 |
|
|
265 |
// TODO we need to differentiate technical |
|
266 |
String taxonRemarks = ""; |
|
267 |
for (Annotation annotation : taxonBase.getAnnotations()){ |
|
268 |
if (AnnotationType.EDITORIAL().equals(annotation.getAnnotationType())){ |
|
269 |
taxonRemarks += CdmUtils.Nz(annotation.getText()); |
|
270 |
} |
|
271 |
} |
|
272 |
for (Annotation annotation : name.getAnnotations()){ |
|
273 |
if (AnnotationType.EDITORIAL().equals(annotation.getAnnotationType())){ |
|
274 |
taxonRemarks += CdmUtils.Nz(annotation.getText()); |
|
275 |
} |
|
276 |
} |
|
277 |
if (StringUtils.isNotBlank(taxonRemarks)){ |
|
278 |
record.setTaxonRemarks(taxonRemarks); |
|
279 |
} |
|
280 |
|
|
281 |
// TODO which date is needed here (taxon, name, sec, ... ?) |
|
250 | 282 |
record.setModified(taxonBase.getUpdated()); |
283 |
|
|
251 | 284 |
// ??? |
252 | 285 |
record.setLanguage(null); |
253 | 286 |
|
... | ... | |
256 | 289 |
//TODO |
257 | 290 |
record.setRightsHolder(null); |
258 | 291 |
record.setAccessRights(null); |
292 |
|
|
293 |
//TODO currently only via default value |
|
259 | 294 |
record.setBibliographicCitation(null); |
260 | 295 |
record.setInformationWithheld(null); |
261 | 296 |
|
262 | 297 |
record.setDatasetId(classification); |
263 | 298 |
record.setDatasetName(classification.getTitleCache()); |
264 | 299 |
|
300 |
//TODO |
|
265 | 301 |
record.setSource(null); |
266 | 302 |
|
267 | 303 |
return; |
Also available in: Unified diff
New Developments for DwcA-Export