Example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY

List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY.

Prototype

int STATUS_ANY

To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY.

Click Source Link

Usage

From source file:com.liferay.journal.service.test.JournalArticleServiceTest.java

License:Open Source License

protected List<JournalArticle> createArticlesWithKeyword(int count) throws Exception {

    _keyword = RandomTestUtil.randomString();

    List<JournalArticle> articles = searchArticlesByKeyword(_keyword, WorkflowConstants.STATUS_ANY);

    if (articles.isEmpty()) {
        return addArticles(count, _keyword);
    } else {//ww w  . ja va  2s  . c o  m
        createArticlesWithKeyword(count);
    }

    return null;
}

From source file:com.liferay.journal.web.asset.JournalArticleAssetRendererFactory.java

License:Open Source License

@Override
public AssetRenderer<JournalArticle> getAssetRenderer(long classPK, int type) throws PortalException {

    JournalArticle article = _journalArticleLocalService.fetchJournalArticle(classPK);

    if (article == null) {
        JournalArticleResource articleResource = _journalArticleResourceLocalService
                .getArticleResource(classPK);

        if (type == TYPE_LATEST_APPROVED) {
            article = _journalArticleLocalService.fetchDisplayArticle(articleResource.getGroupId(),
                    articleResource.getArticleId());
        }//from   w  w w .ja v a2 s .co  m

        if (article == null) {
            article = _journalArticleLocalService.fetchLatestArticle(articleResource.getGroupId(),
                    articleResource.getArticleId(), WorkflowConstants.STATUS_ANY);
        }

        if ((article == null) && (type == TYPE_LATEST)) {
            article = _journalArticleLocalService.fetchLatestArticle(classPK, WorkflowConstants.STATUS_ANY);
        }
    }

    JournalArticleAssetRenderer journalArticleAssetRenderer = getJournalArticleAssetRenderer(article);

    journalArticleAssetRenderer.setAssetRendererType(type);

    return journalArticleAssetRenderer;
}

From source file:com.liferay.journal.web.internal.display.context.JournalDisplayContext.java

License:Open Source License

public List<ManagementBarFilterItem> getManagementBarStatusFilterItems()
        throws PortalException, PortletException {

    List<ManagementBarFilterItem> managementBarFilterItems = new ArrayList<>();

    managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_ANY));
    managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_DRAFT));

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    int workflowDefinitionLinksCount = WorkflowDefinitionLinkLocalServiceUtil.getWorkflowDefinitionLinksCount(
            themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId(), JournalFolder.class.getName());

    if (workflowDefinitionLinksCount > 0) {
        managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_PENDING));
        managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_DENIED));
    }//from   ww  w . j a  v  a  2s . c om

    managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_SCHEDULED));
    managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_APPROVED));
    managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_EXPIRED));

    return managementBarFilterItems;
}

From source file:com.liferay.journal.web.internal.display.context.JournalDisplayContext.java

License:Open Source License

