Search in sources :

Example 1 with CmsContentQuery

use of com.publiccms.views.pojo.query.CmsContentQuery in project PublicCMS-preview by sanluan.

the class CmsContentService method delete.

/**
 * @param siteId
 * @param ids
 * @return list of data deleted
 */
@SuppressWarnings("unchecked")
public List<CmsContent> delete(short siteId, Serializable[] ids) {
    List<CmsContent> entityList = new ArrayList<>();
    for (CmsContent entity : getEntitys(ids)) {
        if (siteId == entity.getSiteId() && !entity.isDisabled()) {
            if (0 < entity.getChilds()) {
                for (CmsContent child : (List<CmsContent>) getPage(new CmsContentQuery(siteId, null, null, null, null, null, entity.getId(), null, null, null, null, null, null, null, null), null, null, null, null, null).getList()) {
                    child.setDisabled(true);
                    entityList.add(child);
                }
            }
            entity.setDisabled(true);
            entityList.add(entity);
        }
    }
    return entityList;
}
Also used : CmsContent(com.publiccms.entities.cms.CmsContent) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CmsContentQuery(com.publiccms.views.pojo.query.CmsContentQuery)

Example 2 with CmsContentQuery

use of com.publiccms.views.pojo.query.CmsContentQuery in project PublicCMS-preview by sanluan.

the class MyContentListDirective method execute.

@Override
public void execute(RenderHandler handler, SysApp app, SysUser user) throws IOException, Exception {
    PageHandler page = service.getPage(new CmsContentQuery(getSite(handler).getId(), handler.getIntegerArray("status"), handler.getInteger("categoryId"), handler.getIntegerArray("categoryIds"), false, null, handler.getLong("parentId"), handler.getBoolean("emptyParent"), handler.getBoolean("onlyUrl"), handler.getBoolean("hasImages"), handler.getBoolean("hasFiles"), null, user.getId(), null, handler.getDate("endPublishDate")), handler.getBoolean("containChild"), null, null, handler.getInteger("pageIndex", 1), handler.getInteger("count", 30));
    handler.put("page", page);
}
Also used : PageHandler(com.publiccms.common.handler.PageHandler) CmsContentQuery(com.publiccms.views.pojo.query.CmsContentQuery)

Example 3 with CmsContentQuery

use of com.publiccms.views.pojo.query.CmsContentQuery in project PublicCMS-preview by sanluan.

the class CmsContentListDirective method execute.

@Override
public void execute(RenderHandler handler) throws IOException, Exception {
    CmsContentQuery queryEntity = new CmsContentQuery();
    queryEntity.setSiteId(getSite(handler).getId());
    queryEntity.setEndPublishDate(handler.getDate("endPublishDate"));
    if (handler.getBoolean("advanced", false)) {
        queryEntity.setStatus(handler.getIntegerArray("status"));
        queryEntity.setDisabled(handler.getBoolean("disabled", false));
        queryEntity.setEmptyParent(handler.getBoolean("emptyParent"));
        queryEntity.setTitle(handler.getString("title"));
    } else {
        queryEntity.setStatus(new Integer[] { CmsContentService.STATUS_NORMAL });
        queryEntity.setDisabled(false);
        queryEntity.setEmptyParent(true);
        Date now = CommonUtils.getMinuteDate();
        if (null == queryEntity.getEndPublishDate() || queryEntity.getEndPublishDate().after(now)) {
            queryEntity.setEndPublishDate(now);
        }
    }
    queryEntity.setCategoryId(handler.getInteger("categoryId"));
    queryEntity.setCategoryIds(handler.getIntegerArray("categoryIds"));
    queryEntity.setModelIds(handler.getStringArray("modelId"));
    queryEntity.setParentId(handler.getLong("parentId"));
    queryEntity.setOnlyUrl(handler.getBoolean("onlyUrl"));
    queryEntity.setHasImages(handler.getBoolean("hasImages"));
    queryEntity.setHasFiles(handler.getBoolean("hasFiles"));
    queryEntity.setUserId(handler.getLong("userId"));
    queryEntity.setStartPublishDate(handler.getDate("startPublishDate"));
    PageHandler page = service.getPage(queryEntity, handler.getBoolean("containChild"), handler.getString("orderField"), handler.getString("orderType"), handler.getInteger("pageIndex", 1), handler.getInteger("count", 30));
    handler.put("page", page).render();
}
Also used : PageHandler(com.publiccms.common.handler.PageHandler) CmsContentQuery(com.publiccms.views.pojo.query.CmsContentQuery) Date(java.util.Date)

Example 4 with CmsContentQuery

use of com.publiccms.views.pojo.query.CmsContentQuery in project PublicCMS-preview by sanluan.

the class CmsContentService method recycle.

/**
 * @param siteId
 * @param ids
 * @return list of data deleted
 */
@SuppressWarnings("unchecked")
public List<CmsContent> recycle(short siteId, Serializable[] ids) {
    List<CmsContent> entityList = new ArrayList<>();
    for (CmsContent entity : getEntitys(ids)) {
        if (siteId == entity.getSiteId() && entity.isDisabled()) {
            if (0 < entity.getChilds()) {
                for (CmsContent child : (List<CmsContent>) getPage(new CmsContentQuery(siteId, null, null, null, null, null, entity.getId(), null, null, null, null, null, null, null, null), false, null, null, null, null).getList()) {
                    child.setDisabled(false);
                    entityList.add(child);
                }
            }
            entity.setDisabled(false);
            entityList.add(entity);
        }
    }
    return entityList;
}
Also used : CmsContent(com.publiccms.entities.cms.CmsContent) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CmsContentQuery(com.publiccms.views.pojo.query.CmsContentQuery)

Aggregations

CmsContentQuery (com.publiccms.views.pojo.query.CmsContentQuery)4 PageHandler (com.publiccms.common.handler.PageHandler)2 CmsContent (com.publiccms.entities.cms.CmsContent)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Date (java.util.Date)1