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

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

Introduction

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

Prototype

int STATUS_APPROVED

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

Click Source Link

Usage

From source file:com.liferay.journal.util.impl.JournalUtil.java

License:Open Source License

/**
 * @deprecated As of 4.0.0, with no direct replacement
 *///from   www  . ja v  a2s.c o m
@Deprecated
public static List<JournalArticle> getArticles(Hits hits) throws PortalException {

    List<com.liferay.portal.kernel.search.Document> documents = hits.toList();

    List<JournalArticle> articles = new ArrayList<>(documents.size());

    for (com.liferay.portal.kernel.search.Document document : documents) {
        String articleId = document.get(Field.ARTICLE_ID);
        long groupId = GetterUtil.getLong(document.get(Field.SCOPE_GROUP_ID));

        JournalArticle article = JournalArticleLocalServiceUtil.fetchLatestArticle(groupId, articleId,
                WorkflowConstants.STATUS_APPROVED);

        if (article == null) {
            articles = null;

            Indexer<JournalArticle> indexer = IndexerRegistryUtil.getIndexer(JournalArticle.class);

            long companyId = GetterUtil.getLong(document.get(Field.COMPANY_ID));

            indexer.delete(companyId, document.getUID());
        } else if (articles != null) {
            articles.add(article);
        }
    }

    return articles;
}

From source file:com.liferay.journal.util.impl.JournalUtil.java

License:Open Source License

public static boolean isHead(JournalArticle article) {
    JournalArticle latestArticle = JournalArticleLocalServiceUtil.fetchLatestArticle(
            article.getResourcePrimKey(),
            new int[] { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_IN_TRASH });

    if ((latestArticle != null) && !latestArticle.isIndexable()) {
        return false;
    } else if ((latestArticle != null) && (article.getId() == latestArticle.getId())) {

        return true;
    }/*from  www.  ja v  a 2  s.  co  m*/

    return false;
}

From source file:com.liferay.journal.util.impl.JournalUtil.java

License:Open Source License

public static boolean isHeadListable(JournalArticle article) {
    JournalArticle latestArticle = JournalArticleLocalServiceUtil
            .fetchLatestArticle(article.getResourcePrimKey(), new int[] { WorkflowConstants.STATUS_APPROVED,
                    WorkflowConstants.STATUS_IN_TRASH, WorkflowConstants.STATUS_SCHEDULED });

    if ((latestArticle != null) && (article.getId() == latestArticle.getId())) {

        return true;
    }/*from  www  . ja  v a  2 s .co m*/

    return false;
}

From source file:com.liferay.journal.verify.JournalServiceVerifyProcess.java

License:Open Source License

protected void updateModifiedDate(JournalArticleResource articleResource) {
    JournalArticle article = _journalArticleLocalService
            .fetchLatestArticle(articleResource.getResourcePrimKey(), WorkflowConstants.STATUS_APPROVED, true);

    if (article == null) {
        return;/*  w  w  w .j  av a 2 s. c  o  m*/
    }

    AssetEntry assetEntry = _assetEntryLocalService.fetchEntry(articleResource.getGroupId(),
            articleResource.getUuid());

    if (assetEntry == null) {
        return;
    }

    Date modifiedDate = article.getModifiedDate();

    if (modifiedDate.equals(assetEntry.getModifiedDate())) {
        return;
    }

    article.setModifiedDate(assetEntry.getModifiedDate());

    _journalArticleLocalService.updateJournalArticle(article);
}

From source file:com.liferay.journal.verify.JournalServiceVerifyProcess.java

License:Open Source License

