package commands;

import java.io.IOException;

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

import dao.FacadeDAO;

public class TurmaRemover extends AbstractCommand {

	/*
	 * (não-Javadoc)
	 * 
	 * @seecomandos.AbstractCommand#processarComando(javax.servlet.http.
	 * HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	public void processarComando(HttpServletRequest request,
			HttpServletResponse response, HttpServlet servlet) {
		// TODO Stub de método gerado automaticamente
		String idParam = request.getParameter("id");
		long id = Long.parseLong(idParam);

		String msg = FacadeDAO.getInstance(servlet).getTurmaDAO().removerTurma(
				id);

		request.setAttribute("mensagem", msg);

		RequestDispatcher rd = request
				.getRequestDispatcher("Command?comando=TurmaPrepararRemocao");

		try {
			rd.forward(request, response);
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
