Revision 136d38e9
Added by Katja Luther over 3 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java | ||
---|---|---|
71 | 71 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
72 | 72 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
73 | 73 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
74 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
74 | 75 |
import eu.etaxonomy.cdm.model.term.IEnumTerm; |
75 | 76 |
import eu.etaxonomy.taxeditor.event.EventUtility; |
76 | 77 |
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants; |
... | ... | |
615 | 616 |
} |
616 | 617 |
if (firstRemotingMonitor.isDone()){ |
617 | 618 |
createResult(label, showResult, firstRemotingMonitor); |
619 |
Set<Taxon> taxaToUpdate = getTaxaToUpdate(firstRemotingMonitor); |
|
620 |
updateNameEditors(taxaToUpdate); |
|
618 | 621 |
return Status.OK_STATUS; |
619 | 622 |
} |
620 | 623 |
|
... | ... | |
653 | 656 |
|
654 | 657 |
|
655 | 658 |
|
656 |
private Set<Taxon> getTaxaToUpdate(IRemotingProgressMonitor remotingMonitor) { |
|
657 |
Set<Taxon> taxaToUpdate = new HashSet<>(); |
|
658 |
if (remotingMonitor.getResult() instanceof UpdateResult){ |
|
659 |
for (CdmBase object: ((UpdateResult)remotingMonitor.getResult()).getUpdatedObjects()){ |
|
660 |
Taxon taxon = null; |
|
661 | 659 |
|
662 |
if (object instanceof Taxon){ |
|
663 |
taxon = HibernateProxyHelper.deproxy(object, Taxon.class); |
|
664 |
|
|
665 |
|
|
666 |
}else if (object instanceof Synonym){ |
|
667 |
Synonym syn = HibernateProxyHelper.deproxy(object, Synonym.class); |
|
668 |
taxon = syn.getAcceptedTaxon(); |
|
669 |
} |
|
670 |
|
|
671 |
taxaToUpdate.add(taxon); |
|
672 |
} |
|
673 |
}else if (remotingMonitor.getResult() instanceof ImportResult){ |
|
674 |
Map<String, Integer> result = ((ImportResult)remotingMonitor.getResult()).getUpdatedRecords(); |
|
675 |
for (Map.Entry<String, Integer> object: result.entrySet()){ |
|
676 |
Taxon taxon = null; |
|
677 |
if (object instanceof Taxon){ |
|
678 |
taxon = HibernateProxyHelper.deproxy(object, Taxon.class); |
|
679 |
}else if (object instanceof Synonym){ |
|
680 |
Synonym syn = HibernateProxyHelper.deproxy(object, Synonym.class); |
|
681 |
taxon = syn.getAcceptedTaxon(); |
|
682 |
} |
|
683 |
taxaToUpdate.add(taxon); |
|
684 |
} |
|
685 |
|
|
686 |
} |
|
687 |
return taxaToUpdate; |
|
688 |
} |
|
689 | 660 |
|
690 | 661 |
|
691 | 662 |
|
... | ... | |
721 | 692 |
return Status.OK_STATUS; |
722 | 693 |
} |
723 | 694 |
|
695 |
private static Set<Taxon> getTaxaToUpdate(IRemotingProgressMonitor remotingMonitor) { |
|
696 |
Set<Taxon> taxaToUpdate = new HashSet<>(); |
|
697 |
if (remotingMonitor.getResult() instanceof UpdateResult){ |
|
698 |
for (CdmBase object: ((UpdateResult)remotingMonitor.getResult()).getUpdatedObjects()){ |
|
699 |
Taxon taxon = null; |
|
700 |
|
|
701 |
if (object instanceof Taxon){ |
|
702 |
taxon = HibernateProxyHelper.deproxy(object, Taxon.class); |
|
703 |
|
|
724 | 704 |
|
705 |
}else if (object instanceof Synonym){ |
|
706 |
Synonym syn = HibernateProxyHelper.deproxy(object, Synonym.class); |
|
707 |
taxon = syn.getAcceptedTaxon(); |
|
708 |
}else if (object instanceof TaxonNode){ |
|
709 |
taxon = ((TaxonNode)object).getTaxon() != null? ((TaxonNode)object).getTaxon():null; |
|
710 |
} |
|
711 |
if (taxon != null){ |
|
712 |
taxaToUpdate.add(taxon); |
|
713 |
} |
|
714 |
} |
|
715 |
}else if (remotingMonitor.getResult() instanceof ImportResult){ |
|
716 |
Map<String, Integer> result = ((ImportResult)remotingMonitor.getResult()).getUpdatedRecords(); |
|
717 |
for (Map.Entry<String, Integer> object: result.entrySet()){ |
|
718 |
Taxon taxon = null; |
|
719 |
if (object instanceof Taxon){ |
|
720 |
taxon = HibernateProxyHelper.deproxy(object, Taxon.class); |
|
721 |
}else if (object instanceof Synonym){ |
|
722 |
Synonym syn = HibernateProxyHelper.deproxy(object, Synonym.class); |
|
723 |
taxon = syn.getAcceptedTaxon(); |
|
724 |
} |
|
725 |
taxaToUpdate.add(taxon); |
|
726 |
} |
|
727 |
|
|
728 |
} |
|
729 |
return taxaToUpdate; |
|
730 |
} |
|
725 | 731 |
public static void createResult(String label, boolean showResult, |
726 | 732 |
IRemotingProgressMonitor remotingMonitor) { |
727 | 733 |
final StringBuilder reportSb = new StringBuilder(); |
Also available in: Unified diff
ref #8874: add taxonnode to getUpdatedTaxon