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.journal.service.persistence.JournalArticleFinderImpl.java
License:Open Source License
protected int doCountByC_G_C_A_V_T_D_C_T_S_T_D_S_R(long companyId, long groupId, long classNameId, String[] articleIds, Double version, String[] titles, String[] descriptions, String[] contents, String type, String[] structureIds, String[] templateIds, Date displayDateGT, Date displayDateLT, int status, Date reviewDate, boolean andOperator, boolean inlineSQLHelper) throws SystemException { articleIds = CustomSQLUtil.keywords(articleIds, false); titles = CustomSQLUtil.keywords(titles); descriptions = CustomSQLUtil.keywords(descriptions, false); contents = CustomSQLUtil.keywords(contents, false); structureIds = CustomSQLUtil.keywords(structureIds, false); templateIds = CustomSQLUtil.keywords(templateIds, false); Timestamp displayDateGT_TS = CalendarUtil.getTimestamp(displayDateGT); Timestamp displayDateLT_TS = CalendarUtil.getTimestamp(displayDateLT); Timestamp reviewDate_TS = CalendarUtil.getTimestamp(reviewDate); Session session = null;/*from ww w .j a v a 2 s . c o m*/ try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_BY_C_G_C_A_V_T_D_C_T_S_T_D_S_R); if (groupId <= 0) { sql = StringUtil.replace(sql, "(groupId = ?) AND", ""); } sql = CustomSQLUtil.replaceKeywords(sql, "articleId", StringPool.LIKE, false, articleIds); if ((version == null) || (version <= 0)) { sql = StringUtil.replace(sql, "(version = ?) [$AND_OR_CONNECTOR$]", ""); } sql = CustomSQLUtil.replaceKeywords(sql, "lower(title)", StringPool.LIKE, false, titles); sql = CustomSQLUtil.replaceKeywords(sql, "description", StringPool.LIKE, false, descriptions); sql = CustomSQLUtil.replaceKeywords(sql, "content", StringPool.LIKE, false, contents); sql = CustomSQLUtil.replaceKeywords(sql, "structureId", StringPool.LIKE, false, structureIds); sql = CustomSQLUtil.replaceKeywords(sql, "templateId", StringPool.LIKE, false, templateIds); if (status == WorkflowConstants.STATUS_ANY) { sql = StringUtil.replace(sql, "(status = ?) AND", ""); } sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); if ((articleIds != null) && ((articleIds.length > 1) || ((articleIds.length == 1) && (articleIds[0] != null))) && (version == null)) { sql = StringUtil.replace(sql, "MAX(version) AS tempVersion", "version AS tempVersion"); sql = StringUtil.replace(sql, "[$GROUP_BY_CLAUSE$]", ""); } else { sql = StringUtil.replace(sql, "[$GROUP_BY_CLAUSE$]", "GROUP BY groupId, articleId"); } if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, JournalArticle.class.getName(), "JournalArticle.resourcePrimKey", groupId); sql = StringUtil.replace(sql, "(companyId", "(JournalArticle.companyId"); } SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (groupId > 0) { qPos.add(groupId); } qPos.add(classNameId); qPos.add(articleIds, 2); if ((version != null) && (version > 0)) { qPos.add(version); } qPos.add(titles, 2); qPos.add(descriptions, 2); qPos.add(contents, 2); qPos.add(type); qPos.add(type); qPos.add(structureIds, 2); qPos.add(templateIds, 2); qPos.add(displayDateGT_TS); qPos.add(displayDateGT_TS); qPos.add(displayDateLT_TS); qPos.add(displayDateLT_TS); if (status != WorkflowConstants.STATUS_ANY) { qPos.add(status); } qPos.add(reviewDate_TS); qPos.add(reviewDate_TS); 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.journal.service.persistence.JournalArticleFinderImpl.java
License:Open Source License
protected List<JournalArticle> doFindByC_G_C_A_V_T_D_C_T_S_T_D_S_R(long companyId, long groupId, long classNameId, String[] articleIds, Double version, String[] titles, String[] descriptions, String[] contents, String type, String[] structureIds, String[] templateIds, Date displayDateGT, Date displayDateLT, int status, Date reviewDate, boolean andOperator, int start, int end, OrderByComparator orderByComparator, boolean inlineSQLHelper) throws SystemException { articleIds = CustomSQLUtil.keywords(articleIds, false); titles = CustomSQLUtil.keywords(titles); descriptions = CustomSQLUtil.keywords(descriptions, false); contents = CustomSQLUtil.keywords(contents, false); structureIds = CustomSQLUtil.keywords(structureIds, false); templateIds = CustomSQLUtil.keywords(templateIds, false); Timestamp displayDateGT_TS = CalendarUtil.getTimestamp(displayDateGT); Timestamp displayDateLT_TS = CalendarUtil.getTimestamp(displayDateLT); Timestamp reviewDate_TS = CalendarUtil.getTimestamp(reviewDate); Session session = null;//from w ww . j a va 2 s . c om try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_C_G_C_A_V_T_D_C_T_S_T_D_S_R); if (groupId <= 0) { sql = StringUtil.replace(sql, "(groupId = ?) AND", ""); } sql = CustomSQLUtil.replaceKeywords(sql, "articleId", StringPool.LIKE, false, articleIds); if ((version == null) || (version <= 0)) { sql = StringUtil.replace(sql, "(version = ?) [$AND_OR_CONNECTOR$]", ""); } sql = CustomSQLUtil.replaceKeywords(sql, "lower(title)", StringPool.LIKE, false, titles); sql = CustomSQLUtil.replaceKeywords(sql, "description", StringPool.LIKE, false, descriptions); sql = CustomSQLUtil.replaceKeywords(sql, "content", StringPool.LIKE, false, contents); sql = CustomSQLUtil.replaceKeywords(sql, "structureId", StringPool.LIKE, false, structureIds); sql = CustomSQLUtil.replaceKeywords(sql, "templateId", StringPool.LIKE, false, templateIds); if (status == WorkflowConstants.STATUS_ANY) { sql = StringUtil.replace(sql, "(status = ?) AND", ""); } sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); if ((articleIds != null) && ((articleIds.length > 1) || ((articleIds.length == 1) && (articleIds[0] != null))) && (version == null)) { sql = StringUtil.replace(sql, "MAX(version) AS tempVersion", "version AS tempVersion"); sql = StringUtil.replace(sql, "[$GROUP_BY_CLAUSE$]", ""); } else { sql = StringUtil.replace(sql, "[$GROUP_BY_CLAUSE$]", "GROUP BY groupId, articleId"); } sql = CustomSQLUtil.replaceOrderBy(sql, orderByComparator); if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, JournalArticle.class.getName(), "JournalArticle.resourcePrimKey", groupId); sql = StringUtil.replace(sql, "(companyId", "(JournalArticle.companyId"); } SQLQuery q = session.createSQLQuery(sql); q.addEntity("JournalArticle", JournalArticleImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (groupId > 0) { qPos.add(groupId); } qPos.add(classNameId); qPos.add(articleIds, 2); if ((version != null) && (version > 0)) { qPos.add(version); } qPos.add(titles, 2); qPos.add(descriptions, 2); qPos.add(contents, 2); qPos.add(type); qPos.add(type); qPos.add(structureIds, 2); qPos.add(templateIds, 2); qPos.add(displayDateGT_TS); qPos.add(displayDateGT_TS); qPos.add(displayDateLT_TS); qPos.add(displayDateLT_TS); if (status != WorkflowConstants.STATUS_ANY) { qPos.add(status); } qPos.add(reviewDate_TS); qPos.add(reviewDate_TS); return (List<JournalArticle>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.journal.service.persistence.JournalArticleFinderImpl.java
License:Open Source License
protected JournalArticle getLatestArticle(long groupId, String articleId, int status) throws SystemException { List<JournalArticle> articles = null; if (status == WorkflowConstants.STATUS_ANY) { articles = JournalArticleUtil.findByG_A(groupId, articleId, 0, 1); } else {/*from w ww . ja v a2 s .c o m*/ articles = JournalArticleUtil.findByG_A_ST(groupId, articleId, status, 0, 1); } if (articles.isEmpty()) { return null; } return articles.get(0); }
From source file:com.liferay.portlet.journal.util.JournalIndexer.java
License:Open Source License
@Override public void postProcessContextQuery(BooleanQuery contextQuery, SearchContext searchContext) throws Exception { Long classNameId = (Long) searchContext.getAttribute(Field.CLASS_NAME_ID); if (classNameId != null) { contextQuery.addRequiredTerm("classNameId", classNameId.toString()); }//from ww w. j a v a2s .c o m int status = GetterUtil.getInteger(searchContext.getAttribute(Field.STATUS), WorkflowConstants.STATUS_APPROVED); if (status != WorkflowConstants.STATUS_ANY) { contextQuery.addRequiredTerm(Field.STATUS, status); } String articleType = (String) searchContext.getAttribute("articleType"); if (Validator.isNotNull(articleType)) { contextQuery.addRequiredTerm(Field.TYPE, articleType); } String structureId = (String) searchContext.getAttribute("structureId"); if (Validator.isNotNull(structureId)) { contextQuery.addRequiredTerm("structureId", structureId); } String templateId = (String) searchContext.getAttribute("templateId"); if (Validator.isNotNull(templateId)) { contextQuery.addRequiredTerm("templateId", templateId); } }
From source file:com.liferay.portlet.journalcontent.action.ViewAction.java
License:Open Source License
@Override public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { PortletPreferences preferences = renderRequest.getPreferences(); ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); long groupId = ParamUtil.getLong(renderRequest, "groupId"); if (groupId <= 0) { groupId = GetterUtil.getLong(preferences.getValue("groupId", StringPool.BLANK)); }/*w ww . java 2 s . com*/ String articleId = ParamUtil.getString(renderRequest, "articleId"); String templateId = ParamUtil.getString(renderRequest, "templateId"); if (Validator.isNull(articleId)) { articleId = GetterUtil.getString(preferences.getValue("articleId", StringPool.BLANK)); templateId = GetterUtil.getString(preferences.getValue("templateId", StringPool.BLANK)); } String viewMode = ParamUtil.getString(renderRequest, "viewMode"); String languageId = LanguageUtil.getLanguageId(renderRequest); int page = ParamUtil.getInteger(renderRequest, "page", 1); String xmlRequest = PortletRequestUtil.toXML(renderRequest, renderResponse); JournalArticle article = null; JournalArticleDisplay articleDisplay = null; if ((groupId > 0) && Validator.isNotNull(articleId)) { try { article = JournalArticleLocalServiceUtil.getLatestArticle(groupId, articleId, WorkflowConstants.STATUS_APPROVED); } catch (NoSuchArticleException nsae) { } try { if (article == null) { article = JournalArticleLocalServiceUtil.getLatestArticle(groupId, articleId, WorkflowConstants.STATUS_ANY); } double version = article.getVersion(); articleDisplay = JournalContentUtil.getDisplay(groupId, articleId, version, templateId, viewMode, languageId, themeDisplay, page, xmlRequest); } catch (Exception e) { renderRequest.removeAttribute(WebKeys.JOURNAL_ARTICLE); articleDisplay = JournalContentUtil.getDisplay(groupId, articleId, templateId, viewMode, languageId, themeDisplay, page, xmlRequest); } } if (article != null) { renderRequest.setAttribute(WebKeys.JOURNAL_ARTICLE, article); } if (articleDisplay != null) { renderRequest.setAttribute(WebKeys.JOURNAL_ARTICLE_DISPLAY, articleDisplay); } else { renderRequest.removeAttribute(WebKeys.JOURNAL_ARTICLE_DISPLAY); } return mapping.findForward("portlet.journal_content.view"); }
From source file:com.liferay.portlet.messageboards.action.ViewMessageAction.java
License:Open Source License
@Override public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception { try {/* www .jav a2s.com*/ long messageId = ParamUtil.getLong(renderRequest, "messageId"); PortalPreferences preferences = PortletPreferencesFactoryUtil.getPortalPreferences(renderRequest); String threadView = ParamUtil.getString(renderRequest, "threadView"); if (Validator.isNotNull(threadView)) { preferences.setValue(PortletKeys.MESSAGE_BOARDS, "thread-view", threadView); } else { threadView = preferences.getValue(PortletKeys.MESSAGE_BOARDS, "thread-view", PropsValues.MESSAGE_BOARDS_THREAD_VIEWS_DEFAULT); } if (!ArrayUtil.contains(PropsValues.MESSAGE_BOARDS_THREAD_VIEWS, threadView)) { threadView = PropsValues.MESSAGE_BOARDS_THREAD_VIEWS_DEFAULT; preferences.setValue(PortletKeys.MESSAGE_BOARDS, "thread-view", threadView); } boolean includePrevAndNext = PropsValues.MESSAGE_BOARDS_THREAD_PREVIOUS_AND_NEXT_NAVIGATION_ENABLED; MBMessageDisplay messageDisplay = MBMessageServiceUtil.getMessageDisplay(messageId, WorkflowConstants.STATUS_ANY, threadView, includePrevAndNext); renderRequest.setAttribute(WebKeys.MESSAGE_BOARDS_MESSAGE, messageDisplay); return mapping.findForward("portlet.message_boards.view_message"); } catch (Exception e) { if (e instanceof NoSuchMessageException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass().getName()); return mapping.findForward("portlet.message_boards.error"); } else { throw e; } } }
From source file:com.liferay.portlet.messageboards.service.impl.MBMessageLocalServiceImpl.java
License:Open Source License
public List<MBMessage> getCategoryMessages(long groupId, long categoryId, int status, int start, int end) throws SystemException { if (status == WorkflowConstants.STATUS_ANY) { return mbMessagePersistence.findByG_C(groupId, categoryId, start, end); } else {/*from ww w .j av a2 s.c o m*/ return mbMessagePersistence.findByG_C_S(groupId, categoryId, status, start, end); } }
From source file:com.liferay.portlet.messageboards.service.impl.MBMessageLocalServiceImpl.java
License:Open Source License
public List<MBMessage> getCategoryMessages(long groupId, long categoryId, int status, int start, int end, OrderByComparator obc) throws SystemException { if (status == WorkflowConstants.STATUS_ANY) { return mbMessagePersistence.findByG_C(groupId, categoryId, start, end, obc); } else {/*from ww w.ja va2s . c o m*/ return mbMessagePersistence.findByG_C_S(groupId, categoryId, status, start, end, obc); } }
From source file:com.liferay.portlet.messageboards.service.impl.MBMessageLocalServiceImpl.java
License:Open Source License
public int getCategoryMessagesCount(long groupId, long categoryId, int status) throws SystemException { if (status == WorkflowConstants.STATUS_ANY) { return mbMessagePersistence.countByG_C(groupId, categoryId); } else {/*from ww w . j a va 2s. c o m*/ return mbMessagePersistence.countByG_C_S(groupId, categoryId, status); } }
From source file:com.liferay.portlet.messageboards.service.impl.MBMessageLocalServiceImpl.java
License:Open Source License
public List<MBMessage> getCompanyMessages(long companyId, int status, int start, int end) throws SystemException { if (status == WorkflowConstants.STATUS_ANY) { return mbMessagePersistence.findByCompanyId(companyId, start, end); } else {//w w w . j a v a 2 s.c o m return mbMessagePersistence.findByC_S(companyId, status, start, end); } }