List of usage examples for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS
String OPEN_PARENTHESIS
To view the source code for com.liferay.portal.kernel.util StringPool OPEN_PARENTHESIS.
Click Source Link
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistenceImpl.java
License:Open Source License
/** * Returns the number of document library file entries that the user has permission to view where groupId = ? and folderId = any ? and fileEntryTypeId = ?. * * @param groupId the group ID// w w w . j av a 2 s . c o m * @param folderIds the folder IDs * @param fileEntryTypeId the file entry type ID * @return the number of matching document library file entries that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByG_F_F(long groupId, long[] folderIds, long fileEntryTypeId) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupId)) { return countByG_F_F(groupId, folderIds, fileEntryTypeId); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_DLFILEENTRY_WHERE); boolean conjunctionable = false; if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_F_GROUPID_5); conjunctionable = true; if ((folderIds == null) || (folderIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < folderIds.length; i++) { query.append(_FINDER_COLUMN_G_F_F_FOLDERID_5); if ((i + 1) < folderIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (conjunctionable) { query.append(WHERE_AND); } query.append(_FINDER_COLUMN_G_F_F_FILEENTRYTYPEID_5); conjunctionable = true; String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), DLFileEntry.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 (folderIds != null) { qPos.add(folderIds); } qPos.add(fileEntryTypeId); Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the document library file entry types where groupId = any ?. * * <p>//from ww w .j a v a2s. 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 groupIds the group IDs * @param start the lower bound of the range of document library file entry types * @param end the upper bound of the range of document library file entry types (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching document library file entry types * @throws SystemException if a system exception occurred */ public List<DLFileEntryType> findByGroupId(long[] groupIds, 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_GROUPID; finderArgs = new Object[] { StringUtil.merge(groupIds) }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID; finderArgs = new Object[] { StringUtil.merge(groupIds), start, end, orderByComparator }; } List<DLFileEntryType> list = (List<DLFileEntryType>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if (list == null) { StringBundler query = new StringBundler(); query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE); boolean conjunctionable = false; if ((groupIds == null) || (groupIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < groupIds.length; i++) { query.append(_FINDER_COLUMN_GROUPID_GROUPID_5); if ((i + 1) < groupIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (groupIds != null) { qPos.add(groupIds); } list = (List<DLFileEntryType>) 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.documentlibrary.service.persistence.DLFileEntryTypePersistenceImpl.java
License:Open Source License
/** * Returns an ordered range of all the document library file entry types that the user has permission to view where groupId = any ?. * * <p>/*from www . j ava2s . 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 groupIds the group IDs * @param start the lower bound of the range of document library file entry types * @param end the upper bound of the range of document library file entry types (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching document library file entry types that the user has permission to view * @throws SystemException if a system exception occurred */ public List<DLFileEntryType> filterFindByGroupId(long[] groupIds, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupIds)) { return findByGroupId(groupIds, start, end, orderByComparator); } StringBundler query = new StringBundler(); if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE); } else { query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1); } boolean conjunctionable = false; if ((groupIds == null) || (groupIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < groupIds.length; i++) { query.append(_FINDER_COLUMN_GROUPID_GROUPID_5); if ((i + 1) < groupIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_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); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), DLFileEntryType.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryTypeImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryTypeImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (groupIds != null) { qPos.add(groupIds); } return (List<DLFileEntryType>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypePersistenceImpl.java
License:Open Source License
/** * Returns the number of document library file entry types where groupId = any ?. * * @param groupIds the group IDs//w w w.ja v a 2s. co m * @return the number of matching document library file entry types * @throws SystemException if a system exception occurred */ public int countByGroupId(long[] groupIds) throws SystemException { Object[] finderArgs = new Object[] { StringUtil.merge(groupIds) }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(); query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE); boolean conjunctionable = false; if ((groupIds == null) || (groupIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < groupIds.length; i++) { query.append(_FINDER_COLUMN_GROUPID_GROUPID_5); if ((i + 1) < groupIds.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); if (groupIds != null) { qPos.add(groupIds); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID, finderArgs, count); closeSession(session); } } return count.intValue(); }
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypePersistenceImpl.java
License:Open Source License
/** * Returns the number of document library file entry types that the user has permission to view where groupId = any ?. * * @param groupIds the group IDs// w w w.jav a 2 s. c om * @return the number of matching document library file entry types that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByGroupId(long[] groupIds) throws SystemException { if (!InlineSQLHelperUtil.isEnabled(groupIds)) { return countByGroupId(groupIds); } StringBundler query = new StringBundler(); query.append(_FILTER_SQL_COUNT_DLFILEENTRYTYPE_WHERE); boolean conjunctionable = false; if ((groupIds == null) || (groupIds.length > 0)) { if (conjunctionable) { query.append(WHERE_AND); } query.append(StringPool.OPEN_PARENTHESIS); for (int i = 0; i < groupIds.length; i++) { query.append(_FINDER_COLUMN_GROUPID_GROUPID_5); if ((i + 1) < groupIds.length) { query.append(WHERE_OR); } } query.append(StringPool.CLOSE_PARENTHESIS); conjunctionable = true; } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), DLFileEntryType.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds); 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); if (groupIds != null) { qPos.add(groupIds); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFolderFinderImpl.java
License:Open Source License
protected int doCountF_FE_FS_ByG_F_S_M_M(long groupId, long folderId, int status, String[] mimeTypes, boolean includeMountFolders, boolean inlineSQLHelper) throws SystemException { Session session = null;/*from w w w .j av a 2 s .com*/ try { session = openSession(); StringBundler sb = new StringBundler(7); sb.append(StringPool.OPEN_PARENTHESIS); String sql = CustomSQLUtil.get(COUNT_F_BY_G_M_F); if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFolder.class.getName(), "DLFolder.folderId", groupId); } sb.append(sql); sb.append(") UNION ALL ("); sb.append(getFileEntriesSQL(groupId, status, mimeTypes, inlineSQLHelper)); sb.append(") UNION ALL ("); sb.append(getFileShortcutsSQL(groupId, status, mimeTypes, inlineSQLHelper)); sb.append(StringPool.CLOSE_PARENTHESIS); sql = sb.toString(); sql = updateSQL(sql, folderId, status, includeMountFolders); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (!includeMountFolders) { qPos.add(false); } qPos.add(folderId); qPos.add(groupId); if (status != WorkflowConstants.STATUS_ANY) { qPos.add(status); } qPos.add(folderId); qPos.add(groupId); qPos.add(folderId); int count = 0; Iterator<Long> itr = q.iterate(); while (itr.hasNext()) { Long l = itr.next(); if (l != null) { count += l.intValue(); } } return count; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFolderFinderImpl.java
License:Open Source License
protected int doCountFE_FS_ByG_F_S_M(long groupId, long folderId, int status, String[] mimeTypes, boolean inlineSQLHelper) throws SystemException { Session session = null;//www . j a v a2 s . c o m try { session = openSession(); StringBundler sb = new StringBundler(7); sb.append(StringPool.OPEN_PARENTHESIS); String sql = getFileEntriesSQL(groupId, status, mimeTypes, inlineSQLHelper); sb.append(sql); sb.append(") UNION ALL ("); sb.append(getFileShortcutsSQL(groupId, status, mimeTypes, inlineSQLHelper)); sb.append(StringPool.CLOSE_PARENTHESIS); sql = sb.toString(); sql = updateSQL(sql, folderId, status, false); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (status != WorkflowConstants.STATUS_ANY) { qPos.add(status); } qPos.add(folderId); qPos.add(groupId); qPos.add(folderId); int count = 0; Iterator<Long> itr = q.iterate(); while (itr.hasNext()) { Long l = itr.next(); if (l != null) { count += l.intValue(); } } return count; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFolderFinderImpl.java
License:Open Source License
protected String getFileEntriesSQL(long groupId, int status, String[] mimeTypes, boolean inlineSQLHelper) { StringBundler sb = new StringBundler(); String sql = null;/*from www.j a v a2 s.c o m*/ if (status == WorkflowConstants.STATUS_ANY) { sql = CustomSQLUtil.get(COUNT_FE_BY_G_F); } else { sql = CustomSQLUtil.get(COUNT_FE_BY_G_F_S); if ((inlineSQLHelper && InlineSQLHelperUtil.isEnabled(groupId)) || ((mimeTypes != null) && (mimeTypes.length > 0))) { sql = StringUtil.replace(sql, "[$JOIN$]", CustomSQLUtil.get(JOIN_FV_BY_DL_FILE_ENTRY)); } else { sql = StringUtil.replace(sql, "[$JOIN$]", ""); } } if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFileEntry.class.getName(), "DLFileEntry.fileEntryId", groupId); } sb.append(sql); if ((mimeTypes != null) && (mimeTypes.length > 0)) { sb.append(WHERE_AND); sb.append(StringPool.OPEN_PARENTHESIS); sb.append(getMimeTypes(mimeTypes, "DLFileEntry")); sb.append(StringPool.CLOSE_PARENTHESIS); } return sb.toString(); }
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFolderFinderImpl.java
License:Open Source License
protected String getFileShortcutsSQL(long groupId, int status, String[] mimeTypes, boolean inlineSQLHelper) { String sql = CustomSQLUtil.get(COUNT_FS_BY_G_F_S); if ((inlineSQLHelper && InlineSQLHelperUtil.isEnabled(groupId)) || ((mimeTypes != null) && (mimeTypes.length > 0))) { sql = StringUtil.replace(sql, "[$JOIN$]", CustomSQLUtil.get(JOIN_FS_BY_DL_FILE_ENTRY)); } else {/* w w w . j a va2 s . c o m*/ sql = StringUtil.replace(sql, "[$JOIN$]", ""); } if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFileShortcut.class.getName(), "DLFileShortcut.fileShortcutId", groupId); } StringBundler sb = new StringBundler(sql); if ((mimeTypes != null) && (mimeTypes.length > 0)) { sb.append(WHERE_AND); sb.append(StringPool.OPEN_PARENTHESIS); sb.append(getMimeTypes(mimeTypes, "DLFileEntry")); sb.append(StringPool.CLOSE_PARENTHESIS); } return sb.toString(); }
From source file:com.liferay.portlet.dynamicdatamapping.storage.ExpandoStorageAdapter.java
License:Open Source License
private String _toExpression(Condition condition) { if (condition.isJunction()) { Junction junction = (Junction) condition; return StringPool.OPEN_PARENTHESIS.concat(_toExpression(junction)).concat(StringPool.CLOSE_PARENTHESIS); } else {//from w w w. j a va2 s . com FieldCondition fieldCondition = (FieldCondition) condition; return _toExpression(fieldCondition); } }