package org.pmdreports.manager;

import java.util.ArrayList;
import java.util.List;

import org.pmdreports.dao.RulesetDAO;
import org.pmdreports.model.Ruleset;
import org.pmdreports.report.CodeSizeSnapshotGraph;
import org.pmdreports.report.ComponentComparisonReport;
import org.pmdreports.report.ComponentHistoryReport;
import org.pmdreports.report.ComponentTrendGraphCumulative;
import org.pmdreports.report.ComponentTrendGraphNonCumulative;
import org.pmdreports.report.ProjectTrendGraphCumulative;
import org.pmdreports.report.ProjectTrendGraphNonCumulative;
import org.pmdreports.report.ProjectTrendGraphPerLine;
import org.pmdreports.report.Report;

/**
 * API to generate reports.
 * 
 * @author Ben Northrop Sep 25, 2007
 */
public class ReportManager {

	// DATA MEMBERS
	private final List<Report> reports = new ArrayList<Report>();

	// CONSTRUCTOR
	/**
	 * Default constructor.
	 */
	public ReportManager() {
		ConfigManager configManager = ConfigManager.getInstance();
		RulesetDAO rulesetDAO = new RulesetDAO(configManager.getRulesetsFile());

		List<Ruleset> rulesets = rulesetDAO.retrieveRulesets();
		reports.add(new ProjectTrendGraphCumulative());
		reports.add(new ProjectTrendGraphNonCumulative());
		reports.add(new ProjectTrendGraphPerLine());
		reports.add(new ComponentComparisonReport(rulesets));
		reports.add(new CodeSizeSnapshotGraph());
		reports.add(new ComponentTrendGraphCumulative());
		reports.add(new ComponentTrendGraphNonCumulative());
		reports.add(new ComponentHistoryReport(rulesets));
	}

	/**
	 * Generate all reports.
	 */
	public void generateReports() {
		for (Report report : reports) {
			report.generate(reports);
		}
	}
}
