/*
   * (non-Javadoc)
   *
   * @see dal.SchoolDAL#save(models.School)
   */
  @Override
  public School save(School school) {

    final PreparedStatement statement =
        session.prepare(
            "INSERT INTO student_info.school (school_id,name,address,email,gender_type) "
                + "VALUES (?,?,?,?,?)");
    final BoundStatement boundStatement =
        statement.bind(
            school.getSchoolId(),
            school.getName(),
            school.getAddress(),
            school.getEmail(),
            school.getGenderType());

    final ResultSetFuture savedSchoolFuture = session.executeAsync(boundStatement);

    // final Row response = savedSchoolFuture.getUninterruptibly().one();

    return school;
  }
  /*
   * (non-Javadoc)
   *
   * @see dal.SchoolDAL#delete(models.School)
   */
  @Override
  public int delete(School school) {

    final PreparedStatement statement = session.prepare("DELETE FROM school WHERE school_id = ?");
    final BoundStatement boundStatement = statement.bind(school.getSchoolId());

    try {
      session.executeAsync(boundStatement);
    } catch (Exception e) {
      return 0;
    }

    return 1;
  }
  /**
   * Creates the school for row.
   *
   * @param row the row
   * @return the school
   */
  private School createSchoolForRow(Row row) {

    School school = new School();

    school.setSchoolId(row.getString(Constants.SCHOOL_ID));
    school.setName(row.getString(Constants.NAME));
    school.setAddress(row.getString(Constants.ADDRESS));
    school.setGenderType(row.getString(Constants.GENDER_TYPE));
    school.setEmail(row.getString(Constants.EMAIL));

    return school;
  }