Commit 01cedbc7 authored by Matija Obreza's avatar Matija Obreza
Browse files

More effective loading of Vocabulary terms

parent 955817bf
......@@ -117,8 +117,7 @@ public class VocabularyServiceImpl implements VocabularyService {
if (vocabulary != null) {
// Do not load all terms, only first 50
if (vocabulary.getTerms() != null) {
List<VocabularyTerm> sublist = new ArrayList<>(vocabulary.getTerms().subList(0, Math.min(vocabulary.getTerms().size(), 50)));
vocabulary.setTerms(sublist);
vocabulary.setTerms(vocabRepository.listVocabularyTerms(vocabulary, new PageRequest(0, 50)).getContent());
}
if (vocabulary.getOwner() != null) {
......
......@@ -22,6 +22,8 @@ import org.genesys.catalog.model.vocab.ControlledVocabulary;
import org.genesys.catalog.model.vocab.VocabularyTerm;
import org.genesys.catalog.service.VocabularyService;
import org.genesys.catalog.service.filters.ControlledVocabularyFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
......@@ -42,6 +44,7 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(VocabularyController.API_BASE)
public class VocabularyController {
public static final String API_BASE = "/api/v0/vocabulary";
private static final Logger LOG = LoggerFactory.getLogger(VocabularyController.class);
@Autowired
private VocabularyService vocabularyService;
......@@ -66,7 +69,13 @@ public class VocabularyController {
@RequestParam(name = "l", required = false, defaultValue = "50") final int pageSize,
@RequestParam(name = "d", required = false, defaultValue = "ASC") final Sort.Direction direction,
@RequestParam(name = "s", required = false, defaultValue = "id") final String[] sort) {
return vocabularyService.listTerms(vocabularyService.getVocabulary(uuid), new PageRequest(page, Integer.min(pageSize, 100), direction, sort));
// LOG.warn("Loading vocab");
ControlledVocabulary vocabulary = vocabularyService.getVocabulary(uuid);
// LOG.warn("Loading terms");
Page<VocabularyTerm> x = vocabularyService.listTerms(vocabulary, new PageRequest(page, Integer.min(pageSize, 100), direction, sort));
// LOG.warn("Returning terms");
return x;
}
@DeleteMapping(value = "/{UUID},{version}")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment