Search in sources :

Example 36 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class CollectionServiceIT method testGetCollectionAttributes.

@Test
public void testGetCollectionAttributes() {
    Collection collection = createCollection(CODE);
    assertThat(collection.getAttributes()).hasSize(1);
    Response response = client.target(COLLECTIONS_URL).path(collection.getId()).path("attributes").request(MediaType.APPLICATION_JSON).buildGet().invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    List<JsonAttribute> attributes = response.readEntity(new GenericType<List<JsonAttribute>>() {
    });
    assertThat(attributes).hasSize(1);
    JsonAttribute attribute = attributes.get(0);
    SoftAssertions assertions = new SoftAssertions();
    assertions.assertThat(attribute.getName()).isEqualTo(ATTRIBUTE_NAME);
    assertions.assertThat(attribute.getFullName()).isEqualTo(ATTRIBUTE_FULLNAME);
    assertions.assertThat(attribute.getConstraints()).isEqualTo(ATTRIBUTE_CONSTRAINTS);
    assertions.assertThat(attribute.getUsageCount()).isEqualTo(ATTRIBUTE_COUNT);
    assertions.assertAll();
}
Also used : Response(javax.ws.rs.core.Response) SoftAssertions(org.assertj.core.api.SoftAssertions) JsonCollection(io.lumeer.api.dto.JsonCollection) Collection(io.lumeer.api.model.Collection) List(java.util.List) JsonAttribute(io.lumeer.api.dto.JsonAttribute) Test(org.junit.Test)

Example 37 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class SearchFacade method searchDocumentsByQuery.

private List<Document> searchDocumentsByQuery(Query query) {
    Set<String> collectionIdsFromFilters = collectionIdsFromFilters(parseAttributeFilters(query.getFilters()));
    SearchQuery collectionQuery = createCollectionQuery(query, collectionIdsFromFilters);
    Map<String, Collection> collections = getCollections(collectionQuery);
    Map<String, DataDocument> dataDocuments = new HashMap<>();
    for (Collection collection : collections.values()) {
        SearchQuery usedSearchQuery = collectionIdsFromFilters.contains(collection.getId()) ? createSearchQuery(query) : createSearchQueryWithoutFilters(query);
        dataDocuments.putAll(getDataDocuments(collection.getId(), usedSearchQuery));
    }
    return getDocuments(dataDocuments);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) DataDocument(io.lumeer.engine.api.data.DataDocument) HashMap(java.util.HashMap) Collection(io.lumeer.api.model.Collection)

Example 38 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class SearchFacade method getCollectionsByDocumentsSearch.

private List<Collection> getCollectionsByDocumentsSearch(Query query) {
    java.util.Collection<Collection> searchedCollections = getCollections(query).values();
    List<Collection> matchedCollections = new ArrayList<>();
    for (Collection collection : searchedCollections) {
        long documentCount = dataDao.getDataCount(collection.getId(), createSearchQuery(query));
        if (documentCount > 0) {
            matchedCollections.add(collection);
        }
    }
    return matchedCollections;
}
Also used : ArrayList(java.util.ArrayList) Collection(io.lumeer.api.model.Collection)

Example 39 with Collection

use of io.lumeer.api.model.Collection 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)

Example 40 with Collection

use of io.lumeer.api.model.Collection in project engine by Lumeer.

the class SuggestionFacade method suggestCollections.

private List<Collection> suggestCollections(String text, int limit) {
    SuggestionQuery suggestionQuery = createSuggestionQuery(text, limit);
    List<Collection> collections = collectionDao.getCollections(suggestionQuery);
    collections.forEach(c -> c.setAttributes(Collections.emptySet()));
    return collections;
}
Also used : SuggestionQuery(io.lumeer.storage.api.query.SuggestionQuery) Collection(io.lumeer.api.model.Collection)

Aggregations

Collection (io.lumeer.api.model.Collection)77 Test (org.junit.Test)47 JsonCollection (io.lumeer.api.dto.JsonCollection)34 DataDocument (io.lumeer.engine.api.data.DataDocument)17 MorphiaCollection (io.lumeer.storage.mongodb.model.MorphiaCollection)17 SearchQuery (io.lumeer.storage.api.query.SearchQuery)14 SoftAssertions (org.assertj.core.api.SoftAssertions)12 Document (io.lumeer.api.model.Document)8 ImportedCollection (io.lumeer.api.model.ImportedCollection)8 SuggestionQuery (io.lumeer.storage.api.query.SuggestionQuery)8 Response (javax.ws.rs.core.Response)8 JsonAttribute (io.lumeer.api.dto.JsonAttribute)7 Attribute (io.lumeer.api.model.Attribute)7 HashSet (java.util.HashSet)6 JsonQuery (io.lumeer.api.dto.JsonQuery)5 LocalDateTime (java.time.LocalDateTime)4 List (java.util.List)4 JsonDocument (io.lumeer.api.dto.JsonDocument)3 LinkType (io.lumeer.api.model.LinkType)3 CollectionDao (io.lumeer.storage.api.dao.CollectionDao)3