Search in sources :

Example 11 with DashboardWidget

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() + "'");
}
Also used : DashboardWidget(com.epam.ta.reportportal.entity.dashboard.DashboardWidget) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) DashboardWidget(com.epam.ta.reportportal.entity.dashboard.DashboardWidget) Widget(com.epam.ta.reportportal.entity.widget.Widget) WidgetDeletedEvent(com.epam.ta.reportportal.core.events.activity.WidgetDeletedEvent) Dashboard(com.epam.ta.reportportal.entity.dashboard.Dashboard) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Example 12 with DashboardWidget

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;
}
Also used : DashboardWidget(com.epam.ta.reportportal.entity.dashboard.DashboardWidget) DashboardWidgetId(com.epam.ta.reportportal.entity.dashboard.DashboardWidgetId)

Aggregations

DashboardWidget (com.epam.ta.reportportal.entity.dashboard.DashboardWidget)12 Dashboard (com.epam.ta.reportportal.entity.dashboard.Dashboard)9 Widget (com.epam.ta.reportportal.entity.widget.Widget)6 DashboardWidgetId (com.epam.ta.reportportal.entity.dashboard.DashboardWidgetId)5 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)4 UpdateDashboardRQ (com.epam.ta.reportportal.ws.model.dashboard.UpdateDashboardRQ)3 Test (org.junit.jupiter.api.Test)3 ShareableObjectsHandler (com.epam.ta.reportportal.auth.acl.ShareableObjectsHandler)2 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2 MessageBus (com.epam.ta.reportportal.core.events.MessageBus)2 DashboardUpdatedEvent (com.epam.ta.reportportal.core.events.activity.DashboardUpdatedEvent)2 WidgetDeletedEvent (com.epam.ta.reportportal.core.events.activity.WidgetDeletedEvent)2 GetShareableEntityHandler (com.epam.ta.reportportal.core.shareable.GetShareableEntityHandler)2 WidgetContentRemover (com.epam.ta.reportportal.core.widget.content.remover.WidgetContentRemover)2 DashboardRepository (com.epam.ta.reportportal.dao.DashboardRepository)2 DashboardWidgetRepository (com.epam.ta.reportportal.dao.DashboardWidgetRepository)2 WidgetRepository (com.epam.ta.reportportal.dao.WidgetRepository)2 Project (com.epam.ta.reportportal.entity.project.Project)2 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)2 DashboardBuilder (com.epam.ta.reportportal.ws.converter.builders.DashboardBuilder)2