/**
   * Return all reservations of user define by user name.
   *
   * @param user User name
   * @return ArrayList Reservation
   */
  public ArrayList<Reservation> getUserReservation(String user) {
    if (doLog) Log.d(TAG, "get reservations for user");

    ArrayList<Reservation> comments = new ArrayList<Reservation>();

    Cursor cursor =
        database.query(
            MySQLiteOpenHelper.TABLE_RESERVATION,
            allColumnsReservation,
            null,
            null,
            null,
            null,
            null);
    cursor.moveToFirst();
    while (!cursor.isAfterLast()) {
      Reservation record = cursorToReservation(cursor);
      if (record.getUser().equals(user)) {
        comments.add(record);
      }
      cursor.moveToNext();
    }
    cursor.close();
    if (doLog) Log.d(TAG, comments.size() + "is returned");
    return comments;
  }
  /**
   * Check if reservation with same reservation id is not already in database.
   *
   * @param id Reservation id
   * @return True if exist.
   */
  public boolean getReservationsById(long id) {

    ArrayList<Reservation> res = getAllReservations();
    Iterator<Reservation> it = res.iterator();
    while (it.hasNext()) {
      Reservation help = it.next();
      Log.d(TAG, help.getUser() + " " + help.getReservationId());
      if (help.getReservationId() == id) {
        if (doLog) Log.d(TAG, "reservation with id: " + id + " exist");
        return true;
      }
    }
    if (doLog) Log.d(TAG, "reservation with id: " + id + " doesnt exist");
    return false;
  }
  /**
   * Insert reservation into database.
   *
   * @param res Reservation
   */
  public void createReservation(Reservation res) {
    if (doLog) Log.d(TAG, "DatabaseController - creating reservation");

    Log.d(
        TAG,
        res.getReservationId()
            + " - "
            + res.getUser()
            + " - "
            + res.getStart()
            + " - "
            + res.getEnd()
            + " - "
            + res.getUserId());
    ContentValues values = new ContentValues();
    values.put(MySQLiteOpenHelper.COLUMN_RESERVATION_ID, res.getReservationId());
    values.put(MySQLiteOpenHelper.COLUMN_USER, res.getUser());
    values.put(MySQLiteOpenHelper.COLUMN_USER_PASSWORD, res.getPassword());
    values.put(MySQLiteOpenHelper.COLUMN_RESERVATION_START, res.getStart());
    values.put(MySQLiteOpenHelper.COLUMN_RESERVATION_END, res.getEnd());
    values.put(MySQLiteOpenHelper.COLUMN_USER_ID, res.getUserId());
    database.insert(MySQLiteOpenHelper.TABLE_RESERVATION, null, values);
    if (doLog) Log.d(TAG, "reservation created");
  }