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.TipoHabitacionDao;
import com.ejie.ab63.model.TipoHabitacion;
import com.ejie.x38.dto.JQGridRequestDto;
import com.ejie.x38.dto.JQGridResponseDto;
import com.ejie.x38.dto.JerarquiaDto;
import com.ejie.x38.dto.TableRowDto;

/**
 * Ab6317s00ServiceImpl  
 * 
 *  
 */

@Service(value = "tipoHabitacionService")
public class TipoHabitacionServiceImpl implements TipoHabitacionService {

	@Autowired
	private TipoHabitacionDao ab6317s00Dao;

	/**
	 * Inserts a single row in the Ab6317s00 table.
	 *
	 * @param ab6317s00
	 *            Ab6317s00
	 * @return Ab6317s00
	 */
	@Transactional(rollbackFor = Throwable.class)
	public TipoHabitacion add(TipoHabitacion ab6317s00) {
		return this.ab6317s00Dao.add(ab6317s00);
	}

	/**
	 * Updates a single row in the Ab6317s00 table.
	 *
	 * @param ab6317s00
	 *            Ab6317s00
	 * @return Ab6317s00
	 */
	@Transactional(rollbackFor = Throwable.class)
	public TipoHabitacion update(TipoHabitacion ab6317s00) {
		return this.ab6317s00Dao.update(ab6317s00);
	}

	/**
	 * Finds a single row in the Ab6317s00 table.
	 *
	 * @param ab6317s00
	 *            Ab6317s00
	 * @return Ab6317s00
	 */
	public TipoHabitacion find(TipoHabitacion ab6317s00) {
		return (TipoHabitacion) this.ab6317s00Dao.find(ab6317s00);
	}

	/**
	 * Deletes a single row in the Ab6317s00 table.
	 *
	 * @param ab6317s00
	 *            Ab6317s00
	 */
	@Transactional(rollbackFor = Throwable.class)
	public void remove(TipoHabitacion ab6317s00) {
		this.ab6317s00Dao.remove(ab6317s00);
	}

	/**
	 * Finds a list of rows in the Ab6317s00 table.
	 *
	 * @param ab6317s00
	 *            Ab6317s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @return List<Ab6317s00>
	 */
	public List<TipoHabitacion> findAll(TipoHabitacion ab6317s00, JQGridRequestDto jqGridRequestDto) {
		return (List<TipoHabitacion>) this.ab6317s00Dao.findAll(ab6317s00, jqGridRequestDto);
	}

	/**
	 * Finds rows in the Ab6317s00 table using like.
	 *
	 * @param ab6317s00
	 *            Ab6317s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return List<Ab6317s00>
	 */
	public List<TipoHabitacion> findAllLike(TipoHabitacion ab6317s00, JQGridRequestDto jqGridRequestDto,
			Boolean startsWith) {
		return (List<TipoHabitacion>) this.ab6317s00Dao.findAllLike(ab6317s00, jqGridRequestDto, startsWith);
	}

	/*
	 * OPERACIONES RUP_TABLE
	 */

	/**
	 * Removes rows from the Ab6317s00 table.
	 *
	 * @param filterAb6317s00
	 *            Ab6317s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 */
	public void removeMultiple(TipoHabitacion filterAb6317s00, JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		this.ab6317s00Dao.removeMultiple(filterAb6317s00, jqGridRequestDto, startsWith);
	}

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

	/**
	 * Searches rows in the Ab6317s00 table.
	 *
	 * @param filterAb6317s00
	 *            Ab6317s00
	 * @param searchAb6317s00
	 *            Ab6317s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return List<TableRowDto<Ab6317s00>>
	 */
	public List<TableRowDto<TipoHabitacion>> search(TipoHabitacion filterAb6317s00, TipoHabitacion searchAb6317s00,
			JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		return this.ab6317s00Dao.search(filterAb6317s00, searchAb6317s00, jqGridRequestDto, startsWith);
	}

	/**
	 * Reorder the selection made in Ab6317s00 table.
	 *
	 * @param filterAb6317s00
	 *            Ab6317s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return Object
	 */
	public Object reorderSelection(TipoHabitacion filterAb6317s00, JQGridRequestDto jqGridRequestDto,
			Boolean startsWith) {
		return this.ab6317s00Dao.reorderSelection(filterAb6317s00, jqGridRequestDto, startsWith);
	}

	/*
	 * OPERACIONES RUP_TABLE JERARQUIA
	 */

	/**
	 * Finder method in the hierarchical the Ab6317s00 table.
	 *
	 * @param filterAb6317s00
	 *            Ab6317s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return JQGridResponseDto<JerarquiaDto<Ab6317s00>>
	 */
	public JQGridResponseDto<JerarquiaDto<TipoHabitacion>> jerarquia(TipoHabitacion filterAb6317s00,
			JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		List<JerarquiaDto<TipoHabitacion>> listaAb6317s00 = this.ab6317s00Dao.findAllLikeJerarquia(filterAb6317s00,
				jqGridRequestDto);
		Long recordNum = this.ab6317s00Dao.findAllLikeCountJerarquia(filterAb6317s00, jqGridRequestDto);
		return new JQGridResponseDto<JerarquiaDto<TipoHabitacion>>(jqGridRequestDto, recordNum, listaAb6317s00);
	}

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

}
