List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants ACTION_PUBLISH
int ACTION_PUBLISH
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants ACTION_PUBLISH.
Click Source Link
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);// ww 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 testSaveAsDraftPublishedCalendarBooking() throws Exception { ServiceContext serviceContext = createServiceContext(); Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext); long startTime = System.currentTimeMillis(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); 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);// ww w . j av a 2s .c om 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 testUpdateCalendarBookingPreservesChildReminders() 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.addCalendarBooking(_user, calendar, new long[] { invitedCalendar.getCalendarId() }, RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(), startTime, startTime + (Time.HOUR * 10), null, RandomTestUtil.randomInt(), NotificationType.EMAIL, RandomTestUtil.randomInt(), NotificationType.EMAIL, serviceContext); CalendarBooking childCalendarBooking = getChildCalendarBooking(calendarBooking); childCalendarBooking = CalendarBookingLocalServiceUtil.updateStatus(_user.getUserId(), childCalendarBooking, CalendarBookingWorkflowConstants.STATUS_MAYBE, serviceContext); int firstReminder = RandomTestUtil.randomInt(); int secondReminder = RandomTestUtil.randomInt(1, firstReminder); childCalendarBooking = CalendarBookingLocalServiceUtil.updateCalendarBooking(_user.getUserId(), childCalendarBooking.getCalendarBookingId(), childCalendarBooking.getCalendarId(), new long[0], childCalendarBooking.getTitleMap(), childCalendarBooking.getDescriptionMap(), childCalendarBooking.getLocation(), startTime, startTime + (Time.HOUR * 10), childCalendarBooking.getAllDay(), childCalendarBooking.getRecurrence(), firstReminder, NotificationType.EMAIL.getValue(), secondReminder, NotificationType.EMAIL.getValue(), serviceContext);//w ww . j av a 2 s .c o m calendarBooking = CalendarBookingLocalServiceUtil.updateCalendarBooking(_user.getUserId(), calendarBooking.getCalendarBookingId(), calendarBooking.getCalendarId(), new long[] { invitedCalendar.getCalendarId() }, calendarBooking.getTitleMap(), calendarBooking.getDescriptionMap(), calendarBooking.getLocation(), startTime, startTime + (Time.HOUR * 11), calendarBooking.getAllDay(), calendarBooking.getRecurrence(), RandomTestUtil.randomInt(), calendarBooking.getFirstReminderType(), RandomTestUtil.randomInt(), calendarBooking.getSecondReminderType(), serviceContext); childCalendarBooking = getChildCalendarBooking(calendarBooking); Assert.assertNotEquals(calendarBooking.getFirstReminder(), childCalendarBooking.getFirstReminder()); Assert.assertNotEquals(calendarBooking.getSecondReminder(), childCalendarBooking.getSecondReminder()); Assert.assertEquals(firstReminder, childCalendarBooking.getFirstReminder()); Assert.assertEquals(secondReminder, childCalendarBooking.getSecondReminder()); }
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);/*w w w . ja va 2 s . c o m*/ 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.test.util.CalendarBookingTestUtil.java
License:Open Source License
public static CalendarBooking addPublishedCalendarBooking(User user) throws PortalException { return addCalendarBookingWithAction(user, WorkflowConstants.ACTION_PUBLISH); }
From source file:com.liferay.comment.internal.jsonws.CommentManagerJSONWS.java
License:Open Source License
public long updateComment(String className, long classPK, long commentId, String subject, String body) throws PortalException { DiscussionPermission discussionPermission = _commentManager.getDiscussionPermission(getPermissionChecker()); discussionPermission.checkUpdatePermission(commentId); return _commentManager.updateComment(getUserId(), className, classPK, commentId, subject, body, createServiceContextFunction(WorkflowConstants.ACTION_PUBLISH)); }
From source file:com.liferay.document.library.internal.repository.capabilities.LiferayWorkflowCapability.java
License:Open Source License
@Override public void checkInFileEntry(long userId, FileEntry fileEntry, boolean majorVersion, ServiceContext serviceContext) throws PortalException { boolean keepFileVersionLabel = _dlFileEntryServiceAdapter.isKeepFileVersionLabel(fileEntry.getFileEntryId(), majorVersion, serviceContext); if ((serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_PUBLISH) && !keepFileVersionLabel) { DLFileVersion latestDLFileVersion = _dlFileVersionServiceAdapter .getLatestFileVersion(fileEntry.getFileEntryId(), false); DLUtil.startWorkflowInstance(userId, latestDLFileVersion, DLSyncConstants.EVENT_UPDATE, serviceContext); }/*from w w w .j a va 2 s.com*/ }
From source file:com.liferay.document.library.internal.repository.capabilities.LiferayWorkflowCapability.java
License:Open Source License
private DLFileVersion _getWorkflowDLFileVersion(long fileEntryId, ServiceContext serviceContext) throws PortalException { DLFileEntry dlFileEntry = _dlFileEntryServiceAdapter.getDLFileEntry(fileEntryId); if (dlFileEntry.isCheckedOut()) { return null; }/*www.j av a2s . c o m*/ DLFileVersion dlFileVersion = _dlFileVersionServiceAdapter.getLatestFileVersion(fileEntryId, true); if (dlFileVersion.isApproved() || (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_PUBLISH)) { return dlFileVersion; } return null; }
From source file:com.liferay.dynamic.data.lists.exporter.test.DDLExporterTest.java
License:Open Source License
@Test public void testCSVExport() throws Exception { DDMForm ddmForm = DDMFormTestUtil.createDDMForm(_availableLocales, _defaultLocale); createDDMFormFields(ddmForm);// w w w . jav a2 s . c om DDMFormValues ddmFormValues = DDMFormValuesTestUtil.createDDMFormValues(ddmForm, _availableLocales, _defaultLocale); createDDMFormFieldValues(ddmFormValues); DDLRecordSetTestHelper recordSetTestHelper = new DDLRecordSetTestHelper(_group); DDLRecordSet recordSet = recordSetTestHelper.addRecordSet(ddmForm); DDLRecordTestHelper recordTestHelper = new DDLRecordTestHelper(_group, recordSet); recordTestHelper.addRecord(ddmFormValues, WorkflowConstants.ACTION_PUBLISH); DDLExporter ddlExporter = _ddlExporterFactory.getDDLExporter("csv"); byte[] bytes = ddlExporter.export(recordSet.getRecordSetId()); File file = new File("record-set.csv"); FileUtil.write(file, bytes); String expectedFileContent = read("test-record-set-export.csv"); String actualFileContent = FileUtil.read(file); Assert.assertEquals(expectedFileContent, actualFileContent); }