Project

General

Profile

« Previous | Next » 

Revision 07c3eb13

Added by Katja Luther over 8 years ago

fix delete of specimen with specimenDescriptions

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java
1175 1175
                if (specimen.getDescriptions().contains(specimenDescription)) {
1176 1176
                    specimen.removeDescription(specimenDescription);
1177 1177
                }
1178
                DeleteResult descriptionDelete = descriptionService.isDeletable(specimenDescription, null);
1179
                if (descriptionDelete.isOk()){
1180
                    descriptionService.delete(specimenDescription);
1181
                }
1178 1182
            }
1179 1183
            // check for amplification
1180 1184
            if (relatedObject.isInstanceOf(AmplificationResult.class)) {
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
1313 1313

  
1314 1314
        if (result.isOk()){
1315 1315

  
1316
            synonym = CdmBase.deproxy(dao.merge(synonym), Synonym.class);
1316
            synonym = HibernateProxyHelper.deproxy(dao.merge(synonym), Synonym.class);
1317 1317

  
1318 1318
            //remove synonymRelationship
1319 1319
            Set<Taxon> taxonSet = new HashSet<Taxon>();
......
3064 3064
            if (!(ref instanceof TaxonNameBase)){
3065 3065
            	message = null;
3066 3066
                if (!config.isDeleteSynonymRelations() && (ref instanceof SynonymRelationship)){
3067
                    message = "The Taxon can't be deleted as long as it has synonyms.";
3067
                    message = "The taxon can't be deleted as long as it has synonyms.";
3068 3068

  
3069 3069
                }
3070 3070
                if (!config.isDeleteDescriptions() && (ref instanceof DescriptionBase)){
3071
                    message = "The Taxon can't be deleted as long as it has factual data.";
3071
                    message = "The taxon can't be deleted as long as it has factual data.";
3072 3072

  
3073 3073
                }
3074 3074

  
3075 3075
                if (!config.isDeleteTaxonNodes() && (ref instanceof TaxonNode)){
3076
                    message = "The Taxon can't be deleted as long as it belongs to a taxon node.";
3076
                    message = "The taxon can't be deleted as long as it belongs to a taxon node.";
3077 3077

  
3078 3078
                }
3079 3079
                if (!config.isDeleteTaxonRelationships() && (ref instanceof TaxonNode)){
3080 3080
                    if (!config.isDeleteMisappliedNamesAndInvalidDesignations() && (((TaxonRelationship)ref).getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())|| ((TaxonRelationship)ref).getType().equals(TaxonRelationshipType.INVALID_DESIGNATION_FOR()))){
3081
                        message = "The Taxon can't be deleted as long as it has misapplied names or invalid designations.";
3081
                        message = "The taxon can't be deleted as long as it has misapplied names or invalid designations.";
3082 3082

  
3083 3083
                    } else{
3084
                        message = "The Taxon can't be deleted as long as it belongs to a taxon node.";
3084
                        message = "The taxon can't be deleted as long as it belongs to a taxon node.";
3085 3085

  
3086 3086
                    }
3087 3087
                }
3088 3088
                if (ref instanceof PolytomousKeyNode){
3089
                    message = "The Taxon can't be deleted as long as it is referenced by a polytomous key node.";
3089
                    message = "The taxon can't be deleted as long as it is referenced by a polytomous key node.";
3090 3090

  
3091 3091
                }
3092 3092

  
3093 3093
                if (HibernateProxyHelper.isInstanceOf(ref, IIdentificationKey.class)){
3094
                   message = "Taxon can't be deleted as it is used in an identification key. Remove from identification key prior to deleting this name";
3094
                   message = "Taxon can't be deleted as it is used in an identification key. Remove from identification key prior to deleting this taxon";
3095 3095

  
3096 3096

  
3097 3097
                }
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceTest.java
13 13
import static org.junit.Assert.assertFalse;
14 14
import static org.junit.Assert.assertNotEquals;
15 15
import static org.junit.Assert.assertNotNull;
16
import static org.junit.Assert.assertNull;
16 17
import static org.junit.Assert.assertTrue;
17 18

  
18 19
import java.io.FileNotFoundException;
......
516 517
        config.setDeleteFromDescription(true);
517 518
        deleteResult = occurrenceService.isDeletable(derivedUnit, config);
518 519
        assertTrue(deleteResult.toString(), deleteResult.isOk());
520
        occurrenceService.delete(derivedUnit, config);
521
        specimenDescription =  (SpecimenDescription) descriptionService.find(specimenDescriptionUuid);
522

  
523
        assertNull(specimenDescription);
519 524
    }
520 525

  
521 526
    @Test
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImplTest.java
518 518
	@Test
519 519
	@DataSet
520 520
	public void testMoveTaxonNode(){
521
	    classification = classificationService.load(classificationUuid);
522
	  //  Set<TaxonNode>  nodes = classification.getAllNodes();
523
	    List<TaxonNode>  nodes = classification.getChildNodes();
524
	    System.out.println(nodes.size());
525
	    classification.addChildTaxon(Taxon.NewInstance(BotanicalName.NewInstance(Rank.SPECIES()), null), nodes.size(), null, null);
526
	   nodes =  classification.getChildNodes();
527
	    System.out.println(nodes.size());
521 528

  
522 529
	}
523 530

  

Also available in: Unified diff