package com.ejie.ab39a.service;
import com.ejie.ab39a.dao.TiposReceptoresDao;
import com.ejie.x38.dto.JQGridRequestDto;
import com.ejie.x38.dto.JQGridResponseDto;
import com.ejie.x38.dto.TableRowDto;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.ejie.ab39a.model.TiposReceptores;

/**
 * TiposReceptores.
 *  
 */
@Service(value = "tiposReceptoresService")
public class TiposReceptoresServiceImpl implements TiposReceptoresService {

	@Autowired
	private TiposReceptoresDao tiposReceptoresDao;

	/**
	 * Inserts a single row in the TiposReceptores table.
	 *
	 * @param tiposReceptores TiposReceptores
	 * @return TiposReceptores
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED, rollbackFor = Throwable.class)
	public TiposReceptores add(TiposReceptores tiposReceptores) {
		return this.tiposReceptoresDao.add(tiposReceptores);
	}

	/**
	 * Updates a single row in the TiposReceptores table.
	 *
	 * @param tiposReceptores TiposReceptores
	 * @return TiposReceptores
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED, rollbackFor = Throwable.class)
	public TiposReceptores update(TiposReceptores tiposReceptores) {
		return this.tiposReceptoresDao.update(tiposReceptores);
	 }

	/**
	 * Finds a single row in the TiposReceptores table.
	 *
	 * @param tiposReceptores TiposReceptores
	 * @return TiposReceptores
	 */
	@Override
	@Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED)
	public TiposReceptores find(TiposReceptores tiposReceptores) {
		return this.tiposReceptoresDao.find(tiposReceptores);
	}
	
	/**
	 * Deletes a single row in the TiposReceptores table.
	 *
	 * @param tiposReceptores TiposReceptores
	 */
	@Override
	@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED, rollbackFor = Throwable.class)
	public void remove(TiposReceptores tiposReceptores) {
		this.tiposReceptoresDao.remove(tiposReceptores);
	}

	/**
	 * Finds a list of rows in the TiposReceptores table.
	 *
	 * @param tiposReceptores TiposReceptores
	 * @param jqGridRequestDto JQGridRequestDto
	 * @return List<TiposReceptores>
	 */
	@Override
	@Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED)
	public List<TiposReceptores> findAll(TiposReceptores tiposReceptores, JQGridRequestDto jqGridRequestDto){
		return this.tiposReceptoresDao.findAll(tiposReceptores, jqGridRequestDto);
	}
    
	/**
	 * Finds rows in the TiposReceptores table using like.
	 *
	 * @param tiposReceptores TiposReceptores
	 * @param jqGridRequestDto JQGridRequestDto
     * @param startsWith Boolean	 
	 * @return List<TiposReceptores>
	 */
	@Override
	@Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED) 
	public List<TiposReceptores> findAllLike(TiposReceptores tiposReceptores, JQGridRequestDto jqGridRequestDto, Boolean startsWith){
		return this.tiposReceptoresDao.findAllLike(tiposReceptores, jqGridRequestDto, startsWith);
	}

	/*
	 * OPERACIONES RUP_TABLE
	 */
	 
	/**
	 * Removes rows from the TiposReceptores table.
	 *
	 * @param filterTiposReceptores TiposReceptores
	 * @param jqGridRequestDto JQGridRequestDto
	 * @param startsWith Boolean
	 */	
	@Override
	@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED, rollbackFor = Throwable.class)
	public void removeMultiple(TiposReceptores filterTiposReceptores, JQGridRequestDto jqGridRequestDto,  Boolean startsWith){
		this.tiposReceptoresDao.removeMultiple(filterTiposReceptores, jqGridRequestDto, startsWith);
	}
        
	/**
	 * Filter method in the TiposReceptores table.
	 *
	 * @param filterTiposReceptores TiposReceptores
	 * @param jqGridRequestDto JQGridRequestDto
	 * @param startsWith Boolean
	 * @return JQGridResponseDto<TiposReceptores>
	 */
	@Override	
	@Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED)
	public JQGridResponseDto< TiposReceptores> filter(TiposReceptores filterTiposReceptores, JQGridRequestDto jqGridRequestDto,  Boolean startsWith){
		List<TiposReceptores> listaTiposReceptores =  this.tiposReceptoresDao.findAllLike(filterTiposReceptores, jqGridRequestDto, false);
		Long recordNum =  this.tiposReceptoresDao.findAllLikeCount(filterTiposReceptores != null ? filterTiposReceptores: new TiposReceptores (),false);
		if (jqGridRequestDto.getMultiselection().getSelectedIds()!=null){
			List< TableRowDto< TiposReceptores>> reorderSelection = this.tiposReceptoresDao.reorderSelection(filterTiposReceptores, jqGridRequestDto, startsWith);
			return new JQGridResponseDto<TiposReceptores>(jqGridRequestDto, recordNum, listaTiposReceptores, reorderSelection);
		}
		return new JQGridResponseDto<TiposReceptores>(jqGridRequestDto, recordNum, listaTiposReceptores);   
	}
    
    /**
	 * Reorder the selection made in TiposReceptores table.
	 *
	 * @param filterTiposReceptores TiposReceptores
	 * @param jqGridRequestDto JQGridRequestDto
	 * @param startsWith Boolean
	 * @return Object
	 */	
	@Override
    @Transactional(propagation = Propagation.SUPPORTS, isolation = Isolation.READ_COMMITTED)
    public Object reorderSelection(TiposReceptores filterTiposReceptores, JQGridRequestDto jqGridRequestDto, Boolean startsWith){
		return this.tiposReceptoresDao.reorderSelection(filterTiposReceptores, jqGridRequestDto, startsWith);
	}
    	
}
