Project

General

Profile

Revision a180fd4f

IDa180fd4f4e4277373182ba58dd55b6e794da25ca
Parent 29a5f57c
Child 3cf47767

Added by Andreas Müller about 4 years ago

#5957 Fix empty treeindexes

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImpl.java
286 286
    }
287 287

  
288 288
    @Override
289
    public Map<String, Integer> rankOrderIndexForTreeIndex(List<String> treeIndexClosure,
289
    public Map<String, Integer> rankOrderIndexForTreeIndex(List<String> treeIndexes,
290 290
            Integer minRankOrderIndex,
291 291
            Integer maxRankOrderIndex) {
292

  
293
        Map<String, Integer> result = new HashMap<>();
294
        if (treeIndexes == null || treeIndexes.isEmpty()){
295
            return result;
296
        }
297

  
292 298
        String hql = " SELECT tn.treeIndex, r.orderIndex "
293 299
                + " FROM TaxonNode tn JOIN tn.taxon t JOIN t.name n JOIN n.rank r "
294 300
                + " WHERE tn.treeIndex IN (:treeIndexes) ";
......
300 306
        }
301 307

  
302 308
        Query query =  getSession().createQuery(hql);
303
        query.setParameterList("treeIndexes", treeIndexClosure);
309
        query.setParameterList("treeIndexes", treeIndexes);
304 310
        if (minRankOrderIndex != null){
305 311
            query.setParameter("minOrderIndex", minRankOrderIndex);
306 312
        }
......
308 314
            query.setParameter("maxOrderIndex", maxRankOrderIndex);
309 315
        }
310 316

  
311
        Map<String, Integer> result = new HashMap<>();
312 317
        @SuppressWarnings("unchecked")
313 318
        List<Object[]> list = query.list();
314 319
        for (Object[] o : list){
......
319 324

  
320 325
    @Override
321 326
    public Map<String, UuidAndTitleCache<?>> taxonUuidsForTreeIndexes(Set<String> treeIndexes) {
327
        Map<String, UuidAndTitleCache<?>> result = new HashMap<>();
328
        if (treeIndexes == null || treeIndexes.isEmpty()){
329
            return result;
330
        }
331

  
322 332
        String hql = " SELECT tn.treeIndex, t.uuid, tnb.titleCache "
323 333
                + " FROM TaxonNode tn JOIN tn.taxon t Join t.name tnb "
324 334
                + " WHERE tn.treeIndex IN (:treeIndexes) ";
325 335
        Query query =  getSession().createQuery(hql);
326 336
        query.setParameterList("treeIndexes", treeIndexes);
327 337

  
328
        Map<String, UuidAndTitleCache<?>> result = new HashMap<>();
329 338
        @SuppressWarnings("unchecked")
330 339
        List<Object[]> list = query.list();
331 340
        for (Object[] o : list){

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)