Package br.jus.tjrn.arq.exception

Examples of br.jus.tjrn.arq.exception.ServiceBusinessException


        try {
            dao.insert(entity);
        } catch (DataAccessException e) {
            throw new ServiceDataAccessException(e);
        } catch (PersistenceValidateException e) {
            throw new ServiceBusinessException(e);
        }
    }
View Full Code Here


        try {
            dao.update(entity);
        } catch (DataAccessException e) {
            throw new ServiceDataAccessException(e);
        } catch (PersistenceValidateException e) {
            throw new ServiceBusinessException(e);
        }
    }
View Full Code Here

  @Override
    public void validate(T entity) throws ServiceBusinessException {
    try {
            dao.validate(entity);
        } catch (PersistenceValidateException e) {
            throw new ServiceBusinessException(e);
        }
  }
View Full Code Here

    protected void onBeforeSave(Historicomortalidade entityToSave)
        throws ServiceBusinessException {
      super.onBeforeSave(entityToSave);
     
      if(entityToSave.getQuantidade() == null || entityToSave.getQuantidade() == 0)
        throw new ServiceBusinessException("O campo quantidade não pode ser vazio.");
     
      if(entityToSave.getDataMorte() != null && entityToSave.getDataMorte().before(entityToSave.getLotes().getDataNascimento()))
        throw new ServiceBusinessException("A data de morte não pode ser anterior a data de nascimento do lote!");
    }
View Full Code Here

    public void validate(Consumoracao consumo) throws ServiceBusinessException{
     
      Consumoracao consumoOld = findById(consumo.getId());
     
      if(consumo.getQuantidade() == null || consumo.getQuantidade() == 0)
        throw new ServiceBusinessException("O campo quantidade não pode ser vazio.");
      if(consumoOld!=null && consumoOld.getRacao().equals(consumo.getRacao())){
        if((consumo.getRacao().getQuantidade().intValue() + consumoOld.getQuantidade()) < consumo.getQuantidade())
          throw new ServiceBusinessException("A quantidade da baixa excede o saldo disponível da ração.");
      }else{
        if((consumo.getRacao().getQuantidade().intValue()) < consumo.getQuantidade())
          throw new ServiceBusinessException("A quantidade da baixa excede o saldo disponível da ração.");
      }
     
      if(consumo.getDatal() != null && consumo.getRacao() != null)
        if(consumo.getDatal().before(consumo.getRacao().getData_fabricacao()))
          throw new ServiceBusinessException("A data da baixa deve ser posterior à data de fabricação da ração.");
    }
View Full Code Here

    }
   
    public void update(Produtos produto, Integer valor, int operacao) throws ServiceBusinessException{
      Integer novaQuantidade = produto.getQuantidade() + (operacao * valor);
      if(novaQuantidade < 0)
        throw new ServiceBusinessException("A operação não pode ser concluída, pois a quantidade do produto "+produto.getDescricao()+" ("+novaQuantidade+") é insuficiente.");
     
      if(valor != 0)
        movimentacaoService.insert(produto, new BigDecimal(valor), operacao);
      produto.setQuantidade(novaQuantidade);
      super.update(produto);
View Full Code Here

      entityToSave.setDataCadastro(new Date());
      entityToSave.setAtivo(true);
      super.onBeforeSave(entityToSave);
     
      if(entityToSave.getQuantidade() == null || entityToSave.getQuantidade() == 0)
        throw new ServiceBusinessException("O campo quantidade não pode ser vazio.");
        validateDatas()
    }
View Full Code Here

            long dataChegada = getEntity().getDataChegada().getTime();
            long dataCompra = getEntity().getDataCompra().getTime();
            long dataCadastro = getEntity().getDataCadastro().getTime();

            if (dataCompra > dataChegada && dataCompra > dataCadastro) {
                throw new ServiceBusinessException(" A Data de Compra não pode ser Maior que a Data de Chegada e Maior que Data Cadastro!");
            }
        }
       
        if (getEntity().getDataNascimento() != null && getEntity().getDataDescarte() != null){
           
            long dataNascimento = getEntity().getDataNascimento().getTime();
            long dataDestacarte = getEntity().getDataDescarte().getTime();
           
            if(dataDestacarte < dataNascimento){
                throw new ServiceBusinessException("A Data de Descarte tem que ser Maior que que a Data de Nascimento!");      
            }
        }  
       
        if (getEntity().getDataCadastro() != null && getEntity().getDataDescarte() != null){
           
            long dataCadastro = getEntity().getDataCadastro().getTime();
            long dataDestacarte = getEntity().getDataDescarte().getTime();
           
            if(dataCadastro > dataDestacarte){
                throw new ServiceBusinessException("A Data de Descarte tem que ser Maior que que a Data Atual !");      
            }
        }

    }
View Full Code Here

    }
   
    public void update(Racao racao, Integer valor, int operacao) throws ServiceBusinessException{
      double novaQuantidade = racao.getQuantidade().doubleValue() + (operacao * valor);
      if(novaQuantidade < 0)
        throw new ServiceBusinessException("A operação não pode ser concluída, pois a quantidade da ração "+racao.getDescricao()+" ("+novaQuantidade+") é insuficiente.");
     
      if(valor != 0)
        movimentacaoService.insert(racao, new BigDecimal(valor), operacao);
      racao.setQuantidade(new BigDecimal(novaQuantidade));
      super.update(racao);
View Full Code Here

       
        ServiceUniqueEntityValidator<Racao, RacaoDao> uniqueEntityValidator = ServiceUniqueEntityValidator.create(dao);
        uniqueEntityValidator.validate(entityToValidate, String.format("A ração com a descrição informada (%s) já está cadastrada", entityToValidate.getDescricao()));
       
        if(entity.getQuantidade() == null || entity.getQuantidade().equals(BigDecimal.ZERO))
      throw new ServiceBusinessException("O campo quantidade não pode ser vazio.");
       
        if(entity.getItens() == null || entity.getItens().size() == 0)
          throw new ServiceBusinessException("Nenhum item foi adicionado.");
        else{
          validaItens(entity.getItens());
        }
    }
View Full Code Here

TOP

Related Classes of br.jus.tjrn.arq.exception.ServiceBusinessException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.