Project

General

Profile

Revision b55fd194

IDb55fd194e19d4573bb8f79a1cdbd906446853557
Parent 29e1af1d
Child ea92da24

Added by Katja Luther over 2 years ago

ref #7854: add methods to get DTOs for distribution editor

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImpl.java
468 468
    @Transactional(readOnly = false)
469 469
    public List<MergeResult<DescriptionElementBase>> mergeDescriptionElements(Collection<DescriptionElementBase> descriptionElements, boolean returnTransientEntity) {
470 470
        List<MergeResult<DescriptionElementBase>> mergedObjects = new ArrayList<MergeResult<DescriptionElementBase>>();
471
        List<Distribution> toDelete = new ArrayList<>();
471 472
        for(DescriptionElementBase obj : descriptionElements) {
472
            mergedObjects.add(descriptionElementDao.merge(obj, returnTransientEntity));
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);
479
                }else{
480
                    mergedObjects.add(descriptionElementDao.merge(obj, returnTransientEntity));
481
                }
482
            }
483

  
473 484
        }
485

  
474 486
        return mergedObjects;
475 487
    }
476 488

  
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ITaxonNodeService.java
16 16

  
17 17
import eu.etaxonomy.cdm.api.service.config.SecundumForSubtreeConfigurator;
18 18
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
19
import eu.etaxonomy.cdm.api.service.dto.TaxonDistributionDTO;
19 20
import eu.etaxonomy.cdm.api.service.pager.Pager;
20 21
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
21 22
import eu.etaxonomy.cdm.filter.TaxonNodeFilter;
......
352 353
     */
353 354
    TaxonNodeDto dto(UUID taxonNodeUuid);
354 355

  
356
    /**
357
     * @param parentNodeUuid
358
     * @param areas
359
     * @return
360
     */
361
    List<TaxonDistributionDTO> getTaxonDistributionDTOForSubtree(UUID parentNodeUuid, List<String> propertyPaths);
362

  
355 363
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImpl.java
32 32
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
33 33
import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
34 34
import eu.etaxonomy.cdm.api.service.dto.CdmEntityIdentifier;
35
import eu.etaxonomy.cdm.api.service.dto.TaxonDistributionDTO;
35 36
import eu.etaxonomy.cdm.api.service.pager.Pager;
36 37
import eu.etaxonomy.cdm.api.service.pager.PagerUtils;
37 38
import eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl;
......
1046 1047
        return commonParent;
1047 1048
    }
1048 1049

  
1049
//    @Override
1050
//    @Transactional(readOnly=false)
1051
//    public UUID monitSetSecundum(final SecundumForSubtreeConfigurator configurator) {
1052
//        RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() {
1053
//            @Override
1054
//            public Serializable doRun(IRemotingProgressMonitor monitor) {
1055
//                configurator.setMonitor(monitor);
1056
//                UpdateResult result = setSecundumForSubtree(configurator);
1057
//                return result;
1058
//            }
1059
//        };
1060
//        UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread);
1061
//        monitorThread.setPriority(3);
1062
//        monitorThread.start();
1063
//        return uuid;
1064
//    }
1050
    @Override
1051
    public List<TaxonDistributionDTO> getTaxonDistributionDTOForSubtree(UUID parentNodeUuid, List<String> propertyPaths){
1052
        List<TaxonNode> nodes = listChildrenOf(load(parentNodeUuid), null, null,
1053
               true, true, propertyPaths);
1054
        List<TaxonDistributionDTO> result = new ArrayList<>();
1055
        for(TaxonNode node:nodes){
1056
            TaxonDistributionDTO dto = new TaxonDistributionDTO(node.getTaxon());
1057
            result.add(dto);
1058
        }
1059

  
1060
        return result;
1061
    }
1062

  
1063

  
1065 1064

  
1066 1065
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/TaxonDistributionDTO.java
40 40

  
41 41
    public TaxonDistributionDTO(Taxon taxon){
42 42
        this.taxonUuid = taxon.getUuid();
43
        this.nameCache = taxon.getName().getNameCache();
43
        this.nameCache = taxon.getName().getNameCache() != null ? taxon.getName().getNameCache(): taxon.getName().getTitleCache();
44
        if (nameCache == null){
45
            nameCache = taxon.getTitleCache();
46
        }
44 47
        this.descriptionsWrapper = new TaxonDescriptionDTO(taxon);
45 48
        for (TaxonDescription desc: descriptionsWrapper.descriptions){
46 49
            for (DescriptionElementBase descElement: desc.getElements()){

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)