Search in sources :

Example 16 with SearchQuery

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);
}
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 17 with SearchQuery

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

Example 18 with SearchQuery

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);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) DataDocument(io.lumeer.engine.api.data.DataDocument) Test(org.junit.Test)

Example 19 with SearchQuery

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);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) DataDocument(io.lumeer.engine.api.data.DataDocument) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 20 with SearchQuery

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

Aggregations

SearchQuery (io.lumeer.storage.api.query.SearchQuery)39 Test (org.junit.Test)37 View (io.lumeer.api.model.View)15 Collection (io.lumeer.api.model.Collection)11 MorphiaCollection (io.lumeer.storage.mongodb.model.MorphiaCollection)9 JsonView (io.lumeer.api.dto.JsonView)8 HashSet (java.util.HashSet)8 MorphiaView (io.lumeer.storage.mongodb.model.MorphiaView)7 LinkType (io.lumeer.api.model.LinkType)5 DataDocument (io.lumeer.engine.api.data.DataDocument)5 LinkInstance (io.lumeer.api.model.LinkInstance)4 Permission (io.lumeer.api.model.Permission)4 MorphiaPermission (io.lumeer.storage.mongodb.model.embedded.MorphiaPermission)4 ArrayList (java.util.ArrayList)4 Ignore (org.junit.Ignore)2 HashMap (java.util.HashMap)1