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

/**
 * Ab6315s00ServiceImpl  
 * 
 *  
 */

@Service(value = "especialidadService")
public class EspecialidadServiceImpl implements EspecialidadService {

	@Autowired
	private EapecialidadDao ab6315s00Dao;

	/**
	 * Inserts a single row in the Ab6315s00 table.
	 *
	 * @param ab6315s00
	 *            Ab6315s00
	 * @return Ab6315s00
	 */
	@Transactional(rollbackFor = Throwable.class)
	public Especialidad add(Especialidad ab6315s00) {
		return this.ab6315s00Dao.add(ab6315s00);
	}

	/**
	 * Updates a single row in the Ab6315s00 table.
	 *
	 * @param ab6315s00
	 *            Ab6315s00
	 * @return Ab6315s00
	 */
	@Transactional(rollbackFor = Throwable.class)
	public Especialidad update(Especialidad ab6315s00) {
		return this.ab6315s00Dao.update(ab6315s00);
	}

	/**
	 * Finds a single row in the Ab6315s00 table.
	 *
	 * @param ab6315s00
	 *            Ab6315s00
	 * @return Ab6315s00
	 */
	public Especialidad find(Especialidad ab6315s00) {
		return (Especialidad) this.ab6315s00Dao.find(ab6315s00);
	}

	/**
	 * Deletes a single row in the Ab6315s00 table.
	 *
	 * @param ab6315s00
	 *            Ab6315s00
	 */
	@Transactional(rollbackFor = Throwable.class)
	public void remove(Especialidad ab6315s00) {
		this.ab6315s00Dao.remove(ab6315s00);
	}

	/**
	 * Finds a list of rows in the Ab6315s00 table.
	 *
	 * @param ab6315s00
	 *            Ab6315s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @return List<Ab6315s00>
	 */
	public List<Especialidad> findAll(Especialidad ab6315s00, JQGridRequestDto jqGridRequestDto) {
		return (List<Especialidad>) this.ab6315s00Dao.findAll(ab6315s00, jqGridRequestDto);
	}

	/**
	 * Finds rows in the Ab6315s00 table using like.
	 *
	 * @param ab6315s00
	 *            Ab6315s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return List<Ab6315s00>
	 */
	public List<Especialidad> findAllLike(Especialidad ab6315s00, JQGridRequestDto jqGridRequestDto,
			Boolean startsWith) {
		return (List<Especialidad>) this.ab6315s00Dao.findAllLike(ab6315s00, jqGridRequestDto, startsWith);
	}

	/*
	 * OPERACIONES RUP_TABLE
	 */

	/**
	 * Removes rows from the Ab6315s00 table.
	 *
	 * @param filterAb6315s00
	 *            Ab6315s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 */
	public void removeMultiple(Especialidad filterAb6315s00, JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		this.ab6315s00Dao.removeMultiple(filterAb6315s00, jqGridRequestDto, startsWith);
	}

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

	/**
	 * Searches rows in the Ab6315s00 table.
	 *
	 * @param filterAb6315s00
	 *            Ab6315s00
	 * @param searchAb6315s00
	 *            Ab6315s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return List<TableRowDto<Ab6315s00>>
	 */
	public List<TableRowDto<Especialidad>> search(Especialidad filterAb6315s00, Especialidad searchAb6315s00,
			JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		return this.ab6315s00Dao.search(filterAb6315s00, searchAb6315s00, jqGridRequestDto, startsWith);
	}

	/**
	 * Reorder the selection made in Ab6315s00 table.
	 *
	 * @param filterAb6315s00
	 *            Ab6315s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return Object
	 */
	public Object reorderSelection(Especialidad filterAb6315s00, JQGridRequestDto jqGridRequestDto,
			Boolean startsWith) {
		return this.ab6315s00Dao.reorderSelection(filterAb6315s00, jqGridRequestDto, startsWith);
	}

	/*
	 * OPERACIONES RUP_TABLE JERARQUIA
	 */

	/**
	 * Finder method in the hierarchical the Ab6315s00 table.
	 *
	 * @param filterAb6315s00
	 *            Ab6315s00
	 * @param jqGridRequestDto
	 *            JQGridRequestDto
	 * @param startsWith
	 *            Boolean
	 * @return JQGridResponseDto<JerarquiaDto<Ab6315s00>>
	 */
	public JQGridResponseDto<JerarquiaDto<Especialidad>> jerarquia(Especialidad filterAb6315s00,
			JQGridRequestDto jqGridRequestDto, Boolean startsWith) {
		List<JerarquiaDto<Especialidad>> listaAb6315s00 = this.ab6315s00Dao.findAllLikeJerarquia(filterAb6315s00,
				jqGridRequestDto);
		Long recordNum = this.ab6315s00Dao.findAllLikeCountJerarquia(filterAb6315s00, jqGridRequestDto);
		return new JQGridResponseDto<JerarquiaDto<Especialidad>>(jqGridRequestDto, recordNum, listaAb6315s00);
	}

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

}
