Hi,
I am trying to use DTO entity as a datasource for a chart, i have a normal JPA entity from which i am getting the data and then i programatically create a list of DTO objects then i set them to a DTO collection datasource but its not showing anything on the chart
xml
<data readOnly="true">
<collection id="tripsDc" class="com.company.dashboardoasis.entity.Trip" fetchPlan="dailyTrip">
<loader id="tripsDl" readOnly="true">
<query>
<![CDATA[select e from Trip e
where e.date = :date
order by e.createdDate desc]]>
</query>
</loader>
</collection>
<collection id="dailyTripsDc" class="com.company.dashboardoasis.entity.DailyTrip">
<loader id="dailyTripsDl" readOnly="true">
<query>
<![CDATA[select e from DailyTrip e]]>
</query>
</loader>
<fetchPlan extends="_base"/>
</collection>
</data>
<facets>
<dataLoadCoordinator auto="true"/>
<timer id="timer"
delay="4000"
autostart="true"
repeating="true"/>
</facets>
controller
@ViewComponent
protected Timer timer;
@ViewComponent
private CollectionLoader<Trip> tripsDl;
@ViewComponent
private CollectionContainer<Trip> tripsDc;
@ViewComponent
private CollectionContainer<DailyTrip> dailyTripsDc;
@ViewComponent
private CollectionLoader<DailyTrip> dailyTripsDl;
@Autowired
DashBoardService dashBoardService;
@Subscribe
public void onInit(final InitEvent event) {
tripsDl.setParameter("date", LocalDate.now());
}
@Subscribe
public void onBeforeShow(final BeforeShowEvent event) {
tripsDl.load();
refreshTrips();
}
@Subscribe("timer")
protected void onTimerTick(Timer.TimerActionEvent event) {
refreshTrips();
}
public void refreshTrips() {
tripsDc.setItems(Collections.emptyList());
tripsDl.load();
List<DailyTrip> list = new ArrayList<>();
list.addAll(dashBoardService.generateTrips(tripsDc.getItems()));
dailyTripsDc.getMutableItems().addAll(list);
}
And also how do i set the time facet to only run on the mainView’s initialLayout and it should stop when mainView displays other views
Thanks