use of com.epam.ta.reportportal.entity.dashboard.DashboardWidget in project service-api by reportportal.
the class UpdateDashboardHandlerImpl method removeWidget.
@Override
public OperationCompletionRS removeWidget(Long widgetId, Long dashboardId, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user) {
Dashboard dashboard = getShareableDashboardHandler.getPermitted(dashboardId, projectDetails);
Widget widget = getShareableWidgetHandler.getPermitted(widgetId, projectDetails);
/*
* if user is an owner of the widget - remove it from all dashboards
* should be replaced with copy
*/
if (user.getUsername().equalsIgnoreCase(widget.getOwner())) {
OperationCompletionRS result = deleteWidget(widget);
messageBus.publishActivity(new WidgetDeletedEvent(WidgetConverter.TO_ACTIVITY_RESOURCE.apply(widget), user.getUserId(), user.getUsername()));
return result;
}
DashboardWidget toRemove = dashboard.getDashboardWidgets().stream().filter(dashboardWidget -> widget.getId().equals(dashboardWidget.getId().getWidgetId())).findFirst().orElseThrow(() -> new ReportPortalException(ErrorType.WIDGET_NOT_FOUND_IN_DASHBOARD, widgetId, dashboardId));
dashboardWidgetRepository.delete(toRemove);
return new OperationCompletionRS("Widget with ID = '" + widget.getId() + "' was successfully removed from the dashboard with ID = '" + dashboard.getId() + "'");
}
use of com.epam.ta.reportportal.entity.dashboard.DashboardWidget in project service-api by reportportal.
the class DemoDashboardsService method createDashboardWidget.
private DashboardWidget createDashboardWidget(String owner, Dashboard dashboard, Widget widget, int posX, int posY, int width, int height) {
DashboardWidget dashboardWidget = new DashboardWidget();
dashboardWidget.setId(new DashboardWidgetId(dashboard.getId(), widget.getId()));
dashboardWidget.setDashboard(dashboard);
dashboardWidget.setWidget(widget);
dashboardWidget.setWidgetName(widget.getName());
dashboardWidget.setWidgetType(widget.getWidgetType());
dashboardWidget.setCreatedOn(true);
dashboardWidget.setWidgetOwner(owner);
dashboardWidget.setHeight(height);
dashboardWidget.setWidth(width);
dashboardWidget.setPositionX(posX);
dashboardWidget.setPositionY(posY);
dashboardWidgetRepository.save(dashboardWidget);
return dashboardWidget;
}
Aggregations