Revision aa5b9df6
Added by Katja Luther about 5 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImpl.java | ||
---|---|---|
736 | 736 |
result.addException(new Exception("The moving type "+ movingType +" is not supported.")); |
737 | 737 |
} |
738 | 738 |
|
739 |
|
|
740 | 739 |
taxonNode = newParent.addChildNode(taxonNode, sortIndex, taxonNode.getReference(), taxonNode.getMicroReference()); |
741 |
// result.addUpdatedObject(newParent); |
|
742 | 740 |
result.addUpdatedObject(taxonNode); |
743 |
// result.setCdmEntity(taxonNode); |
|
744 |
|
|
745 |
|
|
746 |
|
|
747 | 741 |
|
748 | 742 |
return result; |
749 | 743 |
} |
... | ... | |
850 | 844 |
@Transactional |
851 | 845 |
public UpdateResult saveNewTaxonNode(TaxonNode newTaxonNode){ |
852 | 846 |
UpdateResult result = new UpdateResult(); |
847 |
UUID parentUuid = newTaxonNode.getParent().getUuid(); |
|
848 |
TaxonNode parent = dao.load(parentUuid); |
|
849 |
if (newTaxonNode.getTaxon().getId() != 0){ |
|
850 |
Taxon taxon = (Taxon)taxonService.load(newTaxonNode.getTaxon().getUuid()); |
|
851 |
newTaxonNode.setTaxon(taxon); |
|
852 |
}else{ |
|
853 |
Taxon taxon = newTaxonNode.getTaxon(); |
|
854 |
taxon.removeTaxonNode(newTaxonNode); |
|
855 |
UUID taxonUUID = taxonService.saveOrUpdate(taxon); |
|
856 |
taxon = (Taxon) taxonService.load(taxonUUID); |
|
857 |
newTaxonNode.setTaxon(taxon); |
|
858 |
} |
|
859 |
|
|
853 | 860 |
if (newTaxonNode.getTaxon().getName().getId() != 0){ |
854 | 861 |
TaxonName name = nameService.load(newTaxonNode.getTaxon().getName().getUuid()); |
855 | 862 |
newTaxonNode.getTaxon().setName(name); |
... | ... | |
863 | 870 |
} |
864 | 871 |
} |
865 | 872 |
} |
866 |
UUID parentUuid = newTaxonNode.getParent().getUuid(); |
|
867 |
Taxon taxon = newTaxonNode.getTaxon(); |
|
868 |
taxon.removeTaxonNode(newTaxonNode); |
|
869 |
UUID taxonUUID = taxonService.saveOrUpdate(taxon); |
|
870 |
taxon = (Taxon) taxonService.load(taxonUUID); |
|
871 |
TaxonNode parent = dao.load(parentUuid); |
|
872 |
newTaxonNode.setTaxon(taxon); |
|
873 |
|
|
873 | 874 |
TaxonNode child = null; |
874 | 875 |
try{ |
875 | 876 |
child = parent.addChildNode(newTaxonNode, newTaxonNode.getReference(), newTaxonNode.getMicroReference()); |
... | ... | |
880 | 881 |
return result; |
881 | 882 |
} |
882 | 883 |
dao.saveOrUpdate(child); |
883 |
//dao.saveOrUpdate(parent); |
|
884 |
|
|
884 | 885 |
result.addUpdatedObject(child.getParent()); |
885 | 886 |
if (child != null){ |
886 | 887 |
result.setCdmEntity(child); |
Also available in: Unified diff
ref #8088: save newly created taxonnode with existing taxon