use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.
the class MongoDbStorage method run.
private List<DataDocument> run(final Bson command) {
final List<DataDocument> result = new ArrayList<>();
Document cursor = (Document) database.runCommand(command).get(CURSOR_KEY);
if (cursor != null) {
((ArrayList<Document>) cursor.get(FIRST_BATCH_KEY)).forEach(d -> {
result.add(MongoUtils.convertDocument(d));
});
}
return result;
}
use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.
the class MongoDataDaoTest method testGetDataByDocumenstIds.
@Test
public void testGetDataByDocumenstIds() {
String id1 = createDocument(KEY1, VALUE1);
String id2 = createDocument(KEY1, VALUE2);
String id3 = createDocument(KEY1, VALUE1);
String id4 = createDocument(KEY1, VALUE2);
SearchQuery searchQuery = SearchQuery.createBuilder(USER).documentIds(Collections.singleton(id2)).build();
List<DataDocument> data = dataDao.getData(COLLECTION_ID, searchQuery);
assertThat(data).extracting(DataDocument::getId).containsOnly(id2);
searchQuery = SearchQuery.createBuilder(USER).documentIds(new HashSet<>(Arrays.asList(id1, id3, id4))).build();
data = dataDao.getData(COLLECTION_ID, searchQuery);
assertThat(data).extracting(DataDocument::getId).containsOnly(id1, id3, id4);
}
use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.
the class MongoDataDaoTest method testGetDataByFulltextAttributeValueAndDocumentsIds.
@Test
public void testGetDataByFulltextAttributeValueAndDocumentsIds() {
String id1 = createDocument(KEY1, VALUE1);
String id2 = createDocument(KEY1, "fulltext");
String id3 = createDocument(KEY1, "something fulltext");
String id4 = createDocument(KEY1, VALUE1);
SearchQuery searchQuery = SearchQuery.createBuilder(USER).fulltext("fulltext").documentIds(new HashSet<>(Arrays.asList(id1, id2))).build();
List<DataDocument> data = dataDao.getData(COLLECTION_ID, searchQuery);
assertThat(data).extracting(DataDocument::getId).containsOnly(id2);
}
use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.
the class MongoDataDaoTest method testCreateData.
@Test
public void testCreateData() {
DataDocument data = new DataDocument().append(KEY1, VALUE1).append(KEY2, VALUE2);
DataDocument storedData = dataDao.createData(COLLECTION_ID, DOCUMENT_ID, data);
assertThat(storedData).isNotNull();
assertThat(storedData.getId()).isNull();
MongoCursor<Document> mongoCursor = dataCollection().find().iterator();
assertThat(mongoCursor.hasNext()).isTrue();
Document document = mongoCursor.next();
assertThat(document.get("_id").toString()).isNotNull().isEqualTo(DOCUMENT_ID);
assertThat(document).containsEntry(KEY1, VALUE1);
assertThat(document).containsEntry(KEY2, VALUE2);
}
use of io.lumeer.engine.api.data.DataDocument in project engine by Lumeer.
the class MorphiaDocumentDaoTest method prepareDocument.
private MorphiaDocument prepareDocument() {
MorphiaDocument document = new MorphiaDocument();
document.setCollectionId(COLLECTION_ID);
document.setCreationDate(CREATION_DATE);
document.setCreatedBy(CREATED_BY);
document.setDataVersion(DATA_VERSION);
document.setData(new DataDocument("something", "that should not be stored"));
return document;
}
Aggregations