<commit_before>package edu.iastate.music.marching.attendance.servlets;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import java.util.logging.Logger;

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

import com.google.appengine.api.datastore.Email;

import edu.iastate.music.marching.attendance.model.interact.AbsenceManager;
import edu.iastate.music.marching.attendance.model.interact.AppDataManager;
import edu.iastate.music.marching.attendance.model.interact.DataTrain;
import edu.iastate.music.marching.attendance.model.interact.EventManager;
import edu.iastate.music.marching.attendance.model.interact.FormManager;
import edu.iastate.music.marching.attendance.model.interact.UserManager;
import edu.iastate.music.marching.attendance.model.store.Absence;
import edu.iastate.music.marching.attendance.model.store.AppData;
import edu.iastate.music.marching.attendance.model.store.Event;
import edu.iastate.music.marching.attendance.model.store.ModelFactory;
import edu.iastate.music.marching.attendance.model.store.User;
import edu.iastate.music.marching.attendance.model.store.User.Section;
import edu.iastate.music.marching.attendance.util.GradeExport;
import edu.iastate.music.marching.attendance.util.PageBuilder;
import edu.iastate.music.marching.attendance.util.Util;
import edu.iastate.music.marching.attendance.util.ValidationExceptions;
import edu.iastate.music.marching.attendance.util.ValidationUtil;

