public SearchContainer<MBMessage> getCommentsSearchContainer() throws PortalException {

    SearchContainer<MBMessage> searchContainer =
        new SearchContainer(
            _liferayPortletRequest, _liferayPortletResponse.createRenderURL(), null, null);

    SearchContext searchContext =
        SearchContextFactory.getInstance(_liferayPortletRequest.getHttpServletRequest());

    searchContext.setAttribute(
        Field.CLASS_NAME_ID, PortalUtil.getClassNameId(JournalArticle.class));

    searchContext.setAttribute("discussion", true);

    List<MBMessage> mbMessages = new ArrayList<>();

    Indexer indexer = IndexerRegistryUtil.getIndexer(MBMessage.class);

    Hits hits = indexer.search(searchContext);

    for (Document document : hits.getDocs()) {
      long entryClassPK = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));

      MBMessage mbMessage = MBMessageLocalServiceUtil.fetchMBMessage(entryClassPK);

      mbMessages.add(mbMessage);
    }

    searchContainer.setResults(mbMessages);

    searchContainer.setTotal(hits.getLength());

    return searchContainer;
  }
예제 #2
0
  public static BaseModelSearchResult<AssetEntry> searchAssetEntries(
      AssetEntryQuery assetEntryQuery,
      long[] assetCategoryIds,
      String[] assetTagNames,
      Map<String, Serializable> attributes,
      long companyId,
      String keywords,
      Layout layout,
      Locale locale,
      long scopeGroupId,
      TimeZone timeZone,
      long userId,
      int start,
      int end)
      throws Exception {

    SearchContext searchContext =
        SearchContextFactory.getInstance(
            assetCategoryIds,
            assetTagNames,
            attributes,
            companyId,
            keywords,
            layout,
            locale,
            scopeGroupId,
            timeZone,
            userId);

    return searchAssetEntries(searchContext, assetEntryQuery, start, end);
  }
예제 #3
0
  public static BaseModelSearchResult<AssetEntry> searchAssetEntries(
      HttpServletRequest request, AssetEntryQuery assetEntryQuery, int start, int end)
      throws Exception {

    SearchContext searchContext = SearchContextFactory.getInstance(request);

    return searchAssetEntries(searchContext, assetEntryQuery, start, end);
  }
예제 #4
0
  public static Hits search(
      HttpServletRequest request, AssetEntryQuery assetEntryQuery, int start, int end)
      throws Exception {

    SearchContext searchContext = SearchContextFactory.getInstance(request);

    return search(searchContext, assetEntryQuery, start, end);
  }
예제 #5
0
파일: TTUtils.java 프로젝트: taotran/eco
  /** @return */
  public static SearchContext getCurrentSearchContext() {
    final LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();

    final PortletRequest req =
        (PortletRequest) liferayFacesContext.getExternalContext().getRequest();

    final HttpServletRequest httpServletRequest =
        PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(req));
    final SearchContext searchContext = SearchContextFactory.getInstance(httpServletRequest);
    return searchContext;
  }