public SearchContainer getSearchContainer(boolean showVersions) throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    SearchContainer articleSearchContainer = new SearchContainer(_liferayPortletRequest, getPortletURL(), null,
            null);/*from w w  w  . ja  va  2 s.  c  o m*/

    if (!isSearch()) {
        articleSearchContainer
                .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
    } else {
        articleSearchContainer.setSearch(true);
    }

    OrderByComparator<JournalArticle> orderByComparator = JournalPortletUtil
            .getArticleOrderByComparator(getOrderByCol(), getOrderByType());

    articleSearchContainer.setOrderByCol(getOrderByCol());
    articleSearchContainer.setOrderByComparator(orderByComparator);
    articleSearchContainer.setOrderByType(getOrderByType());

    EntriesChecker entriesChecker = new EntriesChecker(_liferayPortletRequest, _liferayPortletResponse);

    entriesChecker.setCssClass("entry-selector");
    entriesChecker.setRememberCheckBoxStateURLRegex(
            "^(?!.*" + _liferayPortletResponse.getNamespace() + "redirect).*(folderId=" + getFolderId() + ")");

    articleSearchContainer.setRowChecker(entriesChecker);

    EntriesMover entriesMover = new EntriesMover(themeDisplay.getScopeGroupId());

    articleSearchContainer.setRowMover(entriesMover);

    if (isNavigationMine() || isNavigationRecent()) {
        boolean includeOwner = true;

        if (isNavigationMine()) {
            includeOwner = false;
        }

        if (isNavigationRecent()) {
            articleSearchContainer.setOrderByCol("create-date");
            articleSearchContainer.setOrderByType(getOrderByType());
        }

        int total = JournalArticleServiceUtil.getGroupArticlesCount(themeDisplay.getScopeGroupId(),
                themeDisplay.getUserId(), getFolderId(), getStatus(), includeOwner);

        articleSearchContainer.setTotal(total);

        List results = JournalArticleServiceUtil.getGroupArticles(themeDisplay.getScopeGroupId(),
                themeDisplay.getUserId(), getFolderId(), getStatus(), includeOwner,
                articleSearchContainer.getStart(), articleSearchContainer.getEnd(),
                articleSearchContainer.getOrderByComparator());

        articleSearchContainer.setResults(results);
    } else if (Validator.isNotNull(getDDMStructureKey())) {
        int total = JournalArticleServiceUtil.getArticlesCountByStructureId(themeDisplay.getScopeGroupId(),
                getDDMStructureKey(), getStatus());

        articleSearchContainer.setTotal(total);

        List results = JournalArticleServiceUtil.getArticlesByStructureId(themeDisplay.getScopeGroupId(),
                getDDMStructureKey(), getStatus(), articleSearchContainer.getStart(),
                articleSearchContainer.getEnd(), articleSearchContainer.getOrderByComparator());

        articleSearchContainer.setResults(results);
    } else if (Validator.isNotNull(getDDMTemplateKey())) {
        List<Long> folderIds = new ArrayList<>(1);

        if (getFolderId() != JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

            folderIds.add(getFolderId());
        }

        int total = JournalArticleServiceUtil.searchCount(themeDisplay.getCompanyId(),
                themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(), null);

        articleSearchContainer.setTotal(total);

        List results = JournalArticleServiceUtil.search(themeDisplay.getCompanyId(),
                themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(), null,
                articleSearchContainer.getStart(), articleSearchContainer.getEnd(),
                articleSearchContainer.getOrderByComparator());

        articleSearchContainer.setResults(results);
    } else if (isSearch()) {
        List<Long> folderIds = new ArrayList<>(1);

        if (getFolderId() != JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

            folderIds.add(getFolderId());
        }

        JournalWebConfiguration journalWebConfiguration = (JournalWebConfiguration) _request
                .getAttribute(JournalWebConfiguration.class.getName());

        if (journalWebConfiguration.journalArticlesSearchWithIndex()) {
            boolean orderByAsc = false;

            if (Objects.equals(getOrderByType(), "asc")) {
                orderByAsc = true;
            }

            Sort sort = null;

            if (Objects.equals(getOrderByCol(), "display-date")) {
                sort = new Sort("displayDate", Sort.LONG_TYPE, orderByAsc);
            } else if (Objects.equals(getOrderByCol(), "id")) {
                sort = new Sort(DocumentImpl.getSortableFieldName(Field.ARTICLE_ID), Sort.STRING_TYPE,
                        !orderByAsc);
            } else if (Objects.equals(getOrderByCol(), "modified-date")) {
                sort = new Sort(Field.MODIFIED_DATE, Sort.LONG_TYPE, orderByAsc);
            } else if (Objects.equals(getOrderByCol(), "title")) {
                sort = new Sort("title", Sort.STRING_TYPE, !orderByAsc);
            }

            LinkedHashMap<String, Object> params = new LinkedHashMap<>();

            params.put("expandoAttributes", getKeywords());

            Indexer indexer = JournalSearcher.getInstance();

            SearchContext searchContext = buildSearchContext(themeDisplay.getCompanyId(),
                    themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                    getDDMStructureKey(), getDDMTemplateKey(), getKeywords(), params,
                    articleSearchContainer.getStart(), articleSearchContainer.getEnd(), sort, showVersions);

            Hits hits = indexer.search(searchContext);

            int total = hits.getLength();

            articleSearchContainer.setTotal(total);

            List results = new ArrayList<>();

            Document[] documents = hits.getDocs();

            for (int i = 0; i < documents.length; i++) {
                Document document = documents[i];

                JournalArticle article = null;
                JournalFolder folder = null;

                String className = document.get(Field.ENTRY_CLASS_NAME);
                long classPK = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));

                if (className.equals(JournalArticle.class.getName())) {
                    if (!showVersions) {
                        article = JournalArticleLocalServiceUtil.fetchLatestArticle(classPK,
                                WorkflowConstants.STATUS_ANY, false);
                    } else {
                        String articleId = document.get(Field.ARTICLE_ID);
                        long groupId = GetterUtil.getLong(document.get(Field.GROUP_ID));
                        double version = GetterUtil.getDouble(document.get(Field.VERSION));

                        article = JournalArticleLocalServiceUtil.fetchArticle(groupId, articleId, version);
                    }

                    results.add(article);
                } else if (className.equals(JournalFolder.class.getName())) {
                    folder = JournalFolderLocalServiceUtil.getFolder(classPK);

                    results.add(folder);
                }
            }

            articleSearchContainer.setResults(results);
        } else {
            int total = JournalArticleServiceUtil.searchCount(themeDisplay.getCompanyId(),
                    themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                    getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(),
                    null);

            articleSearchContainer.setTotal(total);

            List results = JournalArticleServiceUtil.search(themeDisplay.getCompanyId(),
                    themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                    getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(),
                    null, articleSearchContainer.getStart(), articleSearchContainer.getEnd(),
                    articleSearchContainer.getOrderByComparator());

            articleSearchContainer.setResults(results);
        }
    } else {
        int total = JournalFolderServiceUtil.getFoldersAndArticlesCount(themeDisplay.getScopeGroupId(), 0,
                getFolderId(), getStatus());

        articleSearchContainer.setTotal(total);

        OrderByComparator<Object> folderOrderByComparator = null;

        boolean orderByAsc = false;

        if (Objects.equals(getOrderByType(), "asc")) {
            orderByAsc = true;
        }

        if (Objects.equals(getOrderByCol(), "display-date")) {
            folderOrderByComparator = new FolderArticleDisplayDateComparator(orderByAsc);
        } else if (Objects.equals(getOrderByCol(), "id")) {
            folderOrderByComparator = new FolderArticleArticleIdComparator(orderByAsc);
        } else if (Objects.equals(getOrderByCol(), "modified-date")) {
            folderOrderByComparator = new FolderArticleModifiedDateComparator(orderByAsc);
        } else if (Objects.equals(getOrderByCol(), "title")) {
            folderOrderByComparator = new FolderArticleTitleComparator(orderByAsc);
        }

        List results = JournalFolderServiceUtil.getFoldersAndArticles(themeDisplay.getScopeGroupId(), 0,
                getFolderId(), getStatus(), themeDisplay.getLocale(), articleSearchContainer.getStart(),
                articleSearchContainer.getEnd(), folderOrderByComparator);

        articleSearchContainer.setResults(results);
    }

    return articleSearchContainer;
}

