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();
}
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);
}
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;
}
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);
}
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;
}
Aggregations