Search in sources :

Example 1 with KPIDataResult

use of de.metas.ui.web.dashboard.KPIDataResult in project metasfresh-webui-api by metasfresh.

the class WEBUI_KPI_TestQuery method doIt.

@Override
protected String doIt() throws JsonProcessingException {
    final int kpiId = getRecord_ID();
    if (kpiId <= 0) {
        throw new EntityNotFoundException("@NotFound@ @" + I_WEBUI_KPI.COLUMNNAME_WEBUI_KPI_ID + "@");
    }
    kpisRepo.invalidateKPI(kpiId);
    final KPI kpi = kpisRepo.getKPI(kpiId);
    final TimeRange timeRange = kpi.getTimeRangeDefaults().createTimeRange(p_DateFrom, p_DateTo);
    final KPIDataResult kpiData = KPIDataLoader.newInstance(elasticsearchClient, kpi).setTimeRange(timeRange).setFormatValues(true).assertESTypesExists().retrieveData();
    final String jsonData = jsonObjectMapper.writeValueAsString(kpiData);
    log.info("jsonData:\n {}", jsonData);
    return jsonData;
}
Also used : TimeRange(de.metas.ui.web.dashboard.TimeRange) I_WEBUI_KPI(de.metas.ui.web.base.model.I_WEBUI_KPI) KPI(de.metas.ui.web.dashboard.KPI) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) KPIDataResult(de.metas.ui.web.dashboard.KPIDataResult)

Aggregations

I_WEBUI_KPI (de.metas.ui.web.base.model.I_WEBUI_KPI)1 KPI (de.metas.ui.web.dashboard.KPI)1 KPIDataResult (de.metas.ui.web.dashboard.KPIDataResult)1 TimeRange (de.metas.ui.web.dashboard.TimeRange)1 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)1