package com.ejie.m62fb.control;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import com.ejie.m62fb.model.M62fbp20s0s00;
import com.ejie.m62fb.service.M62fbp20s0s00Service;
import com.ejie.x38.control.exception.ResourceNotFoundException;
import com.ejie.x38.dto.JQGridJSONModel;
import com.ejie.x38.dto.Pagination;
import com.ejie.x38.util.ObjectConversionManager;

/**
 * M62fbp20s0s00Controller generated by UDA, 06-nov-2012 10:00:27.
 * 
XXXX
 */

@Controller
@RequestMapping(value = "/m62fbp20s0s00")
public class M62fbp20s0s00Controller {

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

	@Autowired
	private M62fbp20s0s00Service m62fbp20s0s00Service;

	/**
	 * Method 'getCreateForm'.
	 * 
	 * @param model
	 *            Model
	 * @return String
	 */
	@RequestMapping(value = "maint", method = RequestMethod.GET)
	public String getCreateForm(Model model) {
		M62fbp20s0s00Controller.logger.info("[GET - View] : m62fbp20s0s00");
		return "m62fbp20s0s00";
	}

	/**
	 * Method 'getById'.
	 * 
	 * @param nifTitular
	 *            String
	 * @param numCorrelNif
	 *            Long
	 * @param codTipoClave
	 *            String
	 * @param itipiden
	 *            Integer
	 * @param nomApellido1
	 *            String
	 * @param nomApellido2
	 *            String
	 * @param nomNombre
	 *            String
	 * @param fecNacimiento
	 *            Date
	 * @param indSexo
	 *            String
	 * @param isexo
	 *            Integer
	 * @param indEstadoCivil
	 *            String
	 * @param iestcivi
	 *            Integer
	 * @param cpais
	 *            Long
	 * @param dpais
	 *            String
	 * @param cterrito
	 *            Long
	 * @param codProvincia
	 *            String
	 * @param dterrito
	 *            String
	 * @param cmunicip
	 *            Integer
	 * @param codMunicipio
	 *            String
	 * @param dmunicip
	 *            String
	 * @param ddirecci
	 *            String
	 * @param email
	 *            String
	 * @param ntelefno
	 *            Integer
	 * @param numTlfno2
	 *            Integer
	 * @param codCalle
	 *            String
	 * @param codPortal
	 *            String
	 * @param decSitViv
	 *            String
	 * @param decMano
	 *            String
	 * @param codPostal
	 *            String
	 * @param numCodPostal
	 *            Integer
	 * @param fecAlta
	 *            Date
	 * @param dirIpUsuario
	 *            String
	 * @param fehUltModif
	 *            Date
	 * @param codUsuUltModif
	 *            String
	 * @param ideRegistro
	 *            Integer
	 * @param codAplicacion
	 *            String
	 * @param idPersona
	 *            Integer
	 * @param desCalle
	 *            String
	 * @return m62fbp20s0s00 M62fbp20s0s00
	 */
	@RequestMapping(value = "/{nifTitular}/{numCorrelNif}/{codTipoClave}/{itipiden}/{nomApellido1}/{nomApellido2}/{nomNombre}/{fecNacimiento}/{indSexo}/{isexo}/{indEstadoCivil}/{iestcivi}/{cpais}/{dpais}/{cterrito}/{codProvincia}/{dterrito}/{cmunicip}/{codMunicipio}/{dmunicip}/{ddirecci}/{email}/{ntelefno}/{numTlfno2}/{codCalle}/{codPortal}/{decSitViv}/{decMano}/{codPostal}/{numCodPostal}/{fecAlta}/{dirIpUsuario}/{fehUltModif}/{codUsuUltModif}/{ideRegistro}/{codAplicacion}/{idPersona}/{desCalle}", method = RequestMethod.GET)
	public @ResponseBody
	M62fbp20s0s00 getById(@PathVariable String nifTitular,
			@PathVariable Long numCorrelNif, @PathVariable String codTipoClave,
			@PathVariable Integer itipiden, @PathVariable String nomApellido1,
			@PathVariable String nomApellido2, @PathVariable String nomNombre,
			@PathVariable Date fecNacimiento, @PathVariable String indSexo,
			@PathVariable Integer isexo, @PathVariable String indEstadoCivil,
			@PathVariable Integer iestcivi, @PathVariable Long cpais,
			@PathVariable String dpais, @PathVariable Long cterrito,
			@PathVariable String codProvincia, @PathVariable String dterrito,
			@PathVariable Integer cmunicip, @PathVariable String codMunicipio,
			@PathVariable String dmunicip, @PathVariable String ddirecci,
			@PathVariable String email, @PathVariable Integer ntelefno,
			@PathVariable Integer numTlfno2, @PathVariable String codCalle,
			@PathVariable String codPortal, @PathVariable String decSitViv,
			@PathVariable String decMano, @PathVariable String codPostal,
			@PathVariable Integer numCodPostal, @PathVariable Date fecAlta,
			@PathVariable String dirIpUsuario, @PathVariable Date fehUltModif,
			@PathVariable String codUsuUltModif,
			@PathVariable Integer ideRegistro,
			@PathVariable String codAplicacion,
			@PathVariable Integer idPersona, @PathVariable String desCalle) {
		M62fbp20s0s00 m62fbp20s0s00 = new M62fbp20s0s00();
		m62fbp20s0s00.setNifTitular(nifTitular);
		m62fbp20s0s00.setNumCorrelNif(numCorrelNif);
		m62fbp20s0s00.setCodTipoClave(codTipoClave);
		m62fbp20s0s00.setItipiden(itipiden);
		m62fbp20s0s00.setNomApellido1(nomApellido1);
		m62fbp20s0s00.setNomApellido2(nomApellido2);
		m62fbp20s0s00.setNomNombre(nomNombre);
		m62fbp20s0s00.setFecNacimiento(fecNacimiento);
		m62fbp20s0s00.setIndSexo(indSexo);
		m62fbp20s0s00.setIsexo(isexo);
		m62fbp20s0s00.setIndEstadoCivil(indEstadoCivil);
		m62fbp20s0s00.setIestcivi(iestcivi);
		m62fbp20s0s00.setCpais(cpais);
		m62fbp20s0s00.setDpais(dpais);
		m62fbp20s0s00.setCterrito(cterrito);
		m62fbp20s0s00.setCodProvincia(codProvincia);
		m62fbp20s0s00.setDterrito(dterrito);
		m62fbp20s0s00.setCmunicip(cmunicip);
		m62fbp20s0s00.setCodMunicipio(codMunicipio);
		m62fbp20s0s00.setDmunicip(dmunicip);
		m62fbp20s0s00.setDdirecci(ddirecci);
		m62fbp20s0s00.setEmail(email);
		m62fbp20s0s00.setNtelefno(ntelefno);
		m62fbp20s0s00.setNumTlfno2(numTlfno2);
		m62fbp20s0s00.setCodCalle(codCalle);
		m62fbp20s0s00.setCodPortal(codPortal);
		m62fbp20s0s00.setDecSitViv(decSitViv);
		m62fbp20s0s00.setDecMano(decMano);
		m62fbp20s0s00.setCodPostal(codPostal);
		m62fbp20s0s00.setNumCodPostal(numCodPostal);
		m62fbp20s0s00.setFecAlta(fecAlta);
		m62fbp20s0s00.setDirIpUsuario(dirIpUsuario);
		m62fbp20s0s00.setFehUltModif(fehUltModif);
		m62fbp20s0s00.setCodUsuUltModif(codUsuUltModif);
		m62fbp20s0s00.setIdeRegistro(ideRegistro);
		m62fbp20s0s00.setCodAplicacion(codAplicacion);
		m62fbp20s0s00.setIdPersona(idPersona);
		m62fbp20s0s00.setDesCalle(desCalle);
		m62fbp20s0s00 = this.m62fbp20s0s00Service.find(m62fbp20s0s00);
		M62fbp20s0s00Controller.logger
				.info("[GET - findBy_PK] : Obtener M62fbp20s0s00 por PK");
		return m62fbp20s0s00;
	}

