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.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

@Override
public JournalArticle fetchArticleByUrlTitle(long groupId, String urlTitle) {

    JournalArticle article = fetchLatestArticleByUrlTitle(groupId, urlTitle, WorkflowConstants.STATUS_APPROVED);

    if (article != null) {
        return article;
    }//  w  w w  .j  a  v a2 s . c  o m

    return fetchLatestArticleByUrlTitle(groupId, urlTitle, WorkflowConstants.STATUS_ANY);
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

@Override
public JournalArticle fetchLatestArticle(long resourcePrimKey) {
    return fetchLatestArticle(resourcePrimKey, WorkflowConstants.STATUS_ANY);
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

/**
 * Returns the latest web content article matching the resource primary key
 * and workflow status, optionally preferring articles with approved
 * workflow status.//w w w  . ja  v a2  s .  c  om
 *
 * @param  resourcePrimKey the primary key of the resource instance
 * @param  status the web content article's workflow status. For more
 *         information see {@link WorkflowConstants} for constants starting
 *         with the "STATUS_" prefix.
 * @param  preferApproved whether to prefer returning the latest matching
 *         article that has workflow status {@link
 *         WorkflowConstants#STATUS_APPROVED} over returning one that has a
 *         different status
 * @return the latest web content article matching the resource primary key
 *         and workflow status, optionally preferring articles with an
 *         approved workflow status, or <code>null</code> if no matching web
 *         content article could be found
 */
@Override
public JournalArticle fetchLatestArticle(long resourcePrimKey, int status, boolean preferApproved) {

    JournalArticle article = null;

    OrderByComparator<JournalArticle> orderByComparator = new ArticleVersionComparator();

    if (status == WorkflowConstants.STATUS_ANY) {
        if (preferApproved) {
            article = journalArticlePersistence.fetchByR_ST_First(resourcePrimKey,
                    WorkflowConstants.STATUS_APPROVED, orderByComparator);
        }

        if (article == null) {
            article = journalArticlePersistence.fetchByResourcePrimKey_First(resourcePrimKey,
                    orderByComparator);
        }
    } else {
        article = journalArticlePersistence.fetchByR_ST_First(resourcePrimKey, status, orderByComparator);
    }

    return article;
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

/**
 * Returns the latest web content article matching the group, article ID,
 * and workflow status./*www . j  a v a  2s  .c  o m*/
 *
 * @param  groupId the primary key of the web content article's group
 * @param  articleId the primary key of the web content article
 * @param  status the web content article's workflow status. For more
 *         information see {@link WorkflowConstants} for constants starting
 *         with the "STATUS_" prefix.
 * @return the latest matching web content article, or <code>null</code> if
 *         no matching web content article could be found
 */
@Override
public JournalArticle fetchLatestArticle(long groupId, String articleId, int status) {

    OrderByComparator<JournalArticle> orderByComparator = new ArticleVersionComparator();

    if (status == WorkflowConstants.STATUS_ANY) {
        return journalArticlePersistence.fetchByG_A_NotST_First(groupId, articleId,
                WorkflowConstants.STATUS_IN_TRASH, orderByComparator);
    }

    return journalArticlePersistence.fetchByG_A_ST_First(groupId, articleId, status, orderByComparator);
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

@Override
public JournalArticle fetchLatestArticleByUrlTitle(long groupId, String urlTitle, int status) {

    List<JournalArticle> articles = null;

    OrderByComparator<JournalArticle> orderByComparator = new ArticleVersionComparator();

    if (status == WorkflowConstants.STATUS_ANY) {
        articles = journalArticlePersistence.findByG_UT(groupId, urlTitle, 0, 1, orderByComparator);
    } else {/*from www.  j  av  a 2 s. c  o m*/
        articles = journalArticlePersistence.findByG_UT_ST(groupId, urlTitle, status, 0, 1, orderByComparator);
    }

    if (articles.isEmpty()) {
        return null;
    }

    return articles.get(0);
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

/**
 * Returns the latest approved web content article, or the latest unapproved
 * article if none are approved. Both approved and unapproved articles must
 * match the group and article ID.//from  w  w w.  j av a  2s.  c  o m
 *
 * @param  groupId the primary key of the web content article's group
 * @param  articleId the primary key of the web content article
 * @return the matching web content article
 */
@Override
public JournalArticle getArticle(long groupId, String articleId) throws PortalException {

    // Get the latest article that is approved, if none are approved, get
    // the latest unapproved article

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

    if (article != null) {
        return article;
    }

    return getLatestArticle(groupId, articleId, WorkflowConstants.STATUS_ANY);
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

/**
 * Returns the latest web content article that is approved, or the latest
 * unapproved article if none are approved. Both approved and unapproved
 * articles must match the group and URL title.
 *
 * @param  groupId the primary key of the web content article's group
 * @param  urlTitle the web content article's accessible URL title
 * @return the matching web content article
 */// ww w.  ja  v a2  s  .  c  o m
@Override
public JournalArticle getArticleByUrlTitle(long groupId, String urlTitle) throws PortalException {

    // Get the latest article that is approved, if none are approved, get
    // the latest unapproved article

    JournalArticle article = fetchLatestArticleByUrlTitle(groupId, urlTitle, WorkflowConstants.STATUS_APPROVED);

    if (article != null) {
        return article;
    }

    return getLatestArticleByUrlTitle(groupId, urlTitle, WorkflowConstants.STATUS_ANY);
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

@Override
public List<JournalArticle> getArticlesByStructureId(long groupId, String ddmStructureKey, int start, int end,
        OrderByComparator<JournalArticle> obc) {

    return getArticlesByStructureId(groupId, ddmStructureKey, WorkflowConstants.STATUS_ANY, start, end, obc);
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the web content articles matching the
 * company, version, and workflow status.
 *
 * <p>/*  w w w .j a  v a 2  s.  c om*/
 * Useful when paginating results. Returns a maximum of <code>end -
 * start</code> instances. <code>start</code> and <code>end</code> are not
 * primary keys, they are indexes in the result set. Thus, <code>0</code>
 * refers to the first result in the set. Setting both <code>start</code>
 * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full
 * result set.
 * </p>
 *
 * @param  companyId the primary key of the web content article's company
 * @param  version the web content article's version
 * @param  status the web content article's workflow status. For more
 *         information see {@link WorkflowConstants} for constants starting
 *         with the "STATUS_" prefix.
 * @param  start the lower bound of the range of web content articles to
 *         return
 * @param  end the upper bound of the range of web content articles to
 *         return (not inclusive)
 * @return the range of matching web content articles ordered by article ID
 */
@Override
public List<JournalArticle> getCompanyArticles(long companyId, double version, int status, int start, int end) {

    if (status == WorkflowConstants.STATUS_ANY) {
        return journalArticlePersistence.findByC_V(companyId, version, start, end,
                new ArticleIDComparator(true));
    } else {
        return journalArticlePersistence.findByC_V_ST(companyId, version, status, start, end,
                new ArticleIDComparator(true));
    }
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

/**
 * Returns an ordered range of all the web content articles matching the
 * company and workflow status.//from   w  w  w  .  j  av  a  2s.c  o  m
 *
 * <p>
 * Useful when paginating results. Returns a maximum of <code>end -
 * start</code> instances. <code>start</code> and <code>end</code> are not
 * primary keys, they are indexes in the result set. Thus, <code>0</code>
 * refers to the first result in the set. Setting both <code>start</code>
 * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full
 * result set.
 * </p>
 *
 * @param  companyId the primary key of the web content article's company
 * @param  status the web content article's workflow status. For more
 *         information see {@link WorkflowConstants} for constants starting
 *         with the "STATUS_" prefix.
 * @param  start the lower bound of the range of web content articles to
 *         return
 * @param  end the upper bound of the range of web content articles to
 *         return (not inclusive)
 * @return the range of matching web content articles ordered by article ID
 */
@Override
public List<JournalArticle> getCompanyArticles(long companyId, int status, int start, int end) {

    if (status == WorkflowConstants.STATUS_ANY) {
        return journalArticlePersistence.findByCompanyId(companyId, start, end, new ArticleIDComparator(true));
    } else {
        return journalArticlePersistence.findByC_ST(companyId, status, start, end,
                new ArticleIDComparator(true));
    }
}