package com.ejie.m62fb.control;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.ejie.m62fb.model.tipos.P28Tipos;
import com.ejie.m62fb.utils.bean.BeanUtils;
import com.ejie.t17i.model.Pais;
import com.ejie.t17i.service.PaisService;

/**
 * DireccionesController generated by UDA, 14-nov-2014 11:14:18.
 * 
XXXX
 */

@Controller
@RequestMapping(value = "/pruebas")
public class PruebasController {

	private static final Logger LOGGER = LoggerFactory
			.getLogger(PruebasController.class);


	@Autowired
	private ComboController comboController;
	@Autowired
	private PaisService paisService;
	/*
	 * METODOS COMPONENTE RUP_TABLE
	 */

	/**
	 * Metodo de presentacion del RUP_TABLE.
	 * 
	 * @param model
	 *            Model
	 * @return String
	 */
	@RequestMapping(method = RequestMethod.GET)
	public String getFormEdit(Model model) {
		PruebasController.LOGGER.info("[GET - View] : pruebas");
		this.precargarCombosFiltro(model);
		return "pruebas";
	}

	/**
	 * Funcion encargada de precargar los combos para el filtro
	 * 
	 * @param model
	 *            Model
	 */
	private void precargarCombosFiltro(Model model) {
		// Estado Civil
		model.addAttribute("comboEstadoCivil", P28Tipos
				.serializeComboP28(this.comboController.getComboP28(P28Tipos.ESTADO_CIVIL)));
		// Sexo
		model.addAttribute("comboSexo", P28Tipos
				.serializeComboP28(this.comboController.getComboP28(P28Tipos.SEXO)));
		// NACIONALIDAD
		model.addAttribute("comboNacionalidad", BeanUtils.serialize(paisService.findAll(new Pais(), null), "nombre", "id"));
	}
}
