예제 #1
0
 @RemotingInclude
 @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 public Contato salvarContato(Contato contato) throws Exception {
   Contato contatoSalvo;
   try {
     if (contato.getId() == null || contato.getId().equals(new Long(0))) {
       contatoSalvo = (Contato) contatoDao.save(contato);
     } else {
       contatoSalvo = (Contato) contatoDao.update(contato);
     }
   } catch (Exception e) {
     logger.error("Erro ao salvar contato: " + contato.getNome());
     ;
     throw e;
   }
   return contatoSalvo;
 }
예제 #2
0
 @RemotingInclude
 @Transactional(readOnly = true)
 public Contato buscarPorNome(String nome) throws Exception {
   try {
     return contatoDao.buscarPorNome(nome);
   } catch (Exception e) {
     logger.info("Não há contato cadastrado com o nome: " + nome + " no sistema");
   }
   return null;
 }
예제 #3
0
 @RemotingInclude
 @Transactional(readOnly = true)
 public List<Contato> listarPorCliente(Pessoa pessoa) throws Exception {
   List<Contato> contatos;
   try {
     contatos = contatoDao.listarPorCliente(pessoa);
   } catch (Exception e) {
     e.printStackTrace();
     logger.error(e);
     throw e;
   }
   return contatos;
 }
예제 #4
0
 @RemotingInclude
 @Transactional(readOnly = true)
 public List<Contato> listarContatos() throws Exception {
   List<Contato> contatos;
   try {
     contatos = (List<Contato>) contatoDao.listAll();
   } catch (Exception e) {
     e.printStackTrace();
     logger.error(e);
     throw e;
   }
   return contatos;
 }
예제 #5
0
 @RemotingInclude
 @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 public Contato excluirContato(Contato contato) throws Exception {
   try {
     contatoDao.remover(contato);
     logger.info("Contato com o nome: " + contato.getNome() + " foi removido do sistema");
   } catch (ConstraintViolationException e) {
     logger.error(e);
     throw new ContatoNaoExclusaoDependenciaExistenteException(contato.getNome());
   } catch (Exception e) {
     logger.error(e);
     throw e;
   }
   return contato;
 }
예제 #6
0
 @RemotingInclude
 @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 public Boolean excluirContatoByPessoa(Pessoa pessoa) throws Exception {
   try {
     contatoDao.removerByPessoa(pessoa);
     logger.info(
         "Contatos do cliente: " + pessoa.getNomeSistema() + " foram removidos do sistema");
     return true;
   } catch (ConstraintViolationException e) {
     logger.error(e);
     throw new ContatoNaoExclusaoDependenciaExistenteException(pessoa.getNomeSistema());
   } catch (Exception e) {
     logger.error(e);
     throw e;
   }
 }