Search in sources :

Example 6 with Collection

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

the class CollectionFacade method getCollection.

public Collection getCollection(String collectionId) {
    Collection collection = collectionDao.getCollectionById(collectionId);
    permissionsChecker.checkRole(collection, Role.READ);
    return keepOnlyActualUserRoles(collection);
}
Also used : Collection(io.lumeer.api.model.Collection)

Example 7 with Collection

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

the class CollectionFacade method updateCollectionAttribute.

public Attribute updateCollectionAttribute(String collectionId, String attributeFullName, Attribute attribute) {
    Collection collection = collectionDao.getCollectionById(collectionId);
    permissionsChecker.checkRole(collection, Role.MANAGE);
    collection.updateAttribute(attributeFullName, attribute);
    collectionDao.updateCollection(collection.getId(), collection);
    return attribute;
}
Also used : Collection(io.lumeer.api.model.Collection)

Example 8 with Collection

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

the class DocumentFacade method getDocument.

public Document getDocument(String collectionId, String documentId) {
    Collection collection = collectionDao.getCollectionById(collectionId);
    permissionsChecker.checkRole(collection, Role.READ);
    Document document = documentDao.getDocumentById(documentId);
    DataDocument data = dataDao.getData(collection.getId(), documentId);
    document.setData(data);
    return document;
}
Also used : DataDocument(io.lumeer.engine.api.data.DataDocument) Collection(io.lumeer.api.model.Collection) DataDocument(io.lumeer.engine.api.data.DataDocument) Document(io.lumeer.api.model.Document)

Example 9 with Collection

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

the class DocumentFacade method createDocument.

public Document createDocument(String collectionId, Document document) {
    Collection collection = collectionDao.getCollectionById(collectionId);
    permissionsChecker.checkRole(collection, Role.WRITE);
    DataDocument data = DocumentUtils.checkDocumentKeysValidity(document.getData());
    Document storedDocument = createDocument(collection, document);
    DataDocument storedData = dataDao.createData(collection.getId(), storedDocument.getId(), data);
    storedDocument.setData(storedData);
    updateCollectionMetadata(collection, data.keySet(), Collections.emptySet(), 1);
    return storedDocument;
}
Also used : DataDocument(io.lumeer.engine.api.data.DataDocument) Collection(io.lumeer.api.model.Collection) DataDocument(io.lumeer.engine.api.data.DataDocument) Document(io.lumeer.api.model.Document)

Example 10 with Collection

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

the class DocumentFacade method patchDocumentData.

public Document patchDocumentData(String collectionId, String documentId, DataDocument data) {
    Collection collection = collectionDao.getCollectionById(collectionId);
    permissionsChecker.checkRole(collection, Role.WRITE);
    DataDocument oldData = dataDao.getData(collectionId, documentId);
    Set<String> attributesToAdd = new HashSet<>(data.keySet());
    attributesToAdd.removeAll(oldData.keySet());
    updateCollectionMetadata(collection, attributesToAdd, Collections.emptySet(), 0);
    // TODO archive the old document
    DataDocument patchedData = dataDao.patchData(collection.getId(), documentId, data);
    Document updatedDocument = updateDocument(collection, documentId);
    updatedDocument.setData(patchedData);
    return updatedDocument;
}
Also used : DataDocument(io.lumeer.engine.api.data.DataDocument) Collection(io.lumeer.api.model.Collection) DataDocument(io.lumeer.engine.api.data.DataDocument) Document(io.lumeer.api.model.Document) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

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