Example usage for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS

List of usage examples for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS.

Prototype

String CLOSE_PARENTHESIS

To view the source code for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS.

Click Source Link

Usage

From source file:com.liferay.knowledgebase.service.persistence.KBArticlePersistenceImpl.java

License:Open Source License

/**
 * Returns the number of k b articles that the user has permission to view where groupId = ? and parentResourcePrimKey = ? and sections LIKE any ? and latest = ?.
 *
 * @param groupId the group ID/*  w w  w .  j a v a  2 s.c om*/
 * @param parentResourcePrimKey the parent resource prim key
 * @param sectionses the sectionses
 * @param latest the latest
 * @return the number of matching k b articles that the user has permission to view
 * @throws SystemException if a system exception occurred
 */
public int filterCountByG_P_S_L(long groupId, long parentResourcePrimKey, String[] sectionses, boolean latest)
        throws SystemException {
    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
        return countByG_P_S_L(groupId, parentResourcePrimKey, sectionses, latest);
    }

    StringBundler query = new StringBundler();

    query.append(_FILTER_SQL_COUNT_KBARTICLE_WHERE);

    boolean conjunctionable = false;

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_P_S_L_GROUPID_5);

    conjunctionable = true;

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_P_S_L_PARENTRESOURCEPRIMKEY_5);

    conjunctionable = true;

    if ((sectionses == null) || (sectionses.length > 0)) {
        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(StringPool.OPEN_PARENTHESIS);

        for (int i = 0; i < sectionses.length; i++) {
            String sections = sectionses[i];

            if (sections == null) {
                query.append(_FINDER_COLUMN_G_P_S_L_SECTIONS_4);
            } else {
                if (sections.equals(StringPool.BLANK)) {
                    query.append(_FINDER_COLUMN_G_P_S_L_SECTIONS_6);
                } else {
                    query.append(_FINDER_COLUMN_G_P_S_L_SECTIONS_5);
                }
            }

            if ((i + 1) < sectionses.length) {
                query.append(WHERE_OR);
            }
        }

        query.append(StringPool.CLOSE_PARENTHESIS);

        conjunctionable = true;
    }

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_P_S_L_LATEST_5);

    conjunctionable = true;

    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), KBArticle.class.getName(),
            _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);

    Session session = null;

    try {
        session = openSession();

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);

        qPos.add(parentResourcePrimKey);

        if (sectionses != null) {
            qPos.add(sectionses);
        }

        qPos.add(latest);

        Long count = (Long) q.uniqueResult();

        return count.intValue();
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}

From source file:com.liferay.knowledgebase.service.persistence.KBArticlePersistenceImpl.java

License:Open Source License

/**
 * Returns the number of k b articles where groupId = &#63; and parentResourcePrimKey = &#63; and sections LIKE any &#63; and main = &#63;.
 *
 * @param groupId the group ID// w  w  w.  j  a  v  a  2  s . c  o m
 * @param parentResourcePrimKey the parent resource prim key
 * @param sectionses the sectionses
 * @param main the main
 * @return the number of matching k b articles
 * @throws SystemException if a system exception occurred
 */
public int countByG_P_S_M(long groupId, long parentResourcePrimKey, String[] sectionses, boolean main)
        throws SystemException {
    Object[] finderArgs = new Object[] { groupId, parentResourcePrimKey, StringUtil.merge(sectionses), main };

    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P_S_M, finderArgs,
            this);

    if (count == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_COUNT_KBARTICLE_WHERE);

        boolean conjunctionable = false;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_G_P_S_M_GROUPID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_G_P_S_M_PARENTRESOURCEPRIMKEY_5);

        conjunctionable = true;

        if ((sectionses == null) || (sectionses.length > 0)) {
            if (conjunctionable) {
                query.append(WHERE_AND);
            }

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < sectionses.length; i++) {
                String sections = sectionses[i];

                if (sections == null) {
                    query.append(_FINDER_COLUMN_G_P_S_M_SECTIONS_4);
                } else {
                    if (sections.equals(StringPool.BLANK)) {
                        query.append(_FINDER_COLUMN_G_P_S_M_SECTIONS_6);
                    } else {
                        query.append(_FINDER_COLUMN_G_P_S_M_SECTIONS_5);
                    }
                }

                if ((i + 1) < sectionses.length) {
                    query.append(WHERE_OR);
                }
            }

            query.append(StringPool.CLOSE_PARENTHESIS);

            conjunctionable = true;
        }

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_G_P_S_M_MAIN_5);

        conjunctionable = true;

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            qPos.add(groupId);

            qPos.add(parentResourcePrimKey);

            if (sectionses != null) {
                qPos.add(sectionses);
            }

            qPos.add(main);

            count = (Long) q.uniqueResult();
        } catch (Exception e) {
            throw processException(e);
        } finally {
            if (count == null) {
                count = Long.valueOf(0);
            }

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P_S_M, finderArgs, count);

            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:com.liferay.knowledgebase.service.persistence.KBArticlePersistenceImpl.java

