Search in sources :

Example 1 with TurmaPlanejada

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

the class PlanningServiceSimpleImpl method createTurma.

@Override
@Transactional
public Long createTurma(TurmaDTO turma) {
    TurmaDAO dao = factory.getTurmaDAO();
    Turma _turma = new TurmaPlanejada((TurmaPlanejadaDTO) turma);
    Long id = null;
    try {
        id = dao.create(_turma);
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    return id;
}
Also used : TurmaPlanejada(com.tomasio.projects.trainning.model.TurmaPlanejada) DAOException(com.tomasio.projects.trainning.exception.DAOException) Turma(com.tomasio.projects.trainning.model.Turma) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with TurmaPlanejada

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

the class HibernateTurmaDAO method searchTurmasPlanejadas.

@Override
public List<TurmaPlanejadaDTO> searchTurmasPlanejadas(Long planejamentoId, Long planoId, Long cursoId, Long responsavelId, String search) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        Criteria criteria = session.createCriteria(TurmaPlanejada.class);
        criteria.createAlias("itemPlanejamento", "item");
        criteria.createAlias("curso", "c");
        if (planejamentoId != null && planejamentoId > 0L) {
            criteria.add(Restrictions.eq("item.planejamento.id", planejamentoId));
        }
        if (cursoId != null && cursoId > 0L) {
            criteria.add(Restrictions.eq("curso.id", cursoId));
        }
        if (responsavelId != null && responsavelId > 0L) {
            criteria.add(Restrictions.eq("responsavelId", responsavelId));
        }
        if (planoId != null && planoId > 0L) {
            criteria.add(Restrictions.eq("c.plano.id", planoId));
        }
        if (search != null) {
            Disjunction or = Restrictions.disjunction();
            or.add(Restrictions.ilike("c.codigo", "%" + search + "%")).add(Restrictions.ilike("c.descricao", "%" + search + "%"));
            criteria.add(or);
        }
        @SuppressWarnings("unchecked") List<TurmaPlanejada> turmas = criteria.list();
        List<TurmaPlanejadaDTO> dto = new ArrayList<TurmaPlanejadaDTO>();
        for (TurmaPlanejada turma : turmas) {
            dto.add(turma.createDTOWithoutDependencies());
        }
        return dto;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateTurmaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("turmas.find.list.error"));
    }
}
Also used : TurmaPlanejada(com.tomasio.projects.trainning.model.TurmaPlanejada) DAOException(com.tomasio.projects.trainning.exception.DAOException) Disjunction(org.hibernate.criterion.Disjunction) HibernateException(org.hibernate.HibernateException) ArrayList(java.util.ArrayList) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session) TurmaPlanejadaDTO(com.tomasio.projects.trainning.dto.TurmaPlanejadaDTO)

Example 3 with TurmaPlanejada

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

the class HibernateTurmaDAO method instantiateTurma.

@SuppressWarnings("unused")
private Turma instantiateTurma(TurmaDTO dto) {
    Turma turma;
    if (dto instanceof TurmaEfetivaDTO) {
        TurmaEfetivaDTO aux = (TurmaEfetivaDTO) dto;
        turma = new TurmaEfetiva(aux);
    } else {
        TurmaPlanejadaDTO aux = (TurmaPlanejadaDTO) dto;
        turma = new TurmaPlanejada(aux);
    }
    return turma;
}
Also used : TurmaPlanejada(com.tomasio.projects.trainning.model.TurmaPlanejada) TurmaEfetivaDTO(com.tomasio.projects.trainning.dto.TurmaEfetivaDTO) Turma(com.tomasio.projects.trainning.model.Turma) StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) TurmaPlanejadaDTO(com.tomasio.projects.trainning.dto.TurmaPlanejadaDTO)

Example 4 with TurmaPlanejada

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

the class ImportOfertasTurmasPlanejadasFromTabelaoImpl method execute.

@Override
public void execute() {
    try {
        DAOFactory factory = DAOUtil.getDAOFactory();
        TreinamentoSolicitadoDAO treinamentoDAO = factory.getTreinamentoSolicitadoDAO();
        OrganizacaoDAO organizacaoDAO = factory.getOrganizacaoDAO();
        PlanejamentoDAO planejamentoDAO = factory.getPlanejamentoDAO();
        CursoDAO cursoDAO = factory.getCursoDAO();
        ItemPlanejamentoDAO itemDAO = factory.getItemPlanejamentoDAO();
        TurmaDAO turmaDAO = factory.getTurmaDAO();
        Planejamento planejamento = planejamentoDAO.find(108232L);
        List<ItemPlanejamentoDTO> itens = itemDAO.findAll(planejamento.getId());
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/dctp?user=root&password=roland");
        Statement stm = conn.createStatement();
        ResultSet rs = stm.executeQuery("SELECT * FROM planofertas");
        while (rs.next()) {
            String codigoCurso = rs.getString("codcurso");
            String siglaOrganizacao = rs.getString("local");
            Integer quantidade = rs.getInt("quantidade");
            Date inicio = rs.getDate("INICIO");
            Date fim = rs.getDate("FIM");
            TurmaPlanejada turma = new TurmaPlanejada();
            Set<Fase> fases = new HashSet<Fase>();
            Fase fase = new Fase();
            fase.setDataInicio(inicio);
            fase.setDataTermino(fim);
            fases.add(fase);
            siglaOrganizacao = corrigirLocal(siglaOrganizacao);
            Organizacao organizacao = organizacaoDAO.findBySigla(siglaOrganizacao);
            if (organizacao == null) {
                System.out.println(siglaOrganizacao);
                continue;
            }
            Curso curso = cursoDAO.findByCodigo(codigoCurso);
            if (curso == null) {
                System.out.println(codigoCurso);
                continue;
            }
            ItemPlanejamento item = null;
            for (ItemPlanejamentoDTO itemPlanejamentoDTO : itens) {
                if (itemPlanejamentoDTO.getCurso().getId().equals(curso.getId())) {
                    item = new ItemPlanejamento(itemPlanejamentoDTO);
                }
            }
            if (item == null) {
                System.out.println(codigoCurso);
            }
            turma.setResponsavelId(organizacao.getId());
            turma.setFases(fases);
            turma.setItemPlanejamento(item);
            turma.setCurso(curso);
            turma.setQuantidadeVagas(quantidade);
        // turmaDAO.create(turma);
        // if (solicitacao.getItemPlanejamento() == null) {
        // //System.out.println("sem sigla" + codigoCurso);
        // }
        // 
        // 
        // 
        // //           solicitacao.setPlanejamento(planejamento);
        // System.out.println(curso.getId());
        // System.out.println(organizacao.getId());
        // System.out.println(planejamento.getId());
        // System.out.println(quantidade);
        // curso.setPlano(plano.find(1L));
        }
        conn.close();
    } catch (SQLException ex) {
        ex.printStackTrace();
    } catch (DAOException ex) {
        ex.printStackTrace();
    }
}
Also used : TurmaPlanejada(com.tomasio.projects.trainning.model.TurmaPlanejada) Fase(com.tomasio.projects.trainning.model.Fase) DAOException(com.tomasio.projects.trainning.exception.DAOException) Organizacao(com.tomasio.projects.trainning.model.Organizacao) Curso(com.tomasio.projects.trainning.model.Curso) ItemPlanejamento(com.tomasio.projects.trainning.model.ItemPlanejamento) HashSet(java.util.HashSet) ItemPlanejamento(com.tomasio.projects.trainning.model.ItemPlanejamento) Planejamento(com.tomasio.projects.trainning.model.Planejamento)

Example 5 with TurmaPlanejada

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

the class PlanningServiceSimpleImpl method updateTurma.

@Override
@Transactional
public void updateTurma(TurmaDTO turma) {
    TurmaPlanejada _turma = new TurmaPlanejada((TurmaPlanejadaDTO) turma);
    TurmaDAO dao = factory.getTurmaDAO();
    try {
        dao.update(_turma);
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
}
Also used : TurmaPlanejada(com.tomasio.projects.trainning.model.TurmaPlanejada) DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

TurmaPlanejada (com.tomasio.projects.trainning.model.TurmaPlanejada)6 DAOException (com.tomasio.projects.trainning.exception.DAOException)5 TurmaPlanejadaDTO (com.tomasio.projects.trainning.dto.TurmaPlanejadaDTO)3 CoreException (com.tomasio.projects.trainning.exeption.CoreException)2 Turma (com.tomasio.projects.trainning.model.Turma)2 ArrayList (java.util.ArrayList)2 Criteria (org.hibernate.Criteria)2 HibernateException (org.hibernate.HibernateException)2 Session (org.hibernate.Session)2 Transactional (org.springframework.transaction.annotation.Transactional)2 TurmaEfetivaDTO (com.tomasio.projects.trainning.dto.TurmaEfetivaDTO)1 Curso (com.tomasio.projects.trainning.model.Curso)1 Fase (com.tomasio.projects.trainning.model.Fase)1 ItemPlanejamento (com.tomasio.projects.trainning.model.ItemPlanejamento)1 Organizacao (com.tomasio.projects.trainning.model.Organizacao)1 Planejamento (com.tomasio.projects.trainning.model.Planejamento)1 StatusTurmaEfetiva (com.tomasio.projects.trainning.model.StatusTurmaEfetiva)1 TurmaEfetiva (com.tomasio.projects.trainning.model.TurmaEfetiva)1 HashSet (java.util.HashSet)1 Disjunction (org.hibernate.criterion.Disjunction)1