/* ----------------------------------------
 * Origin  : GFI INFORMATIQUE 
 * Project : CDPP Propagation Tool 
 * ----------------------------------------
 * History 
 * Version : 01/05/2015 : SCA : V2.1
 * ----------------------------------------
 */
package fr.tlse.irap.server.frontServices;

import java.util.Date;

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

import fr.tlse.irap.flare.FlareFluxWrapper;
import fr.tlse.irap.flare.FlareWrapper;
import fr.tlse.irap.flare.IFlare;
import fr.tlse.irap.server.serviceDAO.IAsciiDAO;
import fr.tlse.irap.tool.radial.CMEType;

@WebService(endpointInterface = "fr.tlse.irap.flare.IFlare")
public class FlareImpl implements IFlare {

	private IAsciiDAO asciiDAO;

	public FlareImpl(){
	}

	public void setAsciiDAO(IAsciiDAO asciiDAO) {
		this.asciiDAO = asciiDAO;
	}
	public IAsciiDAO getAsciiDAO() {
		return asciiDAO;
	}

	@WebMethod
	public FlareWrapper fetchFlares(Date t1, Date t2) {
		FlareWrapper flareWrapper = null;
		try {
			flareWrapper = new FlareWrapper(asciiDAO.loadFlares(t1, t2));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flareWrapper;
	}

	@WebMethod
	public FlareWrapper fetchLinkcatFlares(Date t1, Date t2, CMEType cmeType, String observatory) {
		FlareWrapper flareWrapper = null;
		try {
			flareWrapper = new FlareWrapper(asciiDAO.loadLinkcatFlares(t1, t2, cmeType, observatory));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flareWrapper;
	}

	@Override
	public FlareFluxWrapper getFlux(String fluxType, String measure, Date t1, Date t2) {
		FlareFluxWrapper flareFluxWrapper = null;
		try {
			flareFluxWrapper = new FlareFluxWrapper(asciiDAO.loadFlareFlux(t1, t2, fluxType, measure));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flareFluxWrapper;
	}

}
