/*
 * Copyright
 *   2007 axYus - www.axyus.com
 *  2010 C.Marchand - christophe.marchand@axyus.com
 *
 * This file is part of XEMELIOS.
 *
 * XEMELIOS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * XEMELIOS 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with XEMELIOS; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package fr.gouv.finances.dgfip.xemelios.refCollecSpl.importer;

import fr.gouv.finances.dgfip.xemelios.data.impl.pool.PoolManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import org.apache.log4j.Logger;

/**
 *
 * @author cmarchand
 */
public class ArchiveRequester {
    private static final Logger logger = Logger.getLogger(ArchiveRequester.class);

    public static String getPresenceArchive(String annee, String collectivite) {
        String ret = "Non";
        Connection con = null;
        try {
            con = PoolManager.getInstance().getConnection();
            PreparedStatement ps = con.prepareStatement("SELECT 1 FROM CG_ACCUEIL_IX WHERE COLLECTIVITE=? AND EXERCICE=?");
            ps.setString(1,collectivite);
            ps.setString(2,annee);
            ResultSet rs = ps.executeQuery();
            if(rs.next()) ret = "Oui";
            rs.close();
            ps.close();
        } catch(Exception ex) {
            logger.error("getPresenceArchive("+annee+","+collectivite+")",ex);
        } finally {
            if(con!=null) PoolManager.getInstance().releaseConnection(con);
        }
        return ret;
    }

}
