use of io.lumeer.api.dto.JsonDocument in project engine by Lumeer.
the class SearchFacadeIT method createDocument.
private Document createDocument(String collectionId, Object value) {
Document document = new JsonDocument(new DataDocument(DOCUMENT_KEY, value));
document.setCollectionId(collectionId);
document.setCreatedBy(USER);
document.setCreationDate(LocalDateTime.now());
document.setDataVersion(DocumentFacade.INITIAL_VERSION);
Document storedDocument = documentDao.createDocument(document);
DataDocument storedData = dataDao.createData(collectionId, storedDocument.getId(), document.getData());
storedDocument.setData(storedData);
return storedDocument;
}
use of io.lumeer.api.dto.JsonDocument in project engine by Lumeer.
the class DocumentServiceIT method testGetDocument.
@Test
@Ignore("Works manually but there is unexpected exception in tests")
public void testGetDocument() {
String id = createDocument().getId();
Response response = client.target(DOCUMENTS_URL_PREFIX).path(collection.getId()).path("documents").path(id).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
JsonDocument document = response.readEntity(JsonDocument.class);
SoftAssertions assertions = new SoftAssertions();
assertions.assertThat(document.getId()).isEqualTo(id);
assertions.assertThat(document.getCollectionId()).isNull();
assertions.assertThat(document.getCreatedBy()).isEqualTo(USER);
assertions.assertThat(document.getCreationDate()).isBeforeOrEqualTo(LocalDateTime.now());
assertions.assertThat(document.getUpdatedBy()).isNull();
assertions.assertThat(document.getUpdateDate()).isNull();
assertions.assertThat(document.getDataVersion()).isEqualTo(1);
assertions.assertAll();
DataDocument data = document.getData();
assertThat(data).isNotNull();
assertThat(data).containsEntry(KEY1, VALUE1);
assertThat(data).containsEntry(KEY2, VALUE2);
}
use of io.lumeer.api.dto.JsonDocument in project engine by Lumeer.
the class ImportFacade method createDocumentFromRow.
private Document createDocumentFromRow(String[] headers, String[] row, int[] counts) {
final DataDocument d = new DataDocument();
for (int i = 0; i < Math.min(headers.length, row.length); i++) {
if (row[i] != null) {
d.append(headers[i], row[i]);
counts[i]++;
}
}
return new JsonDocument(d);
}
use of io.lumeer.api.dto.JsonDocument 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.dto.JsonDocument 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