예제 #1
0
  public PageResponse<QueryPageRow> queryMetaData(QueryMetadataPageRequest request)
      throws SerializationException {
    if (request == null) {
      throw new IllegalArgumentException("request cannot be null");
    }
    if (request.getPageSize() != null && request.getPageSize() < 0) {
      throw new IllegalArgumentException("pageSize cannot be less than zero.");
    }

    // Setup parameters for generic repository query
    Map<String, String[]> queryMap = createQueryMap(request.getMetadata());

    DateQuery[] dates = createDateQueryForRepository(request);

    long start = System.currentTimeMillis();
    AssetItemIterator iterator = rulesRepository.query(queryMap, request.isSearchArchived(), dates);
    log.debug("Search time: " + (System.currentTimeMillis() - start));

    List<QueryPageRow> rowList =
        new QueryMetadataPageRowBuilder().withPageRequest(request).withContent(iterator).build();
    boolean bHasMoreRows = iterator.hasNext();
    PageResponse<QueryPageRow> response =
        new PageResponseBuilder<QueryPageRow>()
            .withStartRowIndex(request.getStartRowIndex())
            .withPageRowList(rowList)
            .withLastPage(!bHasMoreRows)
            .buildWithTotalRowCount(
                -1); // its impossible to know the exact selected count until we'v reached
    // the end of iterator
    long methodDuration = System.currentTimeMillis() - start;
    log.debug("Queried repository (Metadata) in " + methodDuration + " ms.");
    return response;
  }
예제 #2
0
  /** @deprecated in favour of {@link #queryMetaData(QueryMetadataPageRequest)} */
  public TableDataResult queryMetaData(
      final MetaDataQuery[] qr,
      Date createdAfter,
      Date createdBefore,
      Date modifiedAfter,
      Date modifiedBefore,
      boolean seekArchived,
      int skip,
      int numRows)
      throws SerializationException {
    if (numRows == 0) {
      throw new DetailedSerializationException(
          "Unable to return zero results (bug)",
          "probably have the parameters around the wrong way, sigh...");
    }

    Map<String, String[]> q =
        new HashMap<String, String[]>() {
          {
            for (MetaDataQuery aQr : qr) {
              String vals = (aQr.valueList == null) ? "" : aQr.valueList.trim();
              if (vals.length() > 0) {
                put(aQr.attribute, vals.split(",\\s?"));
              }
            }
          }
        };

    DateQuery[] dates = new DateQuery[2];

    dates[0] =
        new DateQuery(
            "jcr:created", DateUtil.isoDate(createdAfter), DateUtil.isoDate(createdBefore));
    dates[1] =
        new DateQuery(
            AssetItem.LAST_MODIFIED_PROPERTY_NAME,
            DateUtil.isoDate(modifiedAfter),
            DateUtil.isoDate(modifiedBefore));
    AssetItemIterator it = rulesRepository.query(q, seekArchived, dates);
    // Add Filter to check Permission
    List<AssetItem> resultList = new ArrayList<AssetItem>();

    RepositoryFilter categoryFilter = new CategoryFilter();

    while (it.hasNext()) {
      AssetItem ai = it.next();

      resultList.add(ai);
    }

    return new TableDisplayHandler("searchresults").loadRuleListTable(resultList, skip, numRows);
  }