Project

General

Profile

Revision d2540808

IDd2540808742b201b76d5c065044b5ee7489c4531
Parent c26edffc
Child 65890142

Added by Patrick Plitzner over 2 years ago

ref #7509 Add service method for common parent taxon node

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ITaxonNodeService.java
332 332
    UpdateResult moveTaxonNodes(Set<UUID> taxonNodeUuids, UUID newParentNodeUuid, int movingType,
333 333
            IProgressMonitor monitor);
334 334

  
335

  
335
    /**
336
     * Retrieves the first taxon node that is direct or indirect parent
337
     * to all nodes of the given list of nodes.<br>
338
     * If no common parent node could be found the classification is returned.
339
     * @param nodes the direct/indirect child taxon nodes for which the common
340
     * parent should be retrieved
341
     * @return the common direct/indirect parent of all nodes
342
     */
343
    public TaxonNodeDto getCommonParent(List<TaxonNodeDto> nodes);
336 344

  
337 345
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImpl.java
974 974
        return nodeFilterDao.idList(filter);
975 975
    }
976 976

  
977
    @Override
978
    public TaxonNodeDto getCommonParent(List<TaxonNodeDto> nodes) {
979
        int highestRank = -1;
980
        String parentTreeIndex = null;
981
        for (TaxonNodeDto nodeDto : nodes) {
982
            String nodeTreeIndex = nodeDto.getTreeIndex();
983
            if(parentTreeIndex==null){
984
                parentTreeIndex = nodeTreeIndex;
985
            }
986
            else if(nodeTreeIndex.length()<parentTreeIndex.length()){
987
                parentTreeIndex = nodeTreeIndex;
988
            }
989
            else if(nodeTreeIndex.length()<parentTreeIndex.length()){
990
                parentTreeIndex = nodeTreeIndex;
991
            }
992
        }
993
        return null;
994
    }
995

  
996

  
977 997
//    @Override
978 998
//    @Transactional(readOnly=false)
979 999
//    public UUID monitSetSecundum(final SecundumForSubtreeConfigurator configurator) {

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)