Project

General

Profile

Revision b296585f

IDb296585f4b05faf59dae26d3bcf99f3886a1d7a2
Parent 87e6bb6f
Child f6930dd5

Added by Andreas Müller about 3 years ago

ref #6066 add getChildNodes to classification service

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/ClassificationDaoHibernateImpl.java
319 319
    }
320 320

  
321 321

  
322
    /**
323
     * {@inheritDoc}
324
     */
325
    @Override
326
    public Map<UUID, UUID> getTaxonNodeUuidByTaxonUuid(UUID classificationUuid, List<UUID> taxonUuids) {
327
        String hql = " SELECT t.uuid, tn.uuid "
328
                + " FROM Taxon t JOIN t.taxonNodes tn "
329
                + " WHERE (1=1)"
330
                + "     AND tn.classification.uuid = :classificationUuid "
331
                + "     AND t.uuid IN (:taxonUuids) "
332
                ;
333
        Query query =  getSession().createQuery(hql);
334
        query.setParameter("classificationUuid", classificationUuid);
335
        query.setParameterList("taxonUuids", taxonUuids);
336

  
337
        Map<UUID, UUID> result = new HashMap<>();
338
        @SuppressWarnings("unchecked")
339
        List<Object[]> list = query.list();
340
        for (Object[] o : list){
341
            result.put((UUID)o[0], (UUID)o[1]);
342
        }
343
        return result;
344
    }
345

  
346

  
347

  
322 348
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/taxon/IClassificationDao.java
97 97
     */
98 98
    Map<UUID, String> treeIndexForTaxonUuids( UUID classificationUuid, List<UUID> originalTaxonUuids);
99 99

  
100
    /**
101
     * Returns a map of taxon uuids mapping to taxon node uuids in the given classification
102
     */
103
    public Map<UUID, UUID> getTaxonNodeUuidByTaxonUuid(UUID classificationUuid, List<UUID> taxonUuids);
104

  
100 105

  
101 106
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/ClassificationController.java
9 9
*/
10 10
package eu.etaxonomy.cdm.remote.controller;
11 11

  
12
import io.swagger.annotations.Api;
13

  
14 12
import java.io.IOException;
15 13
import java.util.Arrays;
16 14
import java.util.List;
......
29 27
import org.springframework.web.bind.annotation.RequestParam;
30 28

  
31 29
import eu.etaxonomy.cdm.api.service.IClassificationService;
30
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
32 31
import eu.etaxonomy.cdm.api.service.ITermService;
32
import eu.etaxonomy.cdm.api.service.NodeSortMode;
33 33
import eu.etaxonomy.cdm.api.service.dto.GroupedTaxonDTO;
34
import eu.etaxonomy.cdm.api.service.pager.Pager;
34 35
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
35 36
import eu.etaxonomy.cdm.model.name.Rank;
36 37
import eu.etaxonomy.cdm.model.taxon.Classification;
37 38
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
39
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
40
import eu.etaxonomy.cdm.remote.controller.util.PagerParameters;
38 41
import eu.etaxonomy.cdm.remote.editor.RankPropertyEditor;
39 42
import eu.etaxonomy.cdm.remote.editor.UUIDListPropertyEditor;
40 43
import eu.etaxonomy.cdm.remote.editor.UuidList;
44
import io.swagger.annotations.Api;
41 45

  
42 46
/**
43 47
 * @author a.kohlbecker
......
51 55

  
52 56

  
53 57
    private ITermService termService;
58
    private ITaxonNodeService taxonNodeService;
54 59

  
55 60
    @Override
56 61
    @Autowired
......
63 68
        this.termService = termService;
64 69
    }
65 70

  
71
    @Autowired
72
    public void setTaxonNodeService(ITaxonNodeService taxonNodeService) {
73
        this.taxonNodeService = taxonNodeService;
74
    }
75

  
66 76

  
67 77
    @InitBinder
68 78
    @Override
......
123 133
        return rootNodes;
124 134
    }
125 135

  
136
    /**
137
    *
138
    * @param uuid
139
    * @param pageIndex
140
    * @param pageSize
141
    * @param sortMode
142
    * @param response
143
    * @return
144
    * @throws IOException
145
    */
146
   @RequestMapping(
147
           value = {"childNodes"},
148
           method = RequestMethod.GET)
149
   public Pager<TaxonNodeDto> doPageChildNodes(
150
           @PathVariable("uuid") UUID classificationUuid,
151
           @RequestParam(value = "taxonUuid", required = true) UUID taxonUuid,
152
           @RequestParam(value = "pageNumber", required = false) Integer pageIndex,
153
           @RequestParam(value = "pageSize", required = false) Integer pageSize,
154
           @RequestParam(value="sortMode", defaultValue="AlphabeticalOrder") NodeSortMode sortMode,
155
           @RequestParam(value="doSynonyms", defaultValue="false") Boolean doSynonyms,
156
           HttpServletResponse response
157
           ) throws IOException {
158

  
159
       PagerParameters pagerParameters = new PagerParameters(pageSize, pageIndex);
160
       pagerParameters.normalizeAndValidate(response);
161

  
162
//       service.startTransaction();
163
       boolean recursive = false;
164
       UUID taxonNodeUuid = service.getTaxonNodeUuidByTaxonUuid(classificationUuid, taxonUuid) ;
165
       Pager<TaxonNodeDto> pager = taxonNodeService.pageChildNodesDTOs(taxonNodeUuid, recursive, doSynonyms, sortMode, pageSize, pageIndex);
166
//       service.commitTransaction()
167

  
168
       return pager;
169
   }
170

  
126 171

  
127 172
    /**
128 173
     * @param classificationUuid
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ClassificationServiceImpl.java
11 11
package eu.etaxonomy.cdm.api.service;
12 12

  
13 13
import java.util.ArrayList;
14
import java.util.Arrays;
14 15
import java.util.Collection;
15 16
import java.util.Collections;
16 17
import java.util.Comparator;
......
684 685
        return result;
685 686
    }
686 687

  
688
    /**
689
     * {@inheritDoc}
690
     */
691
    @Override
692
    public UUID getTaxonNodeUuidByTaxonUuid(UUID classificationUuid, UUID taxonUuid) {
693
        Map<UUID, UUID> map = dao.getTaxonNodeUuidByTaxonUuid(classificationUuid, Arrays.asList(taxonUuid));
694
        UUID taxonNodeUuid = map.get(taxonUuid);
695
        return taxonNodeUuid;
696
    }
697

  
687 698
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IClassificationService.java
58 58
     */
59 59
    public TaxonNode getRootNode(UUID classificationUuid);
60 60

  
61
    public UUID getTaxonNodeUuidByTaxonUuid(UUID classificationUuid, UUID taxonUuid);
62

  
61 63
    /**
62 64
     *
63 65
     * @param limit

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)