use of io.lumeer.api.model.Document in project engine by Lumeer.
the class SearchFacadeIT method testSearchDocumentsByCombination.
@Test
public void testSearchDocumentsByCombination() {
createDocument(collectionIds.get(0), "word");
createDocument(collectionIds.get(0), "fulltext");
createDocument(collectionIds.get(1), "something fulltext");
createDocument(collectionIds.get(1), "some other word anything");
createDocument(collectionIds.get(2), "full word");
createDocument(collectionIds.get(2), "anything");
List<Document> documents = searchFacade.searchDocuments(new JsonQuery(null, Collections.singleton(collectionIds.get(0)), null, null, "anything", null, null));
assertThat(documents).extracting(Document::getId).isEmpty();
}
use of io.lumeer.api.model.Document in project engine by Lumeer.
the class DocumentServiceIT method createDocument.
private Document createDocument() {
Document document = prepareDocument();
document.setCollectionId(collection.getId());
document.setCreatedBy(USER);
document.setCreationDate(LocalDateTime.now());
document.setDataVersion(DocumentFacade.INITIAL_VERSION);
Document storedDocument = documentDao.createDocument(document);
DataDocument storedData = dataDao.createData(collection.getId(), storedDocument.getId(), document.getData());
storedDocument.setData(storedData);
return storedDocument;
}
use of io.lumeer.api.model.Document in project engine by Lumeer.
the class DocumentFacade method updateDocumentData.
public Document updateDocumentData(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());
Set<String> attributesToDec = new HashSet<>(oldData.keySet());
attributesToDec.removeAll(data.keySet());
updateCollectionMetadata(collection, attributesToAdd, attributesToDec, 0);
// TODO archive the old document
DataDocument updatedData = dataDao.updateData(collection.getId(), documentId, data);
Document updatedDocument = updateDocument(collection, documentId);
updatedDocument.setData(updatedData);
return updatedDocument;
}
use of io.lumeer.api.model.Document in project engine by Lumeer.
the class DocumentService method createDocument.
@POST
public Response createDocument(JsonDocument document) {
Document storedDocument = documentFacade.createDocument(collectionId, document);
URI resourceUri = getResourceUri(storedDocument.getId());
return Response.created(resourceUri).build();
}
use of io.lumeer.api.model.Document in project engine by Lumeer.
the class DocumentService method getDocuments.
@GET
public List<JsonDocument> getDocuments(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize) {
Pagination pagination = new Pagination(page, pageSize);
List<Document> documents = documentFacade.getDocuments(collectionId, pagination);
return JsonDocument.convert(documents);
}
Aggregations