Project

General

Profile

« Previous | Next » 

Revision a01e75f6

Added by Cherian Mathew almost 9 years ago

added cdmEntity object in UpdateResult and updated service class accordingly

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImpl.java
482 482
    		tax.removeDescription(taxDescription, true);
483 483

  
484 484
            deleteResult.addUpdatedObject(tax);
485
            deleteResult.setCdmEntity(tax);
485 486
    	}
486 487

  
487 488
        return deleteResult;
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ServiceBase.java
72 72
    	DeleteResult result = new DeleteResult();
73 73
    	try{
74 74
    		dao.delete(persistentObject);
75
    		result.setCdmEntity(persistentObject);
75 76
    	} catch(DataAccessException e){
76 77
    		result.setError();
77 78
    		result.addException(e);
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImpl.java
262 262
        result.addUpdatedObject(oldTaxonParentNode);
263 263
        TaxonNode newTaxonNode = dao.load(newAcceptedTaxonNodeUUID);
264 264
        result.addUpdatedObject(newTaxonNode);
265
        makeTaxonNodeASynonymOfAnotherTaxonNode(oldTaxonNode,
265

  
266
        Synonym synonym = makeTaxonNodeASynonymOfAnotherTaxonNode(oldTaxonNode,
266 267
                newTaxonNode,
267 268
                synonymRelationshipType,
268 269
                citation,
269 270
                citationMicroReference);
271
        result.setCdmEntity(oldTaxonParentNode);
270 272
        return result;
271 273
    }
272 274

  
......
368 370
		            }
369 371

  
370 372
		            result.addUpdatedObject(taxonNode.getParent());
373
		            if(result.getCdmEntity() == null){
374
		                result.setCdmEntity(taxonNode);
375
                    }
371 376
		            UUID uuid = dao.delete(taxonNode);
372 377
		            logger.debug("Deleted node " +uuid.toString());
373 378
	        	}else {
......
417 422
    	if (config.getTaxonNodeConfig().isDeleteTaxon()){
418 423
    	    result = taxonService.deleteTaxon(taxon, config, node.getClassification());
419 424
    	    result.addUpdatedObject(parent);
420

  
425
    	    result.setCdmEntity(node);
421 426
    		return result;
422 427
    	} else{
423 428
    		result = new DeleteResult();
424 429
    		boolean success = taxon.removeTaxonNode(node);
425 430
    		if (success) {
426 431
    		    result.addUpdatedObject(parent);
432
    		    result.setCdmEntity(node);
427 433
    			if (!dao.delete(node).equals(null)){
428 434
    				return result;
429 435
    			} else {
......
436 442
    			return result;
437 443
    		}
438 444
    	}
445

  
439 446
    }
440 447

  
441 448

  
......
453 460
        UpdateResult result = new UpdateResult();
454 461
        result.addUpdatedObject(taxonNode.getParent());
455 462
        result.addUpdatedObject(newParent);
456

  
463
        result.setCdmEntity(taxonNode);
457 464
        Reference reference = taxonNode.getReference();
458 465
        String microReference = taxonNode.getMicroReference();
459 466
        newParent.addChildNode(taxonNode, reference, microReference);
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
264 264
        Taxon taxon = (Taxon)dao.load(acceptedTaxonUuid);
265 265
        result.addUpdatedObject(synonym);
266 266
        result.addUpdatedObject(taxon);
267
        result.setCdmEntity(synonym);
267 268
        swapSynonymAndAcceptedTaxon(synonym, taxon);
268 269
        return result;
269 270
    }
......
997 998
    }
998 999

  
999 1000
    @Override
1001
    @Transactional(readOnly = true)
1000 1002
    public DeleteResult deleteTaxon(UUID taxonUuid, TaxonDeletionConfigurator config, UUID classificationUuid)  {
1001 1003
        return deleteTaxon((Taxon)dao.load(taxonUuid), config, classificationDao.load(classificationUuid));
1002 1004
    }
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/UpdateResult.java
11 11
	package eu.etaxonomy.cdm.api.service;
12 12

  
13 13
	import java.io.Serializable;
14
	import java.util.ArrayList;
15
	import java.util.HashSet;
16
	import java.util.List;
17
	import java.util.Set;
14
import java.util.ArrayList;
15
import java.util.HashSet;
16
import java.util.List;
17
import java.util.Set;
18 18

  
19
	import org.apache.log4j.Logger;
19
import org.apache.log4j.Logger;
20 20

  
21
	import eu.etaxonomy.cdm.model.common.CdmBase;
22
	import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
21
import eu.etaxonomy.cdm.model.common.CdmBase;
22
import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
23 23

  
24 24
	/**
25 25
	 * This class represents the result of an update action.
......
29 29
	 *
30 30
	 */
31 31
public class UpdateResult implements Serializable{
32
	
33
	
32

  
33

  
34 34

  
35 35
		@SuppressWarnings("unused")
36 36
		private static final Logger logger = Logger.getLogger(UpdateResult.class);
......
41 41

  
42 42
		private final Set<CdmBase> upatedObjects = new HashSet<CdmBase>();
43 43

  
44
		private CdmBase cdmEntity;
45

  
44 46
//		private Set<PersistPair> objectsToDelete = new HashSet<PersistPair>();
45 47
	//
46 48
//		private Set<PersistPair> objectsToSave = new HashSet<DeleteResult.PersistPair>();
......
208 210
									"Related Objects: "+relatedObjectString;
209 211
		}
210 212

  
213
        public CdmBase getCdmEntity() {
214
            return cdmEntity;
215
        }
216
        public void setCdmEntity(CdmBase cdmEntity) {
217
            this.cdmEntity = cdmEntity;
218
        }
219

  
220

  
211 221

  
212
	
213 222

  
214 223
}

Also available in: Unified diff