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.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
/** * Moves the blogs entry to the recycle bin. Social activity counters for * this entry get disabled./*from w w w .j a v a 2 s . com*/ * * @param userId the primary key of the user moving the blogs entry * @param entry the blogs entry to be moved * @return the moved blogs entry */ @Indexable(type = IndexableType.REINDEX) @Override public BlogsEntry moveEntryToTrash(long userId, BlogsEntry entry) throws PortalException { // Entry if (entry.isInTrash()) { throw new TrashEntryException(); } int oldStatus = entry.getStatus(); if (oldStatus == WorkflowConstants.STATUS_PENDING) { entry.setStatus(WorkflowConstants.STATUS_DRAFT); blogsEntryPersistence.update(entry); } entry = updateStatus(userId, entry.getEntryId(), WorkflowConstants.STATUS_IN_TRASH, new ServiceContext()); // Social JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", entry.getTitle()); SocialActivityManagerUtil.addActivity(userId, entry, SocialActivityConstants.TYPE_MOVE_TO_TRASH, extraDataJSONObject.toString(), 0); // Workflow if (oldStatus == WorkflowConstants.STATUS_PENDING) { workflowInstanceLinkLocalService.deleteWorkflowInstanceLink(entry.getCompanyId(), entry.getGroupId(), BlogsEntry.class.getName(), entry.getEntryId()); } return entry; }
From source file:com.liferay.bookmarks.service.impl.BookmarksFolderLocalServiceImpl.java
License:Open Source License
protected void moveDependentsToTrash(List<Object> foldersAndEntries, long trashEntryId) throws PortalException { for (Object object : foldersAndEntries) { if (object instanceof BookmarksEntry) { // Entry BookmarksEntry entry = (BookmarksEntry) object; if (entry.isInTrash()) { continue; }/*ww w . j a v a 2s. c o m*/ int oldStatus = entry.getStatus(); entry.setStatus(WorkflowConstants.STATUS_IN_TRASH); bookmarksEntryPersistence.update(entry); // Trash int status = oldStatus; if (oldStatus == WorkflowConstants.STATUS_PENDING) { status = WorkflowConstants.STATUS_DRAFT; } if (oldStatus != WorkflowConstants.STATUS_APPROVED) { trashVersionLocalService.addTrashVersion(trashEntryId, BookmarksEntry.class.getName(), entry.getEntryId(), status, null); } // Asset assetEntryLocalService.updateVisible(BookmarksEntry.class.getName(), entry.getEntryId(), false); // Indexer Indexer<BookmarksEntry> indexer = IndexerRegistryUtil.nullSafeGetIndexer(BookmarksEntry.class); indexer.reindex(entry); } else if (object instanceof BookmarksFolder) { // Folder BookmarksFolder folder = (BookmarksFolder) object; if (folder.isInTrash()) { continue; } int oldStatus = folder.getStatus(); folder.setStatus(WorkflowConstants.STATUS_IN_TRASH); bookmarksFolderPersistence.update(folder); // Trash if (oldStatus != WorkflowConstants.STATUS_APPROVED) { trashVersionLocalService.addTrashVersion(trashEntryId, BookmarksFolder.class.getName(), folder.getFolderId(), oldStatus, null); } // Folders and entries List<Object> curFoldersAndEntries = getFoldersAndEntries(folder.getGroupId(), folder.getFolderId()); moveDependentsToTrash(curFoldersAndEntries, trashEntryId); // Asset assetEntryLocalService.updateVisible(BookmarksFolder.class.getName(), folder.getFolderId(), false); // Indexer Indexer<BookmarksFolder> indexer = IndexerRegistryUtil.nullSafeGetIndexer(BookmarksFolder.class); indexer.reindex(folder); } } }
From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testInviteToPublishedCalendarBookingResultsInPendingChild() throws Exception { ServiceContext serviceContext = createServiceContext(); Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext); Calendar invitedCalendar = CalendarTestUtil.addCalendar(calendar.getCalendarResource(), serviceContext); long startTime = System.currentTimeMillis(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); CalendarBooking calendarBooking = CalendarBookingTestUtil.addMasterCalendarBooking(_user, calendar, new long[] { invitedCalendar.getCalendarId() }, startTime, startTime + (Time.HOUR * 10), serviceContext);//from w w w .j a va2s. co m CalendarBooking childCalendarBooking = getChildCalendarBooking(calendarBooking); Assert.assertEquals(WorkflowConstants.STATUS_PENDING, childCalendarBooking.getStatus()); }
From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testMoveToTrashCalendarBookingShouldMoveItsChildrenToTrash() throws Exception { ServiceContext serviceContext = createServiceContext(); Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext); Calendar invitedCalendar = CalendarTestUtil.addCalendar(calendar.getCalendarResource(), serviceContext); long startTime = System.currentTimeMillis(); CalendarBooking calendarBooking = CalendarBookingTestUtil.addMasterCalendarBooking(_user, calendar, new long[] { invitedCalendar.getCalendarId() }, startTime, startTime + (Time.HOUR * 10), serviceContext);//w ww. j av a 2 s . c om CalendarBooking childCalendarBooking = getChildCalendarBooking(calendarBooking); Assert.assertEquals(WorkflowConstants.STATUS_PENDING, childCalendarBooking.getStatus()); CalendarBookingLocalServiceUtil.moveCalendarBookingToTrash(_user.getUserId(), calendarBooking); childCalendarBooking = getChildCalendarBooking(calendarBooking); Assert.assertEquals(WorkflowConstants.STATUS_IN_TRASH, childCalendarBooking.getStatus()); }
From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testRestoredFromTrashEventResultsInRestoredFromTrashChildren() throws Exception { ServiceContext serviceContext = createServiceContext(); Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext); Calendar invitedCalendar = CalendarTestUtil.addCalendar(calendar.getCalendarResource(), serviceContext); long startTime = System.currentTimeMillis(); CalendarBooking calendarBooking = CalendarBookingTestUtil.addMasterCalendarBooking(_user, calendar, new long[] { invitedCalendar.getCalendarId() }, startTime, startTime + (Time.HOUR * 10), serviceContext);/*from www . j a va 2 s . c o m*/ CalendarBooking childCalendarBooking = getChildCalendarBooking(calendarBooking); Assert.assertEquals(WorkflowConstants.STATUS_PENDING, childCalendarBooking.getStatus()); CalendarBookingLocalServiceUtil.moveCalendarBookingToTrash(_user.getUserId(), calendarBooking); childCalendarBooking = getChildCalendarBooking(calendarBooking); Assert.assertEquals(WorkflowConstants.STATUS_IN_TRASH, childCalendarBooking.getStatus()); CalendarBookingLocalServiceUtil.restoreCalendarBookingFromTrash(_user.getUserId(), calendarBooking.getCalendarBookingId()); childCalendarBooking = getChildCalendarBooking(calendarBooking); Assert.assertEquals(WorkflowConstants.STATUS_PENDING, childCalendarBooking.getStatus()); }
From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testUpdateCalendarBookingPreservesChildStatus() throws Exception { ServiceContext serviceContext = createServiceContext(); Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext); Calendar invitedCalendar = CalendarTestUtil.addCalendar(calendar.getCalendarResource(), serviceContext); long startTime = System.currentTimeMillis(); long endTime = startTime + (Time.HOUR * 10); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); CalendarBooking calendarBooking = CalendarBookingTestUtil.addMasterCalendarBooking(_user, calendar, new long[] { invitedCalendar.getCalendarId() }, startTime, endTime, serviceContext); CalendarBooking childCalendarBooking = getChildCalendarBooking(calendarBooking); Assert.assertEquals(WorkflowConstants.STATUS_PENDING, childCalendarBooking.getStatus()); CalendarBookingLocalServiceUtil.updateStatus(_user.getUserId(), childCalendarBooking, CalendarBookingWorkflowConstants.STATUS_MAYBE, serviceContext); calendarBooking = CalendarBookingLocalServiceUtil.updateCalendarBooking(_user.getUserId(), calendarBooking.getCalendarBookingId(), calendarBooking.getCalendarId(), new long[] { invitedCalendar.getCalendarId() }, RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomString(), startTime, endTime, calendarBooking.getAllDay(), calendarBooking.getRecurrence(), calendarBooking.getFirstReminder(), calendarBooking.getFirstReminderType(), calendarBooking.getSecondReminder(), calendarBooking.getSecondReminderType(), serviceContext); childCalendarBooking = getChildCalendarBooking(calendarBooking); Assert.assertEquals(CalendarBookingWorkflowConstants.STATUS_MAYBE, childCalendarBooking.getStatus()); long newEndTime = endTime + 1000000; calendarBooking = CalendarBookingLocalServiceUtil.updateCalendarBooking(_user.getUserId(), calendarBooking.getCalendarBookingId(), calendarBooking.getCalendarId(), new long[] { invitedCalendar.getCalendarId() }, RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomString(), startTime, newEndTime, calendarBooking.getAllDay(), calendarBooking.getRecurrence(), calendarBooking.getFirstReminder(), calendarBooking.getFirstReminderType(), calendarBooking.getSecondReminder(), calendarBooking.getSecondReminderType(), serviceContext); childCalendarBooking = getChildCalendarBooking(calendarBooking); Assert.assertNotEquals(CalendarBookingWorkflowConstants.STATUS_MAYBE, childCalendarBooking.getStatus()); }
From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java
License:Open Source License
@Test public void testUpdateChildCalendarBookingPreservesStatus() throws Exception { ServiceContext serviceContext = createServiceContext(); Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext); Calendar invitedCalendar = CalendarTestUtil.addCalendar(calendar.getCalendarResource(), serviceContext); long startTime = System.currentTimeMillis(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); CalendarBooking calendarBooking = CalendarBookingTestUtil.addMasterCalendarBooking(_user, calendar, new long[] { invitedCalendar.getCalendarId() }, startTime, startTime + (Time.HOUR * 10), serviceContext);/*from ww w . jav a 2 s. c om*/ CalendarBooking childCalendarBooking = getChildCalendarBooking(calendarBooking); Assert.assertEquals(WorkflowConstants.STATUS_PENDING, childCalendarBooking.getStatus()); childCalendarBooking = CalendarBookingLocalServiceUtil.updateStatus(_user.getUserId(), childCalendarBooking, CalendarBookingWorkflowConstants.STATUS_MAYBE, serviceContext); CalendarBookingLocalServiceUtil.updateCalendarBooking(_user.getUserId(), childCalendarBooking.getCalendarBookingId(), childCalendarBooking.getCalendarId(), new long[] { invitedCalendar.getCalendarId() }, RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), childCalendarBooking.getAllDay(), childCalendarBooking.getRecurrence(), childCalendarBooking.getFirstReminder(), childCalendarBooking.getFirstReminderType(), childCalendarBooking.getSecondReminder(), childCalendarBooking.getSecondReminderType(), serviceContext); childCalendarBooking = getChildCalendarBooking(calendarBooking); Assert.assertEquals(CalendarBookingWorkflowConstants.STATUS_MAYBE, childCalendarBooking.getStatus()); }
From source file:com.liferay.calendar.service.test.CalendarBookingServiceTest.java
License:Open Source License
@Test public void testGetUnapprovedCalendarBookingsForOmniadmin() throws Exception { ServiceContext serviceContext = createServiceContext(); Calendar calendar = CalendarTestUtil.addCalendar(_user1, serviceContext); CalendarBooking calendarBooking = CalendarBookingTestUtil.addRegularCalendarBooking(_user1, calendar, serviceContext);/*w w w .ja v a 2s . co m*/ calendarBooking.setStatus(WorkflowConstants.STATUS_PENDING); CalendarBookingLocalServiceUtil.updateCalendarBooking(calendarBooking); int[] statuses = { WorkflowConstants.STATUS_PENDING }; List<CalendarBooking> calendarBookings = Collections.emptyList(); try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_omnidminUser)) { calendarBookings = CalendarBookingServiceUtil.getCalendarBookings(calendar.getCalendarId(), statuses); } Assert.assertTrue(!calendarBookings.isEmpty()); }
From source file:com.liferay.calendar.service.test.CalendarBookingServiceTest.java
License:Open Source License
@Test public void testGetUnapprovedCalendarBookingsForRegularUser() throws Exception { ServiceContext serviceContext = createServiceContext(); Calendar calendar = CalendarTestUtil.addCalendar(_user1, serviceContext); CalendarBooking calendarBooking = CalendarBookingTestUtil.addRegularCalendarBooking(_user1, calendar, serviceContext);//from ww w . j a v a 2 s .co m calendarBooking.setStatus(WorkflowConstants.STATUS_PENDING); CalendarBookingLocalServiceUtil.updateCalendarBooking(calendarBooking); int[] statuses = { WorkflowConstants.STATUS_PENDING }; List<CalendarBooking> calendarBookings = Collections.emptyList(); try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_user1)) { calendarBookings = CalendarBookingServiceUtil.getCalendarBookings(calendar.getCalendarId(), statuses); } Assert.assertTrue(!calendarBookings.isEmpty()); try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_user2)) { calendarBookings = CalendarBookingServiceUtil.getCalendarBookings(calendar.getCalendarId(), statuses); } Assert.assertTrue(calendarBookings.toString(), calendarBookings.isEmpty()); }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Moves the latest version of the web content article matching the group * and article ID to the recycle bin./*from w w w. ja va2s. c om*/ * * @param userId the primary key of the user updating the web content * article * @param article the web content article * @return the updated web content article, which was moved to the Recycle * Bin */ @Indexable(type = IndexableType.REINDEX) @Override public JournalArticle moveArticleToTrash(long userId, JournalArticle article) throws PortalException { // Article if (article.isInTrash()) { throw new TrashEntryException(); } int oldStatus = article.getStatus(); if (oldStatus == WorkflowConstants.STATUS_PENDING) { article.setStatus(WorkflowConstants.STATUS_DRAFT); } journalArticlePersistence.update(article); List<JournalArticle> articleVersions = journalArticlePersistence.findByG_A(article.getGroupId(), article.getArticleId()); articleVersions = ListUtil.sort(articleVersions, new ArticleVersionComparator()); List<ObjectValuePair<Long, Integer>> articleVersionStatusOVPs = new ArrayList<>(); if ((articleVersions != null) && !articleVersions.isEmpty()) { articleVersionStatusOVPs = getArticleVersionStatuses(articleVersions); } article = updateStatus(userId, article.getId(), WorkflowConstants.STATUS_IN_TRASH, new HashMap<String, Serializable>(), new ServiceContext()); // Trash JournalArticleResource articleResource = journalArticleResourceLocalService .getArticleResource(article.getResourcePrimKey()); UnicodeProperties typeSettingsProperties = new UnicodeProperties(); typeSettingsProperties.put("title", article.getArticleId()); TrashEntry trashEntry = trashEntryLocalService.addTrashEntry(userId, article.getGroupId(), JournalArticle.class.getName(), article.getResourcePrimKey(), articleResource.getUuid(), null, oldStatus, articleVersionStatusOVPs, typeSettingsProperties); String trashArticleId = TrashUtil.getTrashTitle(trashEntry.getEntryId()); for (JournalArticle articleVersion : articleVersions) { articleVersion.setArticleId(trashArticleId); articleVersion.setStatus(WorkflowConstants.STATUS_IN_TRASH); journalArticlePersistence.update(articleVersion); } articleResource.setArticleId(trashArticleId); journalArticleResourcePersistence.update(articleResource); article.setArticleId(trashArticleId); article = journalArticlePersistence.update(article); // Asset assetEntryLocalService.updateVisible(JournalArticle.class.getName(), article.getResourcePrimKey(), false); // Attachments for (FileEntry fileEntry : article.getImagesFileEntries()) { PortletFileRepositoryUtil.movePortletFileEntryToTrash(userId, fileEntry.getFileEntryId()); } // Comment if (isArticleCommentsEnabled(article.getCompanyId())) { CommentManagerUtil.moveDiscussionToTrash(JournalArticle.class.getName(), article.getResourcePrimKey()); } // Social JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", article.getTitleMapAsXML()); SocialActivityManagerUtil.addActivity(userId, article, SocialActivityConstants.TYPE_MOVE_TO_TRASH, extraDataJSONObject.toString(), 0); if (oldStatus == WorkflowConstants.STATUS_PENDING) { workflowInstanceLinkLocalService.deleteWorkflowInstanceLink(article.getCompanyId(), article.getGroupId(), JournalArticle.class.getName(), article.getId()); } return article; }