package com.ejie.ab39a.service;
import com.ejie.ab39a.dao.TiposIdentifDao;
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.TiposIdentif;

/**
 * TiposIdentif.
 *  
 */
@Service(value = "tiposIdentifService")
public class TiposIdentifServiceImpl implements TiposIdentifService {

	@Autowired
	private TiposIdentifDao tiposIdentifDao;

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

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

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

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

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