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.exportimport.test.util.lar.BaseStagedModelDataHandlerTestCase.java
License:Open Source License
protected void validateRatings(StagedModel stagedModel, StagedModel importedStagedModel) throws Exception { List<RatingsEntry> ratingsEntries = RatingsEntryLocalServiceUtil.getEntries( ExportImportClassedModelUtil.getClassName(stagedModel), ExportImportClassedModelUtil.getClassPK(stagedModel), WorkflowConstants.STATUS_ANY); List<RatingsEntry> importedRatingsEntries = RatingsEntryLocalServiceUtil.getEntries( ExportImportClassedModelUtil.getClassName(importedStagedModel), ExportImportClassedModelUtil.getClassPK(importedStagedModel), WorkflowConstants.STATUS_ANY); Assert.assertEquals(importedRatingsEntries.toString(), ratingsEntries.size(), importedRatingsEntries.size()); for (RatingsEntry ratingsEntry : ratingsEntries) { Iterator<RatingsEntry> iterator = importedRatingsEntries.iterator(); while (iterator.hasNext()) { RatingsEntry importedRatingsEntry = iterator.next(); if (ratingsEntry.getScore() == importedRatingsEntry.getScore()) { iterator.remove();//w w w. j a v a 2s. c o m break; } } } Assert.assertTrue(importedRatingsEntries.toString(), importedRatingsEntries.isEmpty()); }
From source file:com.liferay.faces.demos.bean.UsersModelBean.java
License:Open Source License
public List<SelectItem> getStatusSelectItems() { if (statusSelectItems == null) { LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance(); statusSelectItems = new ArrayList<SelectItem>(); statusSelectItems.add(//from w ww . j a va 2 s. c o m new SelectItem(WorkflowConstants.STATUS_ANY, liferayFacesContext.getMessage("any-status"))); statusSelectItems.add( new SelectItem(WorkflowConstants.STATUS_APPROVED, liferayFacesContext.getMessage("active"))); statusSelectItems.add( new SelectItem(WorkflowConstants.STATUS_INACTIVE, liferayFacesContext.getMessage("inactive"))); } return statusSelectItems; }
From source file:com.liferay.faces.demos.list.UserLazyDataModel.java
License:Open Source License
public int countRows() { int totalCount = 0; try {/* w w w .j ava 2 s .c o m*/ LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>(); params.put("expandoAttributes", null); Sort sort = SortFactoryUtil.getSort(User.class, DEFAULT_SORT_CRITERIA, "asc"); boolean andSearch = true; int status = WorkflowConstants.STATUS_ANY; String firstName = null; String middleName = null; String lastName = null; String screenName = null; String emailAddress = null; Hits hits = UserLocalServiceUtil.search(companyId, firstName, middleName, lastName, screenName, emailAddress, status, params, andSearch, QueryUtil.ALL_POS, QueryUtil.ALL_POS, sort); totalCount = hits.getLength(); } catch (Exception e) { logger.error(e.getMessage(), e); } return totalCount; }
From source file:com.liferay.faces.demos.list.UserLazyDataModel.java
License:Open Source License
/** * This method is called by the PrimeFaces {@link DataTable} according to the rows specified in the currently * displayed page of data./*from w w w . j ava 2 s . c o m*/ * * @param first The zero-relative first row index. * @param pageSize The number of rows to fetch. * @param sortField The name of the field which the table is sorted by. * @param sortOrder The sort order, which can be either ascending (default) or descending. * @param filters The query criteria. Note that in order for the filtering to work with the Liferay API, the * end-user must specify complete, matching words. Wildcards and partial matches are not * supported. */ @Override public List<User> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) { List<User> users = null; Sort sort; // sort if (sortField != null) { if (sortOrder.equals(SortOrder.DESCENDING)) { sort = SortFactoryUtil.getSort(User.class, sortField, "desc"); } else { sort = SortFactoryUtil.getSort(User.class, sortField, "asc"); } } else { sort = SortFactoryUtil.getSort(User.class, DEFAULT_SORT_CRITERIA, "asc"); } try { LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>(); int liferayOneRelativeFinishRow = first + pageSize + 1; boolean andSearch = true; int status = WorkflowConstants.STATUS_ANY; String firstName = trimExpresssion((String) filters.get("firstName")); String middleName = trimExpresssion((String) filters.get("middleName")); String lastName = trimExpresssion((String) filters.get("lastName")); String screenName = trimExpresssion((String) filters.get("screenName")); String emailAddress = trimExpresssion((String) filters.get("emailAddress")); // For the sake of speed, search for users in the index rather than // querying the database directly. Hits hits = UserLocalServiceUtil.search(companyId, firstName, middleName, lastName, screenName, emailAddress, status, params, andSearch, first, liferayOneRelativeFinishRow, sort); List<Document> documentHits = hits.toList(); logger.debug( ("filters firstName=[{0}] middleName=[{1}] lastName=[{2}] screenName=[{3}] emailAddress=[{4}] active=[{5}] andSearch=[{6}] startRow=[{7}] liferayOneRelativeFinishRow=[{8}] sortColumn=[{9}] reverseOrder=[{10}] hitCount=[{11}]"), firstName, middleName, lastName, screenName, emailAddress, status, andSearch, first, liferayOneRelativeFinishRow, sortField, sort.isReverse(), documentHits.size()); // Convert the results from the search index into a list of user // objects. users = new ArrayList<User>(documentHits.size()); for (Document document : documentHits) { long userId = GetterUtil.getLong(document.get(Field.USER_ID)); try { User user = UserLocalServiceUtil.getUserById(userId); users.add(user); } catch (NoSuchUserException nsue) { logger.error("User with userId=[{0}] does not exist in the search index. Please reindex."); } } } catch (Exception e) { logger.error(e.getMessage(), e); } return users; }
From source file:com.liferay.journal.content.web.internal.display.context.JournalContentDisplayContext.java
License:Open Source License
public JournalArticle getArticle() { if (_article != null) { return _article; }//w w w . j av a2 s . c o m _article = (JournalArticle) _portletRequest.getAttribute(WebKeys.JOURNAL_ARTICLE); if (_article != null) { return _article; } long articleResourcePrimKey = ParamUtil.getLong(_portletRequest, "articleResourcePrimKey"); if (articleResourcePrimKey > 0) { _article = JournalArticleLocalServiceUtil.fetchLatestArticle(articleResourcePrimKey, WorkflowConstants.STATUS_ANY, true); } else { _article = JournalArticleLocalServiceUtil.fetchLatestArticle(getArticleGroupId(), getArticleId(), WorkflowConstants.STATUS_ANY); } return _article; }
From source file:com.liferay.journal.content.web.internal.display.context.JournalContentDisplayContext.java
License:Open Source License
public JournalArticle getLatestArticle() { if (_latestArticle != null) { return _latestArticle; }/*from ww w.j a v a 2s .com*/ JournalArticleDisplay articleDisplay = getArticleDisplay(); if (articleDisplay == null) { return null; } _latestArticle = JournalArticleLocalServiceUtil.fetchLatestArticle(articleDisplay.getGroupId(), articleDisplay.getArticleId(), WorkflowConstants.STATUS_ANY); return _latestArticle; }
From source file:com.liferay.journal.content.web.internal.portlet.JournalContentPortlet.java
License:Open Source License
@Override public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { PortletPreferences portletPreferences = renderRequest.getPreferences(); ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); long articleGroupId = PrefsParamUtil.getLong(portletPreferences, renderRequest, "groupId", themeDisplay.getScopeGroupId()); String articleId = PrefsParamUtil.getString(portletPreferences, renderRequest, "articleId"); String ddmTemplateKey = PrefsParamUtil.getString(portletPreferences, renderRequest, "ddmTemplateKey"); JournalArticle article = null;// w w w.j av a2 s . com JournalArticleDisplay articleDisplay = null; if ((articleGroupId > 0) && Validator.isNotNull(articleId)) { String viewMode = ParamUtil.getString(renderRequest, "viewMode"); String languageId = LanguageUtil.getLanguageId(renderRequest); int page = ParamUtil.getInteger(renderRequest, "page", 1); article = _journalArticleLocalService.fetchLatestArticle(articleGroupId, articleId, WorkflowConstants.STATUS_APPROVED); try { if (article == null) { article = _journalArticleLocalService.getLatestArticle(articleGroupId, articleId, WorkflowConstants.STATUS_ANY); } if (Validator.isNull(ddmTemplateKey)) { ddmTemplateKey = article.getDDMTemplateKey(); } articleDisplay = _journalContent.getDisplay(article, ddmTemplateKey, viewMode, languageId, page, new PortletRequestModel(renderRequest, renderResponse), themeDisplay); } catch (Exception e) { renderRequest.removeAttribute(WebKeys.JOURNAL_ARTICLE); } } 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); } super.doView(renderRequest, renderResponse); }
From source file:com.liferay.journal.search.test.JournalIndexerTest.java
License:Open Source License
@Test public void testIndexVersions() throws Exception { SearchContext searchContext = SearchContextTestUtil.getSearchContext(_group.getGroupId()); assertSearchCount(0, _group.getGroupId(), searchContext); JournalFolder folder = JournalTestUtil.addFolder(_group.getGroupId(), RandomTestUtil.randomString()); String content = "Liferay Architectural Approach"; JournalArticle article = JournalTestUtil.addArticleWithWorkflow(_group.getGroupId(), folder.getFolderId(), "title", content, true); assertSearchCount(1, _group.getGroupId(), false, WorkflowConstants.STATUS_ANY, searchContext); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); article = JournalTestUtil.updateArticle(article, article.getTitleMap(), article.getContent(), false, true, serviceContext);/*w w w . j av a2 s . co m*/ assertSearchCount(2, _group.getGroupId(), false, WorkflowConstants.STATUS_ANY, searchContext); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); JournalTestUtil.updateArticle(article, article.getTitleMap(), article.getContent(), false, true, serviceContext); assertSearchCount(3, _group.getGroupId(), false, WorkflowConstants.STATUS_ANY, searchContext); }
From source file:com.liferay.journal.search.test.JournalIndexerTest.java
License:Open Source License
protected void indexVersions(boolean delete, boolean all) throws Exception { SearchContext searchContext = SearchContextTestUtil.getSearchContext(_group.getGroupId()); assertSearchCount(0, _group.getGroupId(), searchContext); JournalFolder folder = JournalTestUtil.addFolder(_group.getGroupId(), RandomTestUtil.randomString()); String content = "Liferay Architectural Approach"; JournalArticle article = JournalTestUtil.addArticleWithWorkflow(_group.getGroupId(), folder.getFolderId(), "title", content, true); assertSearchCount(1, _group.getGroupId(), searchContext); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); article = JournalTestUtil.updateArticle(article, article.getTitleMap(), article.getContent(), false, true, serviceContext);/*from w w w .j a va2 s . c om*/ assertSearchCount(2, _group.getGroupId(), false, WorkflowConstants.STATUS_ANY, searchContext); if (delete) { if (all) { JournalArticleLocalServiceUtil.deleteArticle(_group.getGroupId(), article.getArticleId(), serviceContext); assertSearchCount(0, _group.getGroupId(), false, WorkflowConstants.STATUS_ANY, searchContext); } else { JournalArticleLocalServiceUtil.deleteArticle(article); assertSearchCount(1, _group.getGroupId(), false, WorkflowConstants.STATUS_ANY, searchContext); } } else { if (all) { JournalArticleLocalServiceUtil.expireArticle(TestPropsValues.getUserId(), _group.getGroupId(), article.getArticleId(), article.getUrlTitle(), serviceContext); } else { JournalArticleLocalServiceUtil.expireArticle(TestPropsValues.getUserId(), _group.getGroupId(), article.getArticleId(), article.getVersion(), article.getUrlTitle(), serviceContext); } assertSearchCount(2, _group.getGroupId(), false, WorkflowConstants.STATUS_ANY, searchContext); } }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
@Override public JournalArticle fetchArticle(long groupId, String articleId) { // Get the latest article that is approved, if none are approved, get // the latest unapproved article JournalArticle article = fetchLatestArticle(groupId, articleId, WorkflowConstants.STATUS_APPROVED); if (article != null) { return article; }/*w w w . j a v a2 s . co m*/ return fetchLatestArticle(groupId, articleId, WorkflowConstants.STATUS_ANY); }