Example usage for com.liferay.portal.kernel.dao.orm QueryDefinition QueryDefinition

List of usage examples for com.liferay.portal.kernel.dao.orm QueryDefinition QueryDefinition

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.dao.orm QueryDefinition QueryDefinition.

Prototype

public QueryDefinition(int status) 

Source Link

Usage

From source file:com.liferay.blogs.service.test.BlogsEntryTrashHandlerTest.java

License:Open Source License

@Override
protected int getNotInTrashBaseModelsCount(BaseModel<?> parentBaseModel) throws Exception {

    QueryDefinition<BlogsEntry> queryDefinition = new QueryDefinition<>(WorkflowConstants.STATUS_ANY);

    return BlogsEntryLocalServiceUtil.getGroupEntriesCount((Long) parentBaseModel.getPrimaryKeyObj(),
            queryDefinition);//from  ww w. j av a  2  s  .  c o  m
}

From source file:com.liferay.bookmarks.service.impl.BookmarksFolderLocalServiceImpl.java

License:Open Source License

@Override
public List<Object> getFoldersAndEntries(long groupId, long folderId, int status) {

    QueryDefinition<?> queryDefinition = new QueryDefinition<>(status);

    return bookmarksFolderFinder.findF_E_ByG_F(groupId, folderId, queryDefinition);
}

From source file:com.liferay.bookmarks.service.impl.BookmarksFolderLocalServiceImpl.java

License:Open Source License

@Override
public int getFoldersAndEntriesCount(long groupId, long folderId, int status) {

    QueryDefinition<?> queryDefinition = new QueryDefinition<>(status);

    return bookmarksFolderFinder.countF_E_ByG_F(groupId, folderId, queryDefinition);
}

From source file:com.liferay.bookmarks.service.impl.BookmarksFolderServiceImpl.java

License:Open Source License

@Override
public List<Object> getFoldersAndEntries(long groupId, long folderId, int status) {

    QueryDefinition<?> queryDefinition = new QueryDefinition<>(status);

    return bookmarksFolderFinder.filterFindBF_E_ByG_F(groupId, folderId, queryDefinition);
}

From source file:com.liferay.bookmarks.service.impl.BookmarksFolderServiceImpl.java

License:Open Source License

@Override
public int getFoldersAndEntriesCount(long groupId, long folderId, int status) {

    QueryDefinition<?> queryDefinition = new QueryDefinition<>(status);

    return bookmarksFolderFinder.filterCountF_E_ByG_F(groupId, folderId, queryDefinition);
}

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

License:Open Source License

/**
 * Returns the number of web content articles that are not recycled.
 *
 * @param  groupId the primary key of the web content article's group
 * @param  folderId the primary key of the web content article folder
 * @return the number of web content articles that are not recycled
 *//*from   w  ww .ja  v  a  2 s.  c om*/
@Override
public int getNotInTrashArticlesCount(long groupId, long folderId) {
    QueryDefinition<JournalArticle> queryDefinition = new QueryDefinition<>(WorkflowConstants.STATUS_ANY);

    List<Long> folderIds = new ArrayList<>();

    folderIds.add(folderId);

    return journalArticleFinder.countByG_F(groupId, folderIds, queryDefinition);
}

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

License:Open Source License

/**
 * Returns the number of web content articles matching the group, folders,
 * and status.//  ww  w . jav  a2 s.c o m
 *
 * @param  groupId the primary key of the group (optionally <code>0</code>)
 * @param  folderIds the primary keys of the web content article folders
 *         (optionally {@link Collections#EMPTY_LIST})
 * @param  status the web content article's workflow status. For more
 *         information see {@link WorkflowConstants} for constants starting
 *         with the "STATUS_" prefix.
 * @return the number of matching web content articles
 */
@Override
public int searchCount(long groupId, List<Long> folderIds, int status) {
    QueryDefinition<JournalArticle> queryDefinition = new QueryDefinition<>(status);

    return journalArticleFinder.countByG_F(groupId, folderIds, queryDefinition);
}

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

License:Open Source License

/**
 * Returns the number of web content articles matching the parameters,
 * including keyword parameters for article ID, title, description, and
 * content, a DDM structure key parameter, a DDM template key parameter, and
 * an AND operator switch.// w ww .ja va  2  s .  com
 *
 * @param  companyId the primary key of the web content article's company
 * @param  groupId the primary key of the group (optionally <code>0</code>)
 * @param  folderIds the primary keys of the web content article folders
 *         (optionally {@link Collections#EMPTY_LIST})
 * @param  classNameId the primary key of the DDMStructure class if the web
 *         content article is related to a DDM structure, the primary key of
 *         the class name associated with the article, or
 *         JournalArticleConstants.CLASSNAME_ID_DEFAULT in the journal-api
 *         module otherwise
 * @param  articleId the article ID keywords (space separated, optionally
 *         <code>null</code>)
 * @param  version the web content article's version (optionally
 *         <code>null</code>)
 * @param  title the title keywords (space separated, optionally
 *         <code>null</code>)
 * @param  description the description keywords (space separated, optionally
 *         <code>null</code>)
 * @param  content the content keywords (space separated, optionally
 *         <code>null</code>)
 * @param  ddmStructureKey the primary key of the web content article's DDM
 *         structure, if the article is related to a DDM structure, or
 *         <code>null</code> otherwise
 * @param  ddmTemplateKey the primary key of the web content article's DDM
 *         template
 * @param  displayDateGT the date after which a matching web content
 *         article's display date must be after (optionally
 *         <code>null</code>)
 * @param  displayDateLT the date before which a matching web content
 *         article's display date must be before (optionally
 *         <code>null</code>)
 * @param  status the web content article's workflow status. For more
 *         information see {@link WorkflowConstants} for constants starting
 *         with the "STATUS_" prefix.
 * @param  reviewDate the web content article's scheduled review date
 *         (optionally <code>null</code>)
 * @param  andOperator whether every field must match its value or keywords,
 *         or just one field must match. Group, folder IDs, class name ID,
 *         and status must all match their values.
 * @return the number of matching web content articles
 */