License:Open Source License

/**
 * Returns the number of k b articles that the user has permission to view where groupId = &#63; and parentResourcePrimKey = &#63; and sections LIKE any &#63; and main = &#63;.
 *
 * @param groupId the group ID//  w  w w .  j a  v  a2 s.  c o m
 * @param parentResourcePrimKey the parent resource prim key
 * @param sectionses the sectionses
 * @param main the main
 * @return the number of matching k b articles that the user has permission to view
 * @throws SystemException if a system exception occurred
 */
public int filterCountByG_P_S_M(long groupId, long parentResourcePrimKey, String[] sectionses, boolean main)
        throws SystemException {
    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
        return countByG_P_S_M(groupId, parentResourcePrimKey, sectionses, main);
    }

    StringBundler query = new StringBundler();

    query.append(_FILTER_SQL_COUNT_KBARTICLE_WHERE);

    boolean conjunctionable = false;

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_P_S_M_GROUPID_5);

    conjunctionable = true;

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_P_S_M_PARENTRESOURCEPRIMKEY_5);

    conjunctionable = true;

    if ((sectionses == null) || (sectionses.length > 0)) {
        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(StringPool.OPEN_PARENTHESIS);

        for (int i = 0; i < sectionses.length; i++) {
            String sections = sectionses[i];

            if (sections == null) {
                query.append(_FINDER_COLUMN_G_P_S_M_SECTIONS_4);
            } else {
                if (sections.equals(StringPool.BLANK)) {
                    query.append(_FINDER_COLUMN_G_P_S_M_SECTIONS_6);
                } else {
                    query.append(_FINDER_COLUMN_G_P_S_M_SECTIONS_5);
                }
            }

            if ((i + 1) < sectionses.length) {
                query.append(WHERE_OR);
            }
        }

        query.append(StringPool.CLOSE_PARENTHESIS);

        conjunctionable = true;
    }

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_P_S_M_MAIN_5);

    conjunctionable = true;

    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), KBArticle.class.getName(),
            _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);

    Session session = null;

    try {
        session = openSession();

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);

        qPos.add(parentResourcePrimKey);

        if (sectionses != null) {
            qPos.add(sectionses);
        }

        qPos.add(main);

        Long count = (Long) q.uniqueResult();

        return count.intValue();
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}

From source file:com.liferay.knowledgebase.service.persistence.KBArticlePersistenceImpl.java

License:Open Source License

/**
 * Returns the number of k b articles where groupId = &#63; and parentResourcePrimKey = &#63; and sections LIKE any &#63; and status = &#63;.
 *
 * @param groupId the group ID/*from   ww w .j  a va  2s  .c  om*/
 * @param parentResourcePrimKey the parent resource prim key
 * @param sectionses the sectionses
 * @param status the status
 * @return the number of matching k b articles
 * @throws SystemException if a system exception occurred
 */
public int countByG_P_S_S(long groupId, long parentResourcePrimKey, String[] sectionses, int status)
        throws SystemException {
    Object[] finderArgs = new Object[] { groupId, parentResourcePrimKey, StringUtil.merge(sectionses), status };

    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P_S_S, finderArgs,
            this);

    if (count == null) {
        StringBundler query = new StringBundler();

        query.append(_SQL_COUNT_KBARTICLE_WHERE);

        boolean conjunctionable = false;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_G_P_S_S_GROUPID_5);

        conjunctionable = true;

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_G_P_S_S_PARENTRESOURCEPRIMKEY_5);

        conjunctionable = true;

        if ((sectionses == null) || (sectionses.length > 0)) {
            if (conjunctionable) {
                query.append(WHERE_AND);
            }

            query.append(StringPool.OPEN_PARENTHESIS);

            for (int i = 0; i < sectionses.length; i++) {
                String sections = sectionses[i];

                if (sections == null) {
                    query.append(_FINDER_COLUMN_G_P_S_S_SECTIONS_4);
                } else {
                    if (sections.equals(StringPool.BLANK)) {
                        query.append(_FINDER_COLUMN_G_P_S_S_SECTIONS_6);
                    } else {
                        query.append(_FINDER_COLUMN_G_P_S_S_SECTIONS_5);
                    }
                }

                if ((i + 1) < sectionses.length) {
                    query.append(WHERE_OR);
                }
            }

            query.append(StringPool.CLOSE_PARENTHESIS);

            conjunctionable = true;
        }

        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(_FINDER_COLUMN_G_P_S_S_STATUS_5);

        conjunctionable = true;

        String sql = query.toString();

        Session session = null;

        try {
            session = openSession();

            Query q = session.createQuery(sql);

            QueryPos qPos = QueryPos.getInstance(q);

            qPos.add(groupId);

            qPos.add(parentResourcePrimKey);

            if (sectionses != null) {
                qPos.add(sectionses);
            }

            qPos.add(status);

            count = (Long) q.uniqueResult();
        } catch (Exception e) {
            throw processException(e);
        } finally {
            if (count == null) {
                count = Long.valueOf(0);
            }

            FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_P_S_S, finderArgs, count);

            closeSession(session);
        }
    }

    return count.intValue();
}

