Search in sources :

Example 51 with Collection

use of io.lumeer.api.model.Collection 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 52 with Collection

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

the class CollectionService method getCollections.

@GET
public List<JsonCollection> getCollections(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize) {
    Pagination pagination = new Pagination(page, pageSize);
    List<Collection> collections = collectionFacade.getCollections(pagination);
    return JsonCollection.convert(collections);
}
Also used : Pagination(io.lumeer.api.model.Pagination) JsonCollection(io.lumeer.api.dto.JsonCollection) Collection(io.lumeer.api.model.Collection) GET(javax.ws.rs.GET)

Example 53 with Collection

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

the class MorphiaCollectionDaoTest method testGetCollectionsByFulltext.

@Test
public void testGetCollectionsByFulltext() {
    createCollection(CODE, NAME, ATTRIBUTES);
    createCollection(CODE2, NAME_FULLTEXT, ATTRIBUTES);
    createCollection(CODE3, NAME3, ATTRIBUTES);
    SearchQuery searchQuery = SearchQuery.createBuilder(USER).fulltext("fulltext").build();
    List<Collection> collections = collectionDao.getCollections(searchQuery);
    assertThat(collections).extracting(Resource::getCode).containsOnly(CODE2, CODE3);
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 54 with Collection

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

the class MorphiaCollectionDaoTest method testGetCollectionsByAttributesSuggestions.

@Test
public void testGetCollectionsByAttributesSuggestions() {
    createCollection(CODE, NAME, Collections.emptySet());
    createCollection(CODE2, NAME2, ATTRIBUTES);
    createCollection(CODE3, NAME3, ATTRIBUTES_FULLTEXT);
    SuggestionQuery suggestionQuery = SuggestionQuery.createBuilder(USER).text("sugg").build();
    List<Collection> collections = collectionDao.getCollectionsByAttributes(suggestionQuery);
    assertThat(collections).extracting(Resource::getCode).containsOnly(CODE2, CODE3);
}
Also used : SuggestionQuery(io.lumeer.storage.api.query.SuggestionQuery) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Example 55 with Collection

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

the class MorphiaCollectionDaoTest method testGetCollectionsNoReadRole.

@Test
public void testGetCollectionsNoReadRole() {
    MorphiaCollection collection = prepareCollection(CODE, NAME);
    Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.CLONE.toString()));
    collection.getPermissions().updateUserPermissions(userPermission);
    datastore.save(collectionDao.databaseCollection(), collection);
    MorphiaCollection collection2 = prepareCollection(CODE2, NAME2);
    Permission groupPermission = new MorphiaPermission(GROUP2, Collections.singleton(Role.SHARE.toString()));
    collection2.getPermissions().updateGroupPermissions(groupPermission);
    datastore.save(collectionDao.databaseCollection(), collection2);
    SearchQuery query = SearchQuery.createBuilder(USER2).groups(Collections.singleton(GROUP2)).build();
    List<Collection> collections = collectionDao.getCollections(query);
    assertThat(collections).isEmpty();
}
Also used : SearchQuery(io.lumeer.storage.api.query.SearchQuery) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) Permission(io.lumeer.api.model.Permission) MorphiaCollection(io.lumeer.storage.mongodb.model.MorphiaCollection) Collection(io.lumeer.api.model.Collection) Test(org.junit.Test)

Aggregations

Collection (io.lumeer.api.model.Collection)77 Test (org.junit.Test)47 JsonCollection (io.lumeer.api.dto.JsonCollection)34 DataDocument (io.lumeer.engine.api.data.DataDocument)17 MorphiaCollection (io.lumeer.storage.mongodb.model.MorphiaCollection)17 SearchQuery (io.lumeer.storage.api.query.SearchQuery)14 SoftAssertions (org.assertj.core.api.SoftAssertions)12 Document (io.lumeer.api.model.Document)8 ImportedCollection (io.lumeer.api.model.ImportedCollection)8 SuggestionQuery (io.lumeer.storage.api.query.SuggestionQuery)8 Response (javax.ws.rs.core.Response)8 JsonAttribute (io.lumeer.api.dto.JsonAttribute)7 Attribute (io.lumeer.api.model.Attribute)7 HashSet (java.util.HashSet)6 JsonQuery (io.lumeer.api.dto.JsonQuery)5 LocalDateTime (java.time.LocalDateTime)4 List (java.util.List)4 JsonDocument (io.lumeer.api.dto.JsonDocument)3 LinkType (io.lumeer.api.model.LinkType)3 CollectionDao (io.lumeer.storage.api.dao.CollectionDao)3