List of usage examples for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS
String CLOSE_PARENTHESIS
To view the source code for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS.
Click Source Link
From source file:com.liferay.portlet.messageboards.service.persistence.MBThreadPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the message boards threads where groupId = ? and categoryId = any ? and status = ?. * * <p>// www.j ava 2 s.c o m * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryIds the category IDs * @param status the status * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads * @throws SystemException if a system exception occurred */ public List<MBThread> findByG_C_S(long groupId, long[] categoryIds, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_C_S; finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds), status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_C_S; finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds), status, start, end, orderByComparator }; } List<MBThread> list = (List<MBThread>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_MBTHREAD_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_S_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_S_STATUS_5); conjunctionable = true; if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(MBThreadModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (categoryIds != null) { qPos.add(categoryIds); } qPos.add(status); list = (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { if (list == null) { FinderCacheUtil.removeResult(finderPath, finderArgs); } else { cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } closeSession(session); } } return list; }
From source file:com.liferay.portlet.messageboards.service.persistence.MBThreadPersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the message boards threads that the user has permission to view where groupId = ? and categoryId = any ? and status = ?. * * <p>/*from ww w . ja va 2 s .c o m*/ * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. * </p> * * @param groupId the group ID * @param categoryIds the category IDs * @param status the status * @param start the lower bound of the range of message boards threads * @param end the upper bound of the range of message boards threads (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public List<MBThread> filterFindByG_C_S(long groupId, long[] categoryIds, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return findByG_C_S(groupId, categoryIds, status, start, end, orderByComparator); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_WHERE); } else { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_1); } boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_S_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_S_STATUS_5); conjunctionable = true; if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_MBTHREAD_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(MBThreadModelImpl.ORDER_BY_JPQL); } else { query.append(MBThreadModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, MBThreadImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, MBThreadImpl.class); } QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (categoryIds != null) { qPos.add(categoryIds); } qPos.add(status); return (List<MBThread>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.messageboards.service.persistence.MBThreadPersistenceImpl.java
License:Open Source License
/** * Returns the number of message boards threads where groupId = ? and categoryId = any ?. * * @param groupId the group ID/*from w w w . j av a 2 s .c o m*/ * @param categoryIds the category IDs * @return the number of matching message boards threads * @throws SystemException if a system exception occurred */ public int countByG_C(long groupId, long[] categoryIds) throws SystemException { Object[] finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_MBTHREAD_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); 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); if (categoryIds != null) { qPos.add(categoryIds); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C, finderArgs, count); closeSession(session); } } return count.intValue(); }
From source file:com.liferay.portlet.messageboards.service.persistence.MBThreadPersistenceImpl.java
License:Open Source License
/** * Returns the number of message boards threads that the user has permission to view where groupId = ? and categoryId = any ?. * * @param groupId the group ID//from w ww .ja va2s . com * @param categoryIds the category IDs * @return the number of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_C(long groupId, long[] categoryIds) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_C(groupId, categoryIds); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.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); if (categoryIds != null) { qPos.add(categoryIds); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.messageboards.service.persistence.MBThreadPersistenceImpl.java
License:Open Source License
/** * Returns the number of message boards threads where groupId = ? and categoryId = any ? and status = ?. * * @param groupId the group ID//from ww w .jav a 2 s . c om * @param categoryIds the category IDs * @param status the status * @return the number of matching message boards threads * @throws SystemException if a system exception occurred */ public int countByG_C_S(long groupId, long[] categoryIds, int status) throws SystemException { Object[] finderArgs = new Object[] { groupId, StringUtil.merge(categoryIds), status }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_S, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_MBTHREAD_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_S_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_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); if (categoryIds != null) { qPos.add(categoryIds); } 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_COUNT_BY_G_C_S, finderArgs, count); closeSession(session); } } return count.intValue(); }
From source file:com.liferay.portlet.messageboards.service.persistence.MBThreadPersistenceImpl.java
License:Open Source License
/** * Returns the number of message boards threads that the user has permission to view where groupId = ? and categoryId = any ? and status = ?. * * @param groupId the group ID//from www . j a v a2 s . c o m * @param categoryIds the category IDs * @param status the status * @return the number of matching message boards threads that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_C_S(long groupId, long[] categoryIds, int status) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_C_S(groupId, categoryIds, status); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_MBTHREAD_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_S_GROUPID_5); conjunctionable = true; if ((categoryIds == null) || (categoryIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < categoryIds.length; i++) { query.append(_FINDER_COLUMN_G_C_S_CATEGORYID_5); if ((i + 1) < categoryIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_C_S_STATUS_5); conjunctionable = true; String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), MBThread.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); if (categoryIds != null) { qPos.add(categoryIds); } 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.portlet.tags.service.persistence.TagsAssetFinderImpl.java
License:Open Source License
public int countByAndEntryIds(long groupId, long[] classNameIds, long[] entryIds, long[] notEntryIds, boolean excludeZeroViewCount, Date publishDate, Date expirationDate) throws SystemException { Session session = null;//www . j av a2 s . c o m try { session = openSession(); StringBuilder sb = new StringBuilder(); sb.append("SELECT COUNT(DISTINCT assetId) AS COUNT_VALUE "); sb.append("FROM TagsAsset WHERE"); sb.append(" (visible = ?)"); if (entryIds.length > 0) { sb.append(" AND TagsAsset.assetId IN ("); for (int i = 0; i < entryIds.length; i++) { sb.append(CustomSQLUtil.get(FIND_BY_AND_ENTRY_IDS)); if ((i + 1) < entryIds.length) { sb.append(" AND TagsAsset.assetId IN ("); } } for (int i = 0; i < entryIds.length; i++) { if ((i + 1) < entryIds.length) { sb.append(StringPool.CLOSE_PARENTHESIS); } } if (excludeZeroViewCount) { sb.append(" AND (TagsAsset.viewCount > 0)"); } sb.append(StringPool.CLOSE_PARENTHESIS); } if (notEntryIds.length > 0) { sb.append(" AND ("); for (int i = 0; i < notEntryIds.length; i++) { sb.append("TagsAsset.assetId NOT IN ("); sb.append(CustomSQLUtil.get(FIND_BY_AND_ENTRY_IDS)); sb.append(StringPool.CLOSE_PARENTHESIS); if ((i + 1) < notEntryIds.length) { sb.append(" OR "); } } sb.append(StringPool.CLOSE_PARENTHESIS); } sb.append("[$DATES$]"); if (groupId > 0) { sb.append(" AND (TagsAsset.groupId = ?)"); } sb.append(getClassNameIds(classNameIds)); String sql = sb.toString(); sql = getDates(sql, publishDate, expirationDate); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(true); setEntryIds(qPos, entryIds); setEntryIds(qPos, notEntryIds); setDates(qPos, publishDate, expirationDate); if (groupId > 0) { setGroupId(qPos, groupId); } setClassNamedIds(qPos, classNameIds); Iterator<Long> itr = q.list().iterator(); if (itr.hasNext()) { Long count = itr.next(); if (count != null) { return count.intValue(); } } return 0; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.tags.service.persistence.TagsAssetFinderImpl.java
License:Open Source License
public int countByOrEntryIds(long groupId, long[] classNameIds, long[] entryIds, long[] notEntryIds, boolean excludeZeroViewCount, Date publishDate, Date expirationDate) throws SystemException { Session session = null;/* w w w. j ava 2s . co m*/ try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_BY_OR_ENTRY_IDS); sql = StringUtil.replace(sql, "[$ENTRY_ID$]", getEntryIds(entryIds, StringPool.EQUAL)); if (notEntryIds.length > 0) { StringBuilder sb = new StringBuilder(); sb.append(" AND ("); for (int i = 0; i < notEntryIds.length; i++) { sb.append("TagsAsset.assetId NOT IN ("); sb.append(CustomSQLUtil.get(FIND_BY_AND_ENTRY_IDS)); sb.append(StringPool.CLOSE_PARENTHESIS); if ((i + 1) < notEntryIds.length) { sb.append(" AND "); } } sb.append(StringPool.CLOSE_PARENTHESIS); sql = StringUtil.replace(sql, "[$NOT_ENTRY_ID$]", sb.toString()); } else { sql = StringUtil.replace(sql, "[$NOT_ENTRY_ID$]", StringPool.BLANK); } sql = getDates(sql, publishDate, expirationDate); sql += " AND (visible = ?)"; if (groupId > 0) { sql += " AND (TagsAsset.groupId = ?)"; } sql += getClassNameIds(classNameIds); if (excludeZeroViewCount) { sql += " AND (TagsAsset.viewCount > 0)"; } SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); setEntryIds(qPos, entryIds); setEntryIds(qPos, notEntryIds); setDates(qPos, publishDate, expirationDate); qPos.add(true); if (groupId > 0) { setGroupId(qPos, groupId); } setClassNamedIds(qPos, classNameIds); Iterator<Long> itr = q.list().iterator(); if (itr.hasNext()) { Long count = itr.next(); if (count != null) { return count.intValue(); } } return 0; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.tags.service.persistence.TagsAssetFinderImpl.java
License:Open Source License
public List<TagsAsset> findByAndEntryIds(long groupId, long[] classNameIds, long[] entryIds, long[] notEntryIds, String orderByCol1, String orderByCol2, String orderByType1, String orderByType2, boolean excludeZeroViewCount, Date publishDate, Date expirationDate, int start, int end) throws SystemException { orderByCol1 = checkOrderByCol(orderByCol1); orderByCol2 = checkOrderByCol(orderByCol2); orderByType1 = checkOrderByType(orderByType1); orderByType2 = checkOrderByType(orderByType2); Session session = null;//from w w w.j a va2s . com try { session = openSession(); StringBuilder sb = new StringBuilder(); sb.append("SELECT DISTINCT {TagsAsset.*} "); sb.append("FROM TagsAsset WHERE"); sb.append(" (visible = ?)"); if (entryIds.length > 0) { sb.append(" AND TagsAsset.assetId IN ("); for (int i = 0; i < entryIds.length; i++) { sb.append(CustomSQLUtil.get(FIND_BY_AND_ENTRY_IDS)); if ((i + 1) < entryIds.length) { sb.append(" AND TagsAsset.assetId IN ("); } } for (int i = 0; i < entryIds.length; i++) { if ((i + 1) < entryIds.length) { sb.append(StringPool.CLOSE_PARENTHESIS); } } if (excludeZeroViewCount) { sb.append(" AND (TagsAsset.viewCount > 0)"); } sb.append(StringPool.CLOSE_PARENTHESIS); } if (notEntryIds.length > 0) { sb.append(" AND ("); for (int i = 0; i < notEntryIds.length; i++) { sb.append("TagsAsset.assetId NOT IN ("); sb.append(CustomSQLUtil.get(FIND_BY_AND_ENTRY_IDS)); sb.append(StringPool.CLOSE_PARENTHESIS); if ((i + 1) < notEntryIds.length) { sb.append(" OR "); } } sb.append(StringPool.CLOSE_PARENTHESIS); } sb.append("[$DATES$]"); if (groupId > 0) { sb.append(" AND (TagsAsset.groupId = ?)"); } sb.append(getClassNameIds(classNameIds)); sb.append(" ORDER BY TagsAsset."); sb.append(orderByCol1); sb.append(StringPool.SPACE); sb.append(orderByType1); if (Validator.isNotNull(orderByCol2) && !orderByCol1.equals(orderByCol2)) { sb.append(", TagsAsset."); sb.append(orderByCol2); sb.append(StringPool.SPACE); sb.append(orderByType2); } String sql = sb.toString(); sql = getDates(sql, publishDate, expirationDate); SQLQuery q = session.createSQLQuery(sql); q.addEntity("TagsAsset", TagsAssetImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(true); setEntryIds(qPos, entryIds); setEntryIds(qPos, notEntryIds); setDates(qPos, publishDate, expirationDate); if (groupId > 0) { setGroupId(qPos, groupId); } setClassNamedIds(qPos, classNameIds); return (List<TagsAsset>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.tags.service.persistence.TagsAssetFinderImpl.java
License:Open Source License
public List<TagsAsset> findByOrEntryIds(long groupId, long[] classNameIds, long[] entryIds, long[] notEntryIds, String orderByCol1, String orderByCol2, String orderByType1, String orderByType2, boolean excludeZeroViewCount, Date publishDate, Date expirationDate, int start, int end) throws SystemException { orderByCol1 = checkOrderByCol(orderByCol1); orderByCol2 = checkOrderByCol(orderByCol2); orderByType1 = checkOrderByType(orderByType1); orderByType2 = checkOrderByType(orderByType2); Session session = null;/*w w w.j a va2 s . c o m*/ try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_OR_ENTRY_IDS); sql = StringUtil.replace(sql, "[$ENTRY_ID$]", getEntryIds(entryIds, StringPool.EQUAL)); if (notEntryIds.length > 0) { StringBuilder sb = new StringBuilder(); sb.append(" AND ("); for (int i = 0; i < notEntryIds.length; i++) { sb.append("TagsAsset.assetId NOT IN ("); sb.append(CustomSQLUtil.get(FIND_BY_AND_ENTRY_IDS)); sb.append(StringPool.CLOSE_PARENTHESIS); if ((i + 1) < notEntryIds.length) { sb.append(" AND "); } } sb.append(StringPool.CLOSE_PARENTHESIS); sql = StringUtil.replace(sql, "[$NOT_ENTRY_ID$]", sb.toString()); } else { sql = StringUtil.replace(sql, "[$NOT_ENTRY_ID$]", StringPool.BLANK); } sql = getDates(sql, publishDate, expirationDate); sql += " AND (visible = ?)"; if (groupId > 0) { sql += " AND (TagsAsset.groupId = ?)"; } sql += getClassNameIds(classNameIds); if (excludeZeroViewCount) { sql += " AND (TagsAsset.viewCount > 0)"; } StringBuilder sb = new StringBuilder(); sb.append(" ORDER BY TagsAsset."); sb.append(orderByCol1); sb.append(StringPool.SPACE); sb.append(orderByType1); if (Validator.isNotNull(orderByCol2) && !orderByCol1.equals(orderByCol2)) { sb.append(", TagsAsset."); sb.append(orderByCol2); sb.append(StringPool.SPACE); sb.append(orderByType2); } sql += sb.toString(); SQLQuery q = session.createSQLQuery(sql); q.addEntity("TagsAsset", TagsAssetImpl.class); QueryPos qPos = QueryPos.getInstance(q); setEntryIds(qPos, entryIds); setEntryIds(qPos, notEntryIds); setDates(qPos, publishDate, expirationDate); qPos.add(true); if (groupId > 0) { setGroupId(qPos, groupId); } setClassNamedIds(qPos, classNameIds); return (List<TagsAsset>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }