package commands;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import business.Professor;
import business.Turma;
import dao.FacadeDAO;

public class TurmaPrepararListaAlocacaoProfessor extends AbstractCommand {

	public void processarComando(HttpServletRequest request,
			HttpServletResponse response, HttpServlet servlet) {

		List<Turma> turmasComProfessor = FacadeDAO.getInstance(servlet).getTurmaDAO().listarTurmasComProfessor();
		List<Turma> turmasSemProfessor = FacadeDAO.getInstance(servlet).getTurmaDAO().listarTurmasSemProfessor();
		List<Professor> professores = FacadeDAO.getInstance(servlet).getProfessorDAO().listarProfessores();

		request.setAttribute("turmasComProfessor", turmasComProfessor);
		request.setAttribute("turmasSemProfessor", turmasSemProfessor);
		request.setAttribute("professores", professores);

		RequestDispatcher rd = request
				.getRequestDispatcher("turmaAlocacaoProfessor.jsp");
		try {
			rd.forward(request, response);
		} catch (ServletException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