From source file:com.liferay.knowledgebase.service.persistence.KBArticlePersistenceImpl.java

License:Open Source License

/**
 * Returns the number of k b articles that the user has permission to view where groupId = &#63; and parentResourcePrimKey = &#63; and sections LIKE any &#63; and status = &#63;.
 *
 * @param groupId the group ID//from  w  w w .j av  a2 s  .co m
 * @param parentResourcePrimKey the parent resource prim key
 * @param sectionses the sectionses
 * @param status the status
 * @return the number of matching k b articles that the user has permission to view
 * @throws SystemException if a system exception occurred
 */
public int filterCountByG_P_S_S(long groupId, long parentResourcePrimKey, String[] sectionses, int status)
        throws SystemException {
    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
        return countByG_P_S_S(groupId, parentResourcePrimKey, sectionses, status);
    }

    StringBundler query = new StringBundler();

    query.append(_FILTER_SQL_COUNT_KBARTICLE_WHERE);

    boolean conjunctionable = false;

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_P_S_S_GROUPID_5);

    conjunctionable = true;

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_P_S_S_PARENTRESOURCEPRIMKEY_5);

    conjunctionable = true;

    if ((sectionses == null) || (sectionses.length > 0)) {
        if (conjunctionable) {
            query.append(WHERE_AND);
        }

        query.append(StringPool.OPEN_PARENTHESIS);

        for (int i = 0; i < sectionses.length; i++) {
            String sections = sectionses[i];

            if (sections == null) {
                query.append(_FINDER_COLUMN_G_P_S_S_SECTIONS_4);
            } else {
                if (sections.equals(StringPool.BLANK)) {
                    query.append(_FINDER_COLUMN_G_P_S_S_SECTIONS_6);
                } else {
                    query.append(_FINDER_COLUMN_G_P_S_S_SECTIONS_5);
                }
            }

            if ((i + 1) < sectionses.length) {
                query.append(WHERE_OR);
            }
        }

        query.append(StringPool.CLOSE_PARENTHESIS);

        conjunctionable = true;
    }

    if (conjunctionable) {
        query.append(WHERE_AND);
    }

    query.append(_FINDER_COLUMN_G_P_S_S_STATUS_5);

    conjunctionable = true;

    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), KBArticle.class.getName(),
            _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);

    Session session = null;

    try {
        session = openSession();

        SQLQuery q = session.createSQLQuery(sql);

        q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(groupId);

        qPos.add(parentResourcePrimKey);

        if (sectionses != null) {
            qPos.add(sectionses);
        }

        qPos.add(status);

        Long count = (Long) q.uniqueResult();

        return count.intValue();
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}