	/**
	 * Method 'getAll'.
	 * 
	 * @param filterM62fbp20s0s00
	 *            M62fbp20s0s00
	 * @return List
	 */
	@RequestMapping(method = RequestMethod.GET)
	public @ResponseBody
	List<M62fbp20s0s00> getAll(@ModelAttribute M62fbp20s0s00 filterM62fbp20s0s00) {
		M62fbp20s0s00Controller.logger
				.info("[GET - find_ALL] : Obtener M62fbp20s0s00 por filtro");
		return this.m62fbp20s0s00Service.findAll(filterM62fbp20s0s00, null);
	}

	/**
	 * Method 'findAllLike'.
	 * 
	 * @param filterVendor
	 *            Vendor
	 * @return List
	 */
	@RequestMapping(value = "findAllLike", method = RequestMethod.GET)
	public @ResponseBody
	List<M62fbp20s0s00> findAllLike(
			@RequestParam(value = "nifTitular", required = false) String nifTitular) {
		M62fbp20s0s00 persona = new M62fbp20s0s00();
		persona.setNifTitular(nifTitular);
		M62fbp20s0s00Controller.logger
				.info("[GET - find_ALL] : Obtener Persona por filtro");
		return this.m62fbp20s0s00Service.findAllLike(persona, null, false);
	}

