List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_DRAFT
int STATUS_DRAFT
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_DRAFT.
Click Source Link
From source file:com.liferay.blogs.service.test.BlogsEntryLocalServiceTest.java
License:Open Source License
@Test public void testURLTitleIsNotSavedWhenAddingDraftEntry() throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group, _user.getUserId()); serviceContext.setWorkflowAction(WorkflowConstants.STATUS_DRAFT); BlogsEntry entry = BlogsEntryLocalServiceUtil.addEntry(_user.getUserId(), RandomTestUtil.randomString(), RandomTestUtil.randomString(), serviceContext); Assert.assertTrue(Validator.isNull(entry.getUrlTitle())); }
From source file:com.liferay.blogs.service.test.BlogsEntryLocalServiceTest.java
License:Open Source License
@Test public void testURLTitleIsNotUpdatedWhenUpdatingEntryTitleToDraftEntry() throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group, _user.getUserId()); BlogsEntry entry = BlogsEntryLocalServiceUtil.addEntry(_user.getUserId(), RandomTestUtil.randomString(), RandomTestUtil.randomString(), serviceContext); String urlTitle = entry.getUrlTitle(); serviceContext.setWorkflowAction(WorkflowConstants.STATUS_DRAFT); entry = BlogsEntryLocalServiceUtil.updateEntry(_user.getUserId(), entry.getEntryId(), RandomTestUtil.randomString(), RandomTestUtil.randomString(), serviceContext); Assert.assertEquals(urlTitle, entry.getUrlTitle()); }
From source file:com.liferay.blogs.service.test.BlogsEntryStatusTransitionTest.java
License:Open Source License
@Test public void testApprovedToDraft() throws Exception { BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_APPROVED, getServiceContext(entry), new HashMap<String, Serializable>()); BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_DRAFT, getServiceContext(entry), new HashMap<String, Serializable>()); Assert.assertFalse(isAssetEntryVisible(entry.getEntryId())); Assert.assertEquals(0, searchBlogsEntriesCount(group.getGroupId())); }
From source file:com.liferay.blogs.service.test.BlogsEntryStatusTransitionTest.java
License:Open Source License
@Test public void testDraftToApprovedByUpdate() throws Exception { BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_APPROVED, getServiceContext(entry), new HashMap<String, Serializable>()); BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_DRAFT, getServiceContext(entry), new HashMap<String, Serializable>()); BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_APPROVED, getServiceContext(entry), new HashMap<String, Serializable>()); Assert.assertTrue(isAssetEntryVisible(entry.getEntryId())); Assert.assertEquals(1, searchBlogsEntriesCount(group.getGroupId())); checkSocialActivity(BlogsActivityKeys.UPDATE_ENTRY, 1); }
From source file:com.liferay.blogs.service.test.BlogsEntryStatusTransitionTest.java
License:Open Source License
@Test public void testDraftToScheduledUpdate() throws Exception { BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_APPROVED, getServiceContext(entry), new HashMap<String, Serializable>()); entry = BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_DRAFT, getServiceContext(entry), new HashMap<String, Serializable>()); Calendar displayDate = new GregorianCalendar(); displayDate.add(Calendar.DATE, 1); entry.setDisplayDate(displayDate.getTime()); BlogsEntryLocalServiceUtil.updateBlogsEntry(entry); BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_APPROVED, getServiceContext(entry), new HashMap<String, Serializable>()); Assert.assertFalse(isAssetEntryVisible(entry.getEntryId())); Assert.assertEquals(0, searchBlogsEntriesCount(group.getGroupId())); checkSocialActivity(BlogsActivityKeys.UPDATE_ENTRY, 1); AssetEntry assetEntry = AssetEntryLocalServiceUtil.fetchEntry(BlogsEntry.class.getName(), entry.getEntryId());//w ww . j a va 2 s. c o m Assert.assertNotNull(assetEntry.getPublishDate()); }
From source file:com.liferay.blogs.service.test.BlogsEntryStatusTransitionTest.java
License:Open Source License
@Test public void testScheduledByUpdateToApproved() throws Exception { BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_APPROVED, getServiceContext(entry), new HashMap<String, Serializable>()); Calendar displayDate = new GregorianCalendar(); displayDate.add(Calendar.DATE, 1); entry.setDisplayDate(displayDate.getTime()); entry.setStatus(WorkflowConstants.STATUS_DRAFT); BlogsEntryLocalServiceUtil.updateBlogsEntry(entry); entry = BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_APPROVED, getServiceContext(entry), new HashMap<String, Serializable>()); checkSocialActivity(BlogsActivityKeys.UPDATE_ENTRY, 1); displayDate.add(Calendar.DATE, -2); entry.setDisplayDate(displayDate.getTime()); BlogsEntryLocalServiceUtil.updateBlogsEntry(entry); BlogsEntryLocalServiceUtil.checkEntries(); Assert.assertTrue(isAssetEntryVisible(entry.getEntryId())); Assert.assertEquals(1, searchBlogsEntriesCount(group.getGroupId())); checkSocialActivity(BlogsActivityKeys.UPDATE_ENTRY, 1); }
From source file:com.liferay.blogs.service.test.BlogsEntryStatusTransitionTest.java
License:Open Source License
@Test public void testTrashToDraft() throws Exception { BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_IN_TRASH, getServiceContext(entry), new HashMap<String, Serializable>()); BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_DRAFT, getServiceContext(entry), new HashMap<String, Serializable>()); Assert.assertFalse(isAssetEntryVisible(entry.getEntryId())); Assert.assertEquals(0, searchBlogsEntriesCount(group.getGroupId())); BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_APPROVED, getServiceContext(entry), new HashMap<String, Serializable>()); BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_DRAFT, getServiceContext(entry), new HashMap<String, Serializable>()); BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_IN_TRASH, getServiceContext(entry), new HashMap<String, Serializable>()); BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(), WorkflowConstants.STATUS_DRAFT, getServiceContext(entry), new HashMap<String, Serializable>()); Assert.assertFalse(isAssetEntryVisible(entry.getEntryId())); Assert.assertEquals(0, searchBlogsEntriesCount(group.getGroupId())); }
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; }/* w w w.java 2 s .co 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.bookmarks.trash.test.BookmarksEntryTrashHandlerTest.java
License:Open Source License
@Override public BaseModel<?> updateBaseModel(long primaryKey, ServiceContext serviceContext) throws Exception { BookmarksEntry entry = BookmarksEntryLocalServiceUtil.getEntry(primaryKey); if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_SAVE_DRAFT) { entry = BookmarksEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry, WorkflowConstants.STATUS_DRAFT); }/* ww w . ja v a 2 s.c om*/ return entry; }
From source file:com.liferay.bookmarks.trash.test.BookmarksFolderTrashHandlerTest.java
License:Open Source License
@Override public BaseModel<?> updateBaseModel(long primaryKey, ServiceContext serviceContext) throws Exception { BookmarksFolder folder = BookmarksFolderLocalServiceUtil.getFolder(primaryKey); if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_SAVE_DRAFT) { folder = BookmarksFolderLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), folder, WorkflowConstants.STATUS_DRAFT); }//from w w w . j a v a2 s . c o m return folder; }