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

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

Introduction

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

Prototype

int ACTION_SAVE_DRAFT

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

Click Source Link

Usage

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  ww  .ja  va2s  . c  om*/

    return folder;
}

From source file:com.liferay.bookmarks.util.test.BookmarksTestUtil.java

License:Open Source License

public static BookmarksEntry addEntry(String name, long folderId, boolean approved,
        ServiceContext serviceContext) throws Exception {

    boolean workflowEnabled = WorkflowThreadLocal.isEnabled();

    try {//ww  w.  j  a  v  a2  s  .  c o  m
        WorkflowThreadLocal.setEnabled(true);

        String url = "http://www.liferay.com";
        String description = "This is a test entry.";

        serviceContext = (ServiceContext) serviceContext.clone();

        serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);

        BookmarksEntry entry = BookmarksEntryServiceUtil.addEntry(serviceContext.getScopeGroupId(), folderId,
                name, url, description, serviceContext);

        serviceContext.setCommand(Constants.ADD);
        serviceContext.setLayoutFullURL("http://localhost");

        if (approved) {
            entry.setStatus(WorkflowConstants.STATUS_APPROVED);

            entry = BookmarksEntryServiceUtil.updateEntry(entry.getEntryId(), serviceContext.getScopeGroupId(),
                    entry.getFolderId(), entry.getName(), entry.getUrl(), entry.getUrl(), serviceContext);
        }

        return entry;
    } finally {
        WorkflowThreadLocal.setEnabled(workflowEnabled);
    }
}

From source file:com.liferay.calendar.service.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testAddCalendarBookingWorkflowActionSaveDraft() throws PortalException {

    ServiceContext serviceContext = createServiceContext();

    CalendarResource calendarResource = CalendarResourceUtil.getUserCalendarResource(_user.getUserId(),
            serviceContext);//  w  w w .  j  a va 2  s  .  c  o m

    Calendar calendar = calendarResource.getDefaultCalendar();

    long startTime = DateUtil.newTime();

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);

    CalendarBooking calendarBooking = CalendarBookingLocalServiceUtil.addCalendarBooking(_user.getUserId(),
            calendar.getCalendarId(), new long[0], CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT,
            RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(),
            RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), false, null, 0, null, 0,
            null, serviceContext);

    Assert.assertEquals(WorkflowConstants.STATUS_DRAFT, calendarBooking.getStatus());
}

From source file:com.liferay.calendar.service.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testUpdateCalendarBookingWorkflowActionPublish() throws PortalException {

    ServiceContext serviceContext = createServiceContext();

    CalendarResource calendarResource = CalendarResourceUtil.getUserCalendarResource(_user.getUserId(),
            serviceContext);//  w w  w  . ja  v  a2 s  .c  om

    Calendar calendar = calendarResource.getDefaultCalendar();

    long startTime = DateUtil.newTime();

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);

    CalendarBooking calendarBooking = CalendarBookingLocalServiceUtil.addCalendarBooking(_user.getUserId(),
            calendar.getCalendarId(), new long[0], CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT,
            RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(),
            RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), false, null, 0, null, 0,
            null, serviceContext);

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH);

    calendarBooking = CalendarBookingLocalServiceUtil.updateCalendarBooking(_user.getUserId(),
            calendarBooking.getCalendarBookingId(), calendar.getCalendarId(), new long[0],
            RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(),
            RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), false, null, 0, null, 0,
            null, RandomTestUtil.randomInt(), serviceContext);

    Assert.assertEquals(WorkflowConstants.STATUS_APPROVED, calendarBooking.getStatus());
}