	/**
	 * Method 'edit'.
	 * 
	 * @param m62fbp20s0s00
	 *            M62fbp20s0s00
	 * @return M62fbp20s0s00
	 */
	@RequestMapping(method = RequestMethod.PUT)
	public @ResponseBody
	M62fbp20s0s00 edit(@RequestBody M62fbp20s0s00 m62fbp20s0s00) {
		M62fbp20s0s00 m62fbp20s0s00Aux = this.m62fbp20s0s00Service
				.update(m62fbp20s0s00);
		M62fbp20s0s00Controller.logger
				.info("[PUT] : M62fbp20s0s00 actualizado correctamente");
		return m62fbp20s0s00Aux;
	}

	/**
	 * Method 'add'.
	 * 
	 * @param m62fbp20s0s00
	 *            M62fbp20s0s00
	 * @return M62fbp20s0s00
	 */
	@RequestMapping(method = RequestMethod.POST)
	public @ResponseBody
	M62fbp20s0s00 add(@RequestBody M62fbp20s0s00 m62fbp20s0s00) {
		M62fbp20s0s00 m62fbp20s0s00Aux = this.m62fbp20s0s00Service
				.add(m62fbp20s0s00);
		M62fbp20s0s00Controller.logger
				.info("[POST] : M62fbp20s0s00 insertado correctamente");
		return m62fbp20s0s00Aux;
	}

