/*
 * Preferences.java, 3 juin 2006
 * 
 * This file is part of FilmZ.
 *
 * Copyright © 2006 Johan Cwiklinski
 *
 * File :               Preferences.java
 * Author's email :     johan@x-tnd.be
 * Author's Website :   http://www.x-tnd.be/
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 */

package be.xtnd.films;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import be.xtnd.commons.db.Database;
import be.xtnd.gui.FilmzMain;

/**
 * 
 * @author Johan Cwiklinski
 *
 */
public class Preferences {
	private Database db = FilmzMain.db;
	private String covers_path;
	private String plugins_path;
	private Integer default_collection;
	//private boolean restrict = true;
	private String web_default;
	static Logger logger = Logger.getLogger(Preferences.class.getName());
	/** */
	public static final String TABLE = "preferences";

	/**
	 * 
	 *
	 */
	public Preferences(){
		PropertyConfigurator.configure(ClassLoader.getSystemResource("be/xtnd/films/log4j.properties"));
		String requete = "SELECT * FROM "+TABLE;
		try {
			ResultSet rs = db.execQuery(requete);
			rs.first();
			this.covers_path = rs.getString("covers_path");
			this.default_collection = rs.getInt("default_collection");
			//this.restrict = rs.getBoolean("restrict");
			this.web_default = rs.getString("web_default");
			this.plugins_path = rs.getString("plugins_path");
		} catch (SQLException e) {
			logger.fatal("SQLException loading preferences "+e.getMessage() + " (code" + e.getErrorCode() + ")");
			e.printStackTrace();
		}
	}

	/**
	 * @return Renvoie covers_path.
	 */
	public String getCovers_path() {
		return covers_path;
	}

	/**
	 * @param covers_path covers_path à définir.
	 */
	public void setCovers_path(String covers_path) {
		this.covers_path = covers_path;
	}

	/**
	 * @return Renvoie default_collection.
	 */
	public Integer getDefault_collection() {
		return default_collection;
	}

	/**
	 * @param default_collection default_collection à définir.
	 */
	public void setDefault_collection(Integer default_collection) {
		this.default_collection = default_collection;
	}

	/**
	 * @return Renvoie restrict.
	 */
	/*public boolean isRestrict() {
		return restrict;
	}*/

	/**
	 * @param restrict restrict à définir.
	 */
	/*public void setRestrict(boolean restrict) {
		this.restrict = restrict;
	}*/

	/**
	 * @return Renvoie web_default.
	 */
	public String getWeb_default() {
		return web_default;
	}

	/**
	 * @param web_default web_default à définir.
	 */
	public void setWeb_default(String web_default) {
		this.web_default = web_default;
	}

	/**
	 * @return Renvoie plugins_path.
	 */
	public String getPlugins_path() {
		return plugins_path;
	}

	/**
	 * @param plugins_path plugins_path à définir.
	 */
	public void setPlugins_path(String plugins_path) {
		this.plugins_path = plugins_path;
	}
}
