/**
 * Dates 15.01.2013
 *
 * @author Philipp Haussleiter
 *
 */
package controllers;

import java.util.Calendar;
import java.util.List;
import models.DataDate;

public class Dates extends SecureApplication {

    public static void show(Integer year) {
    		int currentYear = Calendar.getInstance().get(Calendar.YEAR);
    		if (year == null) {
            year = currentYear;
        }
        List<DataDate> dates = DataDate.find("year = ? order by fullDate desc", year).fetch();
        int start = currentYear;
        int end = DataDate.getLastYear();
        render(dates, year, start, end);
    }

    public static void cleanAll() {
        DataDate.cleanAll();
        int currentYear = Calendar.getInstance().get(Calendar.YEAR);
        show(currentYear);
    }
    
	public static void cleanYear(Integer year) {
		if (year != null) {
			DataDate.cleanYear(year);
		}
		int currentYear = Calendar.getInstance().get(Calendar.YEAR);
		show(currentYear);
	}
}
