/* ----------------------------------------
 * Origin  : GFI INFORMATIQUE 
 * Project : CDPP Propagation Tool 
 * ----------------------------------------
 * History 
 * Version : 12/12/2018 : SCA : V2.2.5
 * Version : 06/04/2023 : LBE : V2.7
 * DM-ID : redmine#8642 : 06/04/2023 : Added 3D shockwave
 * ----------------------------------------
 */
package fr.tlse.irap.server.frontServices;

import java.util.Date;

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

import fr.tlse.irap.server.serviceDAO.IAsciiDAO;
import fr.tlse.irap.shock.IShock;
import fr.tlse.irap.shock.ShockWrapper;
import fr.tlse.irap.shock.Shockwave3dEvent;
import fr.tlse.irap.shock.Shockwave3dEvents;
import org.apache.log4j.Logger;

@WebService(endpointInterface = "fr.tlse.irap.shock.IShock")
public class ShockImpl implements IShock {
    private static final Logger logger = Logger.getLogger(ShockImpl.class);

    private IAsciiDAO asciiDAO;

    public ShockImpl() {
    }

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

    public IAsciiDAO getAsciiDAO() {
        return asciiDAO;
    }

    @WebMethod
    public ShockWrapper fetchShocks(Date t1, Date t2) {
        ShockWrapper shockWrapper = null;
        try {
            shockWrapper = new ShockWrapper(asciiDAO.loadShocks(t1, t2));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return shockWrapper;
    }

	/**
	 * Fetch shockwaves event from catalog at date.
         * Call fetchShockwaves3dList before to know available list
	 */
    @WebMethod
    public Shockwave3dEvent fetchShockwave3d(Date pDate) {
        Shockwave3dEvent lEvents = new Shockwave3dEvent();
        try {
            //System.out.println("**************** calling ascii DAO load shockwaves****************");
            lEvents = asciiDAO.loadShockwave3d(pDate);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return lEvents;
    }
    
	/**
	 * Fetch list of shockwaves events
         * @return list of empty Shockwave3dEvent (only time is filled).
         */
	@WebMethod
	public Shockwave3dEvents fetchShockwaves3dList() {
		logger.info("fetchShocksList called");
		Shockwave3dEvents lEvents = new Shockwave3dEvents();
		try {
			lEvents = asciiDAO.loadShockwaves3dList();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return lEvents;
	}
    
    

}
