Search in sources :

Example 11 with Distribuicao

use of com.tomasio.projects.trainning.model.Distribuicao in project trainning by fernandotomasio.

the class AtividadesEnsinoServiceSimpleImpl method createDistribuicao.

@Override
@Transactional
public Long createDistribuicao(DistribuicaoDTO distribuicao) {
    DistribuicaoDAO dao = factory.getDistribuicaoDAO();
    Distribuicao _distribuicao = new Distribuicao(distribuicao);
    Long id = null;
    try {
        id = dao.create(_distribuicao);
    } catch (DAOException ex) {
        ex.printStackTrace();
        throw new CoreException(ex.getMessage());
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new CoreException("Erro em tempo de execução: " + ex.getMessage());
    }
    return id;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Distribuicao(com.tomasio.projects.trainning.model.Distribuicao) DistribuicaoDAO(com.tomasio.projects.trainning.dao.DistribuicaoDAO) DAOException(com.tomasio.projects.trainning.exception.DAOException) ParseException(java.text.ParseException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with Distribuicao

use of com.tomasio.projects.trainning.model.Distribuicao in project trainning by fernandotomasio.

the class AtividadesEnsinoServiceSimpleImpl method findAllDistribuicoesByOrganizacao.

@Override
@Transactional(readOnly = true)
public DistribuicaoDTO[] findAllDistribuicoesByOrganizacao(Long organizacaoId) {
    DistribuicaoDAO dao = factory.getDistribuicaoDAO();
    DistribuicaoDTO[] distribuicoesArray = null;
    try {
        List<Distribuicao> distribuicoes = dao.findAllByOrganizacao(organizacaoId);
        if (distribuicoes != null) {
            distribuicoesArray = new DistribuicaoDTO[distribuicoes.size()];
            for (int i = 0; i < distribuicoes.size(); i++) {
                distribuicoesArray[i] = distribuicoes.get(i).createDTOWithoutDependencies();
            }
        }
    } catch (DAOException ex) {
        ex.printStackTrace();
        throw new CoreException(ex.getMessage());
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new CoreException("Erro em tempo de execução: " + ex.getMessage());
    }
    return distribuicoesArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) DistribuicaoDTO(com.tomasio.projects.trainning.dto.DistribuicaoDTO) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Distribuicao(com.tomasio.projects.trainning.model.Distribuicao) DistribuicaoDAO(com.tomasio.projects.trainning.dao.DistribuicaoDAO) DAOException(com.tomasio.projects.trainning.exception.DAOException) ParseException(java.text.ParseException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with Distribuicao

use of com.tomasio.projects.trainning.model.Distribuicao in project trainning by fernandotomasio.

the class PlanningServiceSimpleImpl method createDistribuicao.

@Override
@Transactional
public Long createDistribuicao(DistribuicaoDTO distribuicao) {
    DistribuicaoDAO dao = factory.getDistribuicaoDAO();
    Distribuicao _distribuicao = new Distribuicao(distribuicao);
    Long id = null;
    try {
        id = dao.create(_distribuicao);
    } catch (DAOException ex) {
        ex.printStackTrace();
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new CoreException("Erro em tempo de execução: " + ex.getMessage());
    }
    return id;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Distribuicao(com.tomasio.projects.trainning.model.Distribuicao) DAOException(com.tomasio.projects.trainning.exception.DAOException) ParseException(java.text.ParseException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with Distribuicao

use of com.tomasio.projects.trainning.model.Distribuicao in project trainning by fernandotomasio.

the class HibernateDistribuicaoDAO method remove.

@Override
public void remove(Long id) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    Distribuicao distribuicao = find(id);
    try {
        session.delete(distribuicao);
    } catch (HibernateException e) {
        Logger.getLogger(HibernateDistribuicaoDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException("Erro ao remover Distribuicao!");
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) Distribuicao(com.tomasio.projects.trainning.model.Distribuicao) Session(org.hibernate.Session)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)14 Distribuicao (com.tomasio.projects.trainning.model.Distribuicao)14 Transactional (org.springframework.transaction.annotation.Transactional)12 CoreException (com.tomasio.projects.trainning.exeption.CoreException)10 DistribuicaoDAO (com.tomasio.projects.trainning.dao.DistribuicaoDAO)9 ParseException (java.text.ParseException)9 OrganizacaoDAO (com.tomasio.projects.trainning.dao.OrganizacaoDAO)3 DistribuicaoDTO (com.tomasio.projects.trainning.dto.DistribuicaoDTO)3 FaseDTO (com.tomasio.projects.trainning.dto.FaseDTO)2 TurmaEfetivaDTO (com.tomasio.projects.trainning.dto.TurmaEfetivaDTO)2 Organizacao (com.tomasio.projects.trainning.model.Organizacao)2 BigDecimal (java.math.BigDecimal)2 DateTime (org.joda.time.DateTime)2 Days (org.joda.time.Days)2 HibernateDistribuicaoDAO (com.tomasio.projects.trainning.dao.HibernateDistribuicaoDAO)1 HibernateOrganizacaoDAO (com.tomasio.projects.trainning.dao.HibernateOrganizacaoDAO)1 ExternoDTO (com.tomasio.projects.trainning.dto.ExternoDTO)1 HashMap (java.util.HashMap)1 HibernateException (org.hibernate.HibernateException)1 Session (org.hibernate.Session)1