package com.ejie.ab63.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ejie.ab63.dao.DireccionDao;
import com.ejie.ab63.model.Direccion;
import com.ejie.x38.dto.JQGridRequestDto;
import com.ejie.x38.dto.JQGridResponseDto;
import com.ejie.x38.dto.JerarquiaDto;
import com.ejie.x38.dto.TableRowDto;

/**
 * Ab6328s00ServiceImpl  
 * 
 *  
 */

@Service(value = "direccionService")
public class DireccionServiceImpl implements DireccionService {

	@Autowired
	private DireccionDao ab6328s00Dao;

	/**
	 * Inserts a single row in the Ab6328s00 table.
	 *
	 * @param ab6328s00
	 *            Ab6328s00
	 * @return Ab6328s00
	 */
	@Transactional(rollbackFor = Throwable.class)
	public Direccion add(Direccion ab6328s00) {
		return this.ab6328s00Dao.add(ab6328s00);
	}

	/**
	 * Updates a single row in the Ab6328s00 table.
	 *
	 * @param ab6328s00
	 *            Ab6328s00
	 * @return Ab6328s00
	 */
	@Transactional(rollbackFor = Throwable.class)
	public Direccion update(Direccion ab6328s00) {
		return this.ab6328s00Dao.update(ab6328s00);
	}

	/**
	 * Finds a single row in the Ab6328s00 table.
	 *
	 * @param ab6328s00
	 *            Ab6328s00
	 * @return Ab6328s00
	 */
	public Direccion find(Direccion ab6328s00) {
		return (Direccion) this.ab6328s00Dao.find(ab6328s00);
	}

	/**
	 * Deletes a single row in the Ab6328s00 table.
	 *
	 * @param ab6328s00
	 *            Ab6328s00
	 */
	@Transactional(rollbackFor = Throwable.class)
	public void remove(Direccion ab6328s00) {
		this.ab6328s00Dao.remove(ab6328s00);
	}

	/**
	 * Finds a list of rows in the Ab6328s00 table.
	 *
	 * @param ab6328s00
	 *            Ab6328s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @return List<Ab6328s00>
	 */
	public List<Direccion> findAll(Direccion ab6328s00, JQGridRequestDto jqGridRequestDto) {
		return (List<Direccion>) this.ab6328s00Dao.findAll(ab6328s00, jqGridRequestDto);
	}

	/**
	 * Finds rows in the Ab6328s00 table using like.
	 *
	 * @param ab6328s00
	 *            Ab6328s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return List<Ab6328s00>
	 */
	public List<Direccion> findAllLike(Direccion ab6328s00, JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		return (List<Direccion>) this.ab6328s00Dao.findAllLike(ab6328s00, jqGridRequestDto, startsWith);
	}

	/*
	 * OPERACIONES RUP_TABLE
	 */

	/**
	 * Removes rows from the Ab6328s00 table.
	 *
	 * @param filterAb6328s00
	 *            Ab6328s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 */
	public void removeMultiple(Direccion filterAb6328s00, JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		this.ab6328s00Dao.removeMultiple(filterAb6328s00, jqGridRequestDto, startsWith);
	}

	/**
	 * Filter method in the Ab6328s00 table.
	 *
	 * @param filterAb6328s00
	 *            Ab6328s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return JQGridResponseDto<Ab6328s00>
	 */
	public JQGridResponseDto<Direccion> filter(Direccion filterAb6328s00, JQGridRequestDto jqGridRequestDto,
			Boolean startsWith) {
		List<Direccion> listaAb6328s00 = this.ab6328s00Dao.findAllLike(filterAb6328s00, jqGridRequestDto, false);
		Long recordNum = this.ab6328s00Dao.findAllLikeCount(filterAb6328s00 != null ? filterAb6328s00 : new Direccion(),
				false);
		if (jqGridRequestDto.getMultiselection().getSelectedIds() != null) {
			List<TableRowDto<Direccion>> reorderSelection = this.ab6328s00Dao.reorderSelection(filterAb6328s00,
					jqGridRequestDto, startsWith);
			return new JQGridResponseDto<Direccion>(jqGridRequestDto, recordNum, listaAb6328s00, reorderSelection);
		}
		return new JQGridResponseDto<Direccion>(jqGridRequestDto, recordNum, listaAb6328s00);
	}

	/**
	 * Searches rows in the Ab6328s00 table.
	 *
	 * @param filterAb6328s00
	 *            Ab6328s00
	 * @param searchAb6328s00
	 *            Ab6328s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return List<TableRowDto<Ab6328s00>>
	 */
	public List<TableRowDto<Direccion>> search(Direccion filterAb6328s00, Direccion searchAb6328s00,
			JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		return this.ab6328s00Dao.search(filterAb6328s00, searchAb6328s00, jqGridRequestDto, startsWith);
	}

	/**
	 * Reorder the selection made in Ab6328s00 table.
	 *
	 * @param filterAb6328s00
	 *            Ab6328s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return Object
	 */
	public Object reorderSelection(Direccion filterAb6328s00, JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		return this.ab6328s00Dao.reorderSelection(filterAb6328s00, jqGridRequestDto, startsWith);
	}

	/*
	 * OPERACIONES RUP_TABLE JERARQUIA
	 */

	/**
	 * Finder method in the hierarchical the Ab6328s00 table.
	 *
	 * @param filterAb6328s00
	 *            Ab6328s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return JQGridResponseDto<JerarquiaDto<Ab6328s00>>
	 */
	public JQGridResponseDto<JerarquiaDto<Direccion>> jerarquia(Direccion filterAb6328s00,
			JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		List<JerarquiaDto<Direccion>> listaAb6328s00 = this.ab6328s00Dao.findAllLikeJerarquia(filterAb6328s00,
				jqGridRequestDto);
		Long recordNum = this.ab6328s00Dao.findAllLikeCountJerarquia(filterAb6328s00, jqGridRequestDto);
		return new JQGridResponseDto<JerarquiaDto<Direccion>>(jqGridRequestDto, recordNum, listaAb6328s00);
	}

	/**
	 * Finder method for siblings rows in the hierarchical the Ab6328s00 table.
	 *
	 * @param filterAb6328s00
	 *            Ab6328s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @return JQGridResponseDto<JerarquiaDto<Ab6328s00>>
	 */
	public JQGridResponseDto<JerarquiaDto<Direccion>> jerarquiaChildren(Direccion filterAb6328s00,
			JQGridRequestDto jqGridRequestDto) {
		JQGridResponseDto<JerarquiaDto<Direccion>> jqGridResponseDto = new JQGridResponseDto<JerarquiaDto<Direccion>>();
		jqGridResponseDto.addAdditionalParam(JQGridResponseDto.CHILDREN,
				this.ab6328s00Dao.findAllChild(filterAb6328s00, jqGridRequestDto));
		return jqGridResponseDto;
	}

}
