Search in sources :

Example 1 with ContentDashboardItem

use of org.craftercms.studio.model.rest.dashboard.ContentDashboardItem in project studio by craftercms.

the class DashboardServiceImpl method prepareContentDashboardResult.

private List<ContentDashboardItem> prepareContentDashboardResult(List<ItemMetadata> itemMetadataList) {
    List<ContentDashboardItem> contentDashboardItemList = new ArrayList<ContentDashboardItem>();
    if (itemMetadataList != null && itemMetadataList.size() > 0) {
        for (ItemMetadata item : itemMetadataList) {
            ContentDashboardItem contentDashboardItem = new ContentDashboardItem();
            contentDashboardItem.setSiteId(item.getSite());
            contentDashboardItem.setPath(item.getPath());
            contentDashboardItem.setLabel(item.getName());
            contentDashboardItem.setModifier(item.getModifier());
            contentDashboardItem.setModifiedDate(item.getModified());
            contentDashboardItemList.add(contentDashboardItem);
        }
    }
    return contentDashboardItemList;
}
Also used : ArrayList(java.util.ArrayList) ContentDashboardItem(org.craftercms.studio.model.rest.dashboard.ContentDashboardItem) ItemMetadata(org.craftercms.studio.api.v1.dal.ItemMetadata)

Example 2 with ContentDashboardItem

use of org.craftercms.studio.model.rest.dashboard.ContentDashboardItem in project studio by craftercms.

the class DashboardController method getContentDashboard.

@GetMapping(value = CONTENT_DASHBOARD, produces = APPLICATION_JSON_VALUE)
public ResponseBody getContentDashboard(@Valid ContentDashboardRequestParameters requestParameters) {
    String modifier = null;
    String path = null;
    ZonedDateTime dateFrom = null;
    ZonedDateTime dateTo = null;
    String contentType = null;
    long state = 0;
    if (requestParameters.getFilters() != null) {
        modifier = requestParameters.getFilters().getModifier();
        path = requestParameters.getFilters().getPath();
        dateFrom = requestParameters.getFilters().getModifiedDateFrom();
        dateTo = requestParameters.getFilters().getModifiedDateTo();
        contentType = requestParameters.getFilters().getContentType();
        state = requestParameters.getFilters().getState();
    }
    int total = dashboardService.getContentDashboardTotal(requestParameters.getSiteId(), path, modifier, contentType, state, dateFrom, dateTo);
    List<ContentDashboardItem> contentDashboardItems = dashboardService.getContentDashboard(requestParameters.getSiteId(), path, modifier, contentType, state, dateFrom, dateTo, requestParameters.getSortBy(), requestParameters.getOrder(), requestParameters.getOffset(), requestParameters.getLimit());
    ResponseBody responseBody = new ResponseBody();
    PaginatedResultList<ContentDashboardItem> result = new PaginatedResultList<ContentDashboardItem>();
    result.setTotal(total);
    result.setLimit(CollectionUtils.isEmpty(contentDashboardItems) ? 0 : contentDashboardItems.size());
    result.setOffset(requestParameters.getOffset());
    result.setEntities(RESULT_KEY_ITEMS, contentDashboardItems);
    result.setResponse(OK);
    responseBody.setResult(result);
    return responseBody;
}
Also used : ZonedDateTime(java.time.ZonedDateTime) ContentDashboardItem(org.craftercms.studio.model.rest.dashboard.ContentDashboardItem) PaginatedResultList(org.craftercms.studio.model.rest.PaginatedResultList) ResponseBody(org.craftercms.studio.model.rest.ResponseBody) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

ContentDashboardItem (org.craftercms.studio.model.rest.dashboard.ContentDashboardItem)2 ZonedDateTime (java.time.ZonedDateTime)1 ArrayList (java.util.ArrayList)1 ItemMetadata (org.craftercms.studio.api.v1.dal.ItemMetadata)1 PaginatedResultList (org.craftercms.studio.model.rest.PaginatedResultList)1 ResponseBody (org.craftercms.studio.model.rest.ResponseBody)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1