List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY
int STATUS_ANY
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY.
Click Source Link
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Returns the number of web content articles matching the company, version, * and workflow status.//w ww . j av a2 s .c o m * * <p> * Useful when paginating results. Returns a maximum of <code>end - * start</code> instances. <code>start</code> and <code>end</code> are not * primary keys, they are indexes in the result set. Thus, <code>0</code> * refers to the first result in the set. Setting both <code>start</code> * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full * result set. * </p> * * @param companyId the primary key of the web content article's company * @param version the web content article's version * @param status the web content article's workflow status. For more * information see {@link WorkflowConstants} for constants starting * with the "STATUS_" prefix. * @param start the lower bound of the range of web content articles to * return * @param end the upper bound of the range of web content articles to * return (not inclusive) * @return the number of matching web content articles */ @Override public int getCompanyArticlesCount(long companyId, double version, int status, int start, int end) { if (status == WorkflowConstants.STATUS_ANY) { return journalArticlePersistence.countByC_V(companyId, version); } else { return journalArticlePersistence.countByC_V_ST(companyId, version, status); } }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Returns the number of web content articles matching the company and * workflow status.//from w w w . java 2s . co m * * @param companyId the primary key of the web content article's company * @param status the web content article's workflow status. For more * information see {@link WorkflowConstants} for constants starting * with the "STATUS_" prefix. * @return the number of matching web content articles */ @Override public int getCompanyArticlesCount(long companyId, int status) { if (status == WorkflowConstants.STATUS_ANY) { return journalArticlePersistence.countByCompanyId(companyId); } else { return journalArticlePersistence.countByC_ST(companyId, status); } }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Returns the latest web content article matching the resource primary key, * preferring articles with approved workflow status. * * @param resourcePrimKey the primary key of the resource instance * @return the latest web content article matching the resource primary key, * preferring articles with approved workflow status *///from ww w .j a v a2 s. c o m @Override public JournalArticle getLatestArticle(long resourcePrimKey) throws PortalException { return getLatestArticle(resourcePrimKey, WorkflowConstants.STATUS_ANY); }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Returns the latest web content article matching the resource primary key * and workflow status, optionally preferring articles with approved * workflow status.// ww w. j a va 2 s . c om * * @param resourcePrimKey the primary key of the resource instance * @param status the web content article's workflow status. For more * information see {@link WorkflowConstants} for constants starting * with the "STATUS_" prefix. * @param preferApproved whether to prefer returning the latest matching * article that has workflow status {@link * WorkflowConstants#STATUS_APPROVED} over returning one that has a * different status * @return the latest web content article matching the resource primary key * and workflow status, optionally preferring articles with approved * workflow status */ @Override public JournalArticle getLatestArticle(long resourcePrimKey, int status, boolean preferApproved) throws PortalException { List<JournalArticle> articles = null; OrderByComparator<JournalArticle> orderByComparator = new ArticleVersionComparator(); if (status == WorkflowConstants.STATUS_ANY) { if (preferApproved) { articles = journalArticlePersistence.findByR_ST(resourcePrimKey, WorkflowConstants.STATUS_APPROVED, 0, 1, orderByComparator); } if (ListUtil.isEmpty(articles)) { articles = journalArticlePersistence.findByResourcePrimKey(resourcePrimKey, 0, 1, orderByComparator); } } else { articles = journalArticlePersistence.findByR_ST(resourcePrimKey, status, 0, 1, orderByComparator); } if (articles.isEmpty()) { throw new NoSuchArticleException( "No JournalArticle exists with the key {resourcePrimKey=" + resourcePrimKey + "}"); } return articles.get(0); }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Returns the latest web content article with the group and article ID. * * @param groupId the primary key of the web content article's group * @param articleId the primary key of the web content article * @return the latest matching web content article *//*from w w w . jav a 2 s . c om*/ @Override public JournalArticle getLatestArticle(long groupId, String articleId) throws PortalException { return getLatestArticle(groupId, articleId, WorkflowConstants.STATUS_ANY); }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Returns the number of web content articles that are not recycled. * * @param groupId the primary key of the web content article's group * @param folderId the primary key of the web content article folder * @return the number of web content articles that are not recycled *//*from w ww . jav a 2 s.c o m*/ @Override public int getNotInTrashArticlesCount(long groupId, long folderId) { QueryDefinition<JournalArticle> queryDefinition = new QueryDefinition<>(WorkflowConstants.STATUS_ANY); List<Long> folderIds = new ArrayList<>(); folderIds.add(folderId); return journalArticleFinder.countByG_F(groupId, folderIds, queryDefinition); }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Returns the oldest web content article with the group and article ID. * * @param groupId the primary key of the web content article's group * @param articleId the primary key of the web content article * @return the oldest matching web content article *//*from w ww.j ava 2s . com*/ @Override public JournalArticle getOldestArticle(long groupId, String articleId) throws PortalException { return getOldestArticle(groupId, articleId, WorkflowConstants.STATUS_ANY); }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Returns an ordered range of all the web content articles matching the * parameters using the indexer, including a keywords parameter for matching * an article's ID, title, description, or content, a DDM structure key * parameter, a DDM template key parameter, and a finder hash map parameter. * It is preferable to use this method instead of the non-indexed version * whenever possible for performance reasons. * * <p>//from w w w . j a v a2 s. c om * Useful when paginating results. Returns a maximum of <code>end - * start</code> instances. <code>start</code> and <code>end</code> are not * primary keys, they are indexes in the result set. Thus, <code>0</code> * refers to the first result in the set. Setting both <code>start</code> * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full * result set. * </p> * * @param companyId the primary key of the web content article's company * @param groupId the primary key of the group (optionally <code>0</code>) * @param folderIds the primary keys of the web content article folders * (optionally {@link Collections#EMPTY_LIST}) * @param classNameId the primary key of the DDMStructure class if the web * content article is related to a DDM structure, the primary key of * the class name associated with the article, or * JournalArticleConstants.CLASSNAME_ID_DEFAULT in the journal-api * module otherwise * @param ddmStructureKey the primary key of the web content article's DDM * structure, if the article is related to a DDM structure, or * <code>null</code> otherwise * @param ddmTemplateKey the primary key of the web content article's DDM * template * @param keywords the keywords (space separated), which may occur in the * web content article ID, title, description, or content * (optionally <code>null</code>). If the keywords value is not * <code>null</code>, the search uses the OR operator in connecting * query criteria; otherwise it uses the AND operator. * @param params the finder parameters (optionally <code>null</code>) * @param start the lower bound of the range of web content articles to * return * @param end the upper bound of the range of web content articles to * return (not inclusive) * @param sort the field, type, and direction by which to sort (optionally * <code>null</code>) * @return the matching web content articles ordered by <code>sort</code> */ @Override public Hits search(long companyId, long groupId, List<Long> folderIds, long classNameId, String ddmStructureKey, String ddmTemplateKey, String keywords, LinkedHashMap<String, Object> params, int start, int end, Sort sort) { String articleId = null; String title = null; String description = null; String content = null; boolean andOperator = false; if (Validator.isNotNull(keywords)) { articleId = keywords; title = keywords; description = keywords; content = keywords; } else { andOperator = true; } if (params != null) { params.put("keywords", keywords); } return search(companyId, groupId, folderIds, classNameId, articleId, title, description, content, WorkflowConstants.STATUS_ANY, ddmStructureKey, ddmTemplateKey, params, andOperator, start, end, sort); }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Returns a {@link BaseModelSearchResult} containing the total number of * hits and an ordered range of all the web content articles matching the * parameters using the indexer, including a keywords parameter for matching * an article's ID, title, description, or content, a DDM structure key * parameter, a DDM template key parameter, and a finder hash map parameter. * It is preferable to use this method instead of the non-indexed version * whenever possible for performance reasons. * * <p>// ww w .j a v a2 s.c o m * The <code>start</code> and <code>end</code> parameters only affect the * amount of web content articles returned as results, not the total number * of hits. * </p> * * <p> * Useful when paginating results. Returns a maximum of <code>end - * start</code> instances. <code>start</code> and <code>end</code> are not * primary keys, they are indexes in the result set. Thus, <code>0</code> * refers to the first result in the set. Setting both <code>start</code> * and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full * result set. * </p> * * @param companyId the primary key of the web content article's company * @param groupId the primary key of the group (optionally <code>0</code>) * @param folderIds the primary keys of the web content article folders * (optionally {@link Collections#EMPTY_LIST}) * @param classNameId the primary key of the DDMStructure class, the * primary key of the class name associated with the article, or * JournalArticleConstants.CLASSNAME_ID_DEFAULT in the journal-api * module otherwise * @param ddmStructureKey the primary key of the web content article's DDM * structure * @param ddmTemplateKey the primary key of the web content article's DDM * template * @param keywords the keywords (space separated), which may occur in the * web content article ID, title, description, or content * (optionally <code>null</code>). If the keywords value is not * <code>null</code>, the search uses the OR operator in connecting * query criteria; otherwise it uses the AND operator. * @param params the finder parameters (optionally <code>null</code>) * @param start the lower bound of the range of web content articles to * return * @param end the upper bound of the range of web content articles to * return (not inclusive) * @param sort the field, type, and direction by which to sort (optionally * <code>null</code>) * @return a {@link BaseModelSearchResult} containing the total number of * hits and an ordered range of all the matching web content * articles ordered by <code>sort</code> */ @Override public BaseModelSearchResult<JournalArticle> searchJournalArticles(long companyId, long groupId, List<Long> folderIds, long classNameId, String ddmStructureKey, String ddmTemplateKey, String keywords, LinkedHashMap<String, Object> params, int start, int end, Sort sort) throws PortalException { String articleId = null; String title = null; String description = null; String content = null; boolean andOperator = false; if (Validator.isNotNull(keywords)) { articleId = keywords; title = keywords; description = keywords; content = keywords; } else { andOperator = true; } if (params != null) { params.put("keywords", keywords); } return searchJournalArticles(companyId, groupId, folderIds, classNameId, articleId, title, description, content, WorkflowConstants.STATUS_ANY, ddmStructureKey, ddmTemplateKey, params, andOperator, start, end, sort); }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Updates the web content article with additional parameters. * * @param userId the primary key of the user updating the web content * article/* w w w. j a v a 2s. c o m*/ * @param groupId the primary key of the web content article's group * @param folderId the primary key of the web content article folder * @param articleId the primary key of the web content article * @param version the web content article's version * @param titleMap the web content article's locales and localized titles * @param descriptionMap the web content article's locales and localized * descriptions * @param content the HTML content wrapped in XML. For more information, * see the content example in the {@link #addArticle(long, long, * long, long, long, String, boolean, double, Map, Map, String, * String, String, String, int, int, int, int, int, int, int, int, * int, int, boolean, int, int, int, int, int, boolean, boolean, * boolean, String, File, Map, String, ServiceContext)} description. * @param ddmStructureKey the primary key of the web content article's DDM * structure, if the article is related to a DDM structure, or * <code>null</code> otherwise * @param ddmTemplateKey the primary key of the web content article's DDM * template * @param layoutUuid the unique string identifying the web content * article's display page * @param displayDateMonth the month the web content article is set to * display * @param displayDateDay the calendar day the web content article is set to * display * @param displayDateYear the year the web content article is set to * display * @param displayDateHour the hour the web content article is set to * display * @param displayDateMinute the minute the web content article is set to * display * @param expirationDateMonth the month the web content article is set to * expire * @param expirationDateDay the calendar day the web content article is set * to expire * @param expirationDateYear the year the web content article is set to * expire * @param expirationDateHour the hour the web content article is set to * expire * @param expirationDateMinute the minute the web content article is set to * expire * @param neverExpire whether the web content article is not set to auto * expire * @param reviewDateMonth the month the web content article is set for * review * @param reviewDateDay the calendar day the web content article is set for * review * @param reviewDateYear the year the web content article is set for review * @param reviewDateHour the hour the web content article is set for review * @param reviewDateMinute the minute the web content article is set for * review * @param neverReview whether the web content article is not set for review * @param indexable whether the web content is searchable * @param smallImage whether to update web content article's a small image. * A file must be passed in as <code>smallImageFile</code> value, * otherwise the current small image is deleted. * @param smallImageURL the web content article's small image URL * (optionally <code>null</code>) * @param smallImageFile the web content article's new small image file * (optionally <code>null</code>). Must pass in * <code>smallImage</code> value of <code>true</code> to replace the * article's small image file. * @param images the web content's images (optionally <code>null</code>) * @param articleURL the web content article's accessible URL (optionally * <code>null</code>) * @param serviceContext the service context to be applied. Can set the * modification date, expando bridge attributes, asset category IDs, * asset tag names, asset link entry IDs, asset priority, workflow * actions, URL title , and can set whether to add the default * command update for the web content article. With respect to * social activities, by setting the service context's command to * {@link Constants#UPDATE}, the invocation is considered a web * content update activity; otherwise it is considered a web content * add activity. * @return the updated web content article */ @Indexable(type = IndexableType.REINDEX) @Override public JournalArticle updateArticle(long userId, long groupId, long folderId, String articleId, double version, Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, String content, String ddmStructureKey, String ddmTemplateKey, String layoutUuid, int displayDateMonth, int displayDateDay, int displayDateYear, int displayDateHour, int displayDateMinute, int expirationDateMonth, int expirationDateDay, int expirationDateYear, int expirationDateHour, int expirationDateMinute, boolean neverExpire, int reviewDateMonth, int reviewDateDay, int reviewDateYear, int reviewDateHour, int reviewDateMinute, boolean neverReview, boolean indexable, boolean smallImage, String smallImageURL, File smallImageFile, Map<String, byte[]> images, String articleURL, ServiceContext serviceContext) throws PortalException { // Article User user = userLocalService.getUser(userId); articleId = StringUtil.toUpperCase(StringUtil.trim(articleId)); byte[] smallImageBytes = null; try { smallImageBytes = FileUtil.getBytes(smallImageFile); } catch (IOException ioe) { } JournalArticle latestArticle = getLatestArticle(groupId, articleId, WorkflowConstants.STATUS_ANY); JournalArticle article = latestArticle; boolean imported = ExportImportThreadLocal.isImportInProcess(); double latestVersion = latestArticle.getVersion(); boolean addNewVersion = false; if (imported) { article = getArticle(groupId, articleId, version); } else { if ((version > 0) && (version != latestVersion)) { StringBundler sb = new StringBundler(4); sb.append("Version "); sb.append(version); sb.append(" is not the same as "); sb.append(latestVersion); throw new ArticleVersionException(sb.toString()); } serviceContext.validateModifiedDate(latestArticle, ArticleVersionException.class); if (latestArticle.isApproved() || latestArticle.isExpired() || latestArticle.isScheduled()) { addNewVersion = true; version = getNextVersion(article); } } Date displayDate = null; Date expirationDate = null; Date reviewDate = null; if (article.getClassNameId() == JournalArticleConstants.CLASSNAME_ID_DEFAULT) { displayDate = PortalUtil.getDate(displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, user.getTimeZone(), null); if (!neverExpire) { expirationDate = PortalUtil.getDate(expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, user.getTimeZone(), ArticleExpirationDateException.class); } if (!neverReview) { reviewDate = PortalUtil.getDate(reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, user.getTimeZone(), ArticleReviewDateException.class); } } Date now = new Date(); boolean expired = false; if ((expirationDate != null) && expirationDate.before(now)) { expired = true; } validate(user.getCompanyId(), groupId, latestArticle.getClassNameId(), titleMap, content, ddmStructureKey, ddmTemplateKey, displayDate, expirationDate, smallImage, smallImageURL, smallImageFile, smallImageBytes, serviceContext); validateReferences(groupId, ddmStructureKey, ddmTemplateKey, layoutUuid, smallImage, smallImageURL, smallImageBytes, latestArticle.getSmallImageId(), content); if (addNewVersion) { long id = counterLocalService.increment(); article = journalArticlePersistence.create(id); article.setResourcePrimKey(latestArticle.getResourcePrimKey()); article.setGroupId(latestArticle.getGroupId()); article.setCompanyId(latestArticle.getCompanyId()); article.setUserId(user.getUserId()); article.setUserName(user.getFullName()); article.setCreateDate(latestArticle.getCreateDate()); article.setClassNameId(latestArticle.getClassNameId()); article.setClassPK(latestArticle.getClassPK()); article.setArticleId(articleId); article.setVersion(version); article.setSmallImageId(latestArticle.getSmallImageId()); _addArticleLocalizedFields(article.getCompanyId(), article.getId(), titleMap, descriptionMap); } else { _updateArticleLocalizedFields(article.getCompanyId(), article.getId(), titleMap, descriptionMap); } Locale locale = getArticleDefaultLocale(content); String title = titleMap.get(locale); content = format(user, groupId, article, content); article.setFolderId(folderId); article.setTreePath(article.buildTreePath()); article.setUrlTitle(getUniqueUrlTitle(article.getId(), groupId, article.getArticleId(), title, latestArticle.getUrlTitle(), serviceContext)); article.setContent(content); article.setDDMStructureKey(ddmStructureKey); article.setDDMTemplateKey(ddmTemplateKey); article.setDefaultLanguageId(LocaleUtil.toLanguageId(locale)); article.setLayoutUuid(layoutUuid); article.setDisplayDate(displayDate); article.setExpirationDate(expirationDate); article.setReviewDate(reviewDate); article.setIndexable(indexable); article.setSmallImage(smallImage); if (smallImage) { if ((smallImageFile != null) && (smallImageBytes != null)) { article.setSmallImageId(counterLocalService.increment()); } } else { article.setSmallImageId(0); } article.setSmallImageURL(smallImageURL); if (latestArticle.isPending()) { article.setStatus(latestArticle.getStatus()); } else if (!expired) { article.setStatus(WorkflowConstants.STATUS_DRAFT); } else { article.setStatus(WorkflowConstants.STATUS_EXPIRED); } ExpandoBridgeUtil.setExpandoBridgeAttributes(latestArticle.getExpandoBridge(), article.getExpandoBridge(), serviceContext); journalArticlePersistence.update(article); // Asset if (hasModifiedLatestApprovedVersion(groupId, articleId, version)) { updateAsset(userId, article, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority()); } // Dynamic data mapping if (classNameLocalService.getClassNameId(DDMStructure.class) == article.getClassNameId()) { updateDDMStructurePredefinedValues(article.getClassPK(), content, serviceContext); } else { updateDDMLinks(article.getId(), groupId, ddmStructureKey, ddmTemplateKey, addNewVersion); } // Small image saveImages(smallImage, article.getSmallImageId(), smallImageFile, smallImageBytes); // Email PortletPreferences preferences = ServiceContextUtil.getPortletPreferences(serviceContext); // Workflow if (expired && imported) { updateStatus(userId, article, article.getStatus(), articleURL, serviceContext, new HashMap<String, Serializable>()); } if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_PUBLISH) { articleURL = buildArticleURL(articleURL, groupId, folderId, articleId); serviceContext.setAttribute("articleURL", articleURL); sendEmail(article, articleURL, preferences, "requested", serviceContext); startWorkflowInstance(userId, article, serviceContext); } return journalArticlePersistence.findByPrimaryKey(article.getId()); }