/* ----------------------------------------
 * Origin  : GFI INFORMATIQUE 
 * Project : CDPP Propagation Tool 
 * ----------------------------------------
 * History 
 * Version : 01/05/2015 : SCA : V2.1
 * Version : 15/09/2016 : SCA : V2.2 (PSWS-H2020)
 *  Set a default J-map image if not exists
 * ----------------------------------------
 */
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.IJMap;
import fr.tlse.irap.map.JMap;
import fr.tlse.irap.server.serviceDAO.IFitsDAO;
import fr.tlse.irap.spaceElement.Probe;

@WebService(endpointInterface = "fr.tlse.irap.map.IJMap")
public class JMapImpl implements IJMap {
	private static final Logger logger = Logger.getLogger(JMapImpl.class);
	
	private IFitsDAO fitsDAO;

	public JMapImpl() {
	}
	
	@WebMethod
	public JMap getJMap(Probe observer, String type, Date t1, Date t2) {
		logger.info("Start retrieving a jmap file ");
		JMap jMap = new JMap();
		try {
			jMap = fitsDAO.loadJMap(observer, type, t1, t2);
		} catch (Exception e) {
			return jMap;
		}
		logger.info("Stop retrieving a jmap file ");
		return jMap;
		
	}

	@WebMethod
	public JMap getDefaultJMap(Probe observer, String type, Date t1, Date t2) {
		JMap jMap = new JMap();//return null is not allowed
		try {
			jMap = fitsDAO.loadDefaultJMap(observer, type, t1, t2);
		} catch (Exception e) {
			return jMap;
		}
		logger.info("Stop getting a default jmap");
		return jMap;
	}

	public IFitsDAO getFitsDAO() {
		return fitsDAO;
	}

	public void setFitsDAO(IFitsDAO fitsDAO) {
		this.fitsDAO = fitsDAO;
	}

}
