List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED
int STATUS_APPROVED
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED.
Click Source Link
From source file:com.liferay.document.library.util.test.RepositoryModelUtilTest.java
License:Open Source License
@Test public void testToFileVersions() throws Exception { DLFileEntry dlFileEntry = DLTestUtil.addDLFileEntry(_folder.getFolderId()); for (int i = 0; i < 5; i++) { dlFileEntry.setTitle(RandomTestUtil.randomString()); DLFileEntryLocalServiceUtil.updateDLFileEntry(dlFileEntry); }//from ww w. jav a 2 s . co m dlFileEntry = DLFileEntryLocalServiceUtil.getFileEntry(dlFileEntry.getFileEntryId()); List<DLFileVersion> dlFileVersions = dlFileEntry.getFileVersions(WorkflowConstants.STATUS_APPROVED); List<FileVersion> fileVersions = RepositoryModelUtil.toFileVersions(dlFileVersions); Assert.assertEquals(fileVersions.toString(), dlFileVersions.size(), fileVersions.size()); for (int i = 0; i < dlFileVersions.size(); i++) { DLFileVersion dlFileVersion = dlFileVersions.get(i); FileVersion fileVersion = fileVersions.get(i); Assert.assertEquals(dlFileVersion.getFileVersionId(), fileVersion.getFileVersionId()); } }
From source file:com.liferay.document.library.util.test.RepositoryModelUtilTest.java
License:Open Source License
@Test public void testToRepositoryEntries() throws Exception { populateFolderWithDLFileEntries();// w w w . j a v a 2 s . c o m populateFolderWithDLFileShortcuts(); populateFolderWithDLFolders(); QueryDefinition<?> queryDefinition = new QueryDefinition<>(WorkflowConstants.STATUS_APPROVED, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); List<Object> dlFoldersAndDLFileEntriesAndDLFileShortcuts = DLFolderLocalServiceUtil .getFoldersAndFileEntriesAndFileShortcuts(_group.getGroupId(), _folder.getFolderId(), new String[0], true, queryDefinition); List<RepositoryEntry> repositoryEntries = RepositoryModelUtil .toRepositoryEntries(dlFoldersAndDLFileEntriesAndDLFileShortcuts); Assert.assertEquals(repositoryEntries.toString(), dlFoldersAndDLFileEntriesAndDLFileShortcuts.size(), repositoryEntries.size()); }
From source file:com.liferay.document.library.util.test.RepositoryModelUtilTest.java
License:Open Source License
@Test(expected = IllegalArgumentException.class) public void testToRepositoryEntriesWithIllegalArgument() throws Exception { populateFolderWithDLFileEntries();//ww w. j a v a 2 s .c o m populateFolderWithDLFileShortcuts(); populateFolderWithDLFolders(); QueryDefinition<?> queryDefinition = new QueryDefinition<>(WorkflowConstants.STATUS_APPROVED, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); List<Object> dlFoldersAndDLFileEntriesAndDLFileShortcuts = DLFolderLocalServiceUtil .getFoldersAndFileEntriesAndFileShortcuts(_group.getGroupId(), _folder.getFolderId(), new String[0], true, queryDefinition); dlFoldersAndDLFileEntriesAndDLFileShortcuts.add(new Object()); RepositoryModelUtil.toRepositoryEntries(dlFoldersAndDLFileEntriesAndDLFileShortcuts); }
From source file:com.liferay.document.library.web.internal.portlet.action.DownloadEntriesMVCResourceCommand.java
License:Open Source License
protected void zipFolder(long repositoryId, long folderId, String path, ZipWriter zipWriter) throws Exception { List<Object> foldersAndFileEntriesAndFileShortcuts = _dlAppService.getFoldersAndFileEntriesAndFileShortcuts( repositoryId, folderId, WorkflowConstants.STATUS_APPROVED, false, QueryUtil.ALL_POS, QueryUtil.ALL_POS);//w w w. j a va 2 s . c om for (Object entry : foldersAndFileEntriesAndFileShortcuts) { if (entry instanceof Folder) { Folder folder = (Folder) entry; zipFolder(folder.getRepositoryId(), folder.getFolderId(), path.concat(StringPool.SLASH).concat(folder.getName()), zipWriter); } else if (entry instanceof FileEntry) { zipFileEntry((FileEntry) entry, path, zipWriter); } else if (entry instanceof FileShortcut) { FileShortcut fileShortcut = (FileShortcut) entry; FileEntry fileEntry = _dlAppService.getFileEntry(fileShortcut.getToFileEntryId()); zipFileEntry(fileEntry, path, zipWriter); } } }
From source file:com.liferay.dynamic.data.lists.form.web.internal.portlet.action.ExportRecordSetMVCResourceCommand.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); String fileExtension = ParamUtil.getString(resourceRequest, "fileExtension"); String fileName = recordSet.getName(themeDisplay.getLocale()) + CharPool.PERIOD + fileExtension; DDLExporter exporter = _ddlExporterFactory.getDDLExporter(fileExtension); exporter.setLocale(themeDisplay.getLocale()); byte[] bytes = exporter.export(recordSetId, WorkflowConstants.STATUS_APPROVED); String contentType = MimeTypesUtil.getContentType(fileName); PortletResponseUtil.sendFile(resourceRequest, resourceResponse, fileName, bytes, contentType); }
From source file:com.liferay.dynamic.data.lists.internal.search.DDLRecordIndexer.java
License:Open Source License
@Override public void postProcessContextBooleanFilter(BooleanFilter contextBooleanFilter, SearchContext searchContext) throws Exception { int status = GetterUtil.getInteger(searchContext.getAttribute(Field.STATUS), WorkflowConstants.STATUS_APPROVED); if (status != WorkflowConstants.STATUS_ANY) { contextBooleanFilter.addRequiredTerm(Field.STATUS, status); }//from www . j a va 2 s . co m long recordSetId = GetterUtil.getLong(searchContext.getAttribute("recordSetId")); if (recordSetId > 0) { contextBooleanFilter.addRequiredTerm("recordSetId", recordSetId); } long recordSetScope = GetterUtil.getLong(searchContext.getAttribute("recordSetScope"), DDLRecordSetConstants.SCOPE_DYNAMIC_DATA_LISTS); contextBooleanFilter.addRequiredTerm("recordSetScope", recordSetScope); addSearchClassTypeIds(contextBooleanFilter, searchContext); String ddmStructureFieldName = (String) searchContext.getAttribute("ddmStructureFieldName"); Serializable ddmStructureFieldValue = searchContext.getAttribute("ddmStructureFieldValue"); if (Validator.isNotNull(ddmStructureFieldName) && Validator.isNotNull(ddmStructureFieldValue)) { QueryFilter queryFilter = ddmIndexer.createFieldValueQueryFilter(ddmStructureFieldName, ddmStructureFieldValue, searchContext.getLocale()); contextBooleanFilter.add(queryFilter, BooleanClauseOccur.MUST); } }
From source file:com.liferay.dynamic.data.lists.service.impl.DDLRecordLocalServiceImpl.java
License:Open Source License
/** * Updates the record's asset with new asset categories, tag names, and link * entries, removing and adding them as necessary. * * @param userId the primary key of the user updating the record's asset * @param record the record//ww w . j a v a 2 s . c om * @param recordVersion the record version * @param assetCategoryIds the primary keys of the new asset categories * @param assetTagNames the new asset tag names * @param locale the locale to apply to the asset * @param priority the new priority * @throws PortalException if a portal exception occurred */ @Override public void updateAsset(long userId, DDLRecord record, DDLRecordVersion recordVersion, long[] assetCategoryIds, String[] assetTagNames, Locale locale, Double priority) throws PortalException { DDLRecordSet recordSet = record.getRecordSet(); int scope = recordSet.getScope(); if ((scope != DDLRecordSetConstants.SCOPE_DYNAMIC_DATA_LISTS) && (scope != DDLRecordSetConstants.SCOPE_FORMS) && (scope != DDLRecordSetConstants.SCOPE_KALEO_FORMS)) { return; } boolean addDraftAssetEntry = false; boolean visible = true; if ((recordVersion != null) && !recordVersion.isApproved()) { String version = recordVersion.getVersion(); if (!version.equals(DDLRecordConstants.VERSION_DEFAULT)) { int approvedRecordVersionsCount = ddlRecordVersionPersistence.countByR_S(record.getRecordId(), WorkflowConstants.STATUS_APPROVED); if (approvedRecordVersionsCount > 0) { addDraftAssetEntry = true; } } visible = false; } if (scope == DDLRecordSetConstants.SCOPE_FORMS) { visible = false; } DDMStructure ddmStructure = recordSet.getDDMStructure(); String ddmStructureName = ddmStructure.getName(locale); String recordSetName = recordSet.getName(locale); String title = LanguageUtil.format(locale, "new-x-for-list-x", new Object[] { ddmStructureName, recordSetName }, false); if (addDraftAssetEntry) { assetEntryLocalService.updateEntry(userId, record.getGroupId(), record.getCreateDate(), record.getModifiedDate(), DDLRecordConstants.getClassName(scope), recordVersion.getRecordVersionId(), record.getUuid(), 0, assetCategoryIds, assetTagNames, true, false, null, null, null, null, ContentTypes.TEXT_HTML, title, null, StringPool.BLANK, null, null, 0, 0, priority); } else { Date publishDate = null; if (visible) { publishDate = record.getCreateDate(); } assetEntryLocalService.updateEntry(userId, record.getGroupId(), record.getCreateDate(), record.getModifiedDate(), DDLRecordConstants.getClassName(scope), record.getRecordId(), record.getUuid(), 0, assetCategoryIds, assetTagNames, true, visible, null, null, publishDate, null, ContentTypes.TEXT_HTML, title, null, StringPool.BLANK, null, null, 0, 0, priority); } }
From source file:com.liferay.dynamic.data.lists.service.impl.DDLRecordLocalServiceImpl.java
License:Open Source License
/** * Updates the workflow status of the record version. * * @param userId the primary key of the user updating the record's workflow * status//from ww w. ja v a2 s.com * @param recordVersionId the primary key of the record version * @param status * @param serviceContext the service context to be applied. This can set * the modification date and status date. * @return the record * @throws PortalException if a portal exception occurred */ @Indexable(type = IndexableType.REINDEX) @Override public DDLRecord updateStatus(long userId, long recordVersionId, int status, ServiceContext serviceContext) throws PortalException { // Record version User user = userLocalService.getUser(userId); DDLRecordVersion recordVersion = ddlRecordVersionPersistence.findByPrimaryKey(recordVersionId); recordVersion.setStatus(status); recordVersion.setStatusByUserId(user.getUserId()); recordVersion.setStatusByUserName(user.getFullName()); recordVersion.setStatusDate(new Date()); ddlRecordVersionPersistence.update(recordVersion); // Record DDLRecord record = ddlRecordPersistence.findByPrimaryKey(recordVersion.getRecordId()); if (status == WorkflowConstants.STATUS_APPROVED) { if (DLUtil.compareVersions(record.getVersion(), recordVersion.getVersion()) <= 0) { record.setDDMStorageId(recordVersion.getDDMStorageId()); record.setVersion(recordVersion.getVersion()); record.setRecordSetId(recordVersion.getRecordSetId()); record.setDisplayIndex(recordVersion.getDisplayIndex()); record.setVersion(recordVersion.getVersion()); record.setVersionUserId(recordVersion.getUserId()); record.setVersionUserName(recordVersion.getUserName()); ddlRecordPersistence.update(record); } } else { if (Objects.equals(record.getVersion(), recordVersion.getVersion())) { String newVersion = DDLRecordConstants.VERSION_DEFAULT; List<DDLRecordVersion> approvedRecordVersions = ddlRecordVersionPersistence .findByR_S(record.getRecordId(), WorkflowConstants.STATUS_APPROVED); if (!approvedRecordVersions.isEmpty()) { newVersion = approvedRecordVersions.get(0).getVersion(); } record.setVersion(newVersion); ddlRecordPersistence.update(record); } } // Asset Locale locale = serviceContext.getLocale(); updateAsset(userId, record, recordVersion, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), locale, serviceContext.getAssetPriority()); return record; }
From source file:com.liferay.dynamic.data.lists.service.test.DDLRecordServiceTest.java
License:Open Source License
@Test public void testPublishRecordDraftWithoutChanges() throws Exception { DDMForm ddmForm = createDDMForm();/* ww w .ja v a 2 s . c o m*/ ddmForm.addDDMFormField(createTextDDMFormField("Name", true, false)); DDLRecordSet recordSet = addRecordSet(ddmForm); DDLRecordTestHelper recordTestHelper = new DDLRecordTestHelper(_group, recordSet); DDMFormValues ddmFormValues = createDDMFormValues(ddmForm); ddmFormValues.addDDMFormFieldValue(createLocalizedDDMFormFieldValue("Name", "Joe Bloggs")); DDLRecord record = recordTestHelper.addRecord(ddmFormValues, WorkflowConstants.ACTION_SAVE_DRAFT); Assert.assertEquals(WorkflowConstants.STATUS_DRAFT, record.getStatus()); DDLRecordVersion recordVersion = record.getRecordVersion(); Assert.assertTrue(recordVersion.isDraft()); record = updateRecord(record.getRecordId(), record.getDDMFormValues(), WorkflowConstants.ACTION_PUBLISH); Assert.assertEquals(WorkflowConstants.STATUS_APPROVED, record.getStatus()); recordVersion = record.getRecordVersion(); Assert.assertTrue(recordVersion.isApproved()); }
From source file:com.liferay.dynamic.data.lists.web.internal.webdav.DDLWebDAVStorageImpl.java
License:Open Source License
protected List<Resource> getTemplates(WebDAVRequest webDAVRequest) throws Exception { List<Resource> resources = new ArrayList<>(); List<DDMTemplate> ddmTemplates = _ddmTemplateLocalService.getTemplatesByStructureClassNameId( webDAVRequest.getGroupId(), _portal.getClassNameId(DDLRecordSet.class), WorkflowConstants.STATUS_APPROVED, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); for (DDMTemplate ddmTemplate : ddmTemplates) { Resource resource = _ddmWebDav.toResource(webDAVRequest, ddmTemplate, getRootPath(), true); resources.add(resource);/*w w w . j a v a2 s . c o m*/ } return resources; }