From source file:com.liferay.mail.service.persistence.impl.AccountPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, Account> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }// ww w.  j ava  2 s  . com

    Map<Serializable, Account> map = new HashMap<Serializable, Account>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        Account account = fetchByPrimaryKey(primaryKey);

        if (account != null) {
            map.put(primaryKey, account);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Account account = (Account) EntityCacheUtil.getResult(AccountModelImpl.ENTITY_CACHE_ENABLED,
                AccountImpl.class, primaryKey);

        if (account == null) {
            if (uncachedPrimaryKeys == null) {
                uncachedPrimaryKeys = new HashSet<Serializable>();
            }

            uncachedPrimaryKeys.add(primaryKey);
        } else {
            map.put(primaryKey, account);
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_ACCOUNT_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append(String.valueOf(primaryKey));

        query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
        session = openSession();

        Query q = session.createQuery(sql);

        for (Account account : (List<Account>) q.list()) {
            map.put(account.getPrimaryKeyObj(), account);

            cacheResult(account);

            uncachedPrimaryKeys.remove(account.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            EntityCacheUtil.putResult(AccountModelImpl.ENTITY_CACHE_ENABLED, AccountImpl.class, primaryKey,
                    _nullAccount);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.mail.service.persistence.impl.AttachmentPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, Attachment> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }/* w w  w.j  a  va2s .  com*/

    Map<Serializable, Attachment> map = new HashMap<Serializable, Attachment>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        Attachment attachment = fetchByPrimaryKey(primaryKey);

        if (attachment != null) {
            map.put(primaryKey, attachment);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Attachment attachment = (Attachment) EntityCacheUtil.getResult(AttachmentModelImpl.ENTITY_CACHE_ENABLED,
                AttachmentImpl.class, primaryKey);

        if (attachment == null) {
            if (uncachedPrimaryKeys == null) {
                uncachedPrimaryKeys = new HashSet<Serializable>();
            }

            uncachedPrimaryKeys.add(primaryKey);
        } else {
            map.put(primaryKey, attachment);
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_ATTACHMENT_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append(String.valueOf(primaryKey));

        query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
        session = openSession();

        Query q = session.createQuery(sql);

        for (Attachment attachment : (List<Attachment>) q.list()) {
            map.put(attachment.getPrimaryKeyObj(), attachment);

            cacheResult(attachment);

            uncachedPrimaryKeys.remove(attachment.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            EntityCacheUtil.putResult(AttachmentModelImpl.ENTITY_CACHE_ENABLED, AttachmentImpl.class,
                    primaryKey, _nullAttachment);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.mail.service.persistence.impl.FolderPersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, Folder> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }/*from   w  w  w  .j  av a2 s.  co m*/

    Map<Serializable, Folder> map = new HashMap<Serializable, Folder>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        Folder folder = fetchByPrimaryKey(primaryKey);

        if (folder != null) {
            map.put(primaryKey, folder);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Folder folder = (Folder) EntityCacheUtil.getResult(FolderModelImpl.ENTITY_CACHE_ENABLED,
                FolderImpl.class, primaryKey);

        if (folder == null) {
            if (uncachedPrimaryKeys == null) {
                uncachedPrimaryKeys = new HashSet<Serializable>();
            }

            uncachedPrimaryKeys.add(primaryKey);
        } else {
            map.put(primaryKey, folder);
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_FOLDER_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append(String.valueOf(primaryKey));

        query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
        session = openSession();

        Query q = session.createQuery(sql);

        for (Folder folder : (List<Folder>) q.list()) {
            map.put(folder.getPrimaryKeyObj(), folder);

            cacheResult(folder);

            uncachedPrimaryKeys.remove(folder.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            EntityCacheUtil.putResult(FolderModelImpl.ENTITY_CACHE_ENABLED, FolderImpl.class, primaryKey,
                    _nullFolder);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.mail.service.persistence.impl.MessagePersistenceImpl.java

License:Open Source License

@Override
public Map<Serializable, Message> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
        return Collections.emptyMap();
    }/*from  w w  w. j  a va2s.com*/

    Map<Serializable, Message> map = new HashMap<Serializable, Message>();

    if (primaryKeys.size() == 1) {
        Iterator<Serializable> iterator = primaryKeys.iterator();

        Serializable primaryKey = iterator.next();

        Message message = fetchByPrimaryKey(primaryKey);

        if (message != null) {
            map.put(primaryKey, message);
        }

        return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
        Message message = (Message) EntityCacheUtil.getResult(MessageModelImpl.ENTITY_CACHE_ENABLED,
                MessageImpl.class, primaryKey);

        if (message == null) {
            if (uncachedPrimaryKeys == null) {
                uncachedPrimaryKeys = new HashSet<Serializable>();
            }

            uncachedPrimaryKeys.add(primaryKey);
        } else {
            map.put(primaryKey, message);
        }
    }

    if (uncachedPrimaryKeys == null) {
        return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_MESSAGE_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
        query.append(String.valueOf(primaryKey));

        query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
        session = openSession();

        Query q = session.createQuery(sql);

        for (Message message : (List<Message>) q.list()) {
            map.put(message.getPrimaryKeyObj(), message);

            cacheResult(message);

            uncachedPrimaryKeys.remove(message.getPrimaryKeyObj());
        }

        for (Serializable primaryKey : uncachedPrimaryKeys) {
            EntityCacheUtil.putResult(MessageModelImpl.ENTITY_CACHE_ENABLED, MessageImpl.class, primaryKey,
                    _nullMessage);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    return map;
}

From source file:com.liferay.marketplace.app.manager.web.internal.util.MarketplaceAppManagerSearchUtil.java

License:Open Source License

protected static String getKeywordsRegex(String keywords) {
    keywords = StringUtil.replace(keywords, CharPool.SPACE, CharPool.PIPE);

    return StringPool.OPEN_PARENTHESIS + keywords + StringPool.CLOSE_PARENTHESIS;
}