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, int start, int end, OrderByComparator<T> orderByComparator) 

Source Link

Usage

From source file:com.delfilab.gargall.service.impl.GargallServiceImpl.java

License:Open Source License

@AccessControlled(guestAccessEnabled = true)
@Override//from w  w  w . j a v  a 2  s.co m
public List<GargallDLFileEntry> getGargallDLFileEntries(long repositoryId, long folderId, int status, int start,
        int end) throws Exception {

    List<GargallDLFileEntry> gargallDLFileEntries = new ArrayList<GargallDLFileEntry>();

    Set<Long> dlFileEntryIds = new HashSet<Long>();

    PermissionChecker folderPermissionChecker = getPermissionChecker();

    if (folderPermissionChecker.hasPermission(repositoryId, DLFolder.class.getName(), folderId,
            ActionKeys.VIEW)) {

        QueryDefinition queryDefinition = new QueryDefinition(status, start, end, null);

        List<Object> foldersAndFileEntriesAndFileShortcuts = dlFolderLocalService
                .getFoldersAndFileEntriesAndFileShortcuts(repositoryId, folderId, null, false, queryDefinition);
        for (Object folderAndFileEntryAndFileShortcut : foldersAndFileEntriesAndFileShortcuts) {
            if (folderAndFileEntryAndFileShortcut instanceof FileEntry) {
                FileEntry fileEntry = (FileEntry) folderAndFileEntryAndFileShortcut;
                long fileEntryId2 = fileEntry.getFileEntryId();
                DLFileEntry dlFileEntry = DLFileEntryLocalServiceUtil.getDLFileEntry(fileEntryId2);
                if (dlFileEntryIds.contains(dlFileEntry.getFileEntryId())) {
                    continue;
                }
                dlFileEntryIds.add(dlFileEntry.getFileEntryId());
                try {
                    PermissionChecker permissionChecker = getPermissionChecker();

                    if (permissionChecker.hasPermission(dlFileEntry.getGroupId(), DLFileEntry.class.getName(),
                            dlFileEntry.getPrimaryKey(), ActionKeys.VIEW)) {

                        GargallDLFileEntry gargallDlFileEntry = getGargallDLFileEntry(dlFileEntry);

                        gargallDLFileEntries.add(gargallDlFileEntry);
                    }
                } catch (NoSuchFileEntryException nsae) {
                }

            } else if (folderAndFileEntryAndFileShortcut instanceof Folder) {
                //Folder subFolder = (Folder) folderAndFileEntryAndFileShortcut;
                // qui ricorsione
            } else if (folderAndFileEntryAndFileShortcut instanceof DLFileShortcut) {
                //DLFileShortcut dlFileShorcut = (DLFileShortcut) folderAndFileEntryAndFileShortcut;
                // qui non faccio nulla
                continue;
            } //end for su foldersAndFileEntriesAndFileShortcuts
        }
    }
    return gargallDLFileEntries;
}

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, int start, int end,
        OrderByComparator obc) {/*from   w  w w .  j  a va2 s . com*/

    QueryDefinition<?> queryDefinition = new QueryDefinition<>(status, start, end, obc);

    return bookmarksFolderFinder.findF_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, int start, int end) {

    QueryDefinition<?> queryDefinition = new QueryDefinition<>(status, start, end, null);

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

From source file:com.liferay.document.library.util.test.RepositoryModelUtilTest.java

License:Open Source License

@Test
public void testToRepositoryEntries() throws Exception {
    populateFolderWithDLFileEntries();//  w ww .j av  a2s. c  o  m
    populateFolderWithDLFileShortcuts();
    populateFolderWithDLFolders();

    QueryDefinition<?> queryDefinition = new QueryDefinition<>(WorkflowConstants.STATUS_APPROVED,
            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);

    List<Object> dlFoldersAndDLFileEntriesAndDLFileShortcuts = DLFolderLocalServiceUtil
            .getFoldersAndFileEntriesAndFileShortcuts(_group.getGroupId(), _folder.getFolderId(), new String[0],
                    true, queryDefinition);

    List<RepositoryEntry> repositoryEntries = RepositoryModelUtil
            .toRepositoryEntries(dlFoldersAndDLFileEntriesAndDLFileShortcuts);

    Assert.assertEquals(repositoryEntries.toString(), dlFoldersAndDLFileEntriesAndDLFileShortcuts.size(),
            repositoryEntries.size());
}

From source file:com.liferay.document.library.util.test.RepositoryModelUtilTest.java

License:Open Source License

@Test(expected = IllegalArgumentException.class)
public void testToRepositoryEntriesWithIllegalArgument() throws Exception {
    populateFolderWithDLFileEntries();/*  w ww  . ja v  a 2s . com*/
    populateFolderWithDLFileShortcuts();
    populateFolderWithDLFolders();

    QueryDefinition<?> queryDefinition = new QueryDefinition<>(WorkflowConstants.STATUS_APPROVED,
            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);

    List<Object> dlFoldersAndDLFileEntriesAndDLFileShortcuts = DLFolderLocalServiceUtil
            .getFoldersAndFileEntriesAndFileShortcuts(_group.getGroupId(), _folder.getFolderId(), new String[0],
                    true, queryDefinition);

    dlFoldersAndDLFileEntriesAndDLFileShortcuts.add(new Object());

    RepositoryModelUtil.toRepositoryEntries(dlFoldersAndDLFileEntriesAndDLFileShortcuts);
}

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

License:Open Source License

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

    QueryDefinition<JournalArticle> queryDefinition = new QueryDefinition<>(status, start, end, obc);

    return journalArticleFinder.findByG_C_S(groupId, classNameId, ddmStructureKey, queryDefinition);
}

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

