package com.ejie.ad74a.webservices.toolkitWS;

import javax.jws.HandlerChain;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;

import com.ejie.ad74a.service.toolkit.ToolkitService;

@WebService(name = "ToolkitWebService", serviceName = "ToolkitWebService", targetNamespace = "http://com.ejie.ad74a.webservice")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
@HandlerChain(file = "server-handlers.xml")

public class ToolkitWebServiceImpl extends SpringBeanAutowiringSupport implements ToolkitWebService {

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

	@Autowired()
	private ToolkitService toolkitService;

	@Override
	public String existeBeneficiarioAlta(@WebParam(name = "dni", mode = WebParam.Mode.IN) String dni) throws Exception {
		ToolkitWebServiceImpl.logger.debug("ToolkitWebServiceImpl - existeBeneficiarioAlta - dni: " + dni);
		return toolkitService.existeBeneficiarioAlta(dni);
	}

	@Override
	public String getIRPFYear() throws Exception {
		ToolkitWebServiceImpl.logger.debug("ToolkitWebServiceImpl - getIRPFYear - Inicio: ");
		return toolkitService.getIRPFYear();
	}

	@Override
	public String getMotivosBaja() throws Exception {
		ToolkitWebServiceImpl.logger.debug("ToolkitWebServiceImpl - getMotivosBaja");
		return toolkitService.getMotivosBaja();
	}

	@Override
	public String getFechaSistema(@WebParam(name = "pattern", mode = WebParam.Mode.IN) String pattern)
			throws Exception {
		ToolkitWebServiceImpl.logger.debug("ToolkitWebServiceImpl - getFechaSistema - pattern: {} ", pattern);
		return toolkitService.getFechaSistema(pattern);
	}

	@Override
	public String getDatoDireccion(@WebParam(name = "documento", mode = WebParam.Mode.IN) String documento,
			@WebParam(name = "campo", mode = WebParam.Mode.IN) String campo) throws Exception {
		ToolkitWebServiceImpl.logger.debug("ToolkitWebServiceImpl - getDatoDireccion - documento: {} - campo: {}",
				documento, campo);
		return toolkitService.getDatoDireccion(documento, campo);
	}
}
