use of de.metas.ui.web.base.model.I_WEBUI_DashboardItem in project metasfresh-webui-api by metasfresh.
the class UserDashboardRepository method changeUserDashboardItemAndSave.
private void changeUserDashboardItemAndSave(final UserDashboardItemChangeRequest request) {
final I_WEBUI_DashboardItem itemPO = InterfaceWrapperHelper.load(request.getItemId(), I_WEBUI_DashboardItem.class);
if (itemPO == null) {
throw new AdempiereException("no item found for itemId=" + request.getItemId());
}
changeUserDashboardItemAndSave(itemPO, request);
}
use of de.metas.ui.web.base.model.I_WEBUI_DashboardItem in project metasfresh-webui-api by metasfresh.
the class UserDashboardRepository method deleteUserDashboardItem.
public void deleteUserDashboardItem(final UserDashboard dashboard, final DashboardWidgetType dashboardWidgetType, final int itemId) {
dashboard.assertItemIdExists(dashboardWidgetType, itemId);
executeChangeActionAndInvalidate(dashboard.getId(), () -> {
final I_WEBUI_DashboardItem item = InterfaceWrapperHelper.load(itemId, I_WEBUI_DashboardItem.class);
InterfaceWrapperHelper.delete(item);
});
}
use of de.metas.ui.web.base.model.I_WEBUI_DashboardItem 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;
}
Aggregations