From source file:com.liferay.journal.web.internal.display.context.JournalDisplayContext.java

License:Open Source License

public int getStatus() {
    if (_status != null) {
        return _status;
    }/*from  w w  w .j  av a 2  s .com*/

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    int defaultStatus = WorkflowConstants.STATUS_APPROVED;

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (permissionChecker.isContentReviewer(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId())
            || isNavigationMine()) {

        defaultStatus = WorkflowConstants.STATUS_ANY;
    }

    _status = ParamUtil.getInteger(_request, "status", defaultStatus);

    return _status;
}

From source file:com.liferay.journal.web.internal.display.context.JournalDisplayContext.java

License:Open Source License

public boolean isDisabledManagementBar() throws PortalException {
    if (hasResults()) {
        return false;
    }//  www  .j  a  va  2  s . c o m

    if (isSearch()) {
        return false;
    }

    if (!isNavigationHome() || (getStatus() != WorkflowConstants.STATUS_ANY)) {

        return false;
    }

    return true;
}

From source file:com.liferay.journal.web.internal.portlet.action.ActionUtil.java

License:Open Source License

public static JournalArticle getArticle(HttpServletRequest request) throws PortalException {

    String actionName = ParamUtil.getString(request, ActionRequest.ACTION_NAME);

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    long resourcePrimKey = ParamUtil.getLong(request, "resourcePrimKey");
    long groupId = ParamUtil.getLong(request, "groupId", themeDisplay.getScopeGroupId());
    long classNameId = ParamUtil.getLong(request, "classNameId");
    long classPK = ParamUtil.getLong(request, "classPK");
    String articleId = ParamUtil.getString(request, "articleId");
    String ddmStructureKey = ParamUtil.getString(request, "ddmStructureKey");
    int status = ParamUtil.getInteger(request, "status", WorkflowConstants.STATUS_ANY);

    JournalArticle article = null;/*from   w w  w.  j  a  v a 2  s  .  com*/

    if (actionName.equals("addArticle") && (resourcePrimKey != 0)) {
        article = JournalArticleLocalServiceUtil.getLatestArticle(resourcePrimKey, status, false);
    } else if (!actionName.equals("addArticle") && Validator.isNotNull(articleId)) {

        article = JournalArticleServiceUtil.getLatestArticle(groupId, articleId, status);
    } else if ((classNameId > 0) && (classPK > JournalArticleConstants.CLASSNAME_ID_DEFAULT)) {

        String className = PortalUtil.getClassName(classNameId);

        try {
            article = JournalArticleServiceUtil.getLatestArticle(groupId, className, classPK);
        } catch (NoSuchArticleException nsae) {
            return null;
        }
    } else {
        DDMStructure ddmStructure = DDMStructureServiceUtil.fetchStructure(groupId,
                PortalUtil.getClassNameId(JournalArticle.class), ddmStructureKey, true);

        if (ddmStructure == null) {
            return null;
        }

        try {
            article = JournalArticleServiceUtil.getArticle(ddmStructure.getGroupId(),
                    DDMStructure.class.getName(), ddmStructure.getStructureId());

            article.setNew(true);

            article.setId(0);
            article.setGroupId(groupId);
            article.setClassNameId(JournalArticleConstants.CLASSNAME_ID_DEFAULT);
            article.setClassPK(0);
            article.setArticleId(null);
            article.setVersion(0);
        } catch (NoSuchArticleException nsae) {
            return null;
        }
    }

    return article;
}

