package com.ejie.ab61.service.terceros;
import com.ejie.ab61.dao.terceros.TiposCanalAvisoDao;
import com.ejie.ab61.model.terceros.TiposCanalAviso;
import com.ejie.x38.dto.JQGridRequestDto;
import com.ejie.x38.dto.JQGridResponseDto;
import com.ejie.x38.dto.JerarquiaDto;
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.Transactional;

/**
 * TiposCanalAvisoServiceImpl  
 *  
 */

@Service(value = "tiposCanalAvisoService")
public class TiposCanalAvisoServiceImpl implements TiposCanalAvisoService {

	@Autowired
	private TiposCanalAvisoDao tiposCanalAvisoDao;

	/**
	 * Inserts a single row in the TiposCanalAviso table.
	 *
	 * @param tiposCanalAviso TiposCanalAviso
	 * @return TiposCanalAviso
	 */
	@Transactional(rollbackFor = Throwable.class)
	public TiposCanalAviso add(TiposCanalAviso tiposCanalAviso) {
		return this.tiposCanalAvisoDao.add(tiposCanalAviso);
	}

	/**
	 * Updates a single row in the TiposCanalAviso table.
	 *
	 * @param tiposCanalAviso TiposCanalAviso
	 * @return TiposCanalAviso
	 */
	@Transactional(rollbackFor = Throwable.class)
	public TiposCanalAviso update(TiposCanalAviso tiposCanalAviso) {
		return this.tiposCanalAvisoDao.update(tiposCanalAviso);
	 }

	/**
	 * Finds a single row in the TiposCanalAviso table.
	 *
	 * @param tiposCanalAviso TiposCanalAviso
	 * @return TiposCanalAviso
	 */
	public TiposCanalAviso find(TiposCanalAviso tiposCanalAviso) {
		return (TiposCanalAviso) this.tiposCanalAvisoDao.find(tiposCanalAviso);
	}
	
	/**
	 * Deletes a single row in the TiposCanalAviso table.
	 *
	 * @param tiposCanalAviso TiposCanalAviso
	 */
	@Transactional(rollbackFor = Throwable.class)
	public void remove(TiposCanalAviso tiposCanalAviso) {
		this.tiposCanalAvisoDao.remove(tiposCanalAviso);
	}

	/**
	 * Finds a list of rows in the TiposCanalAviso table.
	 *
	 * @param tiposCanalAviso TiposCanalAviso
	 * @param jqGridRequestDto JQGridRequestDto
	 * @return List<TiposCanalAviso>
	 */
	public List<TiposCanalAviso> findAll(TiposCanalAviso tiposCanalAviso, JQGridRequestDto jqGridRequestDto){
		return (List<TiposCanalAviso>) this.tiposCanalAvisoDao.findAll(tiposCanalAviso, jqGridRequestDto);
	}
    
	/**
	 * Finds rows in the TiposCanalAviso table using like.
	 *
	 * @param tiposCanalAviso TiposCanalAviso
	 * @param jqGridRequestDto JQGridRequestDto
     * @param startsWith Boolean	 
	 * @return List<TiposCanalAviso>
	 */
	public List<TiposCanalAviso> findAllLike(TiposCanalAviso tiposCanalAviso, JQGridRequestDto jqGridRequestDto, Boolean startsWith){
		return (List<TiposCanalAviso>) this.tiposCanalAvisoDao.findAllLike(tiposCanalAviso, jqGridRequestDto, startsWith);
	}

	/*
	 * OPERACIONES RUP_TABLE
	 */
	 
	/**
	 * Removes rows from the TiposCanalAviso table.
	 *
	 * @param filterTiposCanalAviso TiposCanalAviso
	 * @param jqGridRequestDto JQGridRequestDto
	 * @param startsWith Boolean
	 */	
	public void removeMultiple(TiposCanalAviso filterTiposCanalAviso, JQGridRequestDto jqGridRequestDto,  Boolean startsWith){
		this.tiposCanalAvisoDao.removeMultiple(filterTiposCanalAviso, jqGridRequestDto, startsWith);
	}
        
