use of io.lumeer.storage.api.query.SearchQuery 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.storage.api.query.SearchQuery in project engine by Lumeer.
the class CollectionFacade method deleteCollection.
public void deleteCollection(String collectionId) {
Collection collection = collectionDao.getCollectionById(collectionId);
permissionsChecker.checkRole(collection, Role.MANAGE);
collectionDao.deleteCollection(collectionId);
documentDao.deleteDocuments(collectionId);
dataDao.deleteDataRepository(collectionId);
SearchQuery queryLinkTypes = createQueryForLinkTypes(collectionId);
List<LinkType> linkTypes = linkTypeDao.getLinkTypes(queryLinkTypes);
if (!linkTypes.isEmpty()) {
linkTypeDao.deleteLinkTypes(queryLinkTypes);
linkInstanceDao.deleteLinkInstances(createQueryForLinkInstances(linkTypes));
}
}
use of io.lumeer.storage.api.query.SearchQuery in project engine by Lumeer.
the class MongoDataDaoTest method testGetDataByDocumenstIds.
@Test
public void testGetDataByDocumenstIds() {
String id1 = createDocument(KEY1, VALUE1);
String id2 = createDocument(KEY1, VALUE2);
String id3 = createDocument(KEY1, VALUE1);
String id4 = createDocument(KEY1, VALUE2);
SearchQuery searchQuery = SearchQuery.createBuilder(USER).documentIds(Collections.singleton(id2)).build();
List<DataDocument> data = dataDao.getData(COLLECTION_ID, searchQuery);
assertThat(data).extracting(DataDocument::getId).containsOnly(id2);
searchQuery = SearchQuery.createBuilder(USER).documentIds(new HashSet<>(Arrays.asList(id1, id3, id4))).build();
data = dataDao.getData(COLLECTION_ID, searchQuery);
assertThat(data).extracting(DataDocument::getId).containsOnly(id1, id3, id4);
}
use of io.lumeer.storage.api.query.SearchQuery in project engine by Lumeer.
the class MongoDataDaoTest method testGetDataByFulltextAttributeValueAndDocumentsIds.
@Test
public void testGetDataByFulltextAttributeValueAndDocumentsIds() {
String id1 = createDocument(KEY1, VALUE1);
String id2 = createDocument(KEY1, "fulltext");
String id3 = createDocument(KEY1, "something fulltext");
String id4 = createDocument(KEY1, VALUE1);
SearchQuery searchQuery = SearchQuery.createBuilder(USER).fulltext("fulltext").documentIds(new HashSet<>(Arrays.asList(id1, id2))).build();
List<DataDocument> data = dataDao.getData(COLLECTION_ID, searchQuery);
assertThat(data).extracting(DataDocument::getId).containsOnly(id2);
}
use of io.lumeer.storage.api.query.SearchQuery in project engine by Lumeer.
the class MongoDataDaoTest method testGetDataCount.
@Test
public void testGetDataCount() {
createDocument();
createDocument();
SearchQuery searchQuery = SearchQuery.createBuilder(USER).build();
long count = dataDao.getDataCount(COLLECTION_ID, searchQuery);
assertThat(count).isEqualTo(2);
}
Aggregations