示例#1
0
 private void setColumns(
     QueryResult result, RestQueryResult restQueryResult, String[] columnNames) {
   if (result instanceof org.modeshape.jcr.api.query.QueryResult) {
     org.modeshape.jcr.api.query.QueryResult modeShapeQueryResult =
         (org.modeshape.jcr.api.query.QueryResult) result;
     String[] columnTypes = modeShapeQueryResult.getColumnTypes();
     for (int i = 0; i < columnNames.length; i++) {
       restQueryResult.addColumn(columnNames[i], columnTypes[i]);
     }
   } else {
     for (String columnName : columnNames) {
       restQueryResult.addColumn(columnName, UNKNOWN_TYPE);
     }
   }
 }
示例#2
0
  private void setRows(
      long offset,
      long limit,
      Session session,
      QueryResult result,
      RestQueryResult restQueryResult,
      String[] columnNames,
      String baseUrl)
      throws RepositoryException {
    RowIterator resultRows = result.getRows();
    if (offset > 0) {
      resultRows.skip(offset);
    }
    if (limit < 0) {
      limit = Long.MAX_VALUE;
    }

    while (resultRows.hasNext() && limit > 0) {
      limit--;
      Row resultRow = resultRows.nextRow();

      RestQueryResult.RestRow restRow =
          createRestRow(session, result, restQueryResult, columnNames, baseUrl, resultRow);
      createLinksFromNodePaths(result, baseUrl, resultRow, restRow);

      restQueryResult.addRow(restRow);
    }
  }