class DbTaskRunner extends AbstractDbDataDao<Transfer> {

  public static String getJson(final DbPreparedStatement preparedStatement,
                               final int limit)
      throws WaarpDatabaseNoConnectionException, WaarpDatabaseSqlException {
    final ArrayNode arrayNode = JsonHandler.createArrayNode();
    try {
      preparedStatement.executeQuery();
      final LocalTransaction localTransaction =
          Configuration.configuration.getLocalTransaction();
      int nb = 0;
      while (preparedStatement.getNext()) {
        final DbTaskRunner runner = getFromStatementNoRule(preparedStatement);
        final ObjectNode node = runner.getJson();
        node.put(Columns.SPECIALID.name(),
                 Long.toString(runner.getSpecialId()));
        if (localTransaction == null) {
          node.put("Running", false);
        } else {
          node.put("Running", localTransaction.contained(runner.getKey()));
        }
        arrayNode.add(node);
        nb++;
        if (nb >= limit) {
          break;
        }
      }
    } finally {
      preparedStatement.realClose();
    }
    return WaarpStringUtils.cleanJsonForHtml(
        JsonHandler.writeAsString(arrayNode)
                   .replaceAll("(\\\"\\{)([^}]+)(\\}\\\")", "\"{$2}\"")
                   .replaceAll("([^\\\\])(\\\\\")([a-zA-Z_0-9]+)(\\\\\")",
                               "$1\\\\\"$3\\\\\""));
  }

  public  DbTaskRunner(final Transfer transfer);
  public  DbTaskRunner(final DbRule rule, final boolean isSender,
                      final RequestPacket requestPacket, final String requested,
                      final Timestamp startTime);
  public  DbTaskRunner(final R66Session session, final DbRule rule,
                      final boolean isSender, final RequestPacket requestPacket);
  public  DbTaskRunner(final R66Session session, final DbRule rule,
                      final long id, final String requester,
                      final String requested);
  public  DbTaskRunner(final long id, final String requester,
                      final String requested);
  public  DbTaskRunner(final long id, final String requester,
                      final String requested, final String owner);
  public  DbTaskRunner(final ObjectNode source);
  public  DbTaskRunner(final long id, final String requested);
  private  DbTaskRunner();

}