package com.ejie.ad74a.validacion;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.stereotype.Component;

import com.ejie.ad74a.exceptions.Ad74aException;
import com.ejie.ad74a.exceptions.ErrorField;
import com.ejie.ad74a.exceptions.Mensaje;
import com.ejie.ad74a.exceptions.ParametroKey;
import com.ejie.ad74a.model.Avisos;
import com.ejie.ad74a.model.Ayuntamientos;
import com.ejie.ad74a.model.Iprem;
import com.ejie.ad74a.service.AvisosService;
import com.ejie.ad74a.service.IpremService;
import com.ejie.ad74a.util.comun.UtilLiterales;
import com.ejie.ad74a.util.comun.UtilValidaciones;
import com.ejie.ad74a.util.comun.Utilidades;
import com.ejie.ad74a.util.constantes.Constantes;
import com.ejie.ad74a.util.constantes.FormaPagoEnum;

@Component(value = "AvisosValidator")
public class AvisosValidator {
	private static final Logger LOGGER = LoggerFactory.getLogger(AvisosValidator.class);

	private static final String LABEL_ID_LLAMADA_INCORRECTO = "avisos.error.identificadorLlamada";
	private static final String LABEL_ORIGEN_DESTINO_IGUALES = "avisos.error.origenDestinoIguales";

	private static final String LABEL_IDENTIFICADORLLAMADA = "avisos.error.identifLlamada";
	private static final String LABEL_ORIGENDESTINO = "avisos.error.origenYDestino";

	@Resource
	private ReloadableResourceBundleMessageSource appMessageSource;

	@Autowired
	private AvisosService avisosService;

	public void validate(List<ErrorField> errorFields, Avisos avisos) {
		AvisosValidator.LOGGER.info("ipremValidator: validate ");
//

		if (avisos != null && avisos.getAvisosBajaBenef() != null && avisos.getAvisosBajaBenef().getIdLlamada() != null
				&& avisos.getAvisosBajaBenef().getIdLlamada().equals("0")) {
			errorFields.add(new ErrorField(AvisosValidator.LABEL_ID_LLAMADA_INCORRECTO,
					AvisosValidator.LABEL_IDENTIFICADORLLAMADA));
		}

		if (avisos != null && avisos.getMaestroActoresByDestino20().getIdActor42()
				.equals(avisos.getMaestroActoresByOrigen20().getIdActor42())) {
			errorFields.add(
					new ErrorField(AvisosValidator.LABEL_ORIGEN_DESTINO_IGUALES, AvisosValidator.LABEL_ORIGENDESTINO));
		}

	}
}
