use of com.epam.ta.reportportal.ws.converter.builders.WidgetBuilder in project service-api by reportportal.
the class ComponentHealthCheckTableEventHandlerTest method getWidget.
private Widget getWidget() {
Widget widget = new Widget();
widget.setId(1L);
widget.setWidgetType("componentHealthCheckTable");
return new WidgetBuilder(widget).addProject(1L).get();
}
use of com.epam.ta.reportportal.ws.converter.builders.WidgetBuilder in project service-api by reportportal.
the class AbstractViewGenerator method generate.
@Transactional
public void generate(boolean refresh, String viewName, Widget widget, Filter launchesFilter, Sort launchesSort, MultiValueMap<String, String> params) {
try {
LOGGER.debug("Widget {} - {}. Generation started", widget.getWidgetType(), widget.getId());
generateView(refresh, viewName, widget, launchesFilter, launchesSort, params);
LOGGER.debug("Widget {} - {}. Generation finished", widget.getWidgetType(), widget.getId());
widgetRepository.save(new WidgetBuilder(widget).addOption(STATE, WidgetState.READY.getValue()).addOption(VIEW_NAME, viewName).addOption(LAST_REFRESH, Date.from(LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant())).get());
LOGGER.debug("Widget {} - {}. State updated to: {}", widget.getWidgetType(), widget.getId(), WidgetOptionUtil.getValueByKey(STATE, widget.getWidgetOptions()));
} catch (Exception exc) {
LOGGER.error("Error during view creation: " + exc.getMessage());
widgetRepository.save(new WidgetBuilder(widget).addOption(STATE, WidgetState.FAILED.getValue()).get());
LOGGER.error("Generation failed. Widget {} - {}. State updated to: {}", widget.getWidgetType(), widget.getId(), WidgetOptionUtil.getValueByKey(STATE, widget.getWidgetOptions()));
}
}
use of com.epam.ta.reportportal.ws.converter.builders.WidgetBuilder in project service-api by reportportal.
the class CreatedMaterializedWidgetStateHandler method handleWidgetState.
@Override
public Map<String, Object> handleWidgetState(Widget widget, MultiValueMap<String, String> params) {
widgetRepository.save(new WidgetBuilder(widget).addOption(STATE, WidgetState.RENDERING.getValue()).get());
eventPublisher.publishEvent(new GenerateWidgetViewEvent(widget.getId(), params));
return emptyMap();
}
use of com.epam.ta.reportportal.ws.converter.builders.WidgetBuilder in project service-api by reportportal.
the class GetWidgetHandlerImpl method getWidgetPreview.
@Override
public Map<String, ?> getWidgetPreview(WidgetPreviewRQ previewRQ, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user) {
WidgetType widgetType = WidgetType.findByName(previewRQ.getWidgetType()).orElseThrow(() -> new ReportPortalException(ErrorType.INCORRECT_REQUEST, formattedSupplier("Unsupported widget type '{}'", previewRQ.getWidgetType())));
List<UserFilter> userFilter = null;
if (CollectionUtils.isNotEmpty(previewRQ.getFilterIds())) {
userFilter = getPermittedFilters(previewRQ.getFilterIds().toArray(Long[]::new), projectDetails, user);
}
if (!unfilteredWidgetTypes.contains(widgetType) && CollectionUtils.isEmpty(userFilter)) {
return Collections.emptyMap();
}
Widget widget = new WidgetBuilder().addWidgetPreviewRq(previewRQ).addProject(projectDetails.getProjectId()).addFilters(userFilter).get();
if (widgetType.isSupportMultilevelStructure()) {
return multilevelLoadContentStrategy.get(widgetType).loadContent(Lists.newArrayList(widget.getContentFields()), buildFilterStrategyMapping.get(widgetType).buildFilter(widget), widget.getWidgetOptions(), null, null, widget.getItemsCount());
} else {
return loadContentStrategy.get(widgetType).loadContent(Lists.newArrayList(widget.getContentFields()), buildFilterStrategyMapping.get(widgetType).buildFilter(widget), widget.getWidgetOptions(), widget.getItemsCount());
}
}
use of com.epam.ta.reportportal.ws.converter.builders.WidgetBuilder in project service-api by reportportal.
the class UpdateWidgetHandlerImpl method updateWidget.
@Override
public OperationCompletionRS updateWidget(Long widgetId, WidgetRQ updateRQ, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user) {
Widget widget = getShareableEntityHandler.getAdministrated(widgetId, projectDetails);
widgetContentFieldsValidator.validate(widget);
if (!widget.getName().equals(updateRQ.getName())) {
BusinessRule.expect(widgetRepository.existsByNameAndOwnerAndProjectId(updateRQ.getName(), user.getUsername(), projectDetails.getProjectId()), BooleanUtils::isFalse).verify(ErrorType.RESOURCE_ALREADY_EXISTS, updateRQ.getName());
}
WidgetActivityResource before = TO_ACTIVITY_RESOURCE.apply(widget);
List<UserFilter> userFilter = getUserFilters(updateRQ.getFilterIds(), projectDetails.getProjectId(), user.getUsername());
String widgetOptionsBefore = parseWidgetOptions(widget);
updateSharing(widget, projectDetails.getProjectId(), updateRQ.getShare());
widget = new WidgetBuilder(widget).addWidgetRq(updateRQ).addFilters(userFilter).get();
widgetRepository.save(widget);
messageBus.publishActivity(new WidgetUpdatedEvent(before, TO_ACTIVITY_RESOURCE.apply(widget), widgetOptionsBefore, parseWidgetOptions(widget), user.getUserId(), user.getUsername()));
return new OperationCompletionRS("Widget with ID = '" + widget.getId() + "' successfully updated.");
}
Aggregations