/** * Returns the autolinker with all resources common to all vocabularies set. * * @return an {@link Autolinker} */ private Autolinker getVocabularyLinks() { return this.autolinker.get() .forSecondaryResource(VocabularyResource.class, this.uriInfo) .withActionableResources(VocabularyTermSuggestionsResource.class) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW); }
/** * Returns the autolinker with all resources common to all categories set. * * @return an {@link Autolinker} */ private Autolinker getCategoryLinks() { return this.autolinker.get() .forSecondaryResource(CategoryResource.class, this.uriInfo) .withActionableResources(CategoryTermSuggestionsResource.class) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW); }
/** * Returns the autolinker with all resources common to all vocabularies set. * * @return an {@link Autolinker} */ private Autolinker getVocabularyLinks() { return this.autolinker.get() .forSecondaryResource(VocabularyResource.class, this.uriInfo) .withActionableResources(VocabularyTermSuggestionsResource.class) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW); }
/** * Returns the autolinker with all resources common to all categories set. * * @return an {@link Autolinker} */ private Autolinker getCategoryLinks() { return this.autolinker.get() .forSecondaryResource(CategoryResource.class, this.uriInfo) .withActionableResources(CategoryTermSuggestionsResource.class) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW); }
/** * Returns the autolinker with all resources common to all categories set. * * @return an {@link Autolinker} */ private Autolinker getCategoryLinks() { return this.autolinker.get() .forSecondaryResource(CategoryResource.class, this.uriInfo) .withActionableResources(CategoryTermSuggestionsResource.class) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW); }
/** * Returns the autolinker with all resources common to all vocabularies set. * * @return an {@link Autolinker} */ private Autolinker getVocabularyLinks() { return this.autolinker.get() .forSecondaryResource(VocabularyResource.class, uriInfo) .withActionableResources(VocabularyTermSuggestionsResource.class) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW); }
@Override public VocabularyTerms suggest(String vocabularyId, String input, @DefaultValue("10") int maxResults, String sort, String customFilter) { if (StringUtils.isEmpty(input) || StringUtils.isEmpty(vocabularyId)) { throw new WebApplicationException(Response.Status.BAD_REQUEST); } Vocabulary vocabulary = this.vm.getVocabulary(vocabularyId); if (vocabulary == null) { throw new WebApplicationException(Response.Status.NOT_FOUND); } List<VocabularyTerm> termSuggestions = vocabulary.search(input, maxResults, sort, customFilter); List<VocabularyTermSummary> termReps = new ArrayList<>(); for (VocabularyTerm term : termSuggestions) { VocabularyTermSummary termRep = this.objectFactory.createVocabularyTermRepresentation(term); termRep.withLinks(this.autolinker.get().forSecondaryResource(VocabularyTermResource.class, this.uriInfo) .withActionableResources(VocabularyResource.class) .withExtraParameters("vocabulary-id", vocabularyId) .withExtraParameters("term-id", term.getId()) .build()); termReps.add(termRep); } VocabularyTerms result = new VocabularyTerms().withVocabularyTerms(termReps); result.withLinks(this.autolinker.get().forResource(getClass(), this.uriInfo).build()); return result; } }
@Override public Vocabularies getAllVocabularies() { Vocabularies result = new Vocabularies(); List<String> vocabularyIDs = this.vm.getAvailableVocabularies(); List<org.phenotips.vocabularies.rest.model.Vocabulary> availableVocabs = new ArrayList<>(); for (String vocabularyID : vocabularyIDs) { Vocabulary vocab = this.vm.getVocabulary(vocabularyID); org.phenotips.vocabularies.rest.model.Vocabulary rep = this.objectFactory.createVocabularyRepresentation(vocab); rep.withLinks(this.autolinker.get().forSecondaryResource(VocabularyResource.class, this.uriInfo) .withActionableResources(VocabularyTermSuggestionsResource.class) .withExtraParameters("vocabulary-id", vocabularyID) .withGrantedRight(userIsAdmin() ? Right.ADMIN : Right.VIEW) .build()); availableVocabs.add(rep); } result.withVocabularies(availableVocabs); result.withLinks(this.autolinker.get().forResource(getClass(), this.uriInfo).build()); return result; }