From source file:com.liferay.JournalArticleAssetRendererFactory.java

License:Open Source License

@Override
public AssetRenderer getAssetRenderer(long classPK, int type) throws PortalException, SystemException {

    JournalArticle article = null;/*  w w w  .j av  a 2s  . co  m*/

    try {
        article = JournalArticleLocalServiceUtil.getArticle(classPK);
    } catch (NoSuchArticleException nsae1) {
        JournalArticleResource articleResource = JournalArticleResourceLocalServiceUtil
                .getArticleResource(classPK);

        boolean approvedArticleAvailable = true;

        if (type == TYPE_LATEST_APPROVED) {
            try {
                article = JournalArticleLocalServiceUtil.getDisplayArticle(articleResource.getGroupId(),
                        articleResource.getArticleId());
            } catch (NoSuchArticleException nsae2) {
                approvedArticleAvailable = false;
            }
        }

        if ((type != TYPE_LATEST_APPROVED) || !approvedArticleAvailable) {
            article = JournalArticleLocalServiceUtil.getLatestArticle(articleResource.getGroupId(),
                    articleResource.getArticleId(), WorkflowConstants.STATUS_ANY);
        }
    }

    JournalArticleAssetRenderer journalArticleAssetRenderer = new JournalArticleAssetRenderer(article);

    journalArticleAssetRenderer.setAssetRendererType(type);

    return journalArticleAssetRenderer;
}

From source file:com.liferay.knowledgebase.admin.asset.KBArticleAssetRendererFactory.java

License:Open Source License

@Override
public AssetRenderer getAssetRenderer(long classPK, int type) throws PortalException {

    KBArticle kbArticle = null;/*  www  .j a  v  a 2 s.c  o  m*/

    if (type == TYPE_LATEST_APPROVED) {
        kbArticle = KBArticleLocalServiceUtil.getLatestKBArticle(classPK, WorkflowConstants.STATUS_APPROVED);
    } else {
        try {
            kbArticle = KBArticleLocalServiceUtil.getKBArticle(classPK);
        } catch (NoSuchArticleException nsae) {
            kbArticle = KBArticleLocalServiceUtil.getLatestKBArticle(classPK, WorkflowConstants.STATUS_ANY);
        }
    }

    KBArticleAssetRenderer kbArticleAssetRenderer = new KBArticleAssetRenderer(kbArticle);

    kbArticleAssetRenderer.setAssetRendererType(type);

    return kbArticleAssetRenderer;
}

From source file:com.liferay.knowledgebase.admin.importer.PrioritizationStrategy.java

License:Open Source License

public static PrioritizationStrategy create(long groupId, long parentKBFolderId,
        boolean prioritizeByNumericalPrefix) {

    Map<String, List<KBArticle>> existingKBArticlesMap = new HashMap<>();

    List<KBArticle> existingParentKBArticles = KBArticleServiceUtil.getKBArticles(groupId, parentKBFolderId,
            WorkflowConstants.STATUS_ANY, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);

    existingKBArticlesMap.put(StringPool.BLANK, existingParentKBArticles);

    for (KBArticle existingParentKBArticle : existingParentKBArticles) {
        long resourcePrimKey = existingParentKBArticle.getResourcePrimKey();

        List<KBArticle> existingChildKBArticles = KBArticleServiceUtil.getKBArticles(groupId, resourcePrimKey,
                WorkflowConstants.STATUS_ANY, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);

        existingKBArticlesMap.put(existingParentKBArticle.getUrlTitle(), existingChildKBArticles);
    }/*from w w  w .  j a v a  2 s  .c o m*/

    return new PrioritizationStrategy(groupId, parentKBFolderId, prioritizeByNumericalPrefix,
            existingKBArticlesMap);
}