Create report from datasource


I want to create a report.

I can create a record from an entity without problems. But I want to create a report from a datasource, which I use to show the entries in a table in cuba. The logic is made in the backend and sended to cuba via rest.

Have you an idea how can I achieve that?

Best regards


You can try creating a report with a List of entities dataset, or select List of entities selected by query in the wizard, defining the same query as in your datasource in the backend.

Suppose you have a service that selects some order on a certain condition, for example:

public class ReportDataServiceBean implements ReportDataService {

    private Persistence persistence;

    public List<Order> getTodaysOrders() {
        Query query = persistence.getEntityManager().createQuery(
                "select o from sales$Order o where @between(o.createTs, now, now+1, day)");
        return query.getResultList();

The same result can be easily achieved with List of entities selected by query dataset, where the query is the following:

e.amount as "amount", as "", as "date"
from sales$Order e  
left join e.customer customer 
where @between ( e.createTs, now, now + 1, DAY)