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.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 .ja va 2 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); Assert.assertEquals(WorkflowConstants.STATUS_DRAFT, 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 w w.j a v a 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); 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 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 ww w. ja v a2s . co m 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 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 2 s . c o m calendarBooking = CalendarBookingLocalServiceUtil .fetchCalendarBooking(calendarBooking.getCalendarBookingId()); Assert.assertEquals(WorkflowConstants.STATUS_DRAFT, calendarBooking.getStatus()); }
From source file:com.liferay.document.library.trash.test.DLFileShortcutTrashHandlerTest.java
License:Open Source License
@Override public BaseModel<?> updateBaseModel(long primaryKey, ServiceContext serviceContext) throws Exception { DLFileShortcut dlFileShortcut = DLFileShortcutLocalServiceUtil.getFileShortcut(primaryKey); if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_SAVE_DRAFT) { DLFileShortcutLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), primaryKey, WorkflowConstants.STATUS_DRAFT, serviceContext); }/* w w w. ja v a 2 s . c o m*/ return dlFileShortcut; }
From source file:com.liferay.document.library.trash.test.DLFolderTrashHandlerTest.java
License:Open Source License
@Override public BaseModel<?> updateBaseModel(long primaryKey, ServiceContext serviceContext) throws Exception { DLFolder dlFolder = DLFolderLocalServiceUtil.getFolder(primaryKey); if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_SAVE_DRAFT) { dlFolder = DLFolderLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), primaryKey, WorkflowConstants.STATUS_DRAFT, null, serviceContext); }/*from w w w. j av a 2 s . co m*/ return dlFolder; }
From source file:com.liferay.dynamic.data.lists.form.web.internal.portlet.action.AddRecordMVCResourceCommand.java
License:Open Source License
protected ServiceContext createServiceContext(ResourceRequest resourceRequest) throws PortalException { ServiceContext serviceContext = ServiceContextFactory.getInstance(DDLRecord.class.getName(), resourceRequest);/*from w w w . ja va2 s. c o m*/ serviceContext.setAttribute("status", WorkflowConstants.STATUS_DRAFT); serviceContext.setAttribute("validateDDMFormValues", Boolean.FALSE); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); return serviceContext; }
From source file:com.liferay.dynamic.data.lists.form.web.internal.portlet.action.AddRecordMVCResourceCommand.java
License:Open Source License
@Override protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); long recordSetId = ParamUtil.getLong(resourceRequest, "recordSetId"); DDLRecordSet recordSet = _ddlRecordSetService.getRecordSet(recordSetId); DDMFormValues ddmFormValues = createDDMFormValues(recordSet, resourceRequest); if (ddmFormValues == null) { return;//w w w.j a v a 2 s . c om } DDLRecordVersion recordVersion = _ddlRecordVersionLocalService.fetchLatestRecordVersion( themeDisplay.getUserId(), recordSetId, recordSet.getVersion(), WorkflowConstants.STATUS_DRAFT); ServiceContext serviceContext = createServiceContext(resourceRequest); if (recordVersion == null) { _ddlRecordService.addRecord(recordSet.getGroupId(), recordSetId, DDLRecordConstants.DISPLAY_INDEX_DEFAULT, ddmFormValues, serviceContext); } else { _ddlRecordService.updateRecord(recordVersion.getRecordId(), false, DDLRecordConstants.DISPLAY_INDEX_DEFAULT, ddmFormValues, serviceContext); } }
From source file:com.liferay.dynamic.data.lists.service.impl.DDLRecordLocalServiceImpl.java
License:Open Source License
/** * Adds a record referencing the record set. * * @param userId the primary key of the record's creator/owner * @param groupId the primary key of the record's group * @param recordSetId the primary key of the record set * @param displayIndex the index position in which the record is displayed * in the spreadsheet view/*from w w w. ja va2 s.c o m*/ * @param ddmFormValues the record values. See <code>DDMFormValues</code> * in the <code>dynamic.data.mapping.api</code> module. * @param serviceContext the service context to be applied. This can set * the UUID, guest permissions, and group permissions for the * record. * @return the record * @throws PortalException if a portal exception occurred */ @Indexable(type = IndexableType.REINDEX) @Override public DDLRecord addRecord(long userId, long groupId, long recordSetId, int displayIndex, DDMFormValues ddmFormValues, ServiceContext serviceContext) throws PortalException { // Record User user = userLocalService.getUser(userId); DDLRecordSet recordSet = ddlRecordSetPersistence.findByPrimaryKey(recordSetId); validate(groupId, recordSet); long recordId = counterLocalService.increment(); DDLRecord record = ddlRecordPersistence.create(recordId); record.setUuid(serviceContext.getUuid()); record.setGroupId(groupId); record.setCompanyId(user.getCompanyId()); record.setUserId(user.getUserId()); record.setUserName(user.getFullName()); record.setVersionUserId(user.getUserId()); record.setVersionUserName(user.getFullName()); long ddmStorageId = storageEngine.create(recordSet.getCompanyId(), recordSet.getDDMStructureId(), ddmFormValues, serviceContext); record.setDDMStorageId(ddmStorageId); record.setRecordSetId(recordSetId); record.setVersion(DDLRecordConstants.VERSION_DEFAULT); record.setDisplayIndex(displayIndex); ddlRecordPersistence.update(record); // Record version DDLRecordVersion recordVersion = addRecordVersion(user, record, ddmStorageId, DDLRecordConstants.VERSION_DEFAULT, displayIndex, WorkflowConstants.STATUS_DRAFT); // Asset Locale locale = serviceContext.getLocale(); updateAsset(userId, record, recordVersion, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), locale, serviceContext.getAssetPriority()); // Workflow WorkflowHandlerRegistryUtil.startWorkflowInstance(user.getCompanyId(), groupId, userId, getWorkflowAssetClassName(recordSet), recordVersion.getRecordVersionId(), recordVersion, serviceContext); return record; }