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;
}
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);
}
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);
}
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);
}
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();
}
Aggregations