Search in sources :

Example 1 with SuggestionQuery

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());
}
Also used : View(io.lumeer.api.model.View) LinkTypeDao(io.lumeer.storage.api.dao.LinkTypeDao) Set(java.util.Set) SearchQuery(io.lumeer.storage.api.query.SearchQuery) Collectors(java.util.stream.Collectors) LinkType(io.lumeer.api.model.LinkType) SuggestionType(io.lumeer.api.model.SuggestionType) Inject(javax.inject.Inject) List(java.util.List) CollectionDao(io.lumeer.storage.api.dao.CollectionDao) ViewDao(io.lumeer.storage.api.dao.ViewDao) RequestScoped(javax.enterprise.context.RequestScoped) SuggestionQuery(io.lumeer.storage.api.query.SuggestionQuery) Attribute(io.lumeer.api.model.Attribute) JsonSuggestions(io.lumeer.api.dto.JsonSuggestions) Collections(java.util.Collections) Collection(io.lumeer.api.model.Collection) SuggestionQuery(io.lumeer.storage.api.query.SuggestionQuery) Collection(io.lumeer.api.model.Collection) LinkType(io.lumeer.api.model.LinkType)

Example 2 with SuggestionQuery

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);
}
Also used : SuggestionQuery(io.lumeer.storage.api.query.SuggestionQuery) JsonView(io.lumeer.api.dto.JsonView) View(io.lumeer.api.model.View) Test(org.junit.Test)

Example 3 with SuggestionQuery

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();
}
Also used : SuggestionQuery(io.lumeer.storage.api.query.SuggestionQuery) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 4 with SuggestionQuery

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);
}
Also used : SuggestionQuery(io.lumeer.storage.api.query.SuggestionQuery) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 5 with SuggestionQuery

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);
}
Also used : SuggestionQuery(io.lumeer.storage.api.query.SuggestionQuery) Collection(io.lumeer.api.model.Collection)

Aggregations

SuggestionQuery (io.lumeer.storage.api.query.SuggestionQuery)11 Test (org.junit.Test)8 Collection (io.lumeer.api.model.Collection)7 View (io.lumeer.api.model.View)5 MorphiaCollection (io.lumeer.storage.mongodb.model.MorphiaCollection)4 JsonView (io.lumeer.api.dto.JsonView)2 MorphiaView (io.lumeer.storage.mongodb.model.MorphiaView)2 JsonSuggestions (io.lumeer.api.dto.JsonSuggestions)1 Attribute (io.lumeer.api.model.Attribute)1 LinkType (io.lumeer.api.model.LinkType)1 SuggestionType (io.lumeer.api.model.SuggestionType)1 CollectionDao (io.lumeer.storage.api.dao.CollectionDao)1 LinkTypeDao (io.lumeer.storage.api.dao.LinkTypeDao)1 ViewDao (io.lumeer.storage.api.dao.ViewDao)1 SearchQuery (io.lumeer.storage.api.query.SearchQuery)1 Collections (java.util.Collections)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 RequestScoped (javax.enterprise.context.RequestScoped)1