Revision 5316cc5a
Added by Andreas Müller over 12 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitImport.java | ||
---|---|---|
258 | 258 |
Integer childId = taxonDataHolder.getId(); |
259 | 259 |
UUID cdmUuid = taxonDataHolder.getCdmUuid(); |
260 | 260 |
Taxon acceptedTaxon; |
261 |
TaxonNameBase nameUsedInSource; |
|
261 | 262 |
|
262 | 263 |
if (cdmUuid != null){ |
263 | 264 |
TaxonBase taxonBase = getTaxonService().find(cdmUuid); |
264 | 265 |
acceptedTaxon = getAcceptedTaxon(taxonBase); |
266 |
nameUsedInSource = taxonBase.getName(); |
|
265 | 267 |
}else{ |
266 | 268 |
//TODO error handling for class cast |
267 | 269 |
Taxon parentTaxon = CdmBase.deproxy(state.getTaxonBase(parentId), Taxon.class); |
268 | 270 |
if (CdmUtils.isNotEmpty(taxonNameStr)) { |
269 | 271 |
TaxonBase taxonBase = state.getTaxonBase(childId); |
272 |
nameUsedInSource = taxonBase.getName(); |
|
270 | 273 |
nameStatus = CdmUtils.Nz(nameStatus).trim().toLowerCase(); |
271 | 274 |
if (validMarkers.contains(nameStatus)){ |
272 | 275 |
Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class); |
... | ... | |
317 | 320 |
}else{//taxonNameStr is empty |
318 | 321 |
//vernacular name case |
319 | 322 |
acceptedTaxon = parentTaxon; |
323 |
nameUsedInSource = null; |
|
320 | 324 |
} |
321 | 325 |
} |
322 | 326 |
|
... | ... | |
328 | 332 |
handleCommonName(state, taxonNameStr, commonNameStr, acceptedTaxon); |
329 | 333 |
} |
330 | 334 |
|
331 |
handleFeatures(state, taxonDataHolder, acceptedTaxon); |
|
335 |
handleFeatures(state, taxonDataHolder, acceptedTaxon, nameUsedInSource);
|
|
332 | 336 |
} |
333 | 337 |
} catch (Exception e) { |
334 | 338 |
e.printStackTrace(); |
... | ... | |
342 | 346 |
* @param taxonDataHolder |
343 | 347 |
* @param acceptedTaxon |
344 | 348 |
*/ |
345 |
private void handleFeatures(TaxonExcelImportState state, NormalExplicitRow taxonDataHolder, Taxon acceptedTaxon) { |
|
349 |
private void handleFeatures(TaxonExcelImportState state, NormalExplicitRow taxonDataHolder, Taxon acceptedTaxon, TaxonNameBase nameUsedInSource) {
|
|
346 | 350 |
//feature |
347 | 351 |
for (UUID featureUuid : taxonDataHolder.getFeatures()){ |
348 | 352 |
Feature feature = getFeature(state, featureUuid); |
349 |
// Feature feature = CdmBase.deproxy(getTermService().find(featureUuid), Feature.class); |
|
350 | 353 |
List<String> textList = taxonDataHolder.getFeatureTexts(featureUuid); |
351 | 354 |
List<String> languageList = taxonDataHolder.getFeatureLanguages(featureUuid); |
352 | 355 |
|
353 |
|
|
354 | 356 |
for (int i = 0; i < textList.size(); i++){ |
355 | 357 |
String featureText = textList.get(i); |
356 | 358 |
String featureLanguage = languageList.get(i); |
... | ... | |
384 | 386 |
} |
385 | 387 |
if (refExists){ |
386 | 388 |
source.setCitation(ref); |
389 |
source.setNameUsedInSource(nameUsedInSource); |
|
387 | 390 |
} |
388 | 391 |
textData.addSource(source); |
389 | 392 |
} |
cdmlib-io/src/test/java/eu/etaxonomy/cdm/io/excel/taxa/NormalExplicitImportTest.java | ||
---|---|---|
50 | 50 |
import eu.etaxonomy.cdm.model.description.TextData; |
51 | 51 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
52 | 52 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
53 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
53 | 54 |
import eu.etaxonomy.cdm.model.reference.Reference; |
54 | 55 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
55 | 56 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
... | ... | |
210 | 211 |
assertEquals("Source author should be 'Meyer et. al.'", "Meyer et. al.",ref.getAuthorTeam().getTitleCache()); |
211 | 212 |
assertEquals("Publication title should be 'My first book'", "My first book", ref.getTitle()); |
212 | 213 |
assertEquals("Publication year should be '1987'", "1987", ref.getYear()); |
213 |
|
|
214 |
TaxonNameBase nameUsedInSource = source.getNameUsedInSource(); |
|
215 |
assertNotNull("Name used in source should not be null", nameUsedInSource); |
|
216 |
assertEquals("Name used in source title should be ", "Abies", nameUsedInSource.getTitleCache()); |
|
217 |
|
|
218 |
|
|
214 | 219 |
//synonym |
215 | 220 |
expectedText = "A synonym description"; |
216 | 221 |
textData = getTextElement(description, expectedText); |
... | ... | |
230 | 235 |
assertEquals("Source author should be 'Theys, A.'", "Theys, A.",ref.getAuthorTeam().getTitleCache()); |
231 | 236 |
assertEquals("Publication title should be 'The ultimate book'", "The ultimate book", ref.getTitle()); |
232 | 237 |
assertEquals("Publication year should be '2011'", "2011", ref.getYear()); |
238 |
nameUsedInSource = source.getNameUsedInSource(); |
|
239 |
assertNotNull("Name used in source should not be null", nameUsedInSource); |
|
240 |
assertEquals("Name used in source title should be Pinus", "Pinus", nameUsedInSource.getTitleCache()); |
|
233 | 241 |
|
234 | 242 |
} |
235 | 243 |
|
Also available in: Unified diff
nameUsedInSource added to NEEI