Search in sources :

Example 6 with Disciplina

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

the class TeachingDocumentsServiceSimpleImpl method createDisciplina.

@Override
@Transactional
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public Long createDisciplina(DisciplinaDTO disciplina) {
    DisciplinaDAO dao = factory.getDisciplinaDAO();
    Disciplina model = new Disciplina(disciplina);
    Long id = null;
    try {
        id = dao.create(model);
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    } catch (Exception ex) {
        throw new CoreException("Erro de sistema: " + ex.getMessage());
    }
    return id;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Disciplina(com.tomasio.projects.trainning.model.Disciplina) ObjetivoDisciplina(com.tomasio.projects.trainning.model.ObjetivoDisciplina) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with Disciplina

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

the class TeachingDocumentsServiceSimpleImpl method updateDisciplina.

@Override
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
@Transactional
public void updateDisciplina(DisciplinaDTO disciplina) {
    DisciplinaDAO dao = factory.getDisciplinaDAO();
    Disciplina model = new Disciplina(disciplina);
    try {
        dao.update(model);
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    } catch (Exception ex) {
        throw new CoreException("Erro de sistema: " + ex.getMessage());
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Disciplina(com.tomasio.projects.trainning.model.Disciplina) ObjetivoDisciplina(com.tomasio.projects.trainning.model.ObjetivoDisciplina) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with Disciplina

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

the class TeachingDocumentsServiceSimpleImpl method findDisciplina.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public DisciplinaDTO findDisciplina(Long id) {
    DisciplinaDAO dao = factory.getDisciplinaDAO();
    Disciplina disciplina = null;
    try {
        disciplina = dao.find(id);
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    } catch (Exception ex) {
        throw new CoreException("Erro de sistema: " + ex.getMessage());
    }
    if (disciplina != null) {
        return disciplina.createDTO();
    } else {
        return null;
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Disciplina(com.tomasio.projects.trainning.model.Disciplina) ObjetivoDisciplina(com.tomasio.projects.trainning.model.ObjetivoDisciplina) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with Disciplina

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

the class TeachingDocumentsServiceSimpleImpl method findAllDisciplinasByPUD.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public DisciplinaDTO[] findAllDisciplinasByPUD(Long pudId) {
    DisciplinaDAO dao = factory.getDisciplinaDAO();
    DisciplinaDTO[] disciplinasArray = null;
    try {
        List<Disciplina> disciplinas = dao.findAllByPUD(pudId);
        disciplinasArray = new DisciplinaDTO[disciplinas.size()];
        for (int i = 0; i < disciplinasArray.length; i++) {
            disciplinasArray[i] = disciplinas.get(i).createDTO();
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    } catch (Exception ex) {
        throw new CoreException("Erro de sistema: " + ex.getMessage());
    }
    return disciplinasArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Disciplina(com.tomasio.projects.trainning.model.Disciplina) ObjetivoDisciplina(com.tomasio.projects.trainning.model.ObjetivoDisciplina) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DisciplinaDTO(com.tomasio.projects.trainning.dto.DisciplinaDTO) ObjetivoDisciplinaDTO(com.tomasio.projects.trainning.dto.ObjetivoDisciplinaDTO) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)9 Disciplina (com.tomasio.projects.trainning.model.Disciplina)9 CoreException (com.tomasio.projects.trainning.exeption.CoreException)5 ObjetivoDisciplina (com.tomasio.projects.trainning.model.ObjetivoDisciplina)5 Transactional (org.springframework.transaction.annotation.Transactional)5 HibernateException (org.hibernate.HibernateException)4 Session (org.hibernate.Session)4 DisciplinaDTO (com.tomasio.projects.trainning.dto.DisciplinaDTO)2 ObjetivoDisciplinaDTO (com.tomasio.projects.trainning.dto.ObjetivoDisciplinaDTO)2 Criteria (org.hibernate.Criteria)2