Search in sources :

Example 1 with PublishingDashboardItem

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

the class DashboardServiceImpl method preparePublishingResult.

private List<PublishingDashboardItem> preparePublishingResult(List<PublishingHistoryItem> publishingHistory) {
    List<PublishingDashboardItem> publishingDashboardItems = new ArrayList<PublishingDashboardItem>();
    for (PublishingHistoryItem historyItem : publishingHistory) {
        PublishingDashboardItem dashboardItem = new PublishingDashboardItem();
        ItemMetadata itemMetadata = objectMetadataManager.getProperties(historyItem.getSiteId(), historyItem.getPath());
        dashboardItem.setSiteId(historyItem.getSiteId());
        dashboardItem.setPath(historyItem.getPath());
        dashboardItem.setLabel(itemMetadata.getName());
        dashboardItem.setEnvironment(historyItem.getEnvironment());
        dashboardItem.setPublishedDate(historyItem.getPublishedDate());
        dashboardItem.setPublisher(historyItem.getPublisher());
        publishingDashboardItems.add(dashboardItem);
    }
    return publishingDashboardItems;
}
Also used : PublishingDashboardItem(org.craftercms.studio.model.rest.dashboard.PublishingDashboardItem) ArrayList(java.util.ArrayList) PublishingHistoryItem(org.craftercms.studio.api.v2.dal.PublishingHistoryItem) ItemMetadata(org.craftercms.studio.api.v1.dal.ItemMetadata)

Example 2 with PublishingDashboardItem

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

the class PublishServiceImpl method preparePublishingResult.

private List<PublishingDashboardItem> preparePublishingResult(List<PublishingHistoryItem> publishingHistory) {
    List<PublishingDashboardItem> publishingDashboardItems = new ArrayList<PublishingDashboardItem>();
    for (PublishingHistoryItem historyItem : publishingHistory) {
        PublishingDashboardItem dashboardItem = new PublishingDashboardItem();
        ItemMetadata itemMetadata = objectMetadataManager.getProperties(historyItem.getSiteId(), historyItem.getPath());
        dashboardItem.setSiteId(historyItem.getSiteId());
        dashboardItem.setPath(historyItem.getPath());
        dashboardItem.setLabel(itemMetadata.getName());
        dashboardItem.setEnvironment(historyItem.getEnvironment());
        dashboardItem.setPublishedDate(historyItem.getPublishedDate());
        dashboardItem.setPublisher(historyItem.getPublisher());
        publishingDashboardItems.add(dashboardItem);
    }
    return publishingDashboardItems;
}
Also used : PublishingDashboardItem(org.craftercms.studio.model.rest.dashboard.PublishingDashboardItem) ArrayList(java.util.ArrayList) PublishingHistoryItem(org.craftercms.studio.api.v2.dal.PublishingHistoryItem) ItemMetadata(org.craftercms.studio.api.v1.dal.ItemMetadata)

Example 3 with PublishingDashboardItem

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

the class DashboardController method getPublishingDashboard.

@GetMapping(value = PUBLISHING_DASHBOARD, produces = APPLICATION_JSON_VALUE)
public ResponseBody getPublishingDashboard(@Valid PublishingDashboardRequestParameters requestParameters) {
    String user = null;
    String environment = null;
    String path = null;
    ZonedDateTime dateFrom = null;
    ZonedDateTime dateTo = null;
    String contentType = null;
    long state = 0;
    if (requestParameters.getFilters() != null) {
        user = requestParameters.getFilters().getPublisher();
        path = requestParameters.getFilters().getPath();
        environment = requestParameters.getFilters().getEnvironment();
        dateFrom = requestParameters.getFilters().getPublishedDateFrom();
        dateTo = requestParameters.getFilters().getPublishedDateTo();
        contentType = requestParameters.getFilters().getContentType();
    }
    int total = 0;
    List<PublishingDashboardItem> publishingHistory = dashboardService.getPublishingHistory(requestParameters.getSiteId(), environment, path, user, dateFrom, dateTo, contentType, state, requestParameters.getSortBy(), requestParameters.getOrder(), requestParameters.getOffset(), requestParameters.getLimit());
    ResponseBody responseBody = new ResponseBody();
    PaginatedResultList<PublishingDashboardItem> result = new PaginatedResultList<PublishingDashboardItem>();
    result.setTotal(total);
    result.setLimit(CollectionUtils.isEmpty(publishingHistory) ? 0 : publishingHistory.size());
    result.setOffset(requestParameters.getOffset());
    result.setEntities(RESULT_KEY_ITEMS, publishingHistory);
    result.setResponse(OK);
    responseBody.setResult(result);
    return responseBody;
}
Also used : PublishingDashboardItem(org.craftercms.studio.model.rest.dashboard.PublishingDashboardItem) ZonedDateTime(java.time.ZonedDateTime) PaginatedResultList(org.craftercms.studio.model.rest.PaginatedResultList) ResponseBody(org.craftercms.studio.model.rest.ResponseBody) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

PublishingDashboardItem (org.craftercms.studio.model.rest.dashboard.PublishingDashboardItem)3 ArrayList (java.util.ArrayList)2 ItemMetadata (org.craftercms.studio.api.v1.dal.ItemMetadata)2 PublishingHistoryItem (org.craftercms.studio.api.v2.dal.PublishingHistoryItem)2 ZonedDateTime (java.time.ZonedDateTime)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