コード例 #1
0
  public static Hits search(
      SearchContext searchContext, AssetEntryQuery assetEntryQuery, int start, int end)
      throws Exception {

    AssetSearcher assetSearcher = getAssetSearcher(searchContext, assetEntryQuery, start, end);

    return assetSearcher.search(searchContext);
  }
コード例 #2
0
  public static BaseModelSearchResult<AssetEntry> searchAssetEntries(
      SearchContext searchContext, AssetEntryQuery assetEntryQuery, int start, int end)
      throws Exception {

    AssetSearcher assetSearcher = getAssetSearcher(searchContext, assetEntryQuery, start, end);

    Hits hits = assetSearcher.search(searchContext);

    List<AssetEntry> assetEntries = getAssetEntries(hits);

    return new BaseModelSearchResult<>(assetEntries, hits.getLength());
  }
コード例 #3
0
  protected static AssetSearcher getAssetSearcher(
      SearchContext searchContext, AssetEntryQuery assetEntryQuery, int start, int end)
      throws Exception {

    Indexer<?> searcher = AssetSearcher.getInstance();

    AssetSearcher assetSearcher = (AssetSearcher) searcher;

    assetSearcher.setAssetEntryQuery(assetEntryQuery);

    Layout layout = assetEntryQuery.getLayout();

    if (layout != null) {
      searchContext.setAttribute(Field.LAYOUT_UUID, layout.getUuid());
    }

    String ddmStructureFieldName = (String) assetEntryQuery.getAttribute("ddmStructureFieldName");
    Serializable ddmStructureFieldValue = assetEntryQuery.getAttribute("ddmStructureFieldValue");

    if (Validator.isNotNull(ddmStructureFieldName) && Validator.isNotNull(ddmStructureFieldValue)) {

      searchContext.setAttribute("ddmStructureFieldName", ddmStructureFieldName);
      searchContext.setAttribute("ddmStructureFieldValue", ddmStructureFieldValue);
    }

    String paginationType = GetterUtil.getString(assetEntryQuery.getPaginationType(), "more");

    if (!paginationType.equals("none") && !paginationType.equals("simple")) {

      searchContext.setAttribute("paginationType", paginationType);
    }

    searchContext.setClassTypeIds(assetEntryQuery.getClassTypeIds());
    searchContext.setEnd(end);
    searchContext.setGroupIds(assetEntryQuery.getGroupIds());

    if (Validator.isNotNull(assetEntryQuery.getKeywords())) {
      searchContext.setLike(true);
    }

    searchContext.setSorts(getSorts(assetEntryQuery, searchContext.getLocale()));
    searchContext.setStart(start);

    return assetSearcher;
  }