	/**
	 * Method 'remove'.
	 * 
	 * @param nifTitular
	 *            String
	 * @param numCorrelNif
	 *            Long
	 * @param codTipoClave
	 *            String
	 * @param itipiden
	 *            Integer
	 * @param nomApellido1
	 *            String
	 * @param nomApellido2
	 *            String
	 * @param nomNombre
	 *            String
	 * @param fecNacimiento
	 *            Date
	 * @param indSexo
	 *            String
	 * @param isexo
	 *            Integer
	 * @param indEstadoCivil
	 *            String
	 * @param iestcivi
	 *            Integer
	 * @param cpais
	 *            Long
	 * @param dpais
	 *            String
	 * @param cterrito
	 *            Long
	 * @param codProvincia
	 *            String
	 * @param dterrito
	 *            String
	 * @param cmunicip
	 *            Integer
	 * @param codMunicipio
	 *            String
	 * @param dmunicip
	 *            String
	 * @param ddirecci
	 *            String
	 * @param email
	 *            String
	 * @param ntelefno
	 *            Integer
	 * @param numTlfno2
	 *            Integer
	 * @param codCalle
	 *            String
	 * @param codPortal
	 *            String
	 * @param decSitViv
	 *            String
	 * @param decMano
	 *            String
	 * @param codPostal
	 *            String
	 * @param numCodPostal
	 *            Integer
	 * @param fecAlta
	 *            Date
	 * @param dirIpUsuario
	 *            String
	 * @param fehUltModif
	 *            Date
	 * @param codUsuUltModif
	 *            String
	 * @param ideRegistro
	 *            Integer
	 * @param codAplicacion
	 *            String
	 * @param idPersona
	 *            Integer
	 * @param desCalle
	 *            String
	 * @return m62fbp20s0s00
	 */
	@RequestMapping(value = "/{nifTitular}/{numCorrelNif}/{codTipoClave}/{itipiden}/{nomApellido1}/{nomApellido2}/{nomNombre}/{fecNacimiento}/{indSexo}/{isexo}/{indEstadoCivil}/{iestcivi}/{cpais}/{dpais}/{cterrito}/{codProvincia}/{dterrito}/{cmunicip}/{codMunicipio}/{dmunicip}/{ddirecci}/{email}/{ntelefno}/{numTlfno2}/{codCalle}/{codPortal}/{decSitViv}/{decMano}/{codPostal}/{numCodPostal}/{fecAlta}/{dirIpUsuario}/{fehUltModif}/{codUsuUltModif}/{ideRegistro}/{codAplicacion}/{idPersona}/{desCalle}", method = RequestMethod.DELETE)
	@ResponseStatus(value = HttpStatus.OK)
	public @ResponseBody
	M62fbp20s0s00 remove(@PathVariable String nifTitular,
			@PathVariable Long numCorrelNif, @PathVariable String codTipoClave,
			@PathVariable Integer itipiden, @PathVariable String nomApellido1,
			@PathVariable String nomApellido2, @PathVariable String nomNombre,
			@PathVariable Date fecNacimiento, @PathVariable String indSexo,
			@PathVariable Integer isexo, @PathVariable String indEstadoCivil,
			@PathVariable Integer iestcivi, @PathVariable Long cpais,
			@PathVariable String dpais, @PathVariable Long cterrito,
			@PathVariable String codProvincia, @PathVariable String dterrito,
			@PathVariable Integer cmunicip, @PathVariable String codMunicipio,
			@PathVariable String dmunicip, @PathVariable String ddirecci,
			@PathVariable String email, @PathVariable Integer ntelefno,
			@PathVariable Integer numTlfno2, @PathVariable String codCalle,
			@PathVariable String codPortal, @PathVariable String decSitViv,
			@PathVariable String decMano, @PathVariable String codPostal,
			@PathVariable Integer numCodPostal, @PathVariable Date fecAlta,
			@PathVariable String dirIpUsuario, @PathVariable Date fehUltModif,
			@PathVariable String codUsuUltModif,
			@PathVariable Integer ideRegistro,
			@PathVariable String codAplicacion,
			@PathVariable Integer idPersona, @PathVariable String desCalle) {
		M62fbp20s0s00 m62fbp20s0s00 = new M62fbp20s0s00();
		m62fbp20s0s00.setNifTitular(nifTitular);
		m62fbp20s0s00.setNumCorrelNif(numCorrelNif);
		m62fbp20s0s00.setCodTipoClave(codTipoClave);
		m62fbp20s0s00.setItipiden(itipiden);
		m62fbp20s0s00.setNomApellido1(nomApellido1);
		m62fbp20s0s00.setNomApellido2(nomApellido2);
		m62fbp20s0s00.setNomNombre(nomNombre);
		m62fbp20s0s00.setFecNacimiento(fecNacimiento);
		m62fbp20s0s00.setIndSexo(indSexo);
		m62fbp20s0s00.setIsexo(isexo);
		m62fbp20s0s00.setIndEstadoCivil(indEstadoCivil);
		m62fbp20s0s00.setIestcivi(iestcivi);
		m62fbp20s0s00.setCpais(cpais);
		m62fbp20s0s00.setDpais(dpais);
		m62fbp20s0s00.setCterrito(cterrito);
		m62fbp20s0s00.setCodProvincia(codProvincia);
		m62fbp20s0s00.setDterrito(dterrito);
		m62fbp20s0s00.setCmunicip(cmunicip);
		m62fbp20s0s00.setCodMunicipio(codMunicipio);
		m62fbp20s0s00.setDmunicip(dmunicip);
		m62fbp20s0s00.setDdirecci(ddirecci);
		m62fbp20s0s00.setEmail(email);
		m62fbp20s0s00.setNtelefno(ntelefno);
		m62fbp20s0s00.setNumTlfno2(numTlfno2);
		m62fbp20s0s00.setCodCalle(codCalle);
		m62fbp20s0s00.setCodPortal(codPortal);
		m62fbp20s0s00.setDecSitViv(decSitViv);
		m62fbp20s0s00.setDecMano(decMano);
		m62fbp20s0s00.setCodPostal(codPostal);
		m62fbp20s0s00.setNumCodPostal(numCodPostal);
		m62fbp20s0s00.setFecAlta(fecAlta);
		m62fbp20s0s00.setDirIpUsuario(dirIpUsuario);
		m62fbp20s0s00.setFehUltModif(fehUltModif);
		m62fbp20s0s00.setCodUsuUltModif(codUsuUltModif);
		m62fbp20s0s00.setIdeRegistro(ideRegistro);
		m62fbp20s0s00.setCodAplicacion(codAplicacion);
		m62fbp20s0s00.setIdPersona(idPersona);
		m62fbp20s0s00.setDesCalle(desCalle);
		this.m62fbp20s0s00Service.remove(m62fbp20s0s00);
		M62fbp20s0s00Controller.logger
				.info("[DELETE] : M62fbp20s0s00 borrado correctamente");
		return m62fbp20s0s00;
	}

