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