Programmatic Datasource

I want to feed a Table from a datasource which I generate programmatically.

Maybe using the DsBuilder but i didn’t find where to pass my query.
Or take a List<Entity> made with Datamanager and then wrap into a CollectionDatasource<Entity, UUID>, but how?

Hi Alex,

A query can be set in the setQuery() method, for example:

CollectionDatasource ds = new DsBuilder(getDsContext())
        .setJavaClass(Order.class)
        .setViewName(View.LOCAL)
        .setId("ordersDs")
        .buildCollectionDatasource();
ds.setQuery("select e from sales$Order e where e.amount >= :custom$amount");
ds.refresh(ParamsMap.of("amount", BigDecimal.ONE));

Same for GroupDatasource:

GroupDatasource ds =  new DsBuilder(getDsContext())
        .setJavaClass(Order.class)
        .setViewName(View.LOCAL)
        .setId("ordersDs")
        .buildGroupDatasource();
ds.setQuery("select e from sales$Order e");
ds.refresh();

Thank you!

Is this somewhere documented? I didn’t find it.

Yes, here. As it turned out to be not very obvious, we’ll think about how to improve this documentation.

Yeah… i scrolled over that part a few times but i was focused on sample code.