protected void verifyArticleExpirationDate() throws Exception {
    try (LoggingTimer loggingTimer = new LoggingTimer()) {
        long companyId = CompanyThreadLocal.getCompanyId();

        JournalServiceConfiguration journalServiceConfiguration = ConfigurationProviderUtil
                .getCompanyConfiguration(JournalServiceConfiguration.class, companyId);

        if (!journalServiceConfiguration.expireAllArticleVersionsEnabled()) {

            return;
        }/*from  www . j  a  v a  2  s . co  m*/

        StringBundler sb = new StringBundler(15);

        sb.append("select JournalArticle.* from JournalArticle left ");
        sb.append("join JournalArticle tempJournalArticle on ");
        sb.append("(JournalArticle.groupId = tempJournalArticle.groupId) ");
        sb.append("and (JournalArticle.articleId = ");
        sb.append("tempJournalArticle.articleId) and ");
        sb.append("(JournalArticle.version < tempJournalArticle.version) ");
        sb.append("and (JournalArticle.status = ");
        sb.append("tempJournalArticle.status) where ");
        sb.append("(JournalArticle.classNameId = ");
        sb.append(JournalArticleConstants.CLASSNAME_ID_DEFAULT);
        sb.append(") and (tempJournalArticle.version is null) and ");
        sb.append("(JournalArticle.expirationDate is not null) and ");
        sb.append("(JournalArticle.status = ");
        sb.append(WorkflowConstants.STATUS_APPROVED);
        sb.append(")");

        try (PreparedStatement ps = connection.prepareStatement(sb.toString());
                ResultSet rs = ps.executeQuery()) {

            while (rs.next()) {
                long groupId = rs.getLong("groupId");
                long articleId = rs.getLong("articleId");
                Timestamp expirationDate = rs.getTimestamp("expirationDate");
                int status = rs.getInt("status");

                updateExpirationDate(groupId, articleId, expirationDate, status);
            }
        }
    }
}

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   w  w  w .j  a  v  a2  s .c o  m*/

    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 int getStatus() {
    if (_status != null) {
        return _status;
    }/*  w w  w.jav  a  2 s .c o  m*/

    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.search.ArticleSearch.java

License:Open Source License

public ArticleSearch(PortletRequest portletRequest, int cur, int delta, PortletURL iteratorURL) {

    super(portletRequest, new ArticleDisplayTerms(portletRequest), new ArticleSearchTerms(portletRequest),
            "curEntry", cur, delta, iteratorURL, headerNames, null);

    PortletConfig portletConfig = (PortletConfig) portletRequest
            .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

    ArticleDisplayTerms displayTerms = (ArticleDisplayTerms) getDisplayTerms();
    ArticleSearchTerms searchTerms = (ArticleSearchTerms) getSearchTerms();

    String portletName = portletConfig.getPortletName();

    if (!portletName.equals(JournalPortletKeys.JOURNAL)) {
        displayTerms.setStatus(WorkflowConstants.STATUS_APPROVED);
        searchTerms.setStatus(WorkflowConstants.STATUS_APPROVED);
    }//  w ww. j av a 2 s .  co m

    iteratorURL.setParameter(ArticleDisplayTerms.ARTICLE_ID, displayTerms.getArticleId());
    iteratorURL.setParameter(ArticleDisplayTerms.CONTENT, displayTerms.getContent());
    iteratorURL.setParameter(ArticleDisplayTerms.DESCRIPTION, displayTerms.getDescription());
    iteratorURL.setParameter(ArticleDisplayTerms.DDM_STRUCTURE_KEY, displayTerms.getDDMStructureKey());
    iteratorURL.setParameter(ArticleDisplayTerms.DDM_TEMPLATE_KEY, displayTerms.getDDMTemplateKey());
    iteratorURL.setParameter(ArticleDisplayTerms.FOLDER_ID, String.valueOf(displayTerms.getFolderId()));
    iteratorURL.setParameter(ArticleDisplayTerms.GROUP_ID, String.valueOf(displayTerms.getGroupId()));
    iteratorURL.setParameter(ArticleDisplayTerms.NAVIGATION, displayTerms.getNavigation());
    iteratorURL.setParameter(ArticleDisplayTerms.STATUS, String.valueOf(displayTerms.getStatus()));
    iteratorURL.setParameter(ArticleDisplayTerms.TITLE, displayTerms.getTitle());
    iteratorURL.setParameter(ArticleDisplayTerms.VERSION, String.valueOf(displayTerms.getVersion()));

    try {
        PortalPreferences preferences = PortletPreferencesFactoryUtil.getPortalPreferences(portletRequest);

        String orderByCol = ParamUtil.getString(portletRequest, "orderByCol");
        String orderByType = ParamUtil.getString(portletRequest, "orderByType");

        if (Validator.isNotNull(orderByCol) && Validator.isNotNull(orderByType)) {

            preferences.setValue(JournalPortletKeys.JOURNAL, "articles-order-by-col", orderByCol);
            preferences.setValue(JournalPortletKeys.JOURNAL, "articles-order-by-type", orderByType);
        } else {
            orderByCol = preferences.getValue(JournalPortletKeys.JOURNAL, "articles-order-by-col", "id");
            orderByType = preferences.getValue(JournalPortletKeys.JOURNAL, "articles-order-by-type", "asc");
        }

        OrderByComparator<JournalArticle> orderByComparator = JournalPortletUtil
                .getArticleOrderByComparator(orderByCol, orderByType);

        setOrderableHeaders(orderableHeaders);
        setOrderByCol(orderByCol);
        setOrderByType(orderByType);
        setOrderByComparator(orderByComparator);
    } catch (Exception e) {
        _log.error(e);
    }
}

From source file:com.liferay.journal.web.internal.webdav.JournalWebDAVStorageImpl.java

License:Open Source License

protected List<Resource> getTemplates(WebDAVRequest webDAVRequest) throws Exception {

    List<Resource> resources = new ArrayList<>();

    List<DDMTemplate> ddmTemplates = _ddmTemplateLocalService.getTemplatesByStructureClassNameId(
            webDAVRequest.getGroupId(), _portal.getClassNameId(JournalArticle.class),
            WorkflowConstants.STATUS_APPROVED, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);

    for (DDMTemplate ddmTemplate : ddmTemplates) {
        Resource resource = _ddmWebDav.toResource(webDAVRequest, ddmTemplate, getRootPath(), true);

        resources.add(resource);/*from   ww  w.j  ava2  s. c o  m*/
    }

    return resources;
}

From source file:com.liferay.journal.web.util.JournalRSSUtil.java

License:Open Source License

public List<JournalArticle> getArticles(JournalFeed feed) {
    long companyId = feed.getCompanyId();
    long groupId = feed.getGroupId();
    List<Long> folderIds = Collections.emptyList();
    String articleId = null;/*from ww w  . j  a  va  2  s .  c  o m*/
    Double version = null;
    String title = null;
    String description = null;
    String content = null;

    String ddmStructureKey = feed.getDDMStructureKey();

    if (Validator.isNull(ddmStructureKey)) {
        ddmStructureKey = null;
    }

    String ddmTemplateKey = feed.getDDMTemplateKey();

    if (Validator.isNull(ddmTemplateKey)) {
        ddmTemplateKey = null;
    }

    Date displayDateGT = null;
    Date displayDateLT = new Date();
    int status = WorkflowConstants.STATUS_APPROVED;
    Date reviewDate = null;
    boolean andOperator = true;
    int start = 0;
    int end = feed.getDelta();

    String orderByCol = feed.getOrderByCol();

    String orderByType = feed.getOrderByType();

    boolean orderByAsc = orderByType.equals("asc");

    OrderByComparator<JournalArticle> obc = new ArticleModifiedDateComparator(orderByAsc);

    if (orderByCol.equals("display-date")) {
        obc = new ArticleDisplayDateComparator(orderByAsc);
    }

    return _journalArticleLocalService.search(companyId, groupId, folderIds,
            JournalArticleConstants.CLASSNAME_ID_DEFAULT, articleId, version, title, description, content,
            ddmStructureKey, ddmTemplateKey, displayDateGT, displayDateLT, status, reviewDate, andOperator,
            start, end, obc);
}