Search in sources :

Example 1 with DashboardWidgetId

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

Example 2 with DashboardWidgetId

use of com.epam.ta.reportportal.entity.dashboard.DashboardWidgetId 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;
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) DashboardWidget(com.epam.ta.reportportal.entity.dashboard.DashboardWidget) Widget(com.epam.ta.reportportal.entity.widget.Widget) DashboardWidget(com.epam.ta.reportportal.entity.dashboard.DashboardWidget) Dashboard(com.epam.ta.reportportal.entity.dashboard.Dashboard) DashboardWidgetId(com.epam.ta.reportportal.entity.dashboard.DashboardWidgetId)

Example 3 with DashboardWidgetId

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

Example 4 with DashboardWidgetId

use of com.epam.ta.reportportal.entity.dashboard.DashboardWidgetId in project service-api by reportportal.

the class DashboardBuilderTest method updateDashboard.

@Test
void updateDashboard() {
    final String name = "name";
    final String description = "description";
    final boolean share = true;
    UpdateDashboardRQ updateDashboardRQ = new UpdateDashboardRQ();
    updateDashboardRQ.setName(name);
    updateDashboardRQ.setDescription(description);
    updateDashboardRQ.setShare(share);
    updateDashboardRQ.setWidgets(Collections.singletonList(new DashboardResource.WidgetObjectModel("kek", 1L, new Size(10, 20), new Position(30, 40))));
    DashboardWidget dashboardWidget = new DashboardWidget();
    dashboardWidget.setHeight(5);
    dashboardWidget.setWidth(10);
    dashboardWidget.setPositionX(1);
    dashboardWidget.setPositionY(2);
    dashboardWidget.setId(new DashboardWidgetId(1L, 1L));
    final Dashboard existDashboard = new Dashboard();
    existDashboard.addWidget(dashboardWidget);
    final Dashboard dashboard = new DashboardBuilder(existDashboard).addUpdateRq(updateDashboardRQ).get();
    assertEquals(name, dashboard.getName());
    assertEquals(description, dashboard.getDescription());
    assertEquals(share, dashboard.isShared());
}
Also used : DashboardWidget(com.epam.ta.reportportal.entity.dashboard.DashboardWidget) Position(com.epam.ta.reportportal.ws.model.Position) Size(com.epam.ta.reportportal.ws.model.Size) Dashboard(com.epam.ta.reportportal.entity.dashboard.Dashboard) UpdateDashboardRQ(com.epam.ta.reportportal.ws.model.dashboard.UpdateDashboardRQ) DashboardWidgetId(com.epam.ta.reportportal.entity.dashboard.DashboardWidgetId) Test(org.junit.jupiter.api.Test)

Example 5 with DashboardWidgetId

use of com.epam.ta.reportportal.entity.dashboard.DashboardWidgetId 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)5 DashboardWidgetId (com.epam.ta.reportportal.entity.dashboard.DashboardWidgetId)5 Dashboard (com.epam.ta.reportportal.entity.dashboard.Dashboard)3 Widget (com.epam.ta.reportportal.entity.widget.Widget)2 Project (com.epam.ta.reportportal.entity.project.Project)1 Position (com.epam.ta.reportportal.ws.model.Position)1 Size (com.epam.ta.reportportal.ws.model.Size)1 UpdateDashboardRQ (com.epam.ta.reportportal.ws.model.dashboard.UpdateDashboardRQ)1 Test (org.junit.jupiter.api.Test)1