List of usage examples for com.liferay.portal.kernel.search Field GROUP_ID
String GROUP_ID
To view the source code for com.liferay.portal.kernel.search Field GROUP_ID.
Click Source Link
From source file:org.xcolab.portlets.search.Indexer.java
License:Open Source License
@Override public Document getDocument(Object obj) throws SearchException { JournalArticle article = (JournalArticle) obj; String articleId = article.getArticleId(); long groupId = article.getGroupId(); long companyId = article.getCompanyId(); double version = article.getVersion(); String content = article.getContent(); String title = article.getTitle(); Date displayDate = article.getDisplayDate(); String description = article.getDescription(); String type = article.getType(); ExpandoBridge expandoBridge = article.getExpandoBridge(); if ((content != null) && ((content.indexOf("<dynamic-content") != -1) || (content.indexOf("<static-content") != -1))) { content = _getIndexableContent(content); content = StringUtil.replace(content, "<![CDATA[", StringPool.BLANK); content = StringUtil.replace(content, "]]>", StringPool.BLANK); }// w w w .j a va 2 s . c om content = StringUtil.replace(content, "&", "&"); content = StringUtil.replace(content, "<", "<"); content = StringUtil.replace(content, ">", ">"); content = HtmlUtil.extractText(content); Document doc = new DocumentImpl(); // check if this is an most recent version of an article boolean isOld = false; try { JournalArticle tmpArticle = JournalArticleLocalServiceUtil.getArticle(groupId, String.valueOf(articleId)); if (article.getVersion() != version) { isOld = true; } } catch (Exception e1) { e1.printStackTrace(); // ignore } if (isOld) { doc.addUID(PORTLET_ID, articleId, "old"); } else { doc.addUID(PORTLET_ID, articleId); } doc.addModifiedDate(displayDate); doc.addKeyword(Field.COMPANY_ID, companyId); doc.addKeyword(Field.PORTLET_ID, PORTLET_ID); doc.addKeyword(Field.GROUP_ID, groupId); doc.addText(Field.TITLE, title); doc.addText(Field.CONTENT, content); doc.addText(Field.DESCRIPTION, description); doc.addKeyword(Field.ENTRY_CLASS_PK, articleId); doc.addKeyword(Field.VERSION, version); doc.addKeyword(Field.TYPE, type); ExpandoBridgeIndexerUtil.addAttributes(doc, expandoBridge); try { Layout pageLayout = getLayoutForContent(articleId); if (pageLayout != null) { Layout tmp = pageLayout; boolean isAbout = false; while (tmp != null && !isAbout) { if (tmp.getFriendlyURL().toLowerCase().contains("/about") || tmp.getFriendlyURL().toLowerCase().contains("/contests")) { isAbout = true; } if (tmp.getParentLayoutId() > 0) { try { tmp = LayoutLocalServiceUtil.getLayout(tmp.getGroupId(), tmp.getPrivateLayout(), tmp.getParentLayoutId()); } catch (com.liferay.portal.NoSuchLayoutException e) { tmp = null; } catch (PortalException e) { tmp = null; } } else { tmp = null; } } if (isAbout) { doc.addKeyword("PAGE_URL", pageLayout.getFriendlyURL()); doc.addKeyword(Field.ENTRY_CLASS_NAME, JournalArticle.class.getName() + ".index"); } } else { doc.addKeyword(Field.ENTRY_CLASS_NAME, JournalArticle.class.getName()); } } catch (SystemException e) { doc.addKeyword(Field.ENTRY_CLASS_NAME, JournalArticle.class.getName()); e.printStackTrace(); } return doc; }
From source file:org.xmlportletfactory.olafk.customer.util.CustomerIndexer.java
License:Open Source License
@Override protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) { String title = document.get(Field.TITLE); String content = snippet;/*from w w w .j a va 2 s.c om*/ if (Validator.isNull(snippet)) { content = StringUtil.shorten(document.get(Field.CONTENT), 200); } String entryId = document.get(Field.ENTRY_CLASS_PK); String groupId = document.get(Field.GROUP_ID); long plid = 0; try { plid = CustomerUtil.getPlid(Long.parseLong(groupId)); } catch (Exception e) { } portletURL.setParameter("p_l_id", String.valueOf(plid)); portletURL.setParameter("view", "editCustomer"); portletURL.setParameter("customerId", String.valueOf(entryId)); portletURL.setParameter("editType", "view"); return new Summary(title, content, portletURL); }
From source file:org.xmlportletfactory.olafk.customer.util.InvoicesIndexer.java
License:Open Source License
@Override protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) { String title = document.get(Field.TITLE); String content = snippet;//from ww w .j a v a 2 s . c o m if (Validator.isNull(snippet)) { content = StringUtil.shorten(document.get(Field.CONTENT), 200); } String entryId = document.get(Field.ENTRY_CLASS_PK); String groupId = document.get(Field.GROUP_ID); long plid = 0; try { plid = InvoicesUtil.getPlid(Long.parseLong(groupId)); } catch (Exception e) { } portletURL.setParameter("p_l_id", String.valueOf(plid)); portletURL.setParameter("view", "editInvoices"); portletURL.setParameter("invoiceId", String.valueOf(entryId)); portletURL.setParameter("editType", "view"); return new Summary(title, content, portletURL); }