use of io.lumeer.storage.api.query.SuggestionQuery in project engine by Lumeer.
the class SuggestionFacade method suggestLinkTypes.
private List<LinkType> suggestLinkTypes(String text, int limit) {
List<Collection> allowedCollections = collectionDao.getCollections(createSimpleSearchQuery());
if (allowedCollections.isEmpty()) {
return Collections.emptyList();
}
List<String> allowedCollectionIds = allowedCollections.stream().map(Collection::getId).collect(Collectors.toList());
SuggestionQuery suggestionQuery = createSuggestionQueryWithIds(text, limit, allowedCollectionIds);
List<LinkType> linkTypes = linkTypeDao.getLinkTypes(suggestionQuery);
return linkTypes.stream().filter(linkType -> allowedCollectionIds.containsAll(linkType.getCollectionIds())).collect(Collectors.toList());
}
use of io.lumeer.storage.api.query.SuggestionQuery in project engine by Lumeer.
the class MongoViewDaoTest method testGetViewsBySuggestionText.
@Test
public void testGetViewsBySuggestionText() {
createView(CODE, NAME);
createView(CODE2, NAME2);
createView(CODE3, NAME3);
SuggestionQuery query = SuggestionQuery.createBuilder(USER).text("test").build();
List<View> views = viewDao.getViews(query);
assertThat(views).extracting(View::getCode).containsOnly(CODE, CODE2);
}
use of io.lumeer.storage.api.query.SuggestionQuery in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsSuggestionsDifferentUser.
@Test
public void testGetCollectionsSuggestionsDifferentUser() {
createCollection(CODE, NAME, ATTRIBUTES);
createCollection(CODE2, NAME_FULLTEXT, ATTRIBUTES);
createCollection(CODE3, NAME_SUGGESTION, ATTRIBUTES);
SuggestionQuery suggestionQuery = SuggestionQuery.createBuilder(USER2).text("TEST").build();
List<Collection> collections = collectionDao.getCollections(suggestionQuery);
assertThat(collections).isEmpty();
}
use of io.lumeer.storage.api.query.SuggestionQuery in project engine by Lumeer.
the class MorphiaCollectionDaoTest method testGetCollectionsSuggestions.
@Test
public void testGetCollectionsSuggestions() {
createCollection(CODE, NAME, ATTRIBUTES);
createCollection(CODE2, NAME_FULLTEXT, ATTRIBUTES);
createCollection(CODE3, NAME_SUGGESTION, ATTRIBUTES);
SuggestionQuery suggestionQuery = SuggestionQuery.createBuilder(USER).text("TEST").build();
List<Collection> collections = collectionDao.getCollections(suggestionQuery);
assertThat(collections).extracting(Resource::getCode).containsOnly(CODE, CODE3);
}
use of io.lumeer.storage.api.query.SuggestionQuery in project engine by Lumeer.
the class SuggestionFacade method suggestAttributes.
private List<Collection> suggestAttributes(String text, int limit) {
SuggestionQuery suggestionQuery = createSuggestionQuery(text, limit);
List<Collection> collections = collectionDao.getCollectionsByAttributes(suggestionQuery);
return keepOnlyMatchingAttributes(collections, text);
}
Aggregations