Example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED

List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED.

Prototype

int STATUS_APPROVED

To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED.

Click Source Link

Usage

From source file:com.liferay.blogs.service.impl.BlogsStatsUserLocalServiceImpl.java

License:Open Source License

@Override
public void updateStatsUser(long groupId, long userId, Date displayDate) throws PortalException {

    Date now = new Date();

    int entryCount = blogsEntryPersistence.countByG_U_LtD_S(groupId, userId, now,
            WorkflowConstants.STATUS_APPROVED);

    if (entryCount == 0) {
        try {//from ww w . j  av a2  s  .c o  m
            blogsStatsUserPersistence.removeByG_U(groupId, userId);
        } catch (NoSuchStatsUserException nssue) {
            if (_log.isWarnEnabled()) {
                _log.warn(nssue, nssue);
            }
        }

        return;
    }

    BlogsStatsUser statsUser = getStatsUser(groupId, userId);

    statsUser.setEntryCount(entryCount);

    BlogsEntry blogsEntry = blogsEntryPersistence.findByG_U_LtD_S_First(groupId, userId, now,
            WorkflowConstants.STATUS_APPROVED, new EntryDisplayDateComparator());

    Date lastDisplayDate = blogsEntry.getDisplayDate();

    Date lastPostDate = statsUser.getLastPostDate();

    if ((displayDate != null) && displayDate.before(now)) {
        if (lastPostDate == null) {
            statsUser.setLastPostDate(displayDate);
        } else if (displayDate.after(lastPostDate)) {
            statsUser.setLastPostDate(displayDate);
        } else if (lastDisplayDate.before(lastPostDate)) {
            statsUser.setLastPostDate(lastDisplayDate);
        }
    } else if ((lastPostDate == null) || lastPostDate.before(lastDisplayDate)) {

        statsUser.setLastPostDate(lastDisplayDate);
    }

    blogsStatsUserPersistence.update(statsUser);
}

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 testApprovedToTrash() 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_IN_TRASH, 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 testDraftToApprovedByAdd() throws Exception {
    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.ADD_ENTRY, 1);
}

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 testDraftToScheduledByAdd() throws Exception {
    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.ADD_ENTRY, 1);

    AssetEntry assetEntry = AssetEntryLocalServiceUtil.fetchEntry(BlogsEntry.class.getName(),
            entry.getEntryId());//w ww.j a  va2  s  .co  m

    Assert.assertNull(assetEntry.getPublishDate());
}

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());//from   ww  w.j  ava 2s.co  m

    Assert.assertNotNull(assetEntry.getPublishDate());
}

From source file:com.liferay.blogs.service.test.BlogsEntryStatusTransitionTest.java

License:Open Source License

@Test
public void testScheduledByAddToApproved() throws Exception {
    Calendar displayDate = new GregorianCalendar();

    displayDate.add(Calendar.DATE, 1);

    entry.setDisplayDate(displayDate.getTime());

    BlogsEntryLocalServiceUtil.updateBlogsEntry(entry);

    entry = BlogsEntryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), entry.getEntryId(),
            WorkflowConstants.STATUS_APPROVED, getServiceContext(entry), new HashMap<String, Serializable>());

    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()));
}

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 testTrashToApproved() 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_IN_TRASH, 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.ADD_ENTRY, 1);
}