Project

General

Profile

Revision 8ec811cd

ID8ec811cdd0911a80bce91c0d9cbfa780eb0ca2d7
Parent bdde6137
Child 0e8f77ab

Added by Andreas Müller 8 months ago

ref #1447 improve findIdenticalNames

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImpl.java
1380 1380
    }
1381 1381

  
1382 1382
    @Override
1383
    public Map<String, Map<UUID,Set<TaxonName>>> findIdenticalNamesNew(List<UUID> sourceRefUuids, List<String> propertyPaths){
1383
    public Map<String, Map<UUID,Set<TaxonName>>> findIdenticalNames(List<UUID> sourceRefUuids, List<String> propertyPaths){
1384 1384
        Set<String> nameCacheCandidates = new HashSet<>();
1385 1385
        try {
1386 1386
            for (int i = 0; i<sourceRefUuids.size()-1;i++){
......
1393 1393

  
1394 1394
                    Query query = getSession().createQuery(
1395 1395
                            " SELECT DISTINCT n1.nameCache "
1396
                          + " FROM TaxonName n1 JOIN n1.sources s1 JOIN s1.citation ref1 "
1397
                          +         " , TaxonName n2 JOIN n2.sources s2 JOIN s2.citation ref2 "
1396
                          + " FROM TaxonBase t1 JOIN t1.name n1 JOIN t1.sources s1 JOIN s1.citation ref1 "
1397
                          +         " , TaxonBase t2 JOIN t2.name n2 JOIN t2.sources s2 JOIN s2.citation ref2 "
1398 1398
                          + " WHERE  ref1.uuid = (:sourceUuid1) "
1399 1399
                          + "       AND n1.id <> n2.id "
1400 1400
                          + "       AND ref2.uuid IN (:sourceUuid2)"
1401 1401
                          + "       AND ref1.uuid <> ref2.uuid "
1402 1402
                          + "       AND n1.nameCache = n2.nameCache) "
1403
                          + "       AND t1.publish = 1 AND t2.publish = 1) "
1403 1404
                          + " ORDER BY n1.nameCache ");
1404 1405
                    query.setParameter("sourceUuid1", sourceUuid1);
1405 1406
                    query.setParameter("sourceUuid2", sourceUuid2);
......
1413 1414
            Map<UUID, List<TaxonName>> duplicates = new HashMap<>();
1414 1415
            for (UUID sourceUuid : sourceRefUuids){
1415 1416
                Query query=getSession().createQuery("SELECT n "
1416
                        + " FROM TaxonName n JOIN n.sources s JOIN s.citation ref "
1417
                        + " WHERE ref.uuid = :sourceUuid AND n.nameCache IN (:nameCacheCandidates) "
1417
                        + " FROM TaxonBase t JOIN t.name n JOIN t.sources s JOIN s.citation ref "
1418
                        + " WHERE ref.uuid = :sourceUuid AND n.nameCache IN (:nameCacheCandidates) AND t.publish = 1 "
1418 1419
                        + " ORDER BY n.nameCache");
1419 1420
                query.setParameter("sourceUuid", sourceUuid);
1420 1421
                query.setParameterList("nameCacheCandidates", nameCacheCandidates);
......
1422 1423
                List<TaxonName> sourceDuplicates = query.list();
1423 1424
                defaultBeanInitializer.initializeAll(sourceDuplicates, propertyPaths);
1424 1425

  
1425
                 duplicates.put(sourceUuid, sourceDuplicates);
1426
                duplicates.put(sourceUuid, sourceDuplicates);
1426 1427
            }
1427 1428

  
1428 1429
            List<String> nameCacheCandidateList = new ArrayList<>(nameCacheCandidates);
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImpl.java
587 587
            nodeCrit.add(Restrictions.eq("classification", classification));
588 588
            nameCrit.add(Restrictions.eq("rank", rank));
589 589

  
590
//          ProjectionList projList = Projections.projectionList();
591
//          projList.add(Projections.property("treeIndex"));
592
//          projList.add(Projections.property("uuid"));
593
//          nodeCrit.setProjection(projList);
594

  
595 590
            @SuppressWarnings("unchecked")
596 591
            List<TaxonNode> list = nodeCrit.list();
597
//          for (Object[] objectArray: list) {
598
//              String treeIndexParent = (String) objectArray[0];
599
//              UUID uuid = (UUID)objectArray[1];
600
//              if (treeIndex.startsWith(treeIndexParent)) {
601
//                  node = load(uuid);
602
//                  break;
603
//              }
604
//          }
605

  
606 592
            for (TaxonNode rankNode : list){
607 593
                TaxonNodeDto dto = new TaxonNodeDto(rankNode);
608 594
                result.add(dto);
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/taxon/ITaxonDao.java
354 354
    /**
355 355
     * see service layer documentation
356 356
     */
357
    public Map<String, Map<UUID,Set<TaxonName>>> findIdenticalNamesNew(List<UUID> sourceRefUuids, List<String> propertyPaths);
357
    public Map<String, Map<UUID,Set<TaxonName>>> findIdenticalNames(List<UUID> sourceRefUuids, List<String> propertyPaths);
358 358

  
359 359
    public List<UuidAndTitleCache<? extends IdentifiableEntity>> getTaxaByNameForEditor(boolean doTaxa, boolean doSynonyms, boolean doNamesWithoutTaxa,
360 360
            boolean doMisappliedNames, boolean doCommonNames, boolean includeUnpublished,
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
1258 1258

  
1259 1259
    @Override
1260 1260
    public Map<String, Map<UUID,Set<TaxonName>>> findIdenticalTaxonNames(List<UUID> sourceRefUuids, List<String> propertyPaths) {
1261
        return this.dao.findIdenticalNamesNew(sourceRefUuids, propertyPaths);
1261
        return this.dao.findIdenticalNames(sourceRefUuids, propertyPaths);
1262 1262
    }
1263 1263

  
1264 1264

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)