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