Search in sources :

Example 1 with I_WEBUI_KPI

use of de.metas.ui.web.base.model.I_WEBUI_KPI in project metasfresh-webui-api by metasfresh.

the class UserDashboardRepository method createUserDashboardItemAndSave.

private int createUserDashboardItemAndSave(final int dashboardId, @NonNull final UserDashboardItemAddRequest request) {
    // 
    // Get the KPI
    final int kpiId = request.getKpiId();
    if (kpiId <= 0) {
        throw new AdempiereException("kpiId is not set").setParameter("request", request);
    }
    final I_WEBUI_KPI kpi = InterfaceWrapperHelper.loadOutOfTrx(kpiId, I_WEBUI_KPI.class);
    final DashboardWidgetType widgetType = request.getWidgetType();
    final int seqNo = retrieveLastSeqNo(dashboardId, widgetType) + 10;
    // 
    final I_WEBUI_DashboardItem webuiDashboardItem = InterfaceWrapperHelper.newInstance(I_WEBUI_DashboardItem.class);
    webuiDashboardItem.setWEBUI_Dashboard_ID(dashboardId);
    webuiDashboardItem.setIsActive(true);
    webuiDashboardItem.setName(kpi.getName());
    webuiDashboardItem.setSeqNo(seqNo);
    webuiDashboardItem.setWEBUI_KPI_ID(kpiId);
    webuiDashboardItem.setWEBUI_DashboardWidgetType(widgetType.getCode());
    // will be set by change request:
    // webuiDashboardItem.setES_TimeRange(esTimeRange);
    // webuiDashboardItem.setES_TimeRange_End(esTimeRangeEnd);
    InterfaceWrapperHelper.save(webuiDashboardItem);
    logger.trace("Created {} for dashboard {}", webuiDashboardItem, dashboardId);
    // Apply the change request
    if (request.getChangeRequest() != null) {
        changeUserDashboardItemAndSave(webuiDashboardItem, request.getChangeRequest());
    }
    final int itemId = webuiDashboardItem.getWEBUI_DashboardItem_ID();
    return itemId;
}
Also used : I_WEBUI_KPI(de.metas.ui.web.base.model.I_WEBUI_KPI) AdempiereException(org.adempiere.exceptions.AdempiereException) I_WEBUI_DashboardItem(de.metas.ui.web.base.model.I_WEBUI_DashboardItem)

Aggregations

I_WEBUI_DashboardItem (de.metas.ui.web.base.model.I_WEBUI_DashboardItem)1 I_WEBUI_KPI (de.metas.ui.web.base.model.I_WEBUI_KPI)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1