use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class MongoViewDaoTest method createView.
private JsonView createView(String code, String name, Set<String> collections) {
JsonView jsonView = prepareView();
jsonView.setCode(code);
jsonView.setName(name);
jsonView.setQuery(new JsonQuery(collections, null, null));
viewDao.databaseCollection().insertOne(jsonView);
return jsonView;
}
use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class MongoViewDaoTest method testGetViews.
@Test
public void testGetViews() {
JsonView view = prepareView();
viewDao.databaseCollection().insertOne(view);
JsonView view2 = prepareView();
view2.setCode(CODE2);
view2.setName(NAME2);
viewDao.databaseCollection().insertOne(view2);
SearchQuery query = SearchQuery.createBuilder(USER).build();
List<View> views = viewDao.getViews(query);
assertThat(views).extracting(View::getCode).containsOnly(CODE, CODE2);
}
use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class MongoViewDaoTest method testGetViewsPagination.
@Test
public void testGetViewsPagination() {
JsonView view = prepareView();
viewDao.databaseCollection().insertOne(view);
JsonView view2 = prepareView();
view2.setCode(CODE2);
view2.setName(NAME2);
viewDao.databaseCollection().insertOne(view2);
SearchQuery query = SearchQuery.createBuilder(USER).page(1).pageSize(1).build();
List<View> views = viewDao.getViews(query);
assertThat(views).extracting(View::getCode).containsOnly(CODE2);
}
use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class MongoViewDao method createView.
@Override
public View createView(final View view) {
try {
JsonView jsonView = new JsonView(view);
databaseCollection().insertOne(jsonView);
return jsonView;
} catch (MongoException ex) {
throw new StorageException("Cannot create view: " + view, ex);
}
}
use of io.lumeer.api.dto.JsonView in project engine by Lumeer.
the class ViewCodec method decode.
@Override
public JsonView decode(final BsonReader reader, final DecoderContext decoderContext) {
Document bson = documentCodec.decode(reader, decoderContext);
String id = bson.getObjectId(ID).toHexString();
String code = bson.getString(CODE);
String name = bson.getString(NAME);
String icon = bson.getString(ICON);
String color = bson.getString(COLOR);
String description = bson.getString(DESCRIPTION);
// TODO try to use better approach
JsonPermissions permissions = PermissionsCodec.convertFromDocument(bson.get(PERMISSIONS, Document.class));
JsonQuery query = QueryCodec.convertFromDocument(bson.get(QUERY, Document.class));
String perspective = bson.getString(PERSPECTIVE);
Object config = bson.get(CONFIG);
JsonView view = new JsonView(code, name, icon, color, description, permissions, query, perspective, config);
view.setId(id);
return view;
}
Aggregations