use of com.epam.ta.reportportal.entity.dashboard.DashboardWidget in project service-api by reportportal.
the class DashboardBuilder method addUpdateRq.
public DashboardBuilder addUpdateRq(UpdateDashboardRQ rq) {
Optional.ofNullable(rq.getName()).ifPresent(name -> dashboard.setName(name));
Optional.ofNullable(rq.getDescription()).ifPresent(description -> dashboard.setDescription(description));
Optional.ofNullable(rq.getShare()).ifPresent(share -> dashboard.setShared(share));
Optional.ofNullable(rq.getWidgets()).ifPresent(widgets -> {
for (DashboardWidget dashboardWidget : dashboard.getDashboardWidgets()) {
widgets.stream().filter(updWidget -> Objects.equals(dashboardWidget.getId().getWidgetId(), updWidget.getWidgetId())).forEach(updWidget -> {
ofNullable(updWidget.getWidgetPosition()).ifPresent(position -> {
dashboardWidget.setPositionX(position.getX());
dashboardWidget.setPositionY(position.getY());
});
ofNullable(updWidget.getWidgetSize()).ifPresent(size -> {
dashboardWidget.setWidth(size.getWidth());
dashboardWidget.setHeight(size.getHeight());
});
});
}
});
return this;
}
use of com.epam.ta.reportportal.entity.dashboard.DashboardWidget in project service-api by reportportal.
the class WidgetConverter method toDashboardWidget.
/**
* Creates many-to-many object representation of dashboards and widgets
*
* @param model Widget model object
* @param dashboard Dashboard
* @param widget Widget
* @return many-to-many object representation
*/
public static DashboardWidget toDashboardWidget(DashboardResource.WidgetObjectModel model, Dashboard dashboard, Widget widget, boolean isCreatedOn) {
DashboardWidgetId id = new DashboardWidgetId();
id.setDashboardId(dashboard.getId());
id.setWidgetId(model.getWidgetId());
DashboardWidget dashboardWidget = new DashboardWidget();
dashboardWidget.setId(id);
dashboardWidget.setWidgetType(widget.getWidgetType());
dashboardWidget.setWidgetName(widget.getName());
dashboardWidget.setPositionX(model.getWidgetPosition().getX());
dashboardWidget.setPositionY(model.getWidgetPosition().getY());
dashboardWidget.setWidth(model.getWidgetSize().getWidth());
dashboardWidget.setHeight(model.getWidgetSize().getHeight());
dashboardWidget.setDashboard(dashboard);
dashboardWidget.setShare(widget.isShared());
dashboardWidget.setWidget(widget);
dashboardWidget.setCreatedOn(isCreatedOn);
dashboardWidget.setWidgetOwner(widget.getOwner());
return dashboardWidget;
}
use of com.epam.ta.reportportal.entity.dashboard.DashboardWidget in project service-api by reportportal.
the class DashboardConverterTest method getDashboard.
private static Dashboard getDashboard() {
Dashboard dashboard = new Dashboard();
dashboard.setId(1L);
dashboard.setName("name");
dashboard.setDescription("description");
dashboard.setCreationDate(LocalDateTime.now());
dashboard.setOwner("owner");
final Project project = new Project();
project.setId(2L);
dashboard.setProject(project);
dashboard.setShared(true);
final DashboardWidget dashboardWidget = new DashboardWidget();
dashboardWidget.setId(new DashboardWidgetId(1L, 3L));
dashboardWidget.setPositionY(2);
dashboardWidget.setPositionX(3);
dashboardWidget.setWidth(5);
dashboardWidget.setHeight(6);
dashboardWidget.setWidgetName("widgetName");
dashboardWidget.setDashboard(dashboard);
final Widget widget = new Widget();
dashboardWidget.setWidget(widget);
dashboard.addWidget(dashboardWidget);
return dashboard;
}
use of com.epam.ta.reportportal.entity.dashboard.DashboardWidget in project service-api by reportportal.
the class DeleteDashboardHandlerImpl method deleteDashboard.
@Override
public OperationCompletionRS deleteDashboard(Long dashboardId, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user) {
Dashboard dashboard = getShareableEntityHandler.getAdministrated(dashboardId, projectDetails);
Set<DashboardWidget> dashboardWidgets = dashboard.getDashboardWidgets();
List<Widget> widgets = dashboardWidgets.stream().filter(DashboardWidget::isCreatedOn).map(DashboardWidget::getWidget).peek(aclHandler::deleteAclForObject).peek(widget -> widgetContentRemovers.forEach(remover -> remover.removeContent(widget))).collect(Collectors.toList());
dashboardWidgets.addAll(widgets.stream().flatMap(w -> w.getDashboardWidgets().stream()).collect(toSet()));
aclHandler.deleteAclForObject(dashboard);
dashboardWidgetRepository.deleteAll(dashboardWidgets);
dashboardRepository.delete(dashboard);
widgetRepository.deleteAll(widgets);
messageBus.publishActivity(new DashboardDeletedEvent(TO_ACTIVITY_RESOURCE.apply(dashboard), user.getUserId(), user.getUsername()));
return new OperationCompletionRS("Dashboard with ID = '" + dashboardId + "' successfully deleted.");
}
use of com.epam.ta.reportportal.entity.dashboard.DashboardWidget in project service-api by reportportal.
the class WidgetConverterTest method getDashboardWIdget.
private static DashboardWidget getDashboardWIdget() {
final DashboardWidget dashboardWidget = new DashboardWidget();
final Widget widget = new Widget();
widget.setId(1L);
dashboardWidget.setWidget(widget);
final Dashboard dashboard = new Dashboard();
dashboard.setId(2L);
dashboardWidget.setId(new DashboardWidgetId(dashboard.getId(), widget.getId()));
dashboardWidget.setDashboard(dashboard);
dashboardWidget.setPositionX(2);
dashboardWidget.setPositionY(4);
dashboardWidget.setHeight(5);
dashboardWidget.setWidth(6);
return dashboardWidget;
}
Aggregations