package edu.fiu.models;

import org.jdbi.v3.core.mapper.RowMapper;
import org.jdbi.v3.core.statement.StatementContext;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Model of a user story
 * @author Juan Diaz
 */
public class UserStory {
    Integer userID;   // User ID in data store
    String text;  // Text from an HTML Text Area

    //SP4
    String submitTime;

  
  public static class Mapper implements RowMapper<UserStory> {
    @Override public UserStory map(final ResultSet rs, final StatementContext ctx) throws SQLException {
      return new UserStory(rs.getInt("userID"), rs.getString("text"), /*SP4*/rs.getString("submitTime"));
    }
  }

  public UserStory(Integer userID, String text,/*SP4 */String submitTime) {
    this.userID = userID;
    this.text = text; 
    this.submitTime = submitTime;
  }

  @Override
  public String toString() {
    return String.format("User<%d,%s,%s>", userID, text, submitTime);
  }

  @Override
  public boolean equals(Object o) {
    UserStory other = (UserStory) o;
    return 
      this.userID.equals(other.userID) &&
      this.text.equals(other.text);
  }
//SP4

  public String getSubmitTime(){
    return submitTime;
  }

  // public void setSubmitTime(String time){

  //   submitTime = time;
  // }

  public Integer getUserID() {
    return userID;
  }
  
  public String getText(){
      return text;
  }

  public void setId(Integer id) {
    userID = id;
  }

  public String getStory() {
    return text;
  }

  public void setText(String input) {
    text = input;
  }

}