@Override
public int searchCount(long companyId, long groupId, List<Long> folderIds, long classNameId, String articleId,
        Double version, String title, String description, String content, String ddmStructureKey,
        String ddmTemplateKey, Date displayDateGT, Date displayDateLT, int status, Date reviewDate,
        boolean andOperator) {

    return journalArticleFinder.countByC_G_F_C_A_V_T_D_C_S_T_D_R(companyId, groupId, folderIds, classNameId,
            articleId, version, title, description, content, ddmStructureKey, ddmTemplateKey, displayDateGT,
            displayDateLT, reviewDate, andOperator, new QueryDefinition<JournalArticle>(status));
}

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

License:Open Source License

/**
 * Returns the number of web content articles matching the parameters,
 * including keyword parameters for article ID, title, description, and
 * content, a DDM structure keys (plural) parameter, a DDM template keys
 * (plural) parameter, and an AND operator switch.
 *
 * @param  companyId the primary key of the web content article's company
 * @param  groupId the primary key of the group (optionally <code>0</code>)
 * @param  folderIds the primary keys of the web content article folders
 *         (optionally {@link Collections#EMPTY_LIST})
 * @param  classNameId the primary key of the DDMStructure class if the web
 *         content article is related to a DDM structure, the primary key of
 *         the class name associated with the article, or
 *         JournalArticleConstants.CLASSNAME_ID_DEFAULT in the journal-api
 *         module otherwise/*from w  ww .  j  a va 2 s.co  m*/
 * @param  articleId the article ID keywords (space separated, optionally
 *         <code>null</code>)
 * @param  version the web content article's version (optionally
 *         <code>null</code>)
 * @param  title the title keywords (space separated, optionally
 *         <code>null</code>)
 * @param  description the description keywords (space separated, optionally
 *         <code>null</code>)
 * @param  content the content keywords (space separated, optionally
 *         <code>null</code>)
 * @param  ddmStructureKeys the primary keys of the web content article's
 *         DDM structures, if the article is related to a DDM structure, or
 *         <code>null</code> otherwise
 * @param  ddmTemplateKeys the primary keys of the web content article's DDM
 *         templates (originally <code>null</code>). If the articles are
 *         related to a DDM structure, the template's structure must match
 *         it.
 * @param  displayDateGT the date after which a matching web content
 *         article's display date must be after (optionally
 *         <code>null</code>)
 * @param  displayDateLT the date before which a matching web content
 *         article's display date must be before (optionally
 *         <code>null</code>)
 * @param  status the web content article's workflow status. For more
 *         information see {@link WorkflowConstants} for constants starting
 *         with the "STATUS_" prefix.
 * @param  reviewDate the web content article's scheduled review date
 *         (optionally <code>null</code>)
 * @param  andOperator whether every field must match its value or keywords,
 *         or just one field must match.  Group, folder IDs, class name ID,
 *         and status must all match their values.
 * @return the number of matching web content articles
 */
@Override
public int searchCount(long companyId, long groupId, List<Long> folderIds, long classNameId, String articleId,
        Double version, String title, String description, String content, String[] ddmStructureKeys,
        String[] ddmTemplateKeys, Date displayDateGT, Date displayDateLT, int status, Date reviewDate,
        boolean andOperator) {

    return journalArticleFinder.countByC_G_F_C_A_V_T_D_C_S_T_D_R(companyId, groupId, folderIds, classNameId,
            articleId, version, title, description, content, ddmStructureKeys, ddmTemplateKeys, displayDateGT,
            displayDateLT, reviewDate, andOperator, new QueryDefinition<JournalArticle>(status));
}

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

License:Open Source License

protected void checkArticlesByExpirationDate(Date expirationDate) throws PortalException {

    List<JournalArticle> articles = journalArticleFinder.findByExpirationDate(
            JournalArticleConstants.CLASSNAME_ID_DEFAULT,
            new Date(expirationDate.getTime() + getArticleCheckInterval()),
            new QueryDefinition<JournalArticle>(WorkflowConstants.STATUS_APPROVED));

    if (_log.isDebugEnabled()) {
        _log.debug("Expiring " + articles.size() + " articles");
    }/*from   w w  w .  j a  v  a  2s .c  o m*/

    for (JournalArticle article : articles) {
        if (isExpireAllArticleVersions(article.getCompanyId())) {
            List<JournalArticle> currentArticles = journalArticlePersistence.findByG_A(article.getGroupId(),
                    article.getArticleId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS,
                    new ArticleVersionComparator(true));

            for (JournalArticle currentArticle : currentArticles) {
                if ((currentArticle.getExpirationDate() == null)
                        || (currentArticle.getVersion() > article.getVersion())) {

                    continue;
                }

                currentArticle.setExpirationDate(article.getExpirationDate());
                currentArticle.setStatus(WorkflowConstants.STATUS_EXPIRED);

                journalArticlePersistence.update(currentArticle);
            }
        } else {
            article.setStatus(WorkflowConstants.STATUS_EXPIRED);

            journalArticlePersistence.update(article);
        }

        updatePreviousApprovedArticle(article);

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

        indexer.reindex(article);
    }

    if (_previousCheckDate == null) {
        _previousCheckDate = new Date(expirationDate.getTime() - getArticleCheckInterval());
    }
}