List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_PENDING
int STATUS_PENDING
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_PENDING.
Click Source Link
From source file:com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
public JournalArticle updateStatus(long userId, JournalArticle article, int status, String articleURL, ServiceContext serviceContext) throws PortalException, SystemException { // Article//from ww w . j a v a 2 s . co m User user = userPersistence.findByPrimaryKey(userId); Date now = new Date(); int oldStatus = article.getStatus(); article.setModifiedDate(serviceContext.getModifiedDate(now)); boolean neverExpire = false; if (status == WorkflowConstants.STATUS_APPROVED) { Date expirationDate = article.getExpirationDate(); if ((expirationDate != null) && expirationDate.before(now)) { neverExpire = true; article.setExpirationDate(null); } } if (status == WorkflowConstants.STATUS_EXPIRED) { article.setExpirationDate(now); } article.setStatus(status); article.setStatusByUserId(user.getUserId()); article.setStatusByUserName(user.getFullName()); article.setStatusDate(serviceContext.getModifiedDate(now)); journalArticlePersistence.update(article, false); if (isLatestVersion(article.getGroupId(), article.getArticleId(), article.getVersion())) { if (status == WorkflowConstants.STATUS_APPROVED) { updateUrlTitles(article.getGroupId(), article.getArticleId(), article.getUrlTitle()); // Asset if ((oldStatus != WorkflowConstants.STATUS_APPROVED) && (article.getVersion() != JournalArticleConstants.VERSION_DEFAULT)) { AssetEntry draftAssetEntry = null; try { draftAssetEntry = assetEntryLocalService.getEntry(JournalArticle.class.getName(), article.getPrimaryKey()); Date[] dateInterval = getDateInterval(article.getGroupId(), article.getArticleId(), article.getDisplayDate(), article.getExpirationDate()); Date displayDate = dateInterval[0]; Date expirationDate = dateInterval[1]; long[] assetCategoryIds = draftAssetEntry.getCategoryIds(); String[] assetTagNames = draftAssetEntry.getTagNames(); List<AssetLink> assetLinks = assetLinkLocalService .getDirectLinks(draftAssetEntry.getEntryId(), AssetLinkConstants.TYPE_RELATED); long[] assetLinkEntryIds = StringUtil .split(ListUtil.toString(assetLinks, AssetLink.ENTRY_ID2_ACCESSOR), 0L); boolean visible = true; if (article.getClassNameId() > 0) { visible = false; } AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, article.getGroupId(), JournalArticle.class.getName(), article.getResourcePrimKey(), article.getUuid(), getClassTypeId(article), assetCategoryIds, assetTagNames, visible, null, null, displayDate, expirationDate, ContentTypes.TEXT_HTML, article.getTitle(), article.getDescription(), article.getDescription(), null, article.getLayoutUuid(), 0, 0, null, false); assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds, AssetLinkConstants.TYPE_RELATED); assetEntryLocalService.deleteEntry(JournalArticle.class.getName(), article.getPrimaryKey()); } catch (NoSuchEntryException nsee) { } } if (article.getClassNameId() == 0) { AssetEntry assetEntry = assetEntryLocalService.updateVisible(JournalArticle.class.getName(), article.getResourcePrimKey(), true); if (neverExpire) { assetEntry.setExpirationDate(null); assetEntryLocalService.updateAssetEntry(assetEntry, false); } } // Expando ExpandoBridge expandoBridge = article.getExpandoBridge(); expandoBridge.setAttributes(serviceContext); // Indexer Indexer indexer = IndexerRegistryUtil.getIndexer(JournalArticle.class); indexer.reindex(article); } else if (oldStatus == WorkflowConstants.STATUS_APPROVED) { updatePreviousApprovedArticle(article); } } if (article.getClassNameId() == 0) { // Email if ((oldStatus == WorkflowConstants.STATUS_PENDING) && ((status == WorkflowConstants.STATUS_APPROVED) || (status == WorkflowConstants.STATUS_DENIED))) { String msg = "granted"; if (status == WorkflowConstants.STATUS_DENIED) { msg = "denied"; } try { PortletPreferences preferences = ServiceContextUtil.getPortletPreferences(serviceContext); sendEmail(article, articleURL, preferences, msg, serviceContext); } catch (Exception e) { _log.error("Unable to send email to notify the change of status " + " to " + msg + " for article " + article.getId() + ": " + e.getMessage()); } } // Subscriptions notifySubscribers(article, serviceContext); } return article; }
From source file:com.liferay.portlet.wiki.service.impl.WikiPageLocalServiceImpl.java
License:Open Source License
public WikiPage getDraftPage(long nodeId, String title) throws PortalException, SystemException { List<WikiPage> pages = wikiPagePersistence.findByN_T_S(nodeId, title, WorkflowConstants.STATUS_DRAFT, 0, 1); if (!pages.isEmpty()) { return pages.get(0); } else {//from w ww .ja va 2 s . c om pages = wikiPagePersistence.findByN_T_S(nodeId, title, WorkflowConstants.STATUS_PENDING, 0, 1); if (!pages.isEmpty()) { return pages.get(0); } else { throw new NoSuchPageException(); } } }
From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java
License:Open Source License
@Override public WikiPage getDraftPage(long nodeId, String title) throws PortalException { List<WikiPage> pages = wikiPagePersistence.findByN_T_S(nodeId, title, WorkflowConstants.STATUS_DRAFT, 0, 1); if (!pages.isEmpty()) { return pages.get(0); }/* www . j a v a 2s .com*/ pages = wikiPagePersistence.findByN_T_S(nodeId, title, WorkflowConstants.STATUS_PENDING, 0, 1); if (!pages.isEmpty()) { return pages.get(0); } else { StringBundler sb = new StringBundler(5); sb.append("{nodeId="); sb.append(nodeId); sb.append(", title="); sb.append(title); sb.append("}"); throw new NoSuchPageException(sb.toString()); } }
From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java
License:Open Source License
@Override public WikiPage movePageToTrash(long userId, WikiPage page) throws PortalException { if (page.isInTrash()) { throw new TrashEntryException(); }/*from ww w . j a v a2 s. co m*/ // Page int oldStatus = page.getStatus(); String oldTitle = page.getTitle(); if (oldStatus == WorkflowConstants.STATUS_PENDING) { page.setStatus(WorkflowConstants.STATUS_DRAFT); wikiPagePersistence.update(page); } List<WikiPage> pageVersions = wikiPagePersistence.findByR_N_H(page.getResourcePrimKey(), page.getNodeId(), false); pageVersions = ListUtil.sort(pageVersions, new PageVersionComparator()); List<ObjectValuePair<Long, Integer>> pageVersionStatusOVPs = new ArrayList<>(); if ((pageVersions != null) && !pageVersions.isEmpty()) { pageVersionStatusOVPs = getPageVersionStatuses(pageVersions); } page = updateStatus(userId, page, WorkflowConstants.STATUS_IN_TRASH, new ServiceContext(), new HashMap<String, Serializable>()); // Trash WikiPageResource pageResource = wikiPageResourcePersistence.fetchByPrimaryKey(page.getResourcePrimKey()); UnicodeProperties typeSettingsProperties = new UnicodeProperties(); typeSettingsProperties.put("title", page.getTitle()); TrashEntry trashEntry = trashEntryLocalService.addTrashEntry(userId, page.getGroupId(), WikiPage.class.getName(), page.getResourcePrimKey(), page.getUuid(), null, oldStatus, pageVersionStatusOVPs, typeSettingsProperties); String trashTitle = TrashUtil.getTrashTitle(trashEntry.getEntryId()); for (WikiPage pageVersion : pageVersions) { pageVersion.setTitle(trashTitle); pageVersion.setStatus(WorkflowConstants.STATUS_IN_TRASH); wikiPagePersistence.update(pageVersion); } pageResource.setTitle(trashTitle); wikiPageResourcePersistence.update(pageResource); page.setTitle(trashTitle); wikiPagePersistence.update(page); // Child pages moveDependentChildPagesToTrash(page.getNodeId(), oldTitle, trashTitle, trashEntry.getEntryId(), true); // Redirect pages moveDependentRedirectorPagesToTrash(page.getNodeId(), oldTitle, trashTitle, trashEntry.getEntryId(), true); // Asset assetEntryLocalService.updateVisible(WikiPage.class.getName(), page.getResourcePrimKey(), false); // Attachments for (FileEntry fileEntry : page.getAttachmentsFileEntries()) { PortletFileRepositoryUtil.movePortletFileEntryToTrash(userId, fileEntry.getFileEntryId()); } // Comment CommentManagerUtil.moveDiscussionToTrash(WikiPage.class.getName(), page.getResourcePrimKey()); // Social JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", TrashUtil.getOriginalTitle(page.getTitle())); extraDataJSONObject.put("version", page.getVersion()); SocialActivityManagerUtil.addActivity(userId, page, SocialActivityConstants.TYPE_MOVE_TO_TRASH, extraDataJSONObject.toString(), 0); // Indexer Indexer<WikiPage> indexer = IndexerRegistryUtil.nullSafeGetIndexer(WikiPage.class); indexer.reindex(page); // Workflow if (oldStatus == WorkflowConstants.STATUS_PENDING) { workflowInstanceLinkLocalService.deleteWorkflowInstanceLink(page.getCompanyId(), page.getGroupId(), WikiPage.class.getName(), page.getPageId()); } return page; }
From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java
License:Open Source License
protected List<ObjectValuePair<Long, Integer>> getPageVersionStatuses(List<WikiPage> pages) { List<ObjectValuePair<Long, Integer>> pageVersionStatusOVPs = new ArrayList<>(pages.size()); for (WikiPage page : pages) { int status = page.getStatus(); if (status == WorkflowConstants.STATUS_PENDING) { status = WorkflowConstants.STATUS_DRAFT; }//from w ww. java2 s. c om ObjectValuePair<Long, Integer> pageVersionStatusOVP = new ObjectValuePair<>(page.getPageId(), status); pageVersionStatusOVPs.add(pageVersionStatusOVP); } return pageVersionStatusOVPs; }
From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java
License:Open Source License
protected void moveDependentToTrash(WikiPage page, long trashEntryId, boolean createTrashVersion) throws PortalException { // Page//from ww w . j a v a 2 s . c o m String oldTitle = page.getTitle(); String trashTitle = oldTitle; if (createTrashVersion) { UnicodeProperties typeSettingsProperties = new UnicodeProperties(); typeSettingsProperties.put("title", oldTitle); TrashVersion trashVersion = trashVersionLocalService.addTrashVersion(trashEntryId, WikiPage.class.getName(), page.getPageId(), page.getStatus(), typeSettingsProperties); trashTitle = TrashUtil.getTrashTitle(trashVersion.getVersionId()); WikiPageResource pageResource = wikiPageResourcePersistence.findByPrimaryKey(page.getResourcePrimKey()); pageResource.setTitle(trashTitle); wikiPageResourcePersistence.update(pageResource); page.setTitle(trashTitle); wikiPagePersistence.update(page); } int oldStatus = page.getStatus(); if (oldStatus == WorkflowConstants.STATUS_IN_TRASH) { return; } // Version pages List<WikiPage> versionPages = wikiPagePersistence.findByR_N(page.getResourcePrimKey(), page.getNodeId()); for (WikiPage versionPage : versionPages) { // Version page versionPage.setTitle(page.getTitle()); int versionPageOldStatus = versionPage.getStatus(); versionPage.setStatus(WorkflowConstants.STATUS_IN_TRASH); wikiPagePersistence.update(versionPage); // Trash int status = versionPageOldStatus; if (versionPageOldStatus == WorkflowConstants.STATUS_PENDING) { status = WorkflowConstants.STATUS_DRAFT; } if (versionPageOldStatus != WorkflowConstants.STATUS_APPROVED) { trashVersionLocalService.addTrashVersion(trashEntryId, WikiPage.class.getName(), versionPage.getPageId(), status, null); } } // Asset if (oldStatus == WorkflowConstants.STATUS_APPROVED) { assetEntryLocalService.updateVisible(WikiPage.class.getName(), page.getResourcePrimKey(), false); } // Attachments WikiNode node = page.getNode(); for (FileEntry fileEntry : page.getAttachmentsFileEntries()) { PortletFileRepositoryUtil.movePortletFileEntryToTrash(node.getStatusByUserId(), fileEntry.getFileEntryId()); } // Indexer Indexer<WikiPage> indexer = IndexerRegistryUtil.nullSafeGetIndexer(WikiPage.class); indexer.reindex(page); // Cache if (WikiCacheThreadLocal.isClearCache()) { wikiCacheHelper.clearCache(page.getNodeId()); } // Workflow if (oldStatus == WorkflowConstants.STATUS_PENDING) { workflowInstanceLinkLocalService.deleteWorkflowInstanceLink(page.getCompanyId(), page.getGroupId(), WikiPage.class.getName(), page.getResourcePrimKey()); } // Child pages moveDependentChildPagesToTrash(page.getNodeId(), oldTitle, trashTitle, trashEntryId, createTrashVersion); // Redirect pages moveDependentRedirectorPagesToTrash(page.getNodeId(), oldTitle, trashTitle, trashEntryId, createTrashVersion); }
From source file:com.liferay.wiki.web.internal.display.context.DefaultWikiListPagesDisplayContext.java
License:Open Source License
@Override public void populateResultsAndTotal(SearchContainer searchContainer) throws PortalException { WikiPage page = (WikiPage) _request.getAttribute(WikiWebKeys.WIKI_PAGE); ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); String navigation = ParamUtil.getString(_request, "navigation", "all-pages"); String keywords = ParamUtil.getString(_request, "keywords"); int total = 0; List<WikiPage> results = new ArrayList<>(); if (Validator.isNotNull(keywords)) { Indexer<WikiPage> indexer = IndexerRegistryUtil.getIndexer(WikiPage.class); SearchContext searchContext = SearchContextFactory.getInstance(_request); searchContext.setAttribute("paginationType", "more"); searchContext.setEnd(searchContainer.getEnd()); searchContext.setIncludeAttachments(true); searchContext.setIncludeDiscussions(true); searchContext.setKeywords(keywords); searchContext.setNodeIds(new long[] { _wikiNode.getNodeId() }); searchContext.setStart(searchContainer.getStart()); Hits hits = indexer.search(searchContext); searchContainer.setTotal(hits.getLength()); List<SearchResult> searchResults = SearchResultUtil.getSearchResults(hits, themeDisplay.getLocale()); for (SearchResult searchResult : searchResults) { WikiPage wikiPage = WikiPageLocalServiceUtil.getPage(searchResult.getClassPK()); results.add(wikiPage);/*ww w . j ava2 s . co m*/ } } else if (navigation.equals("all-pages")) { total = WikiPageServiceUtil.getPagesCount(themeDisplay.getScopeGroupId(), _wikiNode.getNodeId(), true, themeDisplay.getUserId(), true, WorkflowConstants.STATUS_APPROVED); searchContainer.setTotal(total); OrderByComparator<WikiPage> obc = WikiPortletUtil .getPageOrderByComparator(searchContainer.getOrderByCol(), searchContainer.getOrderByType()); results = WikiPageServiceUtil.getPages(themeDisplay.getScopeGroupId(), _wikiNode.getNodeId(), true, themeDisplay.getUserId(), true, WorkflowConstants.STATUS_APPROVED, searchContainer.getStart(), searchContainer.getEnd(), obc); } else if (navigation.equals("categorized-pages") || navigation.equals("tagged-pages")) { AssetEntryQuery assetEntryQuery = new AssetEntryQuery(WikiPage.class.getName(), searchContainer); assetEntryQuery.setEnablePermissions(true); total = AssetEntryServiceUtil.getEntriesCount(assetEntryQuery); searchContainer.setTotal(total); assetEntryQuery.setEnd(searchContainer.getEnd()); assetEntryQuery.setStart(searchContainer.getStart()); List<AssetEntry> assetEntries = AssetEntryServiceUtil.getEntries(assetEntryQuery); for (AssetEntry assetEntry : assetEntries) { WikiPageResource pageResource = WikiPageResourceLocalServiceUtil .getPageResource(assetEntry.getClassPK()); WikiPage assetPage = WikiPageLocalServiceUtil.getPage(pageResource.getNodeId(), pageResource.getTitle()); results.add(assetPage); } } else if (navigation.equals("draft-pages") || navigation.equals("pending-pages")) { long draftUserId = themeDisplay.getUserId(); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); if (permissionChecker.isContentReviewer(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId())) { draftUserId = 0; } int status = WorkflowConstants.STATUS_DRAFT; if (navigation.equals("pending-pages")) { status = WorkflowConstants.STATUS_PENDING; } total = WikiPageServiceUtil.getPagesCount(themeDisplay.getScopeGroupId(), draftUserId, _wikiNode.getNodeId(), status); searchContainer.setTotal(total); results = WikiPageServiceUtil.getPages(themeDisplay.getScopeGroupId(), draftUserId, _wikiNode.getNodeId(), status, searchContainer.getStart(), searchContainer.getEnd()); } else if (navigation.equals("frontpage")) { WikiWebComponentProvider wikiWebComponentProvider = WikiWebComponentProvider .getWikiWebComponentProvider(); WikiGroupServiceConfiguration wikiGroupServiceConfiguration = wikiWebComponentProvider .getWikiGroupServiceConfiguration(); WikiPage wikiPage = WikiPageServiceUtil.getPage(themeDisplay.getScopeGroupId(), _wikiNode.getNodeId(), wikiGroupServiceConfiguration.frontPageName()); searchContainer.setTotal(1); results.add(wikiPage); } else if (navigation.equals("history")) { total = WikiPageLocalServiceUtil.getPagesCount(page.getNodeId(), page.getTitle()); searchContainer.setTotal(total); results = WikiPageLocalServiceUtil.getPages(page.getNodeId(), page.getTitle(), QueryUtil.ALL_POS, QueryUtil.ALL_POS, new PageVersionComparator()); } else if (navigation.equals("incoming-links")) { List<WikiPage> links = WikiPageLocalServiceUtil.getIncomingLinks(page.getNodeId(), page.getTitle()); total = links.size(); searchContainer.setTotal(total); results = ListUtil.subList(links, searchContainer.getStart(), searchContainer.getEnd()); } else if (navigation.equals("orphan-pages")) { List<WikiPage> orphans = WikiPageServiceUtil.getOrphans(themeDisplay.getScopeGroupId(), _wikiNode.getNodeId()); total = orphans.size(); searchContainer.setTotal(total); results = ListUtil.subList(orphans, searchContainer.getStart(), searchContainer.getEnd()); } else if (navigation.equals("outgoing-links")) { List<WikiPage> links = WikiPageLocalServiceUtil.getOutgoingLinks(page.getNodeId(), page.getTitle()); total = links.size(); searchContainer.setTotal(total); results = ListUtil.subList(links, searchContainer.getStart(), searchContainer.getEnd()); } else if (navigation.equals("recent-changes")) { total = WikiPageServiceUtil.getRecentChangesCount(themeDisplay.getScopeGroupId(), _wikiNode.getNodeId()); searchContainer.setTotal(total); results = WikiPageServiceUtil.getRecentChanges(themeDisplay.getScopeGroupId(), _wikiNode.getNodeId(), searchContainer.getStart(), searchContainer.getEnd()); } searchContainer.setResults(results); }
From source file:com.slayer.service.impl.LMSBookLocalServiceImpl.java
License:Open Source License
public LMSBook insertBook(String bookTitle, String author, ServiceContext serviceContext) { // 1. Instantiate an empty object of type LMSBookImpl LMSBook lmsBook = new LMSBookImpl(); // set Additional Audit fields lmsBook.setCompanyId(serviceContext.getCompanyId()); lmsBook.setUserId(serviceContext.getUserId()); // 2. Set the fields for this object lmsBook.setBookTitle(bookTitle);//from ww w .j av a 2 s. co m lmsBook.setAuthor(author); lmsBook.setCreateDate(new Date()); lmsBook.setUuid(serviceContext.getUuid()); lmsBook.setGroupId(serviceContext.getScopeGroupId()); // workflow status lmsBook.setStatus(WorkflowConstants.STATUS_PENDING); lmsBook.setStatusByUserId(serviceContext.getUserId()); lmsBook.setStatusDate(new java.util.Date()); // 4. Call the Service Layer API to persist the object try { lmsBook = lmsBookPersistence.update(lmsBook, false); } catch (SystemException e) { e.printStackTrace(); } try { WorkflowHandlerRegistryUtil.startWorkflowInstance(lmsBook.getCompanyId(), // companyId lmsBook.getGroupId(), // groupId lmsBook.getUserId(), // userId LMSBook.class.getName(), // className lmsBook.getPrimaryKey(), // classPK lmsBook, // model serviceContext); // serviceContext } catch (PortalException e1) { e1.printStackTrace(); } catch (SystemException e1) { e1.printStackTrace(); } _log.debug("Book just got added - debug"); _log.info("Book just got added - info"); _log.warn("Book just got added - warn"); _log.error("Book just got added - error"); _log.fatal("Book just got added - fatal"); try { resourceLocalService.addModelResources(lmsBook, serviceContext); } catch (PortalException e) { e.printStackTrace(); } catch (SystemException e) { e.printStackTrace(); } try { assetEntryLocalService.updateEntry(serviceContext.getUserId(), // userId serviceContext.getScopeGroupId(), // groupId LMSBook.class.getName(), // className lmsBook.getPrimaryKey(), // classPK serviceContext.getAssetCategoryIds(), // category Ids serviceContext.getAssetTagNames()); // tag Names } catch (PortalException e) { e.printStackTrace(); } catch (SystemException e) { e.printStackTrace(); } lmsBook.setExpandoBridgeAttributes(serviceContext); // indexer Indexer indexer = IndexerRegistryUtil.getIndexer(LMSBook.class); try { indexer.reindex(lmsBook); } catch (SearchException e) { e.printStackTrace(); } return lmsBook; }
From source file:com.viapost.stock.service.impl.UserDemandeLocalServiceImpl.java
License:Open Source License
@Override public UserDemande addUserDemande(final ActionRequest request) throws PortalException, SystemException { final UserDemande userDemande = userDemandePersistence .create(counterLocalService.increment(UserDemande.class.getName())); final ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); final long userId = themeDisplay.getUserId(); final ServiceContext serviceContext = ServiceContextFactory.getInstance(UserDemande.class.getName(), request);//from w w w. j a v a2 s .c o m userDemande.setCompanyId(themeDisplay.getCompanyId()); userDemande.setGroupId(themeDisplay.getScopeGroupId()); userDemande.setDate(new Date()); userDemande.setArticle(ParamUtil.getLong(request, "produit")); userDemande.setDemandeId(DemandeLocalServiceUtil.findByQuestion(ParamUtil.getString(request, "question"))); userDemande.setStatus(WorkflowConstants.STATUS_PENDING); userDemandePersistence.update(userDemande); assetEntryLocalService.updateEntry(userId, userDemande.getGroupId(), UserDemande.class.getName(), userDemande.getPrimaryKey(), serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames()); WorkflowHandlerRegistryUtil.startWorkflowInstance(themeDisplay.getCompanyId(), userId, UserDemande.class.getName(), userDemande.getPrimaryKey(), userDemande, serviceContext); return userDemande; }
From source file:it.smc.calendar.sync.calendar.util.CalendarUtil.java
License:Open Source License
public static List<CalendarBooking> getCalendarBookings(PermissionChecker permissionChecker, Calendar calendar, Date startDate, Date endDate) throws PortalException, SystemException { ClassLoader classLoader = ClassLoaderPool.getClassLoader("calendar-portlet"); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(CalendarBooking.class, classLoader); dynamicQuery.add(RestrictionsFactoryUtil.eq("calendarId", calendar.getCalendarId())); Integer[] status = { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_PENDING, 9 /* CalendarBookingWorkflowConstants.STATUS_MAYBE */ }; dynamicQuery.add(RestrictionsFactoryUtil.in("status", status)); if (startDate != null) { dynamicQuery.add(RestrictionsFactoryUtil.ge("startTime", new Long(startDate.getTime()))); }/*from ww w . ja va2s . com*/ if (endDate != null) { dynamicQuery.add(RestrictionsFactoryUtil.le("endTime", new Long(endDate.getTime()))); } List<CalendarBooking> allCalendarBookings = CalendarBookingLocalServiceUtil.dynamicQuery(dynamicQuery); return filterCalendarBookings(allCalendarBookings, permissionChecker, ActionKeys.VIEW); }