From source file:com.liferay.calendar.service.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testUpdateCalendarBookingWorkflowActionSaveDraft() throws PortalException {

    ServiceContext serviceContext = createServiceContext();

    CalendarResource calendarResource = CalendarResourceUtil.getUserCalendarResource(_user.getUserId(),
            serviceContext);//from w  ww  . j av  a2 s .  c  o  m

    Calendar calendar = calendarResource.getDefaultCalendar();

    long startTime = DateUtil.newTime();

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);

    CalendarBooking calendarBooking = CalendarBookingLocalServiceUtil.addCalendarBooking(_user.getUserId(),
            calendar.getCalendarId(), new long[0], CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT,
            RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(),
            RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), false, null, 0, null, 0,
            null, serviceContext);

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);

    calendarBooking = CalendarBookingLocalServiceUtil.updateCalendarBooking(_user.getUserId(),
            calendarBooking.getCalendarBookingId(), calendar.getCalendarId(), new long[0],
            RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(),
            RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), false, null, 0, null, 0,
            null, RandomTestUtil.randomInt(), serviceContext);

    Assert.assertEquals(WorkflowConstants.STATUS_DRAFT, calendarBooking.getStatus());
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testInviteToDraftCalendarBookingResultsInMasterPendingChild() 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_SAVE_DRAFT);

    CalendarBooking calendarBooking = CalendarBookingTestUtil.addMasterCalendarBooking(_user, calendar,
            new long[] { invitedCalendar.getCalendarId() }, startTime, startTime + (Time.HOUR * 10),
            serviceContext);/*w ww  .j a  v  a  2  s.  c om*/

    CalendarBooking childCalendarBooking = getChildCalendarBooking(calendarBooking);

    Assert.assertEquals(CalendarBookingWorkflowConstants.STATUS_MASTER_PENDING,
            childCalendarBooking.getStatus());
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testPublishDraftCalendarBooking() throws Exception {
    ServiceContext serviceContext = createServiceContext();

    Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext);

    long startTime = System.currentTimeMillis();

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);

    CalendarBooking calendarBooking = CalendarBookingTestUtil.addRegularCalendarBooking(_user, calendar,
            startTime, startTime + (Time.HOUR * 10), serviceContext);

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH);

    calendarBooking = CalendarBookingLocalServiceUtil.updateCalendarBooking(_user.getUserId(),
            calendarBooking.getCalendarBookingId(), calendar.getCalendarId(), new long[0],
            RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(),
            RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), false, null, 0, null, 0,
            null, serviceContext);/* ww w. ja va2  s .  c om*/

    calendarBooking = CalendarBookingLocalServiceUtil
            .fetchCalendarBooking(calendarBooking.getCalendarBookingId());

    Assert.assertEquals(WorkflowConstants.STATUS_APPROVED, calendarBooking.getStatus());
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testPublishDraftCalendarBookingResultsInPendingChild() 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_SAVE_DRAFT);

    CalendarBooking calendarBooking = CalendarBookingTestUtil.addMasterCalendarBooking(_user, calendar,
            new long[] { invitedCalendar.getCalendarId() }, startTime, startTime + (Time.HOUR * 10),
            serviceContext);// w  w w . j  av a 2 s. c o  m

    CalendarBooking childCalendarBooking = getChildCalendarBooking(calendarBooking);

    Assert.assertEquals(CalendarBookingWorkflowConstants.STATUS_MASTER_PENDING,
            childCalendarBooking.getStatus());

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH);

    calendarBooking = CalendarBookingLocalServiceUtil.updateCalendarBooking(_user.getUserId(),
            calendarBooking.getCalendarBookingId(), calendar.getCalendarId(),
            new long[] { invitedCalendar.getCalendarId() }, RandomTestUtil.randomLocaleStringMap(),
            RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomString(), startTime,
            startTime + (Time.HOUR * 10), false, null, 0, null, 0, null, serviceContext);

    childCalendarBooking = getChildCalendarBooking(calendarBooking);

    Assert.assertEquals(CalendarBookingWorkflowConstants.STATUS_PENDING, childCalendarBooking.getStatus());
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testSaveAsDraftCalendarBooking() throws Exception {
    ServiceContext serviceContext = createServiceContext();

    Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext);

    long startTime = System.currentTimeMillis();

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);

    CalendarBooking calendarBooking = CalendarBookingTestUtil.addRegularCalendarBooking(_user, calendar,
            startTime, startTime + (Time.HOUR * 10), serviceContext);

    calendarBooking = CalendarBookingLocalServiceUtil
            .fetchCalendarBooking(calendarBooking.getCalendarBookingId());

    Assert.assertEquals(WorkflowConstants.STATUS_DRAFT, calendarBooking.getStatus());
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testSaveAsDraftDraftCalendarBooking() throws Exception {
    ServiceContext serviceContext = createServiceContext();

    Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext);

    long startTime = System.currentTimeMillis();

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);

    CalendarBooking calendarBooking = CalendarBookingTestUtil.addRegularCalendarBooking(_user, calendar,
            startTime, startTime + (Time.HOUR * 10), serviceContext);

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);

    calendarBooking = CalendarBookingLocalServiceUtil.updateCalendarBooking(_user.getUserId(),
            calendarBooking.getCalendarBookingId(), calendar.getCalendarId(), new long[0],
            RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(),
            RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), false, null, 0, null, 0,
            null, serviceContext);/*from   www  . j a va 2  s  . c  o  m*/

    calendarBooking = CalendarBookingLocalServiceUtil
            .fetchCalendarBooking(calendarBooking.getCalendarBookingId());

    Assert.assertEquals(WorkflowConstants.STATUS_DRAFT, calendarBooking.getStatus());
}