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

/**
 * Ab6316s00ServiceImpl  
 * 
 *  
 */

@Service(value = "tipoAseoService")
public class TipoAseoServiceImpl implements TipoAseoService {

	@Autowired
	private TipoAseoDao ab6316s00Dao;

	/**
	 * Inserts a single row in the Ab6316s00 table.
	 *
	 * @param ab6316s00
	 *            Ab6316s00
	 * @return Ab6316s00
	 */
	@Transactional(rollbackFor = Throwable.class)
	public TipoAseo add(TipoAseo ab6316s00) {
		return this.ab6316s00Dao.add(ab6316s00);
	}

	/**
	 * Updates a single row in the Ab6316s00 table.
	 *
	 * @param ab6316s00
	 *            Ab6316s00
	 * @return Ab6316s00
	 */
	@Transactional(rollbackFor = Throwable.class)
	public TipoAseo update(TipoAseo ab6316s00) {
		return this.ab6316s00Dao.update(ab6316s00);
	}

	/**
	 * Finds a single row in the Ab6316s00 table.
	 *
	 * @param ab6316s00
	 *            Ab6316s00
	 * @return Ab6316s00
	 */
	public TipoAseo find(TipoAseo ab6316s00) {
		return (TipoAseo) this.ab6316s00Dao.find(ab6316s00);
	}

	/**
	 * Deletes a single row in the Ab6316s00 table.
	 *
	 * @param ab6316s00
	 *            Ab6316s00
	 */
	@Transactional(rollbackFor = Throwable.class)
	public void remove(TipoAseo ab6316s00) {
		this.ab6316s00Dao.remove(ab6316s00);
	}

	/**
	 * Finds a list of rows in the Ab6316s00 table.
	 *
	 * @param ab6316s00
	 *            Ab6316s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @return List<Ab6316s00>
	 */
	public List<TipoAseo> findAll(TipoAseo ab6316s00, JQGridRequestDto jqGridRequestDto) {
		return (List<TipoAseo>) this.ab6316s00Dao.findAll(ab6316s00, jqGridRequestDto);
	}

	/**
	 * Finds rows in the Ab6316s00 table using like.
	 *
	 * @param ab6316s00
	 *            Ab6316s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return List<Ab6316s00>
	 */
	public List<TipoAseo> findAllLike(TipoAseo ab6316s00, JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		return (List<TipoAseo>) this.ab6316s00Dao.findAllLike(ab6316s00, jqGridRequestDto, startsWith);
	}

	/*
	 * OPERACIONES RUP_TABLE
	 */

	/**
	 * Removes rows from the Ab6316s00 table.
	 *
	 * @param filterAb6316s00
	 *            Ab6316s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 */
	public void removeMultiple(TipoAseo filterAb6316s00, JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		this.ab6316s00Dao.removeMultiple(filterAb6316s00, jqGridRequestDto, startsWith);
	}

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

	/**
	 * Searches rows in the Ab6316s00 table.
	 *
	 * @param filterAb6316s00
	 *            Ab6316s00
	 * @param searchAb6316s00
	 *            Ab6316s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return List<TableRowDto<Ab6316s00>>
	 */
	public List<TableRowDto<TipoAseo>> search(TipoAseo filterAb6316s00, TipoAseo searchAb6316s00,
			JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		return this.ab6316s00Dao.search(filterAb6316s00, searchAb6316s00, jqGridRequestDto, startsWith);
	}

	/**
	 * Reorder the selection made in Ab6316s00 table.
	 *
	 * @param filterAb6316s00
	 *            Ab6316s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return Object
	 */
	public Object reorderSelection(TipoAseo filterAb6316s00, JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		return this.ab6316s00Dao.reorderSelection(filterAb6316s00, jqGridRequestDto, startsWith);
	}

	/*
	 * OPERACIONES RUP_TABLE JERARQUIA
	 */

	/**
	 * Finder method in the hierarchical the Ab6316s00 table.
	 *
	 * @param filterAb6316s00
	 *            Ab6316s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return JQGridResponseDto<JerarquiaDto<Ab6316s00>>
	 */
	public JQGridResponseDto<JerarquiaDto<TipoAseo>> jerarquia(TipoAseo filterAb6316s00,
			JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		List<JerarquiaDto<TipoAseo>> listaAb6316s00 = this.ab6316s00Dao.findAllLikeJerarquia(filterAb6316s00,
				jqGridRequestDto);
		Long recordNum = this.ab6316s00Dao.findAllLikeCountJerarquia(filterAb6316s00, jqGridRequestDto);
		return new JQGridResponseDto<JerarquiaDto<TipoAseo>>(jqGridRequestDto, recordNum, listaAb6316s00);
	}

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

}
