Search in sources :

Example 1 with DashboardBuilder

use of com.epam.ta.reportportal.ws.converter.builders.DashboardBuilder in project service-api by reportportal.

the class CreateDashboardHandlerImpl method createDashboard.

@Override
public EntryCreatedRS createDashboard(ReportPortalUser.ProjectDetails projectDetails, CreateDashboardRQ rq, ReportPortalUser user) {
    BusinessRule.expect(dashboardRepository.existsByNameAndOwnerAndProjectId(rq.getName(), user.getUsername(), projectDetails.getProjectId()), BooleanUtils::isFalse).verify(ErrorType.RESOURCE_ALREADY_EXISTS, rq.getName());
    Dashboard dashboard = new DashboardBuilder().addDashboardRq(rq).addProject(projectDetails.getProjectId()).addOwner(user.getUsername()).get();
    dashboardRepository.save(dashboard);
    aclHandler.initAcl(dashboard, user.getUsername(), projectDetails.getProjectId(), BooleanUtils.isTrue(rq.getShare()));
    messageBus.publishActivity(new DashboardCreatedEvent(TO_ACTIVITY_RESOURCE.apply(dashboard), user.getUserId(), user.getUsername()));
    return new EntryCreatedRS(dashboard.getId());
}
Also used : DashboardCreatedEvent(com.epam.ta.reportportal.core.events.activity.DashboardCreatedEvent) Dashboard(com.epam.ta.reportportal.entity.dashboard.Dashboard) EntryCreatedRS(com.epam.ta.reportportal.ws.model.EntryCreatedRS) DashboardBuilder(com.epam.ta.reportportal.ws.converter.builders.DashboardBuilder)

Example 2 with DashboardBuilder

use of com.epam.ta.reportportal.ws.converter.builders.DashboardBuilder in project service-api by reportportal.

the class UpdateDashboardHandlerImpl method updateDashboard.

@Override
public OperationCompletionRS updateDashboard(ReportPortalUser.ProjectDetails projectDetails, UpdateDashboardRQ rq, Long dashboardId, ReportPortalUser user) {
    Dashboard dashboard = getShareableDashboardHandler.getAdministrated(dashboardId, projectDetails);
    DashboardActivityResource before = TO_ACTIVITY_RESOURCE.apply(dashboard);
    if (!dashboard.getName().equals(rq.getName())) {
        BusinessRule.expect(dashboardRepository.existsByNameAndOwnerAndProjectId(rq.getName(), user.getUsername(), projectDetails.getProjectId()), BooleanUtils::isFalse).verify(ErrorType.RESOURCE_ALREADY_EXISTS, rq.getName());
    }
    dashboard = new DashboardBuilder(dashboard).addUpdateRq(rq).get();
    dashboardRepository.save(dashboard);
    if (before.isShared() != dashboard.isShared()) {
        aclHandler.updateAcl(dashboard, projectDetails.getProjectId(), dashboard.isShared());
        updateWidgetHandler.updateSharing(dashboard.getDashboardWidgets().stream().map(DashboardWidget::getWidget).collect(Collectors.toList()), projectDetails.getProjectId(), dashboard.isShared());
    }
    messageBus.publishActivity(new DashboardUpdatedEvent(before, TO_ACTIVITY_RESOURCE.apply(dashboard), user.getUserId(), user.getUsername()));
    return new OperationCompletionRS("Dashboard with ID = '" + dashboard.getId() + "' successfully updated");
}
Also used : DashboardWidget(com.epam.ta.reportportal.entity.dashboard.DashboardWidget) DashboardActivityResource(com.epam.ta.reportportal.ws.model.activity.DashboardActivityResource) DashboardUpdatedEvent(com.epam.ta.reportportal.core.events.activity.DashboardUpdatedEvent) Dashboard(com.epam.ta.reportportal.entity.dashboard.Dashboard) DashboardBuilder(com.epam.ta.reportportal.ws.converter.builders.DashboardBuilder) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Aggregations

Dashboard (com.epam.ta.reportportal.entity.dashboard.Dashboard)2 DashboardBuilder (com.epam.ta.reportportal.ws.converter.builders.DashboardBuilder)2 DashboardCreatedEvent (com.epam.ta.reportportal.core.events.activity.DashboardCreatedEvent)1 DashboardUpdatedEvent (com.epam.ta.reportportal.core.events.activity.DashboardUpdatedEvent)1 DashboardWidget (com.epam.ta.reportportal.entity.dashboard.DashboardWidget)1 EntryCreatedRS (com.epam.ta.reportportal.ws.model.EntryCreatedRS)1 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)1 DashboardActivityResource (com.epam.ta.reportportal.ws.model.activity.DashboardActivityResource)1