Revision 77861b7e
cleanup
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/csv/caryophyllales/out/CsvNameExport.java | ||
---|---|---|
23 | 23 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
24 | 24 |
import eu.etaxonomy.cdm.ext.geo.CondensedDistributionRecipe; |
25 | 25 |
import eu.etaxonomy.cdm.ext.geo.IEditGeoService; |
26 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
|
26 |
import eu.etaxonomy.cdm.model.common.CdmBase;
|
|
27 | 27 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
28 | 28 |
import eu.etaxonomy.cdm.model.common.Language; |
29 | 29 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
... | ... | |
172 | 172 |
Set<UUID> childrenUuids = new HashSet<UUID>(); |
173 | 173 |
|
174 | 174 |
|
175 |
rootNode = HibernateProxyHelper.deproxy(rootNode, TaxonNode.class);
|
|
175 |
rootNode = CdmBase.deproxy(rootNode);
|
|
176 | 176 |
rootNode.removeNullValueFromChildren(); |
177 | 177 |
for (TaxonNode child: rootNode.getChildNodes()){ |
178 |
child = HibernateProxyHelper.deproxy(child, TaxonNode.class);
|
|
178 |
child = CdmBase.deproxy(child);
|
|
179 | 179 |
childrenUuids.add(child.getUuid()); |
180 | 180 |
} |
181 | 181 |
Set<UUID> parentsNodesUUID = new HashSet<UUID>(childrenUuids); |
182 | 182 |
childrenUuids.clear(); |
183 | 183 |
List<TaxonNode> childrenNodes = new ArrayList<TaxonNode>(); |
184 |
TaxonName name; |
|
185 |
|
|
186 | 184 |
|
187 | 185 |
findChildren(state, childrenUuids, parentsNodesUUID); |
188 | 186 |
|
189 | 187 |
|
190 |
List<HashMap<String,String>> nameRecords = new ArrayList<HashMap<String,String>>(); |
|
191 |
HashMap<String,String> nameRecord = new HashMap<String,String>(); |
|
188 |
List<HashMap<String,String>> nameRecords = new ArrayList<>(); |
|
192 | 189 |
|
193 | 190 |
childrenNodes = getTaxonNodeService().find(childrenUuids); |
194 | 191 |
for(TaxonNode genusNode : childrenNodes) { |
195 |
|
|
196 | 192 |
nameRecords.add(createNewRecord(genusNode, state)); |
197 |
|
|
198 | 193 |
refreshTransaction(); |
199 |
|
|
200 | 194 |
} |
201 | 195 |
|
202 | 196 |
return nameRecords; |
... | ... | |
212 | 206 |
private void findChildren(CsvNameExportState state, Set<UUID> childrenUuids, Set<UUID> parentsNodesUUID) { |
213 | 207 |
TaxonName name; |
214 | 208 |
List<TaxonNode> familyNodes = getTaxonNodeService().find(parentsNodesUUID); |
215 |
parentsNodesUUID =new HashSet<UUID>();
|
|
209 |
parentsNodesUUID =new HashSet<>(); |
|
216 | 210 |
for (TaxonNode familyNode: familyNodes){ |
217 |
familyNode = HibernateProxyHelper.deproxy(familyNode, TaxonNode.class);
|
|
211 |
familyNode = CdmBase.deproxy(familyNode);
|
|
218 | 212 |
familyNode.removeNullValueFromChildren(); |
219 | 213 |
for (TaxonNode child: familyNode.getChildNodes()){ |
220 |
child = HibernateProxyHelper.deproxy(child, TaxonNode.class);
|
|
221 |
Taxon taxon = HibernateProxyHelper.deproxy(child.getTaxon());
|
|
214 |
child = CdmBase.deproxy(child);
|
|
215 |
Taxon taxon = CdmBase.deproxy(child.getTaxon());
|
|
222 | 216 |
if (taxon != null){ |
223 |
name = HibernateProxyHelper.deproxy(taxon.getName(), TaxonName.class);
|
|
217 |
name = CdmBase.deproxy(taxon.getName());
|
|
224 | 218 |
if (child.getTaxon().getName().getRank().isLower(state.getConfig().getRank()) ) { |
225 | 219 |
childrenUuids.add(child.getUuid()); |
226 | 220 |
if (child.hasChildNodes()){ |
... | ... | |
254 | 248 |
boolean isInvalidRel = false; |
255 | 249 |
for (NameRelationship nameRel: nameRelations){ |
256 | 250 |
// NameRelationship nameRel = nameRelations.iterator().next(); |
257 |
IBotanicalName fromName = HibernateProxyHelper.deproxy(nameRel.getFromName(), IBotanicalName.class);
|
|
251 |
IBotanicalName fromName = CdmBase.deproxy(nameRel.getFromName());
|
|
258 | 252 |
|
259 |
nameRel = HibernateProxyHelper.deproxy(nameRel, NameRelationship.class);
|
|
253 |
nameRel = CdmBase.deproxy(nameRel);
|
|
260 | 254 |
nameRelType = nameRel.getType().getTitleCache(); |
261 | 255 |
String relatedNameString = ""; |
262 | 256 |
if (fromName.equals(synonymName)){ |
... | ... | |
308 | 302 |
}else if (nameRel.getType().equals(NameRelationshipType.ORTHOGRAPHIC_VARIANT())){ |
309 | 303 |
|
310 | 304 |
} |
311 |
|
|
312 |
|
|
313 | 305 |
} |
314 | 306 |
} |
315 | 307 |
if (!first){ |
316 | 308 |
synonymString = synonymString + "]"; |
317 | 309 |
} |
318 | 310 |
|
319 |
|
|
320 |
|
|
321 | 311 |
return synonymString; |
322 | 312 |
} |
323 | 313 |
|
... | ... | |
328 | 318 |
private boolean getStatus(INonViralName relatedName) { |
329 | 319 |
boolean result; |
330 | 320 |
if (!relatedName.getStatus().isEmpty()){ |
331 |
NomenclaturalStatus status = HibernateProxyHelper.deproxy(relatedName.getStatus().iterator().next(),NomenclaturalStatus.class);
|
|
321 |
NomenclaturalStatus status = CdmBase.deproxy(relatedName.getStatus().iterator().next());
|
|
332 | 322 |
if (status.getType().isInvalidType()){ |
333 | 323 |
result = true; |
334 | 324 |
}else{ |
... | ... | |
372 | 362 |
Classification classification = getClassificationService().load(classificationUUID); |
373 | 363 |
TaxonNode rootNode = classification.getRootNode(); |
374 | 364 |
rootNode = getTaxonNodeService().load(rootNode.getUuid()); |
375 |
Set<UUID> childrenUuids = new HashSet<UUID>();
|
|
365 |
Set<UUID> childrenUuids = new HashSet<>(); |
|
376 | 366 |
|
377 | 367 |
for (TaxonNode child: rootNode.getChildNodes()){ |
378 |
child = HibernateProxyHelper.deproxy(child, TaxonNode.class);
|
|
368 |
child = CdmBase.deproxy(child);
|
|
379 | 369 |
childrenUuids.add(child.getUuid()); |
380 | 370 |
} |
381 | 371 |
|
382 | 372 |
List<TaxonNode> familyNodes = getTaxonNodeService().find(childrenUuids); |
383 | 373 |
childrenUuids.clear(); |
384 |
List<TaxonNode> genusNodes = new ArrayList<TaxonNode>();
|
|
374 |
List<TaxonNode> genusNodes = new ArrayList<>(); |
|
385 | 375 |
for (TaxonNode familyNode: familyNodes){ |
386 | 376 |
for (TaxonNode child: familyNode.getChildNodes()){ |
387 |
child = HibernateProxyHelper.deproxy(child, TaxonNode.class);
|
|
377 |
child = CdmBase.deproxy(child);
|
|
388 | 378 |
childrenUuids.add(child.getUuid()); |
389 | 379 |
} |
390 | 380 |
|
... | ... | |
409 | 399 |
private void extractDescriptions(HashMap<String, String> nameRecord, Taxon taxon, Feature feature, String columnName, CsvNameExportState state){ |
410 | 400 |
StringBuffer descriptionsString = new StringBuffer(); |
411 | 401 |
TextData textElement; |
412 |
Set<Distribution> distributions = new HashSet<Distribution>();
|
|
402 |
Set<Distribution> distributions = new HashSet<>(); |
|
413 | 403 |
if (taxon.getDescriptions().isEmpty()){ |
414 | 404 |
nameRecord.put(columnName, null); |
415 | 405 |
return; |
... | ... | |
420 | 410 |
for (DescriptionElementBase element: elements){ |
421 | 411 |
if (element.getFeature().equals(feature)){ |
422 | 412 |
if (element instanceof TextData){ |
423 |
textElement = HibernateProxyHelper.deproxy(element, TextData.class);
|
|
413 |
textElement = CdmBase.deproxy(element, TextData.class);
|
|
424 | 414 |
descriptionsString.append(textElement.getText(Language.ENGLISH())); |
425 | 415 |
|
426 | 416 |
}else if (element instanceof Distribution ){ |
427 | 417 |
|
428 |
Distribution distribution = HibernateProxyHelper.deproxy(element, Distribution.class);
|
|
418 |
Distribution distribution = CdmBase.deproxy(element, Distribution.class);
|
|
429 | 419 |
distributions.add(distribution); |
430 |
|
|
431 |
|
|
432 | 420 |
} |
433 | 421 |
|
434 | 422 |
} |
435 | 423 |
} |
436 | 424 |
} |
437 |
|
|
438 |
|
|
439 |
|
|
440 | 425 |
} |
441 | 426 |
if (state.getConfig().isCondensedDistribution()){ |
442 | 427 |
List<Language> langs = new ArrayList<Language>(); |
443 | 428 |
langs.add(Language.ENGLISH()); |
444 | 429 |
|
445 |
|
|
446 | 430 |
CondensedDistribution conDis = geoService.getCondensedDistribution(distributions, true, null,null,CondensedDistributionRecipe.FloraCuba, langs ); |
447 | 431 |
|
448 | 432 |
nameRecord.put(columnName, conDis.toString()); |
... | ... | |
454 | 438 |
if (descriptionsString.length()> 0 ){ |
455 | 439 |
descriptionsString.append(", "); |
456 | 440 |
} |
457 |
area = HibernateProxyHelper.deproxy(distribution.getArea(), NamedArea.class);
|
|
441 |
area = CdmBase.deproxy(distribution.getArea());
|
|
458 | 442 |
if (area.getIdInVocabulary() != null){ |
459 | 443 |
descriptionsString.append(area.getIdInVocabulary()); |
460 | 444 |
}else if (area.getSymbol() != null){ |
... | ... | |
477 | 461 |
if (notesFeature.getRecords().size() == 0){ |
478 | 462 |
return null; |
479 | 463 |
}else{ |
480 |
DefinedTermBase feature= notesFeature.getRecords().iterator().next(); |
|
464 |
DefinedTermBase<?> feature= notesFeature.getRecords().iterator().next();
|
|
481 | 465 |
if (feature instanceof Feature){ |
482 | 466 |
state.setNotesFeature((Feature)feature); |
483 | 467 |
return (Feature) feature; |
... | ... | |
490 | 474 |
} |
491 | 475 |
|
492 | 476 |
private HashMap<String, String> createNewRecord(TaxonNode childNode, CsvNameExportState state){ |
493 |
HashMap<String, String> nameRecord = new HashMap<String,String>();
|
|
477 |
HashMap<String, String> nameRecord = new HashMap<>(); |
|
494 | 478 |
nameRecord.put("classification", childNode.getClassification().getTitleCache()); |
495 | 479 |
TaxonNode familyNode = getHigherNode(childNode, Rank.FAMILY()); |
496 | 480 |
Taxon taxon; |
... | ... | |
501 | 485 |
nameRecord.put("familyName", null); |
502 | 486 |
nameRecord.put("descriptionsFam", null); |
503 | 487 |
}else{ |
504 |
familyNode = HibernateProxyHelper.deproxy(familyNode, TaxonNode.class);
|
|
488 |
familyNode = CdmBase.deproxy(familyNode);
|
|
505 | 489 |
familyNode.getTaxon().setProtectedTitleCache(true); |
506 | 490 |
nameRecord.put("familyTaxon", familyNode.getTaxon().getTitleCache()); |
507 | 491 |
|
508 | 492 |
taxon = (Taxon)getTaxonService().load(familyNode.getTaxon().getUuid()); |
509 |
taxon = HibernateProxyHelper.deproxy(taxon, Taxon.class);
|
|
493 |
taxon = CdmBase.deproxy(taxon);
|
|
510 | 494 |
//if publish flag is set |
511 | 495 |
|
512 | 496 |
// if (taxon.isPublish()){ |
513 |
name = HibernateProxyHelper.deproxy(taxon.getName(), IBotanicalName.class);
|
|
497 |
name = CdmBase.deproxy(taxon.getName());
|
|
514 | 498 |
nameRecord.put("familyName", name.getNameCache()); |
515 | 499 |
extractDescriptions(nameRecord, taxon, Feature.INTRODUCTION(), "descriptionsFam", state); |
516 | 500 |
} |
517 | 501 |
TaxonNode genusNode = getHigherNode(childNode, Rank.GENUS()); |
518 | 502 |
if (genusNode!= null){ |
519 |
genusNode = HibernateProxyHelper.deproxy(genusNode, TaxonNode.class);
|
|
503 |
genusNode = CdmBase.deproxy(genusNode);
|
|
520 | 504 |
genusNode.getTaxon().setProtectedTitleCache(true); |
521 | 505 |
nameRecord.put("genusTaxon", genusNode.getTaxon().getTitleCache()); |
522 | 506 |
|
523 | 507 |
taxon = (Taxon)getTaxonService().load(genusNode.getTaxon().getUuid()); |
524 |
taxon = HibernateProxyHelper.deproxy(taxon, Taxon.class);
|
|
508 |
taxon = CdmBase.deproxy(taxon);
|
|
525 | 509 |
//if publish flag is set |
526 | 510 |
|
527 | 511 |
// if (taxon.isPublish()){ |
528 |
name = HibernateProxyHelper.deproxy(taxon.getName(), IBotanicalName.class);
|
|
512 |
name = CdmBase.deproxy(taxon.getName());
|
|
529 | 513 |
if (name.getNameCache() != null){ |
530 | 514 |
nameRecord.put("genusName", name.getNameCache()); |
531 | 515 |
}else{ |
... | ... | |
539 | 523 |
} |
540 | 524 |
|
541 | 525 |
taxon = (Taxon) getTaxonService().load(childNode.getTaxon().getUuid()); |
542 |
taxon = HibernateProxyHelper.deproxy(taxon, Taxon.class);
|
|
526 |
taxon = CdmBase.deproxy(taxon);
|
|
543 | 527 |
// if (taxon.isPublish()){ |
544 | 528 |
|
545 | 529 |
INonViralName nonViralName = taxon.getName(); |
... | ... | |
554 | 538 |
|
555 | 539 |
getTaxonRelations(nameRecord, taxon); |
556 | 540 |
|
557 |
name = HibernateProxyHelper.deproxy(getNameService().load(taxon.getName().getUuid()), IBotanicalName.class);
|
|
541 |
name = CdmBase.deproxy(getNameService().load(taxon.getName().getUuid()));
|
|
558 | 542 |
nameRecord.put("childName",nameString); |
559 | 543 |
nameRecord.put("nameId", String.valueOf(name.getId())); |
560 | 544 |
nameRecord.put("nameCache", name.getNameCache()); |
... | ... | |
572 | 556 |
String statusString = null; |
573 | 557 |
if (it.hasNext()){ |
574 | 558 |
|
575 |
TypeDesignationBase typeDes = HibernateProxyHelper.deproxy(it.next(), TypeDesignationBase.class);
|
|
559 |
TypeDesignationBase<?> typeDes = CdmBase.deproxy(it.next());
|
|
576 | 560 |
|
577 | 561 |
if (typeDes instanceof NameTypeDesignation){ |
578 |
NameTypeDesignation nameTypeDes = HibernateProxyHelper.deproxy(typeDes, NameTypeDesignation.class);
|
|
562 |
NameTypeDesignation nameTypeDes = CdmBase.deproxy(typeDes, NameTypeDesignation.class);
|
|
579 | 563 |
|
580 |
IBotanicalName typeName = HibernateProxyHelper.deproxy(nameTypeDes.getTypeName(), IBotanicalName.class);
|
|
564 |
IBotanicalName typeName = CdmBase.deproxy(nameTypeDes.getTypeName());
|
|
581 | 565 |
if (typeName != null){ |
582 | 566 |
|
583 | 567 |
typeNameString = "<i>" + typeName.getNameCache() +"</i> " + typeName.getAuthorshipCache(); |
584 | 568 |
if (nameTypeDes.getTypeStatus() != null){ |
585 |
NameTypeDesignationStatus status = HibernateProxyHelper.deproxy(nameTypeDes.getTypeStatus(), NameTypeDesignationStatus.class);
|
|
569 |
NameTypeDesignationStatus status = CdmBase.deproxy(nameTypeDes.getTypeStatus());
|
|
586 | 570 |
statusString = status.getTitleCache(); |
587 | 571 |
} |
588 | 572 |
} |
... | ... | |
590 | 574 |
} |
591 | 575 |
nameRecord.put("typeName", typeNameString); |
592 | 576 |
StringBuffer homotypicalSynonyms = new StringBuffer(); |
593 |
TreeMap<HomotypicalGroup,List<Synonym>> heterotypicSynonymsList = new TreeMap<HomotypicalGroup,List<Synonym>>(new HomotypicalGroupComparator());
|
|
577 |
TreeMap<HomotypicalGroup,List<Synonym>> heterotypicSynonymsList = new TreeMap<>(new HomotypicalGroupComparator()); |
|
594 | 578 |
|
595 |
List<Synonym> homotypicSynonymsList = new ArrayList<Synonym>();
|
|
579 |
List<Synonym> homotypicSynonymsList = new ArrayList<>(); |
|
596 | 580 |
StringBuffer heterotypicalSynonyms = new StringBuffer(); |
597 | 581 |
List<Synonym> homotypicSynonyms; |
598 | 582 |
|
... | ... | |
600 | 584 |
IBotanicalName synonymName; |
601 | 585 |
String doubtfulTitleCache; |
602 | 586 |
for (Synonym synonym: taxon.getSynonyms()){ |
603 |
synonymName = HibernateProxyHelper.deproxy(synonym.getName(), IBotanicalName.class);
|
|
604 |
group = HibernateProxyHelper.deproxy(synonymName.getHomotypicalGroup(), HomotypicalGroup.class);
|
|
587 |
synonymName = CdmBase.deproxy(synonym.getName());
|
|
588 |
group = CdmBase.deproxy(synonymName.getHomotypicalGroup());
|
|
605 | 589 |
synonymName.generateFullTitle(); |
606 | 590 |
if (synonym.isDoubtful()){ |
607 | 591 |
if (!synonymName.getFullTitleCache().startsWith("?")){ |
... | ... | |
614 | 598 |
if (heterotypicSynonymsList.containsKey(group)){ |
615 | 599 |
heterotypicSynonymsList.get(group).add(synonym); |
616 | 600 |
}else{ |
617 |
homotypicSynonyms = new ArrayList<Synonym>();
|
|
601 |
homotypicSynonyms = new ArrayList<>(); |
|
618 | 602 |
homotypicSynonyms.add(synonym); |
619 | 603 |
heterotypicSynonymsList.put(group, homotypicSynonyms); |
620 | 604 |
homotypicSynonyms= null; |
... | ... | |
636 | 620 |
for (TaxonBase<?> synonym : list){ |
637 | 621 |
NomenclaturalStatus status = null; |
638 | 622 |
if (!synonym.getName().getStatus().isEmpty()){ |
639 |
status = HibernateProxyHelper.deproxy(synonym.getName().getStatus().iterator().next(),NomenclaturalStatus.class);
|
|
623 |
status = CdmBase.deproxy(synonym.getName().getStatus().iterator().next());
|
|
640 | 624 |
if (status.getType().isInvalidType()){ |
641 | 625 |
heterotypicalSynonyms.append(" <invalid> "); |
642 |
synonymName = HibernateProxyHelper.deproxy(synonym.getName(), IBotanicalName.class);
|
|
626 |
synonymName = CdmBase.deproxy(synonym.getName());
|
|
643 | 627 |
|
644 | 628 |
synonymString = createSynonymNameString(synonymName, state.getConfig().isInvalidNamesQuoted()) ; |
645 | 629 |
heterotypicalSynonyms.append(synonymString); |
... | ... | |
652 | 636 |
heterotypicalSynonyms.append(" <homonym> "); |
653 | 637 |
} |
654 | 638 |
first = false; |
655 |
synonymName = HibernateProxyHelper.deproxy(synonym.getName(), IBotanicalName.class);
|
|
639 |
synonymName = CdmBase.deproxy(synonym.getName());
|
|
656 | 640 |
synonymString = createSynonymNameString(synonymName, false); |
657 | 641 |
heterotypicalSynonyms.append(synonymString); |
658 | 642 |
} |
... | ... | |
664 | 648 |
for (TaxonBase<?> synonym : homotypicSynonymsList){ |
665 | 649 |
|
666 | 650 |
if (!synonym.getName().getStatus().isEmpty()){ |
667 |
status = HibernateProxyHelper.deproxy(synonym.getName().getStatus().iterator().next(),NomenclaturalStatus.class);
|
|
651 |
status = CdmBase.deproxy(synonym.getName().getStatus().iterator().next());
|
|
668 | 652 |
if (status.getType().isInvalidType()){ |
669 | 653 |
homotypicalSynonyms.append(" <invalid> "); |
670 |
synonymName = HibernateProxyHelper.deproxy(synonym.getName(), IBotanicalName.class);
|
|
654 |
synonymName = CdmBase.deproxy(synonym.getName());
|
|
671 | 655 |
synonymString = createSynonymNameString(synonymName, true); |
672 | 656 |
homotypicalSynonyms.append(synonymString); |
673 | 657 |
continue; |
... | ... | |
679 | 663 |
homotypicalSynonyms.append(" <homonym> "); |
680 | 664 |
} |
681 | 665 |
first = false; |
682 |
synonymName = HibernateProxyHelper.deproxy(synonym.getName(), IBotanicalName.class);
|
|
666 |
synonymName = CdmBase.deproxy(synonym.getName());
|
|
683 | 667 |
|
684 | 668 |
synonymString = createSynonymNameString(synonymName, false); |
685 | 669 |
|
... | ... | |
698 | 682 |
String relNameString = null; |
699 | 683 |
if (nameRelations.size()>0){ |
700 | 684 |
NameRelationship nameRel = nameRelations.iterator().next(); |
701 |
IBotanicalName fromName = HibernateProxyHelper.deproxy(nameRel.getFromName(), IBotanicalName.class);
|
|
685 |
IBotanicalName fromName = CdmBase.deproxy(nameRel.getFromName());
|
|
702 | 686 |
if (fromName.equals(taxon.getName())){ |
703 | 687 |
relatedName = nameRel.getToName(); |
704 | 688 |
|
705 | 689 |
}else{ |
706 | 690 |
relatedName = nameRel.getFromName(); |
707 | 691 |
} |
708 |
nameRel = HibernateProxyHelper.deproxy(nameRel, NameRelationship.class);
|
|
692 |
nameRel = CdmBase.deproxy(nameRel);
|
|
709 | 693 |
nameRelType = nameRel.getType().getTitleCache(); |
710 | 694 |
relNameString = createTaggedNameString(relatedName, getStatus(relatedName)); |
711 | 695 |
} |
... | ... | |
723 | 707 |
* @param taxon |
724 | 708 |
*/ |
725 | 709 |
private void getTaxonRelations(HashMap<String, String> nameRecord, Taxon taxon) { |
726 |
Set<TaxonRelationship> relations = new HashSet<TaxonRelationship>();
|
|
710 |
Set<TaxonRelationship> relations = new HashSet<>(); |
|
727 | 711 |
relations =taxon.getTaxonRelations(); |
728 | 712 |
if (relations.isEmpty()){ |
729 | 713 |
nameRecord.put("missappliedNames", null); |
... | ... | |
750 | 734 |
} |
751 | 735 |
nameRecord.put("missappliedNames", nameString.toString()); |
752 | 736 |
} |
753 |
|
|
754 | 737 |
} |
755 | 738 |
|
756 |
|
|
757 |
|
|
758 |
|
|
759 | 739 |
} |
760 | 740 |
|
Also available in: Unified diff