/* ----------------------------------------
 * Origin  : GFI INFORMATIQUE 
 * Project : CDPP Propagation Tool 
 * ----------------------------------------
 * History 
 * Version : 01/05/2015 : SCA : V2.1
 * Version : 06/11/2017 : SCA : V2.2.1 
 *  Redmine #5403 - DMPT3 : add CarringtonMapCatalog WS
 * Version : 30/11/2022 : LBE : V2.6
 * DM-ID : Redmine #l0481 : 30/11/2022 : HCS added
 * ----------------------------------------
 */
package fr.tlse.irap.server.frontServices;

import java.util.Date;

import javax.jws.WebMethod;
import javax.jws.WebService;

import org.apache.log4j.Logger;

import fr.tlse.irap.map.CarringtonMap;
import fr.tlse.irap.map.CarringtonMapCatalog;
import fr.tlse.irap.map.CarringtonMapType;
import fr.tlse.irap.map.HCSLine;
import fr.tlse.irap.map.ICarringtonMap;
import fr.tlse.irap.server.serviceDAO.IAsciiDAO;
import fr.tlse.irap.server.serviceDAO.IFitsDAO;

@WebService(endpointInterface = "fr.tlse.irap.map.ICarringtonMap")
public class CarringtonMapImpl implements ICarringtonMap {

	private static final Logger logger = Logger.getLogger(CarringtonMapImpl.class);

	private IFitsDAO fitsDAO;
	private IAsciiDAO asciiDAO;

	public CarringtonMapImpl() {
	}

	@WebMethod
	public CarringtonMap getCarringtonMap(Date time, CarringtonMapType cmType) {
		CarringtonMap carringtonMap = null;
		
		try {
			carringtonMap = fitsDAO.loadCarringtonMap(time, cmType);
			logger.info("getCarringtonMap is OK");
		} catch (Exception e) {
			logger.error("CarringtonMapImpl - getCarringtonMap:"+e.getStackTrace());
			e.printStackTrace();
			return carringtonMap;
		}
		return carringtonMap;
	}

	@WebMethod
	public CarringtonMapCatalog getCarringtonMapCatalog() {
		CarringtonMapCatalog CarringtonMapCatalog = null;
		
		try {
			CarringtonMapCatalog = new CarringtonMapCatalog(asciiDAO.loadCarringtonMapTypes());
			logger.info("getCarringtonMapCatalog is OK");
		} catch (Exception e) {
			logger.error("CarringtonMapImpl - getCarringtonMapCatalog:"+e.getStackTrace());
			e.printStackTrace();
			return CarringtonMapCatalog;
		}
		return CarringtonMapCatalog;
	}

	@WebMethod
	public HCSLine getHCSLine(Date time) {
		HCSLine lHcs = null;
		
		try {
			lHcs = asciiDAO.loadHCSLine(time);
			logger.debug("getHCS line is OK");
		} catch (Exception e) {
			logger.error("CarringtonMapImpl - getHCSLine:"+e.getStackTrace());
			e.printStackTrace();
		}
		return lHcs;
	}
        
        
	public IFitsDAO getFitsDAO() {
		return fitsDAO;
	}
	public void setFitsDAO(IFitsDAO fitsDAO) {
		this.fitsDAO = fitsDAO;
	}
	public IAsciiDAO getAsciiDAO() {
		return asciiDAO;
	}
	public void setAsciiDAO(IAsciiDAO asciiDAO) {
		this.asciiDAO = asciiDAO;
	}

}
