// Path: module-alfresco/source/java/com/atolcd/alfresco/audit/cmr/AuditQueriesService.java
// public interface AuditQueriesService {
// 
// 	public Map<Date, Integer> countConnections(final Calendar[] calendars, String period);
// 
// 	public Map<Date, Integer> countCreateUsers(final Calendar[] calendars, String period);
// 
// 	public Map<Date, Integer> countCreateDocs(final Calendar[] calendars, String period);
// 
// 	public Map<Date, Integer> countReadDocs(final Calendar[] calendars, String period);
// 
// 	public Map<Date, Integer> countCheckins(final Calendar[] calendars, String period);
// 
// 	public Map<Date, Integer> countWorkflows(final Calendar[] calendars, String period);
// 
// 	public List<Object[]> topRead();
// 
// 	public List<Object[]> topModif();
// 
// 	public List<Map<String, Object>> lastDocs();
// 
// 	public List<Map<String, Object>> lastModif();
// 
// 	public List<Map<String, Object>> lastUsers();
// 
// 	public List<Map<String, Object>> usersNeverLog();
// 
// 	public List<Object[]> getConnectionLogs(String method, Calendar start, Calendar end, boolean noAdmin, int maxdisplay);
// }
// 
// Path: module-alfresco/source/java/com/atolcd/alfresco/audit/cmr/EnumFonctionnalite.java
// public enum EnumFonctionnalite {
// 	createddocs, modifieddocs, readdocs, conn, createduser, createdwork;
// }


import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.util.Assert;
import com.atolcd.alfresco.audit.cmr.AuditQueriesService;
import com.atolcd.alfresco.audit.cmr.EnumFonctionnalite;

		String start_date = req.getParameter("start");
		String end_date = req.getParameter("stop");

		// Map that will be passed to the template
		Map<String, Object> model = new HashMap<String, Object>();

		Map<String, String> params = new HashMap<String, String>();
		params.put("createddocs", req.getParameter("createddocs"));
		params.put("modifieddocs", req.getParameter("modifieddocs"));
		params.put("readdocs", req.getParameter("readdocs"));
		params.put("conn", req.getParameter("conn"));
		params.put("createduser", req.getParameter("createduser"));
		params.put("createdwork", req.getParameter("createdwork"));

		if (testParameters(start_date, end_date)) { // test parameters
			List<String> parameters = analyzeParameters(params);
			buildTree(parameters, model);
		}

		return model;

	}

	private void buildTree(List<String> parameters, Map<String, Object> model) {

		List<Functionality> functionalities = new ArrayList<Functionality>();

		for (int i = 0; i < parameters.size(); i++) {
			SortedMap<Date, Integer> resQuery = new TreeMap<Date, Integer>();


// Path: module-alfresco/source/java/com/atolcd/alfresco/audit/cmr/AuditQueriesService.java
// public interface AuditQueriesService {
// 
// 	public Map<Date, Integer> countConnections(final Calendar[] calendars, String period);
// 
// 	public Map<Date, Integer> countCreateUsers(final Calendar[] calendars, String period);
// 
// 	public Map<Date, Integer> countCreateDocs(final Calendar[] calendars, String period);
// 
// 	public Map<Date, Integer> countReadDocs(final Calendar[] calendars, String period);
// 
// 	public Map<Date, Integer> countCheckins(final Calendar[] calendars, String period);
// 
// 	public Map<Date, Integer> countWorkflows(final Calendar[] calendars, String period);
// 
// 	public List<Object[]> topRead();
// 
// 	public List<Object[]> topModif();
// 
// 	public List<Map<String, Object>> lastDocs();
// 
// 	public List<Map<String, Object>> lastModif();
// 
// 	public List<Map<String, Object>> lastUsers();
// 
// 	public List<Map<String, Object>> usersNeverLog();
// 
// 	public List<Object[]> getConnectionLogs(String method, Calendar start, Calendar end, boolean noAdmin, int maxdisplay);
// }
// 
// Path: module-alfresco/source/java/com/atolcd/alfresco/audit/cmr/EnumFonctionnalite.java
// public enum EnumFonctionnalite {
// 	createddocs, modifieddocs, readdocs, conn, createduser, createdwork;
// }


// Path: module-alfresco/source/java/com/atolcd/alfresco/audit/web/scripts/ExportGet.java
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.util.Assert;
import com.atolcd.alfresco.audit.cmr.AuditQueriesService;
import com.atolcd.alfresco.audit.cmr.EnumFonctionnalite;

		String start_date = req.getParameter("start");
		String end_date = req.getParameter("stop");

		// Map that will be passed to the template
		Map<String, Object> model = new HashMap<String, Object>();

		Map<String, String> params = new HashMap<String, String>();
		params.put("createddocs", req.getParameter("createddocs"));
		params.put("modifieddocs", req.getParameter("modifieddocs"));
		params.put("readdocs", req.getParameter("readdocs"));
		params.put("conn", req.getParameter("conn"));
		params.put("createduser", req.getParameter("createduser"));
		params.put("createdwork", req.getParameter("createdwork"));

		if (testParameters(start_date, end_date)) { // test parameters
			List<String> parameters = analyzeParameters(params);
			buildTree(parameters, model);
		}

		return model;

	}

	private void buildTree(List<String> parameters, Map<String, Object> model) {

		List<Functionality> functionalities = new ArrayList<Functionality>();

		for (int i = 0; i < parameters.size(); i++) {
			SortedMap<Date, Integer> resQuery = new TreeMap<Date, Integer>();


			switch (EnumFonctionnalite.valueOf(parameters.get(i))) {
