List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY
int STATUS_ANY
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY.
Click Source Link
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryFinderImpl.java
License:Open Source License
public List<DLFileEntry> findByG_U_F_M_S(long groupId, long userId, List<Long> folderIds, String[] mimeTypes, int status, int start, int end, OrderByComparator obc) throws SystemException { Session session = null;//from www .ja v a2 s . c o m String table = DLFileVersionImpl.TABLE_NAME; try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_G_U_F_S); if (userId <= 0) { if (status == WorkflowConstants.STATUS_ANY) { table = DLFileEntryImpl.TABLE_NAME; sql = CustomSQLUtil.get(FIND_BY_G_F); } else { sql = CustomSQLUtil.get(FIND_BY_G_F_S); } } else { if (status == WorkflowConstants.STATUS_ANY) { table = DLFileEntryImpl.TABLE_NAME; sql = CustomSQLUtil.get(FIND_BY_G_U_F); } } StringBundler sb = new StringBundler(); if (folderIds.size() > 0) { sb.append(StringPool.OPEN_PARENTHESIS); sb.append(getFolderIds(folderIds, table)); sb.append(StringPool.CLOSE_PARENTHESIS); } if ((mimeTypes != null) && (mimeTypes.length > 0)) { sb.append(WHERE_AND); sb.append(StringPool.OPEN_PARENTHESIS); sb.append(getMimeTypes(mimeTypes, table)); sb.append(StringPool.CLOSE_PARENTHESIS); } sql = StringUtil.replace(sql, "[$FOLDER_ID$]", sb.toString()); sql = CustomSQLUtil.replaceOrderBy(sql, obc); SQLQuery q = session.createSQLQuery(sql); q.addEntity("DLFileEntry", DLFileEntryImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (userId > 0) { qPos.add(userId); } if (status != WorkflowConstants.STATUS_ANY) { qPos.add(status); } for (Long folderId : folderIds) { qPos.add(folderId); } if (mimeTypes != null) { qPos.add(mimeTypes); } return (List<DLFileEntry>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryFinderImpl.java
License:Open Source License
protected int doCountByG_F_S(long groupId, List<Long> folderIds, int status, boolean inlineSQLHelper) throws SystemException { Session session = null;/* ww w . jav a 2 s. co m*/ try { session = openSession(); String sql = null; String table = "DLFileEntry"; if (status == WorkflowConstants.STATUS_ANY) { sql = CustomSQLUtil.get(COUNT_BY_G_F); } else { sql = CustomSQLUtil.get(COUNT_BY_G_F_S); if (inlineSQLHelper && InlineSQLHelperUtil.isEnabled()) { sql = StringUtil.replace(sql, "[$JOIN$]", CustomSQLUtil.get(DLFolderFinderImpl.JOIN_FV_BY_DL_FILE_ENTRY)); } else { table = "DLFileVersion"; sql = StringUtil.replace(sql, "[$JOIN$]", ""); } } if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFileEntry.class.getName(), "DLFileEntry.fileEntryId", groupId); } sql = StringUtil.replace(sql, "[$FOLDER_ID$]", getFolderIds(folderIds, table)); 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); } for (int i = 0; i < folderIds.size(); i++) { Long folderId = folderIds.get(i); qPos.add(folderId); } Iterator<Long> itr = q.iterate(); 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.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;//ww w . j a v a2s .co m 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;/* w w w. j ava 2 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 List<Object> doFindF_FE_FS_ByG_F_S_M_M(long groupId, long folderId, int status, String[] mimeTypes, boolean includeMountFolders, int start, int end, OrderByComparator obc, boolean inlineSQLHelper) throws SystemException { Session session = null;//from ww w. jav a 2 s . c o m try { session = openSession(); StringBundler sb = new StringBundler(7); sb.append("SELECT * FROM ("); String sql = CustomSQLUtil.get(FIND_F_BY_G_M_F); if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFolder.class.getName(), "DLFolder.folderId", groupId); } sb.append(sql); sb.append(" UNION ALL "); if (status == WorkflowConstants.STATUS_ANY) { sql = CustomSQLUtil.get(FIND_FE_BY_G_F); } else { sql = CustomSQLUtil.get(FIND_FE_BY_G_F_S); } if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFileEntry.class.getName(), "DLFileEntry.fileEntryId", groupId); } sb.append(sql); if ((mimeTypes != null) && (mimeTypes.length > 0)) { for (int i = 0; i < mimeTypes.length; i++) { if (i == 0) { sb.append(" AND ("); } else { sb.append(" OR"); } sb.append(" DLFileEntry.mimeType = '"); sb.append(mimeTypes[i]); sb.append("'"); } sb.append(StringPool.CLOSE_PARENTHESIS); } sb.append(" UNION ALL "); sql = CustomSQLUtil.get(FIND_FS_BY_G_F_S); if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFileShortcut.class.getName(), "DLFileShortcut.fileShortcutId", groupId); } sb.append(sql); if ((mimeTypes != null) && (mimeTypes.length > 0)) { for (int i = 0; i < mimeTypes.length; i++) { if (i == 0) { sb.append(" AND ("); } else { sb.append(" OR"); } sb.append(" mimeType = '"); sb.append(mimeTypes[i]); sb.append("'"); } sb.append(StringPool.CLOSE_PARENTHESIS); } sb.append(") TEMP_TABLE ORDER BY modelFolder DESC, title ASC"); sql = sb.toString(); if (includeMountFolders) { sql = StringUtil.replace(sql, "(DLFolder.mountPoint = ?) AND", ""); } sql = StringUtil.replace(sql, "[$FOLDER_PARENT_FOLDER_ID$]", getFolderId(folderId, "DLFolder")); sql = StringUtil.replace(sql, "[$FILE_ENTRY_FOLDER_ID$]", getFolderId(folderId, "DLFileEntry")); sql = StringUtil.replace(sql, "[$FILE_SHORTCUT_FOLDER_ID$]", getFolderId(folderId, "DLFileShortcut")); sql = CustomSQLUtil.replaceOrderBy(sql, obc); SQLQuery q = session.createSQLQuery(sql); q.addScalar("modelFolderId", Type.LONG); q.addScalar("name", Type.STRING); q.addScalar("title", Type.STRING); q.addScalar("fileShortcutId", Type.LONG); q.addScalar("modelFolder", 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); List<Object> models = new ArrayList<Object>(); Iterator<Object[]> itr = (Iterator<Object[]>) QueryUtil.iterate(q, getDialect(), start, end); while (itr.hasNext()) { Object[] array = itr.next(); long curFolderId = (Long) array[0]; String name = (String) array[1]; //String title = (String)array[2]; long fileShortcutId = (Long) array[3]; long modelFolder = (Long) array[4]; Object obj = null; if (modelFolder == 1) { obj = DLFolderUtil.findByPrimaryKey(curFolderId); } else if (fileShortcutId > 0) { obj = DLFileShortcutUtil.findByPrimaryKey(fileShortcutId); } else { obj = DLFileEntryUtil.findByG_F_N(groupId, curFolderId, name); } models.add(obj); } return models; } 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 List<Object> doFindFE_FS_ByG_F_S(long groupId, long folderId, int status, int start, int end, boolean inlineSQLHelper) throws SystemException { Session session = null;// w w w . j a v a2 s . co m try { session = openSession(); StringBundler sb = new StringBundler(5); sb.append("SELECT * FROM ("); String sql = null; if (status == WorkflowConstants.STATUS_ANY) { sql = CustomSQLUtil.get(FIND_FE_BY_G_F); } else { sql = CustomSQLUtil.get(FIND_FE_BY_G_F_S); } if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFileEntry.class.getName(), "DLFileEntry.fileEntryId", groupId); } sb.append(sql); sb.append(" UNION ALL "); sql = CustomSQLUtil.get(FIND_FS_BY_G_F_S); if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, DLFileShortcut.class.getName(), "DLFileShortcut.fileShortcutId", groupId); } sb.append(sql); sb.append(") TEMP_TABLE ORDER BY modelFolder DESC, title ASC"); sql = sb.toString(); sql = StringUtil.replace(sql, "[$FILE_ENTRY_FOLDER_ID$]", getFolderId(folderId, "DLFileEntry")); sql = StringUtil.replace(sql, "[$FILE_SHORTCUT_FOLDER_ID$]", getFolderId(folderId, "DLFileShortcut")); SQLQuery q = session.createSQLQuery(sql); q.addScalar("modelFolderId", Type.LONG); q.addScalar("name", Type.STRING); q.addScalar("title", Type.STRING); q.addScalar("fileShortcutId", 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); List<Object> models = new ArrayList<Object>(); Iterator<Object[]> itr = (Iterator<Object[]>) QueryUtil.iterate(q, getDialect(), start, end); while (itr.hasNext()) { Object[] array = itr.next(); long folderId2 = (Long) array[0]; String name = (String) array[1]; //String title = (String)array[2]; long fileShortcutId = (Long) array[3]; Object obj = null; if (fileShortcutId > 0) { obj = DLFileShortcutUtil.findByPrimaryKey(fileShortcutId); } else { obj = DLFileEntryUtil.findByG_F_N(groupId, folderId2, name); } models.add(obj); } return models; } 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 w w w . jav a 2 s. co 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 updateSQL(String sql, long folderId, int status, boolean includeMountFolders) { if (includeMountFolders) { sql = StringUtil.replace(sql, "(DLFolder.mountPoint = ?) AND", ""); }//from ww w . jav a 2 s.co m sql = StringUtil.replace(sql, "[$FOLDER_PARENT_FOLDER_ID$]", getFolderId(folderId, "DLFolder")); if (status == WorkflowConstants.STATUS_ANY) { sql = StringUtil.replace(sql, "[$FILE_ENTRY_FOLDER_ID$]", getFolderId(folderId, "DLFileEntry")); } else { sql = StringUtil.replace(sql, "[$FILE_ENTRY_FOLDER_ID$]", getFolderId(folderId, "DLFileVersion")); } return StringUtil.replace(sql, "[$FILE_SHORTCUT_FOLDER_ID$]", getFolderId(folderId, "DLFileShortcut")); }
From source file:com.liferay.portlet.documentlibrary.util.DLIndexer.java
License:Open Source License
@Override public void postProcessContextQuery(BooleanQuery contextQuery, SearchContext searchContext) throws Exception { int status = GetterUtil.getInteger(searchContext.getAttribute(Field.STATUS), WorkflowConstants.STATUS_APPROVED); if (status != WorkflowConstants.STATUS_ANY) { contextQuery.addRequiredTerm(Field.STATUS, status); }// w w w. j a v a2s .co m long[] folderIds = searchContext.getFolderIds(); if ((folderIds != null) && (folderIds.length > 0)) { if (folderIds[0] == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return; } BooleanQuery folderIdsQuery = BooleanQueryFactoryUtil.create(searchContext); for (long folderId : folderIds) { try { DLFolderServiceUtil.getFolder(folderId); } catch (Exception e) { continue; } folderIdsQuery.addTerm(Field.FOLDER_ID, folderId); } contextQuery.add(folderIdsQuery, BooleanClauseOccur.MUST); } }
From source file:com.liferay.portlet.dynamicdatalists.service.persistence.DDLRecordFinderImpl.java
License:Open Source License
public int countByR_S(long recordSetId, int status) throws SystemException { Session session = null;//from w ww.j a v a 2 s . c o m try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_BY_R_S); if (status == WorkflowConstants.STATUS_ANY) { sql = StringUtil.replace(sql, "(DDLRecordVersion.status = ?) AND", ""); } SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); if (status != WorkflowConstants.STATUS_ANY) { qPos.add(status); } qPos.add(recordSetId); Iterator<Long> itr = q.iterate(); 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); } }