Search in sources :

Example 1 with STATE

use of com.epam.ta.reportportal.core.widget.content.updater.MaterializedWidgetStateUpdater.STATE in project service-api by reportportal.

the class MaterializedWidgetProviderHandlerImpl method validateState.

private void validateState(WidgetOptions widgetOptions) {
    WidgetState widgetState = ofNullable(WidgetOptionUtil.getValueByKey(STATE, widgetOptions)).flatMap(WidgetState::findByName).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_UPDATE_WIDGET_REQUEST, "Widget state not provided"));
    BusinessRule.expect(widgetState, it -> !WidgetState.RENDERING.equals(it)).verify(ErrorType.BAD_UPDATE_WIDGET_REQUEST, "Unable to remove widget in 'rendering' state");
}
Also used : WidgetOptions(com.epam.ta.reportportal.entity.widget.WidgetOptions) WidgetState(com.epam.ta.reportportal.entity.widget.WidgetState) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Autowired(org.springframework.beans.factory.annotation.Autowired) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) GetShareableEntityHandler(com.epam.ta.reportportal.core.shareable.GetShareableEntityHandler) Statistics(com.epam.ta.reportportal.entity.statistics.Statistics) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Map(java.util.Map) Pageable(org.springframework.data.domain.Pageable) BusinessRule(com.epam.ta.reportportal.commons.validation.BusinessRule) VIEW_NAME(com.epam.ta.reportportal.core.widget.content.loader.materialized.handler.MaterializedWidgetStateHandler.VIEW_NAME) Optional.ofNullable(java.util.Optional.ofNullable) WidgetOptionUtil(com.epam.ta.reportportal.core.widget.util.WidgetOptionUtil) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Set(java.util.Set) Page(org.springframework.data.domain.Page) WidgetType(com.epam.ta.reportportal.entity.widget.WidgetType) Component(org.springframework.stereotype.Component) Queryable(com.epam.ta.reportportal.commons.querygen.Queryable) Optional(java.util.Optional) Widget(com.epam.ta.reportportal.entity.widget.Widget) DataProviderHandler(com.epam.ta.reportportal.core.item.impl.provider.DataProviderHandler) ControllerUtils(com.epam.ta.reportportal.util.ControllerUtils) STATE(com.epam.ta.reportportal.core.widget.content.updater.MaterializedWidgetStateUpdater.STATE) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) WidgetState(com.epam.ta.reportportal.entity.widget.WidgetState)

Example 2 with STATE

use of com.epam.ta.reportportal.core.widget.content.updater.MaterializedWidgetStateUpdater.STATE in project service-api by reportportal.

the class MaterializedViewContentRemover method validateState.

private void validateState(WidgetOptions widgetOptions) {
    WidgetState widgetState = ofNullable(WidgetOptionUtil.getValueByKey(STATE, widgetOptions)).flatMap(WidgetState::findByName).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_UPDATE_WIDGET_REQUEST, "Widget state not provided"));
    BusinessRule.expect(widgetState, it -> !WidgetState.RENDERING.equals(it)).verify(ErrorType.BAD_UPDATE_WIDGET_REQUEST, "Unable to remove widget in 'rendering' state");
}
Also used : BusinessRule(com.epam.ta.reportportal.commons.validation.BusinessRule) WidgetOptions(com.epam.ta.reportportal.entity.widget.WidgetOptions) WidgetState(com.epam.ta.reportportal.entity.widget.WidgetState) VIEW_NAME(com.epam.ta.reportportal.core.widget.content.loader.materialized.handler.MaterializedWidgetStateHandler.VIEW_NAME) Optional.ofNullable(java.util.Optional.ofNullable) WidgetOptionUtil(com.epam.ta.reportportal.core.widget.util.WidgetOptionUtil) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) WidgetContentRepository(com.epam.ta.reportportal.dao.WidgetContentRepository) WidgetType(com.epam.ta.reportportal.entity.widget.WidgetType) Component(org.springframework.stereotype.Component) Lists(com.google.common.collect.Lists) Widget(com.epam.ta.reportportal.entity.widget.Widget) STATE(com.epam.ta.reportportal.core.widget.content.updater.MaterializedWidgetStateUpdater.STATE) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) WidgetState(com.epam.ta.reportportal.entity.widget.WidgetState)

Aggregations

BusinessRule (com.epam.ta.reportportal.commons.validation.BusinessRule)2 VIEW_NAME (com.epam.ta.reportportal.core.widget.content.loader.materialized.handler.MaterializedWidgetStateHandler.VIEW_NAME)2 STATE (com.epam.ta.reportportal.core.widget.content.updater.MaterializedWidgetStateUpdater.STATE)2 WidgetOptionUtil (com.epam.ta.reportportal.core.widget.util.WidgetOptionUtil)2 Widget (com.epam.ta.reportportal.entity.widget.Widget)2 WidgetOptions (com.epam.ta.reportportal.entity.widget.WidgetOptions)2 WidgetState (com.epam.ta.reportportal.entity.widget.WidgetState)2 WidgetType (com.epam.ta.reportportal.entity.widget.WidgetType)2 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)2 ErrorType (com.epam.ta.reportportal.ws.model.ErrorType)2 Optional.ofNullable (java.util.Optional.ofNullable)2 Component (org.springframework.stereotype.Component)2 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 Queryable (com.epam.ta.reportportal.commons.querygen.Queryable)1 DataProviderHandler (com.epam.ta.reportportal.core.item.impl.provider.DataProviderHandler)1 GetShareableEntityHandler (com.epam.ta.reportportal.core.shareable.GetShareableEntityHandler)1 WidgetContentRepository (com.epam.ta.reportportal.dao.WidgetContentRepository)1 TestItem (com.epam.ta.reportportal.entity.item.TestItem)1 Statistics (com.epam.ta.reportportal.entity.statistics.Statistics)1 ControllerUtils (com.epam.ta.reportportal.util.ControllerUtils)1