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.knowledgebase.service.impl.KBArticleLocalServiceImpl.java
License:Open Source License
protected DynamicQuery buildDynamicQuery(long groupId, String title, String content, int status, Date startDate, Date endDate, boolean andOperator) { Junction junction = null;/*from www . java2s . c o m*/ if (andOperator) { junction = RestrictionsFactoryUtil.conjunction(); } else { junction = RestrictionsFactoryUtil.disjunction(); } Map<String, String> terms = new HashMap<String, String>(); if (Validator.isNotNull(title)) { terms.put("title", title); } if (Validator.isNotNull(content)) { terms.put("content", content); } for (Map.Entry<String, String> entry : terms.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); Disjunction disjunction = RestrictionsFactoryUtil.disjunction(); for (String keyword : KnowledgeBaseUtil.splitKeywords(value)) { Criterion criterion = RestrictionsFactoryUtil.ilike(key, StringUtil.quote(keyword, StringPool.PERCENT)); disjunction.add(criterion); } junction.add(disjunction); } if (status != WorkflowConstants.STATUS_ANY) { Property property = PropertyFactoryUtil.forName("status"); junction.add(property.eq(status)); } if ((endDate != null) && (startDate != null)) { Disjunction disjunction = RestrictionsFactoryUtil.disjunction(); String[] propertyNames = { "createDate", "modifiedDate" }; for (String propertyName : propertyNames) { Property property = PropertyFactoryUtil.forName(propertyName); Conjunction conjunction = RestrictionsFactoryUtil.conjunction(); conjunction.add(property.gt(startDate)); conjunction.add(property.lt(endDate)); disjunction.add(conjunction); } junction.add(disjunction); } DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(KBArticle.class, getClassLoader()); if (status == WorkflowConstants.STATUS_ANY) { Property property = PropertyFactoryUtil.forName("latest"); dynamicQuery.add(property.eq(Boolean.TRUE)); } else if (status == WorkflowConstants.STATUS_APPROVED) { Property property = PropertyFactoryUtil.forName("main"); dynamicQuery.add(property.eq(Boolean.TRUE)); } if (groupId > 0) { Property property = PropertyFactoryUtil.forName("groupId"); dynamicQuery.add(property.eq(groupId)); } return dynamicQuery.add(junction); }
From source file:com.liferay.knowledgebase.service.impl.KBArticleLocalServiceImpl.java
License:Open Source License
protected List<KBArticle> getAllDescendantKBArticles(long resourcePrimKey, int status, OrderByComparator<KBArticle> orderByComparator, boolean includeParentArticle) { List<KBArticle> kbArticles = null; if (includeParentArticle) { kbArticles = getKBArticles(new long[] { resourcePrimKey }, status, null); kbArticles = ListUtil.copy(kbArticles); } else {// ww w . j a v a 2 s . co m kbArticles = new ArrayList<KBArticle>(); } Long[][] params = new Long[][] { new Long[] { resourcePrimKey } }; while ((params = KnowledgeBaseUtil.getParams(params[0])) != null) { List<KBArticle> curKBArticles = null; if (status == WorkflowConstants.STATUS_ANY) { curKBArticles = kbArticlePersistence.findByP_L(ArrayUtil.toArray(params[1]), true); } else if (status == WorkflowConstants.STATUS_APPROVED) { curKBArticles = kbArticlePersistence.findByP_M(ArrayUtil.toArray(params[1]), true); } else { curKBArticles = kbArticlePersistence.findByP_S(ArrayUtil.toArray(params[1]), status); } kbArticles.addAll(curKBArticles); long[] resourcePrimKeys = StringUtil.split(ListUtil.toString(curKBArticles, "resourcePrimKey"), 0L); params[0] = ArrayUtil.append(params[0], ArrayUtil.toArray(resourcePrimKeys)); } if (orderByComparator != null) { kbArticles = ListUtil.sort(kbArticles, orderByComparator); } return Collections.unmodifiableList(kbArticles); }
From source file:com.liferay.knowledgebase.service.impl.KBArticleLocalServiceImpl.java
License:Open Source License
protected void notifySubscribers(KBArticle kbArticle, ServiceContext serviceContext) throws PortalException { if (Validator.isNull(serviceContext.getLayoutFullURL())) { return;// w w w . j a v a 2s. co m } PortletPreferences preferences = portletPreferencesLocalService.getPreferences(kbArticle.getCompanyId(), kbArticle.getGroupId(), PortletKeys.PREFS_OWNER_TYPE_GROUP, PortletKeys.PREFS_PLID_SHARED, PortletKeys.KNOWLEDGE_BASE_ADMIN, null); if (serviceContext.isCommandAdd() && !AdminUtil.getEmailKBArticleAddedEnabled(preferences)) { return; } if (serviceContext.isCommandUpdate() && !AdminUtil.getEmailKBArticleUpdatedEnabled(preferences)) { return; } String fromName = AdminUtil.getEmailFromName(preferences, kbArticle.getCompanyId()); String fromAddress = AdminUtil.getEmailFromAddress(preferences, kbArticle.getCompanyId()); String kbArticleContent = StringUtil.replace(kbArticle.getContent(), new String[] { "href=\"/", "src=\"/" }, new String[] { "href=\"" + serviceContext.getPortalURL() + "/", "src=\"" + serviceContext.getPortalURL() + "/" }); Map<String, String> kbArticleDiffs = getEmailKBArticleDiffs(kbArticle); for (String key : kbArticleDiffs.keySet()) { String value = StringUtil.replace(kbArticleDiffs.get(key), new String[] { "href=\"/", "src=\"/" }, new String[] { "href=\"" + serviceContext.getPortalURL() + "/", "src=\"" + serviceContext.getPortalURL() + "/" }); kbArticleDiffs.put(key, value); } String subject = null; String body = null; if (serviceContext.isCommandAdd()) { subject = AdminUtil.getEmailKBArticleAddedSubject(preferences); body = AdminUtil.getEmailKBArticleAddedBody(preferences); } else { subject = AdminUtil.getEmailKBArticleUpdatedSubject(preferences); body = AdminUtil.getEmailKBArticleUpdatedBody(preferences); } SubscriptionSender subscriptionSender = new AdminSubscriptionSender(kbArticle, serviceContext); subscriptionSender.setBody(body); subscriptionSender.setCompanyId(kbArticle.getCompanyId()); subscriptionSender.setContextAttribute("[$ARTICLE_CONTENT$]", kbArticleContent, false); subscriptionSender.setContextAttribute("[$ARTICLE_CONTENT_DIFF$]", kbArticleDiffs.get("content"), false); subscriptionSender.setContextAttribute("[$ARTICLE_TITLE$]", kbArticle.getTitle(), false); subscriptionSender.setContextAttribute("[$ARTICLE_TITLE_DIFF$]", kbArticleDiffs.get("title"), false); subscriptionSender.setContextUserPrefix("ARTICLE"); subscriptionSender.setFrom(fromAddress, fromName); subscriptionSender.setHtmlFormat(true); subscriptionSender.setMailId("kb_article", kbArticle.getKbArticleId()); subscriptionSender.setPortletId(serviceContext.getPortletId()); subscriptionSender.setReplyToAddress(fromAddress); subscriptionSender.setScopeGroupId(kbArticle.getGroupId()); subscriptionSender.setSubject(subject); subscriptionSender.setUserId(kbArticle.getUserId()); subscriptionSender.addPersistedSubscribers(KBArticle.class.getName(), kbArticle.getGroupId()); subscriptionSender.addPersistedSubscribers(KBArticle.class.getName(), kbArticle.getResourcePrimKey()); while (!kbArticle.isRoot() && (kbArticle.getClassNameId() == kbArticle.getParentResourceClassNameId())) { kbArticle = getLatestKBArticle(kbArticle.getParentResourcePrimKey(), WorkflowConstants.STATUS_APPROVED); subscriptionSender.addPersistedSubscribers(KBArticle.class.getName(), kbArticle.getResourcePrimKey()); } subscriptionSender.flushNotificationsAsync(); }
From source file:com.liferay.knowledgebase.service.impl.KBArticleServiceImpl.java
License:Open Source License
@Override public List<KBArticle> getGroupKBArticles(long groupId, int status, int start, int end, OrderByComparator<KBArticle> orderByComparator) { if (status == WorkflowConstants.STATUS_ANY) { return kbArticlePersistence.filterFindByG_L(groupId, true, start, end, orderByComparator); } else if (status == WorkflowConstants.STATUS_APPROVED) { return kbArticlePersistence.filterFindByG_M(groupId, true, start, end, orderByComparator); }// ww w . j av a 2 s. c o m return kbArticlePersistence.filterFindByG_S(groupId, status, start, end, orderByComparator); }
From source file:com.liferay.knowledgebase.service.impl.KBArticleServiceImpl.java
License:Open Source License
@Override public int getGroupKBArticlesCount(long groupId, int status) { if (status == WorkflowConstants.STATUS_ANY) { return kbArticlePersistence.filterCountByG_L(groupId, true); } else if (status == WorkflowConstants.STATUS_APPROVED) { return kbArticlePersistence.filterCountByG_M(groupId, true); }//from w w w.j ava2s . c o m return kbArticlePersistence.filterCountByG_S(groupId, status); }
From source file:com.liferay.knowledgebase.service.impl.KBArticleServiceImpl.java
License:Open Source License
@Override public List<KBArticle> getKBArticleAndAllDescendantKBArticles(long groupId, long resourcePrimKey, int status, OrderByComparator<KBArticle> orderByComparator) { List<KBArticle> kbArticles = getKBArticles(groupId, new long[] { resourcePrimKey }, status, null); kbArticles = ListUtil.copy(kbArticles); Long[][] params = new Long[][] { new Long[] { resourcePrimKey } }; while ((params = KnowledgeBaseUtil.getParams(params[0])) != null) { List<KBArticle> curKBArticles = null; if (status == WorkflowConstants.STATUS_ANY) { curKBArticles = kbArticlePersistence.filterFindByG_P_L(groupId, ArrayUtil.toArray(params[1]), true); } else if (status == WorkflowConstants.STATUS_APPROVED) { curKBArticles = kbArticlePersistence.filterFindByG_P_M(groupId, ArrayUtil.toArray(params[1]), true); } else {//from ww w . j a va 2 s . c om curKBArticles = kbArticlePersistence.filterFindByG_P_S(groupId, ArrayUtil.toArray(params[1]), status); } kbArticles.addAll(curKBArticles); long[] resourcePrimKeys = StringUtil.split(ListUtil.toString(curKBArticles, "resourcePrimKey"), 0L); params[0] = ArrayUtil.append(params[0], ArrayUtil.toArray(resourcePrimKeys)); } if (orderByComparator != null) { kbArticles = ListUtil.sort(kbArticles, orderByComparator); } return Collections.unmodifiableList(kbArticles); }
From source file:com.liferay.knowledgebase.service.impl.KBArticleServiceImpl.java
License:Open Source License
@Override public List<KBArticle> getKBArticles(long groupId, long parentResourcePrimKey, int status, int start, int end, OrderByComparator<KBArticle> orderByComparator) { if (status == WorkflowConstants.STATUS_ANY) { return kbArticlePersistence.filterFindByG_P_L(groupId, parentResourcePrimKey, true, start, end, orderByComparator);/*from ww w. j a va 2s . c om*/ } else if (status == WorkflowConstants.STATUS_APPROVED) { return kbArticlePersistence.filterFindByG_P_M(groupId, parentResourcePrimKey, true, start, end, orderByComparator); } return kbArticlePersistence.filterFindByG_P_S(groupId, parentResourcePrimKey, status, start, end, orderByComparator); }
From source file:com.liferay.knowledgebase.service.impl.KBArticleServiceImpl.java
License:Open Source License
@Override public List<KBArticle> getKBArticles(long groupId, long[] resourcePrimKeys, int status, int start, int end, OrderByComparator<KBArticle> orderByComparator) { List<KBArticle> kbArticles = new ArrayList<KBArticle>(); Long[][] params = new Long[][] { ArrayUtil.toArray(resourcePrimKeys) }; while ((params = KnowledgeBaseUtil.getParams(params[0])) != null) { List<KBArticle> curKBArticles = null; if (status == WorkflowConstants.STATUS_ANY) { curKBArticles = kbArticlePersistence.filterFindByR_G_L(ArrayUtil.toArray(params[1]), groupId, true, start, end);//from ww w .j av a 2s. c o m } else if (status == WorkflowConstants.STATUS_APPROVED) { curKBArticles = kbArticlePersistence.filterFindByR_G_M(ArrayUtil.toArray(params[1]), groupId, true, start, end); } else { curKBArticles = kbArticlePersistence.filterFindByR_G_S(ArrayUtil.toArray(params[1]), groupId, status, start, end); } kbArticles.addAll(curKBArticles); } if (orderByComparator != null) { kbArticles = ListUtil.sort(kbArticles, orderByComparator); } else { kbArticles = KnowledgeBaseUtil.sort(resourcePrimKeys, kbArticles); } return Collections.unmodifiableList(kbArticles); }
From source file:com.liferay.knowledgebase.service.impl.KBArticleServiceImpl.java
License:Open Source License
@Override public int getKBArticlesCount(long groupId, long parentResourcePrimKey, int status) { if (status == WorkflowConstants.STATUS_ANY) { return kbArticlePersistence.filterCountByG_P_L(groupId, parentResourcePrimKey, true); } else if (status == WorkflowConstants.STATUS_APPROVED) { return kbArticlePersistence.filterCountByG_P_M(groupId, parentResourcePrimKey, true); }/*from w w w.j a v a 2 s.c o m*/ return kbArticlePersistence.filterCountByG_P_S(groupId, parentResourcePrimKey, status); }
From source file:com.liferay.knowledgebase.service.impl.KBArticleServiceImpl.java
License:Open Source License
@Override public int getKBArticlesCount(long groupId, long[] resourcePrimKeys, int status) { int count = 0; Long[][] params = new Long[][] { ArrayUtil.toArray(resourcePrimKeys) }; while ((params = KnowledgeBaseUtil.getParams(params[0])) != null) { if (status == WorkflowConstants.STATUS_ANY) { count += kbArticlePersistence.filterCountByR_G_L(ArrayUtil.toArray(params[1]), groupId, true); } else if (status == WorkflowConstants.STATUS_APPROVED) { count += kbArticlePersistence.filterCountByR_G_M(ArrayUtil.toArray(params[1]), groupId, true); } else {/*ww w . jav a 2s. c o m*/ count += kbArticlePersistence.filterCountByR_G_S(ArrayUtil.toArray(params[1]), groupId, status); } } return count; }