Search in sources :

Example 1 with ProjectInfoWidget

use of com.epam.ta.reportportal.entity.project.email.ProjectInfoWidget in project service-api by reportportal.

the class GetProjectInfoHandlerImpl method getProjectInfoWidgetContent.

@Override
public Map<String, ?> getProjectInfoWidgetContent(String projectName, String interval, String widgetCode) {
    Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(PROJECT_NOT_FOUND, projectName));
    InfoInterval infoInterval = InfoInterval.findByInterval(interval).orElseThrow(() -> new ReportPortalException(BAD_REQUEST_ERROR, interval));
    ProjectInfoWidget widgetType = ProjectInfoWidget.findByCode(widgetCode).orElseThrow(() -> new ReportPortalException(BAD_REQUEST_ERROR, widgetCode));
    List<Launch> launches = launchRepository.findByProjectIdAndStartTimeGreaterThanAndMode(project.getId(), getStartIntervalDate(infoInterval), LaunchModeEnum.DEFAULT);
    Map<String, ?> result;
    switch(widgetType) {
        case INVESTIGATED:
            result = dataConverter.getInvestigatedProjectInfo(launches, infoInterval);
            break;
        case CASES_STATISTIC:
            result = dataConverter.getTestCasesStatisticsProjectInfo(launches);
            break;
        case LAUNCHES_QUANTITY:
            result = dataConverter.getLaunchesQuantity(launches, infoInterval);
            break;
        case ISSUES_CHART:
            result = dataConverter.getLaunchesIssues(launches, infoInterval);
            break;
        case ACTIVITIES:
            result = getActivities(project, infoInterval);
            break;
        case LAST_LAUNCH:
            result = getLastLaunchStatistics(project.getId());
            break;
        default:
            // empty result
            result = Collections.emptyMap();
    }
    return result;
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) ProjectInfoWidget(com.epam.ta.reportportal.entity.project.email.ProjectInfoWidget) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) InfoInterval(com.epam.ta.reportportal.entity.enums.InfoInterval) Launch(com.epam.ta.reportportal.entity.launch.Launch)

Aggregations

InfoInterval (com.epam.ta.reportportal.entity.enums.InfoInterval)1 Launch (com.epam.ta.reportportal.entity.launch.Launch)1 Project (com.epam.ta.reportportal.entity.project.Project)1 ProjectInfoWidget (com.epam.ta.reportportal.entity.project.email.ProjectInfoWidget)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1