Search in sources :

Example 1 with CursoDAO

use of com.tomasio.projects.trainning.dao.CursoDAO in project trainning by fernandotomasio.

the class MatriculasLoggerAdvice method getDetails.

private String getDetails(MatriculaDTO matricula) throws DAOException {
    CursoDAO cursoDAO = factory.getCursoDAO();
    TurmaEfetivaDTO turma = matricula.getTurma();
    String codCurso = cursoDAO.find(turma.getCurso().getId()).getCodigo();
    String numeroTurma = String.valueOf(turma.getNumeroTurma());
    String texto = codCurso + "-" + numeroTurma + " (";
    texto += matricula.getPessoa().getTargetaCompletaOM();
    texto += ")";
    return texto;
}
Also used : TurmaEfetivaDTO(com.tomasio.projects.trainning.dto.TurmaEfetivaDTO) CursoDAO(com.tomasio.projects.trainning.dao.CursoDAO)

Example 2 with CursoDAO

use of com.tomasio.projects.trainning.dao.CursoDAO in project trainning by fernandotomasio.

the class TrainningServiceLoggerAdvice method logUpdateCurso.

@After("update()")
public void logUpdateCurso(JoinPoint joinPoint) {
    CursoDAO dao = factory.getCursoDAO();
    CursoDTO curso = (CursoDTO) joinPoint.getArgs()[0];
    if (curso != null) {
        try {
            curso = dao.find(curso.getId()).createDTO();
            LogDTO log = new LogDTO();
            log.setDataCriacao(new Date());
            log.setUser(getUser());
            log.setObjectId(curso.getObjectId());
            String texto = "ATUALIZADO O CURSO " + getDetails(curso);
            log.setTexto(texto);
            logger.create(log);
        } catch (DAOException ex) {
            Logger.getLogger(TrainningServiceLoggerAdvice.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) LogDTO(com.tomasio.projects.trainning.dto.LogDTO) CursoDTO(com.tomasio.projects.trainning.dto.CursoDTO) CursoDAO(com.tomasio.projects.trainning.dao.CursoDAO) Date(java.util.Date) After(org.aspectj.lang.annotation.After)

Example 3 with CursoDAO

use of com.tomasio.projects.trainning.dao.CursoDAO in project trainning by fernandotomasio.

the class TrainningServiceSimpleImpl method searchCurso.

@Override
@Transactional(readOnly = true)
public CursoDTO[] searchCurso(String searchTerm, Long planoId, Long areaId, Boolean ativo, Boolean permiteEstrangeiro) {
    CursoDAO dao = factory.getCursoDAO();
    CursoDTO[] cursosArray = null;
    try {
        List<Curso> cursos = dao.search(searchTerm, planoId, areaId, ativo, permiteEstrangeiro);
        if (cursos != null) {
            cursosArray = new CursoDTO[cursos.size()];
            for (int i = 0; i < cursos.size(); i++) {
                cursosArray[i] = cursos.get(i).createDTOWithoutDependencies();
            }
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    return cursosArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CursoDTO(com.tomasio.projects.trainning.dto.CursoDTO) Curso(com.tomasio.projects.trainning.model.Curso) CursoDAO(com.tomasio.projects.trainning.dao.CursoDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with CursoDAO

use of com.tomasio.projects.trainning.dao.CursoDAO in project trainning by fernandotomasio.

the class TrainningServiceSimpleImpl method findCursoByCodigo.

@Override
@Transactional(readOnly = true)
public CursoDTO findCursoByCodigo(String codigo) {
    CursoDAO dao = factory.getCursoDAO();
    Curso curso = null;
    try {
        curso = dao.findByCodigo(codigo);
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    if (curso != null) {
        return curso.createDTO();
    } else {
        return null;
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Curso(com.tomasio.projects.trainning.model.Curso) CursoDAO(com.tomasio.projects.trainning.dao.CursoDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with CursoDAO

use of com.tomasio.projects.trainning.dao.CursoDAO in project trainning by fernandotomasio.

the class TrainningServiceSimpleImpl method findCurso.

@Override
@Transactional(readOnly = true)
public CursoDTO findCurso(Long id) {
    CursoDAO dao = factory.getCursoDAO();
    Curso curso = null;
    try {
        curso = dao.find(id);
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    if (curso != null) {
        return curso.createDTO();
    } else {
        return null;
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Curso(com.tomasio.projects.trainning.model.Curso) CursoDAO(com.tomasio.projects.trainning.dao.CursoDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

CursoDAO (com.tomasio.projects.trainning.dao.CursoDAO)19 DAOException (com.tomasio.projects.trainning.exception.DAOException)16 Curso (com.tomasio.projects.trainning.model.Curso)12 CoreException (com.tomasio.projects.trainning.exeption.CoreException)6 Transactional (org.springframework.transaction.annotation.Transactional)6 CursoDTO (com.tomasio.projects.trainning.dto.CursoDTO)5 DAOFactory (com.tomasio.projects.trainning.dao.DAOFactory)4 HibernateCursoDAO (com.tomasio.projects.trainning.dao.HibernateCursoDAO)4 Date (java.util.Date)4 OrganizacaoDAO (com.tomasio.projects.trainning.dao.OrganizacaoDAO)3 LogDTO (com.tomasio.projects.trainning.dto.LogDTO)3 Organizacao (com.tomasio.projects.trainning.model.Organizacao)3 HibernateOrganizacaoDAO (com.tomasio.projects.trainning.dao.HibernateOrganizacaoDAO)2 ItemPlanejamentoDAO (com.tomasio.projects.trainning.dao.ItemPlanejamentoDAO)2 PlanejamentoDAO (com.tomasio.projects.trainning.dao.PlanejamentoDAO)2 ItemPlanejamentoDTO (com.tomasio.projects.trainning.dto.ItemPlanejamentoDTO)2 TurmaEfetivaDTO (com.tomasio.projects.trainning.dto.TurmaEfetivaDTO)2 Periodo (com.tomasio.projects.trainning.model.Periodo)2 SimpleDateFormat (java.text.SimpleDateFormat)2 After (org.aspectj.lang.annotation.After)2