package hirondelle.fish.main.rsvp;
import hirondelle.fish.main.visit.Visit;
import hirondelle.fish.main.visit.VisitDAO;
import hirondelle.web4j.action.ActionImpl;
import hirondelle.web4j.action.ResponsePage;
import hirondelle.web4j.database.SqlId;
import hirondelle.web4j.model.AppException;
import hirondelle.web4j.request.RequestParser;
public final class RsvpShow extends ActionImpl {
public RsvpShow(RequestParser aRequestParser){
super(FORWARD, aRequestParser);
}
public static final SqlId RSVP_LIST_ACTIVE_MEMBERS = new SqlId("RSVP_LIST_ACTIVE_MEMBERS");
public static final SqlId RSVP_FETCH_NUM_YES = new SqlId("RSVP_FETCH_NUM_YES");
public static final SqlId RSVP_LIST_RESPONSES = new SqlId("RSVP_LIST_RESPONSES");
public ResponsePage execute() throws AppException {
VisitDAO dao = new VisitDAO();
Visit nextVisit = dao.fetchNextFutureVisit();
addToRequest(NEXT_VISIT, nextVisit);
if ( nextVisit != null ) {
RsvpDAO rsvpDAO = new RsvpDAO();
addToRequest(ITEMS_FOR_LISTING, rsvpDAO.list(nextVisit.getId()));
addToRequest(NUM_YES_RESPONSES, rsvpDAO.countNumYes(nextVisit.getId()) );
}
return getResponsePage();
}
private static final ResponsePage FORWARD = new ResponsePage("Rsvp", "RsvpShow.jsp", RsvpShow.class);
private static final String NUM_YES_RESPONSES = "numYesResponses";
private static final String NEXT_VISIT = "nextVisit";
}