Subversion Repositories Integrator Subversion

Rev

Rev 182 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

package br.com.ec.domain.service.taxa.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import br.com.ec.domain.model.Taxa;
import br.com.ec.domain.service.taxa.TaxaService;
import br.com.ec.infrastructure.repository.TaxaRepository;
import br.edu.cesmac.core.consulta.ParametrosConsulta;
import br.edu.cesmac.core.exception.NegocioException;
import br.edu.cesmac.core.generic.AbstractService;
import br.edu.cesmac.core.generic.GenericRepository;
import br.edu.cesmac.core.util.VerificadorUtil;
import br.edu.cesmac.core.validador.Validador;

@Service
public class TaxaServiceImpl extends AbstractService<Taxa> implements TaxaService {
       
        private TaxaRepository taxaRepository;

        @Autowired
        public TaxaServiceImpl(Validador validador, TaxaRepository taxaRepository) {
                super(validador);
                this.taxaRepository = taxaRepository;
        }

        @Override
        protected GenericRepository<Taxa> getRepository() {
                return taxaRepository;
        }
       
        @Override
        protected void regrasNegocioCadastrar(Taxa taxa) {
                taxa.setAtivo(true);
//              verificarSeTaxaJaExiste(taxa);
        }
       
        private void verificarSeTaxaJaExiste(Taxa taxa) {
                if (this.consultarPassandoEntidade(taxa, 0, 1).size() > 0) {
                        throw new NegocioException("Taxa já existe");
                }
        }

        @Override
        public List<Taxa> listarTaxasAtivas() {
                Taxa taxaSelecionado = new Taxa();
                taxaSelecionado.setAtivo(true);
                return this.consultarPassandoEntidade(taxaSelecionado, 0, this.obterQuantidadeDeRegistrosPassandoEntidade(taxaSelecionado));
        }
       
        @Override
        public List<Taxa> consultarTaxas(ParametrosConsulta<Taxa> parametrosConsulta) {
                return this.consultarPassandoEntidade(parametrosConsulta.getEntidade(), 0, this.obterQuantidadeDeRegistrosPassandoEntidade(parametrosConsulta.getEntidade()));
        }
       
        @Override
        public Taxa consultarTaxa(Taxa taxa) {
                return taxaRepository.consultarTaxa(taxa);
        }
       
}