License:Open Source License

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

    QueryDefinition<JournalArticle> queryDefinition = new QueryDefinition<>(status, start, end, obc);

    return journalArticleFinder.findByG_C_S(groupId, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
            ddmStructureKey, queryDefinition);
}

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

License:Open Source License

@Override
public List<JournalArticle> getIndexableArticlesByDDMStructureKey(String[] ddmStructureKeys) {

    if (isReindexAllArticleVersions()) {
        return getStructureArticles(ddmStructureKeys);
    }/*from   w  w w  .ja  v  a 2s .  com*/

    QueryDefinition<JournalArticle> approvedQueryDefinition = new QueryDefinition<>(
            WorkflowConstants.STATUS_APPROVED, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
            new ArticleVersionComparator());

    List<JournalArticle> articles = new ArrayList<>();

    articles.addAll(journalArticleFinder.findByG_C_S(0, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
            ddmStructureKeys, approvedQueryDefinition));

    QueryDefinition<JournalArticle> trashQueryDefinition = new QueryDefinition<>(
            WorkflowConstants.STATUS_IN_TRASH, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
            new ArticleVersionComparator());

    articles.addAll(journalArticleFinder.findByG_C_S(0, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
            ddmStructureKeys, trashQueryDefinition));

    return articles;
}

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

License:Open Source License

/**
 * Returns a range of all the web content articles matching the parameters
 * without using the indexer. It is preferable to use the indexed version
 * {@link #search(long, long, long, int, int, int)} instead of this method
 * wherever possible for performance reasons.
 *
 * <p>/*from   w ww  .j a  v  a  2 s .  com*/
 * 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  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.
 * @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 matching web content articles
 */
@Override
public List<JournalArticle> search(long groupId, List<Long> folderIds, int status, int start, int end) {

    QueryDefinition<JournalArticle> queryDefinition = new QueryDefinition<>(status, start, end, null);

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

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
 * parameters without using the indexer, 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. It
 * is preferable to use the indexed version {@link #search(long, long, List,
 * long, String, String, String, String, int, String, String, LinkedHashMap,
 * boolean, int, int, Sort)} instead of this method wherever possible for
 * performance reasons.//  w  w w  . java 2s  .  c om
 *
 * <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  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. Company, group, folder IDs, class
 *         name ID, and status must all match their values.
 * @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)
 * @param  obc the comparator to order the web content articles
 * @return the range of matching web content articles ordered by the
 *         comparator
 */
@Override
public List<JournalArticle> search(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, int start, int end, OrderByComparator<JournalArticle> obc) {

    QueryDefinition<JournalArticle> queryDefinition = new QueryDefinition<>(status, start, end, obc);

    return journalArticleFinder.findByC_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, queryDefinition);
}