Search in sources :

Example 6 with ImportedCollection

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

the class ImportFacade method importDocuments.

public Collection importDocuments(String format, ImportedCollection importedCollection) {
    Collection collectionToCreate = importedCollection.getCollection();
    collectionToCreate.setName(generateCollectionName(collectionToCreate.getName()));
    Collection collection = collectionFacade.createCollection(collectionToCreate);
    switch(format.toLowerCase()) {
        case FORMAT_CSV:
            parseCSVFile(collection, importedCollection.getData());
            break;
    }
    return collection;
}
Also used : ImportedCollection(io.lumeer.api.model.ImportedCollection) Collection(io.lumeer.api.model.Collection)

Example 7 with ImportedCollection

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

the class ImportFacadeIT method testImportEmptyCSV.

@Test
public void testImportEmptyCSV() {
    final String emptyCSV = "";
    ImportedCollection importedCollection = createImportObject(emptyCSV);
    Collection collection = importFacade.importDocuments(ImportFacade.FORMAT_CSV, importedCollection);
    assertThat(collection).isNotNull();
    List<DataDocument> data = dataDao.getData(collection.getId(), query());
    assertThat(data).isEmpty();
}
Also used : DataDocument(io.lumeer.engine.api.data.DataDocument) ImportedCollection(io.lumeer.api.model.ImportedCollection) JsonCollection(io.lumeer.api.dto.JsonCollection) ImportedCollection(io.lumeer.api.model.ImportedCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 8 with ImportedCollection

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

the class ImportFacadeIT method testImportCollectionInfo.

@Test
public void testImportCollectionInfo() {
    final String emptyCSV = "";
    ImportedCollection importedCollection = createImportObject(emptyCSV);
    Collection collection = importFacade.importDocuments(ImportFacade.FORMAT_CSV, importedCollection);
    assertThat(collection).isNotNull();
    assertThat(collection.getName()).isEqualTo(COLLECTION_NAME);
    assertThat(collection.getCode()).isEqualTo(COLLECTION_CODE);
    assertThat(collection.getIcon()).isEqualTo(COLLECTION_ICON);
    assertThat(collection.getColor()).isEqualTo(COLLECTION_COLOR);
}
Also used : ImportedCollection(io.lumeer.api.model.ImportedCollection) JsonCollection(io.lumeer.api.dto.JsonCollection) ImportedCollection(io.lumeer.api.model.ImportedCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Aggregations

Collection (io.lumeer.api.model.Collection)8 ImportedCollection (io.lumeer.api.model.ImportedCollection)8 JsonCollection (io.lumeer.api.dto.JsonCollection)7 Test (org.junit.Test)7 DataDocument (io.lumeer.engine.api.data.DataDocument)6