	/**
	 * Filter method in the TiposCanalAviso table.
	 *
	 * @param filterTiposCanalAviso TiposCanalAviso
	 * @param jqGridRequestDto JQGridRequestDto
	 * @param startsWith Boolean
	 * @return JQGridResponseDto<TiposCanalAviso>
	 */	
	public JQGridResponseDto< TiposCanalAviso> filter(TiposCanalAviso filterTiposCanalAviso, JQGridRequestDto jqGridRequestDto,  Boolean startsWith){
		List<TiposCanalAviso> listaTiposCanalAviso =  this.tiposCanalAvisoDao.findAllLike(filterTiposCanalAviso, jqGridRequestDto, false);
		Long recordNum =  this.tiposCanalAvisoDao.findAllLikeCount(filterTiposCanalAviso != null ? filterTiposCanalAviso: new TiposCanalAviso (),false);
		if (jqGridRequestDto.getMultiselection().getSelectedIds()!=null){
			List< TableRowDto< TiposCanalAviso>> reorderSelection = this.tiposCanalAvisoDao.reorderSelection(filterTiposCanalAviso, jqGridRequestDto, startsWith);
			return new JQGridResponseDto<TiposCanalAviso>(jqGridRequestDto, recordNum, listaTiposCanalAviso, reorderSelection);
		}
		return new JQGridResponseDto<TiposCanalAviso>(jqGridRequestDto, recordNum, listaTiposCanalAviso);   
	}
    
    /**
	 * Searches rows in the TiposCanalAviso table.
	 *
	 * @param filterTiposCanalAviso TiposCanalAviso
	 * @param searchTiposCanalAviso TiposCanalAviso
	 * @param jqGridRequestDto JQGridRequestDto
	 * @param startsWith Boolean
	 * @return List<TableRowDto<TiposCanalAviso>>
	 */	
    public List< TableRowDto< TiposCanalAviso>> search(TiposCanalAviso filterTiposCanalAviso, TiposCanalAviso searchTiposCanalAviso, JQGridRequestDto jqGridRequestDto, Boolean startsWith){
		return this.tiposCanalAvisoDao.search(filterTiposCanalAviso, searchTiposCanalAviso, jqGridRequestDto, startsWith);
	}
    
    /**
	 * Reorder the selection made in TiposCanalAviso table.
	 *
	 * @param filterTiposCanalAviso TiposCanalAviso
	 * @param jqGridRequestDto JQGridRequestDto
	 * @param startsWith Boolean
	 * @return Object
	 */	
    public Object reorderSelection(TiposCanalAviso filterTiposCanalAviso, JQGridRequestDto jqGridRequestDto, Boolean startsWith){
		return this.tiposCanalAvisoDao.reorderSelection(filterTiposCanalAviso, jqGridRequestDto, startsWith);
	}
    
    /*
	 * OPERACIONES RUP_TABLE JERARQUIA
	 */
	 
	/**
	 * Finder method in the hierarchical the TiposCanalAviso table.
	 *
	 * @param filterTiposCanalAviso TiposCanalAviso
	 * @param jqGridRequestDto JQGridRequestDto
	 * @param startsWith Boolean
	 * @return JQGridResponseDto<JerarquiaDto<TiposCanalAviso>>
	 */	
	public JQGridResponseDto<JerarquiaDto<TiposCanalAviso>> jerarquia(TiposCanalAviso filterTiposCanalAviso, JQGridRequestDto jqGridRequestDto, Boolean startsWith){
		List<JerarquiaDto<TiposCanalAviso>> listaTiposCanalAviso =  this.tiposCanalAvisoDao.findAllLikeJerarquia(filterTiposCanalAviso, jqGridRequestDto);
		Long recordNum = this.tiposCanalAvisoDao.findAllLikeCountJerarquia(filterTiposCanalAviso, jqGridRequestDto);
		return new JQGridResponseDto<JerarquiaDto<TiposCanalAviso>>(jqGridRequestDto, recordNum, listaTiposCanalAviso);
	}
	
	/**
	 * Finder method for siblings rows in the hierarchical the TiposCanalAviso table.
	 *
	 * @param filterTiposCanalAviso TiposCanalAviso
	 * @param jqGridRequestDto JQGridRequestDto
	 * @return JQGridResponseDto<JerarquiaDto<TiposCanalAviso>>
	 */	
	public JQGridResponseDto<JerarquiaDto<TiposCanalAviso>> jerarquiaChildren(TiposCanalAviso filterTiposCanalAviso, JQGridRequestDto jqGridRequestDto){
		JQGridResponseDto<JerarquiaDto<TiposCanalAviso>> jqGridResponseDto = new JQGridResponseDto<JerarquiaDto<TiposCanalAviso>>();
		jqGridResponseDto.addAdditionalParam(JQGridResponseDto.CHILDREN, this.tiposCanalAvisoDao.findAllChild(filterTiposCanalAviso, jqGridRequestDto));
		return jqGridResponseDto;
	}
	
	
}

