Search in sources :

Example 41 with DataDocument

use of io.lumeer.engine.api.data.DataDocument 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 42 with DataDocument

use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.

the class ConfigurationManipulator method getConfigurations.

/**
 * Returns an DataDocument containing all configurations for unique nameValue.
 *
 * @param collectionName
 *       the name of collection in system database
 * @param nameValue
 *       the unique name value of stored configuration entry
 * @return List storing all configurations
 */
public List<Config> getConfigurations(final String collectionName, final String nameValue) {
    DataDocument document = systemDataStorage.readDocument(collectionName, entryFilter(nameValue));
    List<DataDocument> configs = document != null ? document.getArrayList(CONFIGS, DataDocument.class) : Collections.emptyList();
    return configs.stream().map(Config::new).collect(Collectors.toList());
}
Also used : DataDocument(io.lumeer.engine.api.data.DataDocument)

Example 43 with DataDocument

use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.

the class ConfigurationManipulator method setConfigurationEntry.

private void setConfigurationEntry(final String collectionName, final String nameValue, List<Config> configs) {
    List<DataDocument> configsDocuments = configs.stream().map(Config::toDataDocument).collect(Collectors.toList());
    DataDocument configDocument = new DataDocument().append(NAMEVALUE, nameValue).append(CONFIGS, configsDocuments);
    systemDataStorage.updateDocument(collectionName, configDocument, entryFilter(nameValue));
}
Also used : DataDocument(io.lumeer.engine.api.data.DataDocument)

Example 44 with DataDocument

use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.

the class DocumentFacade method deleteDocument.

public void deleteDocument(String collectionId, String documentId) {
    Collection collection = collectionDao.getCollectionById(collectionId);
    permissionsChecker.checkRole(collection, Role.WRITE);
    DataDocument data = dataDao.getData(collectionId, documentId);
    updateCollectionMetadata(collection, Collections.emptySet(), data.keySet(), -1);
    documentDao.deleteDocument(documentId);
    dataDao.deleteData(collection.getId(), documentId);
    linkInstanceDao.deleteLinkInstances(createQueryForLinkInstances(documentId));
}
Also used : DataDocument(io.lumeer.engine.api.data.DataDocument) Collection(io.lumeer.api.model.Collection)

Example 45 with DataDocument

use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.

the class DocumentFacade method getDocuments.

public List<Document> getDocuments(String collectionId, Pagination pagination) {
    Collection collection = collectionDao.getCollectionById(collectionId);
    permissionsChecker.checkRole(collection, Role.READ);
    Map<String, DataDocument> dataDocuments = getDataDocuments(collection.getId(), pagination);
    return getDocuments(dataDocuments);
}
Also used : DataDocument(io.lumeer.engine.api.data.DataDocument) Collection(io.lumeer.api.model.Collection)

Aggregations

DataDocument (io.lumeer.engine.api.data.DataDocument)75 Test (org.junit.Test)42 Collection (io.lumeer.api.model.Collection)16 Document (io.lumeer.api.model.Document)16 JsonDocument (io.lumeer.api.dto.JsonDocument)14 Document (org.bson.Document)13 SoftAssertions (org.assertj.core.api.SoftAssertions)10 ReturnDocument (com.mongodb.client.model.ReturnDocument)9 JsonCollection (io.lumeer.api.dto.JsonCollection)9 DataFilter (io.lumeer.engine.api.data.DataFilter)9 ImportedCollection (io.lumeer.api.model.ImportedCollection)6 SearchQuery (io.lumeer.storage.api.query.SearchQuery)6 LocalDateTime (java.time.LocalDateTime)6 BsonDocument (org.bson.BsonDocument)6 LinkedList (java.util.LinkedList)5 FindOneAndUpdateOptions (com.mongodb.client.model.FindOneAndUpdateOptions)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Response (javax.ws.rs.core.Response)4 DataStorageStats (io.lumeer.engine.api.data.DataStorageStats)3