	/**
	 * Method 'removeAll'.
	 * 
	 * @param m62fbp20s0s00Ids
	 *            List
	 * @return m62fbp20s0s00List
	 */
	@RequestMapping(value = "/deleteAll", method = RequestMethod.POST)
	@ResponseStatus(value = HttpStatus.OK)
	public @ResponseBody
	List<List<String>> removeMultiple(
			@RequestBody List<List<String>> m62fbp20s0s00Ids) {
		List<M62fbp20s0s00> m62fbp20s0s00List = new ArrayList<M62fbp20s0s00>();
		for (List<String> m62fbp20s0s00Id : m62fbp20s0s00Ids) {
			Iterator<String> iterator = m62fbp20s0s00Id.iterator();
			M62fbp20s0s00 m62fbp20s0s00 = new M62fbp20s0s00(); // NOPMD - Objeto
																// nuevo en la
																// lista
																// (parametro
																// del servicio)
			m62fbp20s0s00.setNifTitular(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setNumCorrelNif(ObjectConversionManager.convert(
					iterator.next(), Long.class));
			m62fbp20s0s00.setCodTipoClave(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setItipiden(ObjectConversionManager.convert(
					iterator.next(), Integer.class));
			m62fbp20s0s00.setNomApellido1(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setNomApellido2(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setNomNombre(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setFecNacimiento(ObjectConversionManager.convert(
					iterator.next(), java.util.Date.class));
			m62fbp20s0s00.setIndSexo(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setIsexo(ObjectConversionManager.convert(
					iterator.next(), Integer.class));
			m62fbp20s0s00.setIndEstadoCivil(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setIestcivi(ObjectConversionManager.convert(
					iterator.next(), Integer.class));
			m62fbp20s0s00.setCpais(ObjectConversionManager.convert(
					iterator.next(), Long.class));
			m62fbp20s0s00.setDpais(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setCterrito(ObjectConversionManager.convert(
					iterator.next(), Long.class));
			m62fbp20s0s00.setCodProvincia(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setDterrito(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setCmunicip(ObjectConversionManager.convert(
					iterator.next(), java.lang.Integer.class));
			m62fbp20s0s00.setCodMunicipio(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setDmunicip(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setDdirecci(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setEmail(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setNtelefno(ObjectConversionManager.convert(
					iterator.next(), java.lang.Integer.class));
			m62fbp20s0s00.setNumTlfno2(ObjectConversionManager.convert(
					iterator.next(), java.lang.Integer.class));
			m62fbp20s0s00.setCodCalle(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setCodPortal(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setDecSitViv(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setDecMano(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setCodPostal(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setNumCodPostal(ObjectConversionManager.convert(
					iterator.next(), java.lang.Integer.class));
			m62fbp20s0s00.setFecAlta(ObjectConversionManager.convert(
					iterator.next(), java.util.Date.class));
			m62fbp20s0s00.setDirIpUsuario(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setFehUltModif(ObjectConversionManager.convert(
					iterator.next(), java.util.Date.class));
			m62fbp20s0s00.setCodUsuUltModif(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setIdeRegistro(ObjectConversionManager.convert(
					iterator.next(), java.lang.Integer.class));
			m62fbp20s0s00.setCodAplicacion(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00.setIdPersona(ObjectConversionManager.convert(
					iterator.next(), Integer.class));
			m62fbp20s0s00.setDesCalle(ObjectConversionManager.convert(
					iterator.next(), String.class));
			m62fbp20s0s00List.add(m62fbp20s0s00);
		}
		this.m62fbp20s0s00Service.removeMultiple(m62fbp20s0s00List);
		M62fbp20s0s00Controller.logger
				.info("[POST - DELETE_ALL] : M62fbp20s0s00 borrados correctamente");
		return m62fbp20s0s00Ids;
	}

	/**
	 * Method 'getAllJQGrid'.
	 * 
	 * @param filterM62fbr44s0s00
	 *            M62fbr44s0s00
	 * @param pagination
	 *            Pagination
	 * @return JQGridJSONModel
	 */
	@RequestMapping(method = RequestMethod.GET, headers = { "JQGridModel=true" })
	public @ResponseBody
	Object getAllJQGrid(
			@RequestParam(value = "idPersonaFiltro", required = false) Integer idPersona,
			@RequestParam(value = "nifTitularFiltro", required = false) String nifTitular,
			@RequestParam(value = "codTipoDocuFiltro", required = false) String codTipoDocu,
			@RequestParam(value = "nomNombreFiltro", required = false) String nomNombre,
			@RequestParam(value = "nomApellido1Filtro", required = false) String nomApellido1,
			@RequestParam(value = "nomApellido2Filtro", required = false) String nomApellido2,
			HttpServletRequest request) {
		try {
			Pagination pagination = null;

			// Sustituir * por %
			if (nifTitular != null) {
				nifTitular = nifTitular.replaceAll("\\x2a", "%");
			}
			M62fbp20s0s00 personaFiltro = new M62fbp20s0s00();
			personaFiltro.setIdPersona(idPersona);
			personaFiltro.setNifTitular(nifTitular);
			personaFiltro.setNomNombre(nomNombre);
			personaFiltro.setNomApellido1(nomApellido1);
			personaFiltro.setNomApellido2(nomApellido2);
			personaFiltro.setCodTipoClave(codTipoDocu);

			if (request.getHeader("JQGridModel") != null
					&& request.getHeader("JQGridModel").equals("true")) {
				pagination = new Pagination();

				Long pagina = Long.valueOf(request.getParameter("page"));
				// pagina = Long.valueOf("975");
				pagination.setPage(pagina);

				pagination.setRows(Long.valueOf(request.getParameter("rows")));
				pagination.setSort(request.getParameter("sidx"));
				pagination.setAscDsc(request.getParameter("sord"));

				List<M62fbp20s0s00> personas = this.m62fbp20s0s00Service
						.findAll(personaFiltro, pagination);

				if (personas == null) {
					throw new Exception("No data Found.");
				}

				Long total = this.m62fbp20s0s00Service
						.findAllCount(personaFiltro);

				JQGridJSONModel data = new JQGridJSONModel();
				data.setPage(request.getParameter("page"));
				// data.setPage(pagina.toString());
				data.setRecords(total.intValue());
				data.setTotal(total, pagination.getRows());
				data.setRows(personas);
				return data;
			} else {
				List<M62fbp20s0s00> personas = this.m62fbp20s0s00Service
						.findAll(personaFiltro, pagination);
				if (personas == null) {
					throw new Exception("No data Found.");
				}
				return personas;
			}
		} catch (Exception e) {
			throw new ResourceNotFoundException("No data Found.");
		}
	}

	/**
	 * Method 'getRemoteAutocomplete'.
	 * 
	 * @param q
	 *            BigDecimal
	 * @param c
	 *            Boolean
	 * @return List
	 */
	@RequestMapping(value = "autocomplete/remote", method = RequestMethod.GET)
	public @ResponseBody
	List<M62fbp20s0s00> getRemoteAutocomplete(
			@RequestParam(value = "q", required = true) String q,
			@RequestParam(value = "c", required = true) Boolean c) {
		M62fbp20s0s00 persona = new M62fbp20s0s00();
		persona.setNifTitular(q);
		List<M62fbp20s0s00> LISTA = this.m62fbp20s0s00Service.findAllLike(
				persona, null, c);
		return LISTA;
	}

}
