Project

General

Profile

« Previous | Next » 

Revision 3971a637

Added by Katja Luther over 5 years ago

ref #7854: adapt DTOs and merge Method for Distributions

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImpl.java
25 25
import org.springframework.stereotype.Service;
26 26
import org.springframework.transaction.annotation.Transactional;
27 27

  
28
import eu.etaxonomy.cdm.api.service.dto.TaxonDistributionDTO;
28 29
import eu.etaxonomy.cdm.api.service.pager.Pager;
29 30
import eu.etaxonomy.cdm.api.service.pager.impl.AbstractPagerImpl;
30 31
import eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl;
......
466 467

  
467 468
    @Override
468 469
    @Transactional(readOnly = false)
469
    public List<MergeResult<DescriptionElementBase>> mergeDescriptionElements(Collection<DescriptionElementBase> descriptionElements, boolean returnTransientEntity) {
470
        List<MergeResult<DescriptionElementBase>> mergedObjects = new ArrayList<MergeResult<DescriptionElementBase>>();
470
    public List<MergeResult<DescriptionBase>> mergeDescriptionElements(Collection<TaxonDistributionDTO> descriptionElements, boolean returnTransientEntity) {
471
        List<MergeResult<DescriptionBase>> mergedObjects = new ArrayList();
471 472
        List<Distribution> toDelete = new ArrayList<>();
472
        for(DescriptionElementBase obj : descriptionElements) {
473
            if (obj instanceof Distribution){
474
                Distribution distribution = (Distribution)obj;
475
                PresenceAbsenceTerm status = distribution.getStatus();
476
                if (status == null){
477
                   // toDelete.add(distribution);
478
                    deleteDescriptionElement(distribution);
473
        for(TaxonDistributionDTO obj : descriptionElements) {
474
            Taxon taxon = HibernateProxyHelper.deproxy(taxonDao.load(obj.getTaxonUuid()), Taxon.class);
475
            Iterator<TaxonDescription> iterator = obj.getDescriptionsWrapper().getDescriptions().iterator();
476
            while (iterator.hasNext()){
477
                TaxonDescription desc = iterator.next();
478
                if (desc.getTaxon() == null){
479
                    taxon.addDescription(desc);
480
                    //taxonDao.merge(taxon, returnTransientEntity);
481
                    //mergedObjects.add(dao.merge(desc, returnTransientEntity));
479 482
                }else{
480
                    mergedObjects.add(descriptionElementDao.merge(obj, returnTransientEntity));
483
                    mergedObjects.add(dao.merge(desc, returnTransientEntity));
481 484
                }
485

  
482 486
            }
483 487

  
488

  
484 489
        }
485 490

  
486 491
        return mergedObjects;
......
869 874

  
870 875
    }
871 876

  
877

  
872 878
}

Also available in: Unified diff