public class DirectorServlet extends AbstractBaseServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6100206975846317440L;

	private static final Logger LOG = Logger.getLogger(DirectorServlet.class
			.getName());

	public enum Page {
		index, appinfo, attendance, export, forms, unanchored, users, user, info, viewabsence, student, makeevent, deletestudent, studentinfo, viewevent, deleteevent, postdelete;
	}

	private static final String SERVLET_PATH = "director";

	public static final String INDEX_URL = pageToUrl(
			DirectorServlet.Page.index, SERVLET_PATH);

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		if (!isLoggedIn(req, resp)) {
			resp.sendRedirect(AuthServlet.getLoginUrl(req));
			return;
		} else if (!isLoggedIn(req, resp, User.Type.Director)) {
			resp.sendRedirect(ErrorServlet.getLoginFailedUrl(req));
			return;
		}

		Page page = parsePathInfo(req.getPathInfo(), Page.class);

		if (page == null)
			ErrorServlet.showError(req, resp, 404);
		else
			switch (page) {
			case index:
				showIndex(req, resp);
				break;
			case viewabsence:
				viewAbsence(req, resp, new ArrayList<String>(), "");
				break;
			case attendance:
				showAttendance(req, resp, null, null);
				break;
			case appinfo:
				showAppInfo(req, resp, new ArrayList<String>(), null);
				break;
			case unanchored:
				showUnanchored(req, resp, null, null);
				break;
			case users:
				showUsers(req, resp);
				break;
			case user:
				showUserInfo(req, resp);
				break;
			case info:
				showInfo(req, resp, new ArrayList<String>(), null);
				break;
			case student:
				showStudent(req, resp, new ArrayList<String>(), "");
				break;
			case makeevent:
				showMakeEvent(req, resp);
				break;
			case viewevent:
				viewEvent(req, resp);
				break;
			case export:
				showGradeExport(req, resp);
			default:
				ErrorServlet.showError(req, resp, 404);
			}
	}

	private void viewEvent(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		DataTrain train = DataTrain.getAndStartTrain();
		String sid = req.getParameter("id");

		List<String> errors = new ArrayList<String>();
		PageBuilder page = new PageBuilder(Page.viewevent, SERVLET_PATH);
		if (sid != null && !sid.equals("")) {
			try {
				Event event = train.getEventManager().get(Long.parseLong(sid));
				page.setAttribute("event", event);
				AbsenceManager ac = train.getAbsenceManager();
				List<Absence> absences = ac.getAll(event);
				int absent = 0;
				int tardy = 0;
				int earlyout = 0;
				for (Absence a : absences) {
					switch (a.getType()) {
					case Absence:
						absent++;<commit_msg>Bug fix, director export page was missing a break in the routing table<commit_after>package edu.iastate.music.marching.attendance.servlets;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import java.util.logging.Logger;

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

import com.google.appengine.api.datastore.Email;

import edu.iastate.music.marching.attendance.model.interact.AbsenceManager;
import edu.iastate.music.marching.attendance.model.interact.AppDataManager;
import edu.iastate.music.marching.attendance.model.interact.DataTrain;
import edu.iastate.music.marching.attendance.model.interact.EventManager;
import edu.iastate.music.marching.attendance.model.interact.FormManager;
import edu.iastate.music.marching.attendance.model.interact.UserManager;
import edu.iastate.music.marching.attendance.model.store.Absence;
import edu.iastate.music.marching.attendance.model.store.AppData;
import edu.iastate.music.marching.attendance.model.store.Event;
import edu.iastate.music.marching.attendance.model.store.ModelFactory;
import edu.iastate.music.marching.attendance.model.store.User;
import edu.iastate.music.marching.attendance.model.store.User.Section;
import edu.iastate.music.marching.attendance.util.GradeExport;
import edu.iastate.music.marching.attendance.util.PageBuilder;
import edu.iastate.music.marching.attendance.util.Util;
import edu.iastate.music.marching.attendance.util.ValidationExceptions;
import edu.iastate.music.marching.attendance.util.ValidationUtil;

public class DirectorServlet extends AbstractBaseServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6100206975846317440L;

	private static final Logger LOG = Logger.getLogger(DirectorServlet.class
			.getName());

	public enum Page {
		index, appinfo, attendance, export, forms, unanchored, users, user, info, viewabsence, student, makeevent, deletestudent, studentinfo, viewevent, deleteevent, postdelete;
	}

	private static final String SERVLET_PATH = "director";

	public static final String INDEX_URL = pageToUrl(
			DirectorServlet.Page.index, SERVLET_PATH);

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		if (!isLoggedIn(req, resp)) {
			resp.sendRedirect(AuthServlet.getLoginUrl(req));
			return;
		} else if (!isLoggedIn(req, resp, User.Type.Director)) {
			resp.sendRedirect(ErrorServlet.getLoginFailedUrl(req));
			return;
		}

		Page page = parsePathInfo(req.getPathInfo(), Page.class);

		if (page == null)
			ErrorServlet.showError(req, resp, 404);
		else
			switch (page) {
			case index:
				showIndex(req, resp);
				break;
			case viewabsence:
				viewAbsence(req, resp, new ArrayList<String>(), "");
				break;
			case attendance:
				showAttendance(req, resp, null, null);
				break;
			case appinfo:
				showAppInfo(req, resp, new ArrayList<String>(), null);
				break;
			case unanchored:
				showUnanchored(req, resp, null, null);
				break;
			case users:
				showUsers(req, resp);
				break;
			case user:
				showUserInfo(req, resp);
				break;
			case info:
				showInfo(req, resp, new ArrayList<String>(), null);
				break;
			case student:
				showStudent(req, resp, new ArrayList<String>(), "");
				break;
			case makeevent:
				showMakeEvent(req, resp);
				break;
			case viewevent:
				viewEvent(req, resp);
				break;
			case export:
				showGradeExport(req, resp);
				break;
			default:
				ErrorServlet.showError(req, resp, 404);
			}
	}

	private void viewEvent(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		DataTrain train = DataTrain.getAndStartTrain();
		String sid = req.getParameter("id");

		List<String> errors = new ArrayList<String>();
		PageBuilder page = new PageBuilder(Page.viewevent, SERVLET_PATH);
		if (sid != null && !sid.equals("")) {
			try {
				Event event = train.getEventManager().get(Long.parseLong(sid));
				page.setAttribute("event", event);
				AbsenceManager ac = train.getAbsenceManager();
				List<Absence> absences = ac.getAll(event);
				int absent = 0;
				int tardy = 0;
				int earlyout = 0;
				for (Absence a : absences) {
					switch (a.getType()) {
					case Absence:
						absent++;
{'fraction_non_alphanumeric': 0.11429813124728379, 'fraction_numerical': 0.006084311169056932, 'mean_word_length': 4.647239263803681, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7323556', 'n_tokens_mistral': 3437, 'n_tokens_neox': 2945, 'n_words': 608}