Search in sources :

Example 1 with WidgetInfoDto

use of org.entando.entando.aps.system.services.widgettype.model.WidgetInfoDto in project entando-core by entando.

the class WidgetController method getWidgetInfo.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/widgets/{widgetCode}/info", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<WidgetInfoDto>> getWidgetInfo(@PathVariable String widgetCode) {
    logger.trace("getWidgetInfo by code {}", widgetCode);
    WidgetInfoDto info = this.widgetService.getWidgetInfo(widgetCode);
    return new ResponseEntity<>(new SimpleRestResponse<>(info), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) WidgetInfoDto(org.entando.entando.aps.system.services.widgettype.model.WidgetInfoDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl)

Example 2 with WidgetInfoDto

use of org.entando.entando.aps.system.services.widgettype.model.WidgetInfoDto in project entando-core by entando.

the class WidgetService method getWidgetInfo.

@Override
public WidgetInfoDto getWidgetInfo(String widgetCode) {
    try {
        List<IPage> publishedUtilizer = this.getPageManager().getOnlineWidgetUtilizers(widgetCode);
        List<IPage> draftUtilizer = this.getPageManager().getDraftWidgetUtilizers(widgetCode);
        WidgetType type = this.getWidgetManager().getWidgetType(widgetCode);
        WidgetInfoDto info = new WidgetInfoDto();
        info.setCode(widgetCode);
        info.setTitles(type.getTitles());
        publishedUtilizer.stream().forEach(page -> info.addPublishedUtilizer(getWidgetDetails(page, widgetCode)));
        draftUtilizer.stream().forEach(page -> info.addDraftUtilizer(getWidgetDetails(page, widgetCode)));
        return info;
    } catch (ApsSystemException e) {
        logger.error("Failed to load widget info for widgetCode {} ", widgetCode);
        throw new RestServerError("error in loading widget info", e);
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) WidgetInfoDto(org.entando.entando.aps.system.services.widgettype.model.WidgetInfoDto) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 3 with WidgetInfoDto

use of org.entando.entando.aps.system.services.widgettype.model.WidgetInfoDto in project entando-core by entando.

the class WidgetService method getComponentUsageDetails.

@Override
public PagedMetadata<ComponentUsageEntity> getComponentUsageDetails(String componentCode, RestListRequest restListRequest) {
    WidgetInfoDto widgetInfoDto = this.getWidgetInfo(componentCode);
    List<ComponentUsageEntity> totalReferenced = widgetInfoDto.getPublishedUtilizers().stream().map(widgetDetail -> new ComponentUsageEntity(ComponentUsageEntity.TYPE_PAGE, widgetDetail.getPageCode(), IPageService.STATUS_ONLINE)).collect(Collectors.toList());
    List<ComponentUsageEntity> draftReferenced = widgetInfoDto.getDraftUtilizers().stream().map(widgetDetail -> new ComponentUsageEntity(ComponentUsageEntity.TYPE_PAGE, widgetDetail.getPageCode(), IPageService.STATUS_DRAFT)).collect(Collectors.toList());
    totalReferenced.addAll(draftReferenced);
    return pagedMetadataMapper.getPagedResult(restListRequest, totalReferenced);
}
Also used : ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException) ServletContextAware(org.springframework.web.context.ServletContextAware) Arrays(java.util.Arrays) BeanComparator(org.apache.commons.beanutils.BeanComparator) GuiFragment(org.entando.entando.aps.system.services.guifragment.GuiFragment) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ApsProperties(com.agiletec.aps.util.ApsProperties) StringUtils(org.apache.commons.lang3.StringUtils) IPage(com.agiletec.aps.system.services.page.IPage) IPageService(org.entando.entando.aps.system.services.page.IPageService) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) PageDto(org.entando.entando.aps.system.services.page.model.PageDto) RestServerError(org.entando.entando.aps.system.exception.RestServerError) IGroupManager(com.agiletec.aps.system.services.group.IGroupManager) IPageManager(com.agiletec.aps.system.services.page.IPageManager) WidgetInfoDto(org.entando.entando.aps.system.services.widgettype.model.WidgetInfoDto) Widget(com.agiletec.aps.system.services.page.Widget) Service(org.springframework.stereotype.Service) IManager(com.agiletec.aps.system.common.IManager) PagedMetadataMapper(org.entando.entando.web.common.assembler.PagedMetadataMapper) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) GroupServiceUtilizer(org.entando.entando.aps.system.services.group.GroupServiceUtilizer) WidgetRequest(org.entando.entando.web.widget.model.WidgetRequest) Logger(org.slf4j.Logger) WidgetDto(org.entando.entando.aps.system.services.widgettype.model.WidgetDto) PageSearchRequest(org.entando.entando.web.page.model.PageSearchRequest) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ComponentUsageEntity(org.entando.entando.web.component.ComponentUsageEntity) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Collectors(java.util.stream.Collectors) IGuiFragmentManager(org.entando.entando.aps.system.services.guifragment.IGuiFragmentManager) WidgetDetails(org.entando.entando.aps.system.services.widgettype.model.WidgetDetails) List(java.util.List) RestListRequest(org.entando.entando.web.common.model.RestListRequest) GroupUtilizer(com.agiletec.aps.system.services.group.GroupUtilizer) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) WidgetValidator(org.entando.entando.web.widget.validator.WidgetValidator) ServletContext(javax.servlet.ServletContext) IDtoBuilder(org.entando.entando.aps.system.services.IDtoBuilder) BeanUtils(org.springframework.beans.BeanUtils) WidgetInfoDto(org.entando.entando.aps.system.services.widgettype.model.WidgetInfoDto) ComponentUsageEntity(org.entando.entando.web.component.ComponentUsageEntity)

Example 4 with WidgetInfoDto

use of org.entando.entando.aps.system.services.widgettype.model.WidgetInfoDto in project entando-core by entando.

the class WidgetMockHelper method mockWidgetInfoDto.

/**
 */
public static WidgetInfoDto mockWidgetInfoDto() {
    WidgetInfoDto widgetInfoDto = new WidgetInfoDto();
    widgetInfoDto.setCode(WIDGET_1_CODE);
    widgetInfoDto.setPublishedUtilizers(mockPublishedUtilizers());
    widgetInfoDto.setDraftUtilizers(mockDraftUtilizers());
    return widgetInfoDto;
}
Also used : WidgetInfoDto(org.entando.entando.aps.system.services.widgettype.model.WidgetInfoDto)

Aggregations

WidgetInfoDto (org.entando.entando.aps.system.services.widgettype.model.WidgetInfoDto)4 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)2 IPage (com.agiletec.aps.system.services.page.IPage)2 RestServerError (org.entando.entando.aps.system.exception.RestServerError)2 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)1 IManager (com.agiletec.aps.system.common.IManager)1 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)1 GroupUtilizer (com.agiletec.aps.system.services.group.GroupUtilizer)1 IGroupManager (com.agiletec.aps.system.services.group.IGroupManager)1 IPageManager (com.agiletec.aps.system.services.page.IPageManager)1 Widget (com.agiletec.aps.system.services.page.Widget)1 ApsProperties (com.agiletec.aps.util.ApsProperties)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 ServletContext (javax.servlet.ServletContext)1 BeanComparator (org.apache.commons.beanutils.BeanComparator)1 StringUtils (org.apache.commons.lang3.StringUtils)1