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;
}
Aggregations