Project

General

Profile

Revision fd734dc9

IDfd734dc9d65d796ab9ec9b66a7e03f7d8dd656de
Parent 117f7bd2
Child 16076af1

Added by Andreas Müller 9 months ago

ref #9520 fix ClassificationServiceImpl und TaxonServiceImplTest for non-cascading parent node

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ClassificationServiceImpl.java
558 558
    public UpdateResult createHierarchyInClassification(Classification classification, CreateHierarchyForClassificationConfigurator configurator){
559 559

  
560 560
        UpdateResult result = new UpdateResult();
561
        Set<TaxonNode> taxonNodesToSave = new HashSet<>();
562

  
561 563
    	classification = dao.findByUuid(classification.getUuid());
562 564
    	Map<String, List<TaxonNode>> map = getSortedGenusList(classification.getAllNodes());
563 565

  
......
610 612
    			parentNode = newClassification.addChildTaxon(taxon, 0, null, null);
611 613
    			result.addUpdatedObject(parentNode);
612 614
    		}
613
    		//iterate over the rest of the list
615
    		taxonNodesToSave.add(parentNode);
616

  
617
    		//iterate over the remaining list
614 618
    		for(TaxonNode tn : listOfTaxonNodes){
615 619
    			//if TaxonNode has a parent and this is not the classification then skip it
616 620
    			//and add to new classification via the parentNode as children of it
......
625 629
    			//FIXME: citation from node
626 630
    			//TODO: addChildNode without citation and references
627 631
    			TaxonNode taxonNode = parentNode.addChildNode(clone, clone.getReference(), clone.getMicroReference());
632
    			taxonNodesToSave.add(taxonNode);
633

  
628 634
    			result.addUnChangedObject(clone);
629 635
    			if(tn.hasChildNodes()){
630 636
    				//save hierarchy in new classification
......
636 642
    		}
637 643
    	}
638 644
    	dao.saveOrUpdate(newClassification);
645
    	taxonNodeDao.saveOrUpdateAll(taxonNodesToSave);
639 646
    	result.setCdmEntity(newClassification);
640 647
    	return result;
641 648
    }
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonServiceImplTest.java
1850 1850
    	Taxon c1SubSpecies1 = Taxon.NewInstance(null, null);c1SubSpecies1.setUuid(UUID.fromString("96ae2fad-76df-429f-b179-42e00838fea4"));
1851 1851
    	Taxon c1SubSpecies2 = Taxon.NewInstance(null, null);c1SubSpecies2.setUuid(UUID.fromString("5d3f6147-ca72-40e0-be8a-6c835a09a579"));
1852 1852
    	TaxonNode c1childNodeSpecies1 = cl1.addParentChild(c1Genus, c1Species, null, null);
1853
    	nodeService.saveOrUpdate(c1childNodeSpecies1.getParent());
1853 1854
    	nodeService.saveOrUpdate(c1childNodeSpecies1);
1854 1855
    	TaxonNode c1childNodeSubSpecies1 =cl1.addParentChild(c1Species, c1SubSpecies1, null, null);
1855 1856
    	nodeService.saveOrUpdate(c1childNodeSubSpecies1);
......
1861 1862
    	Taxon c2SubSpecies1 = Taxon.NewInstance(null, null);c2SubSpecies1.setUuid(UUID.fromString("61f039c8-01f3-4f5d-8e16-1602139774e7"));
1862 1863
    	Taxon c2SubSpecies2 = Taxon.NewInstance(null, null);c2SubSpecies2.setUuid(UUID.fromString("2ed6b6f8-05f9-459a-a075-2bca57e3013e"));
1863 1864
    	TaxonNode c2childNodeSpecies1 = cl2.addParentChild(c2Genus, c2Species, null, null);
1864
    	nodeService.saveOrUpdate(c2childNodeSpecies1);
1865
    	nodeService.saveOrUpdate(c2childNodeSpecies1.getParent());
1866
        nodeService.saveOrUpdate(c2childNodeSpecies1);
1865 1867
    	TaxonNode c2childNodeSubSpecies1 = cl2.addParentChild(c2Species, c2SubSpecies1, null, null);
1866 1868
    	nodeService.saveOrUpdate(c2childNodeSubSpecies1);
1867 1869
    	TaxonNode c2childNodeSubSpecies2 = cl2.addParentChild(c2Species, c2SubSpecies2, null, null);
......
1872 1874
    	Taxon c3SubSpecies1 = Taxon.NewInstance(null, null);c3SubSpecies1.setUuid(UUID.fromString("01c07585-a422-40cd-9339-a74c56901d9f"));
1873 1875
    	Taxon c3SubSpecies2 = Taxon.NewInstance(null, null);c3SubSpecies2.setUuid(UUID.fromString("390c8e23-e05f-4f89-b417-50cf080f4c91"));
1874 1876
    	TaxonNode c3childNodeSpecies1 = cl3.addParentChild(c3Genus, c3Species, null, null);
1875
    	nodeService.saveOrUpdate(c3childNodeSpecies1);
1877
    	nodeService.saveOrUpdate(c3childNodeSpecies1.getParent());
1878
        nodeService.saveOrUpdate(c3childNodeSpecies1);
1876 1879
    	TaxonNode c3childNodeSubSpecies1 = cl3.addParentChild(c3Species, c3SubSpecies1, null, null);
1877 1880
    	nodeService.saveOrUpdate(c3childNodeSubSpecies1);
1878 1881
    	TaxonNode c3childNodeSubSpecies2 = cl3.addParentChild(c3Species, c3SubSpecies2, null, null);
......
1890 1893
    	service.saveOrUpdate(c1Species);
1891 1894
       	service.saveOrUpdate(c2Species);
1892 1895
       	service.save(c4Species);
1896
       	commitAndStartNewTransaction();
1893 1897

  
1894 1898
    	//Tests
1895 1899
       	//default starting at species 1

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)