package org.yacos.web.chairman.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.yacos.core.conferences.Conference;
import org.yacos.core.conferences.IConferenceManager;
import org.yacos.core.evaluation.Criterion;
import org.yacos.core.evaluation.IEvaluationManager;
import org.yacos.core.users.IUserManager;
import org.yacos.core.users.User;
import org.yacos.core.users.Role.RoleType;
import org.yacos.web.system.session.SessionService;

public class ReportConfCreateController implements Controller {
	
	private IConferenceManager conferenceManager;

	private IUserManager userManager;

	private IEvaluationManager evaluationManager;

	public IEvaluationManager getEvaluationManager() {
		return evaluationManager;
	}
	public void setEvaluationManager(IEvaluationManager evaluationManager) {
		this.evaluationManager = evaluationManager;
	}
	public IUserManager getUserManager() {
		return userManager;
	}
	public void setUserManager(IUserManager userManager) {
		this.userManager = userManager;
	}
	public IConferenceManager getConferenceManager() {
		return conferenceManager;
	}
	public void setConferenceManager(IConferenceManager conferenceManager) {
		this.conferenceManager = conferenceManager;
	}

	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		Conference conf = SessionService.getInstance().getCurrentConference();
		List<Criterion> listCriterionForConf = evaluationManager.getCriterions(conf.getId());
		List<User> listUsersForConf = userManager.getUsers(conf.getId(), RoleType.PCMEMBER);
		
		Map<String, Object> model = new HashMap<String, Object>();
		model.put("conferenceReport", conf);
		model.put("criterionReport", listCriterionForConf);
		model.put("userReport", listUsersForConf);
		
		return new ModelAndView("reportConfCreate", model);
	}

}
