Search in sources :

Example 86 with DAOException

use of com.tomasio.projects.trainning.exception.DAOException in project trainning by fernandotomasio.

the class TrainningServiceSimpleImpl method findAllCursos.

@Override
@Transactional(readOnly = true)
public CursoDTO[] findAllCursos(Long planoId, Long areaId, Boolean ativo, Boolean permiteEstrangeiro) {
    CursoDAO dao = factory.getCursoDAO();
    CursoDTO[] cursosArray = null;
    try {
        List<Curso> cursos = dao.findAll(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 87 with DAOException

use of com.tomasio.projects.trainning.exception.DAOException in project trainning by fernandotomasio.

the class TrainningServiceSimpleImpl method findAllAreas.

@Override
@Transactional(readOnly = true)
public AreaDTO[] findAllAreas() {
    AreaDAO dao = factory.getAreaDAO();
    AreaDTO[] areasArray = null;
    try {
        List<Area> areas = dao.findAll();
        if (areas != null) {
            areasArray = new AreaDTO[areas.size()];
            for (int i = 0; i < areas.size(); i++) {
                areasArray[i] = areas.get(i).createDTO();
            }
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    return areasArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Area(com.tomasio.projects.trainning.model.Area) CoreException(com.tomasio.projects.trainning.exeption.CoreException) AreaDTO(com.tomasio.projects.trainning.dto.AreaDTO) AreaDAO(com.tomasio.projects.trainning.dao.AreaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 88 with DAOException

use of com.tomasio.projects.trainning.exception.DAOException in project trainning by fernandotomasio.

the class UserServiceSimpleImpl method findRoleGroup.

@Override
public NetworkGroupDTO findRoleGroup(String id) {
    NetworkGroupDAO dao = factory.getNetworkGroupDAO();
    NetworkGroupDTO group = null;
    try {
        group = dao.findRole(id);
    } catch (DAOException ex) {
        throw new CoreException("Erro de acesso ao serviço de diretórios: " + ex.getMessage());
    }
    return group;
}
Also used : NetworkGroupDTO(com.tomasio.projects.trainning.dto.NetworkGroupDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) NetworkGroupDAO(com.tomasio.projects.trainning.dao.NetworkGroupDAO)

Example 89 with DAOException

use of com.tomasio.projects.trainning.exception.DAOException in project trainning by fernandotomasio.

the class UserServiceSimpleImpl method removeUser.

@Override
public void removeUser(String uid) {
    NetworkUserDAO userDAO = factory.getNetworkUserDAO();
    NetworkGroupDAO groupDAO = factory.getNetworkGroupDAO();
    try {
        NetworkUserDTO user = userDAO.find(uid);
        userDAO.remove(uid);
        NetworkGroupDTO organizationGroup = groupDAO.findOrganization(user.getOrganizacao());
        if (organizationGroup != null) {
            organizationGroup.getMembers().remove(user.getId());
            if (organizationGroup.getMembers().size() > 0) {
                groupDAO.update(organizationGroup);
            } else {
                groupDAO.removeOrganization(user.getOrganizacao());
            }
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de acesso ao serviço de diretórios: " + ex.getMessage());
    }
}
Also used : NetworkGroupDTO(com.tomasio.projects.trainning.dto.NetworkGroupDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) NetworkUserDTO(com.tomasio.projects.trainning.dto.NetworkUserDTO) CoreException(com.tomasio.projects.trainning.exeption.CoreException) NetworkUserDAO(com.tomasio.projects.trainning.dao.NetworkUserDAO) NetworkGroupDAO(com.tomasio.projects.trainning.dao.NetworkGroupDAO)

Example 90 with DAOException

use of com.tomasio.projects.trainning.exception.DAOException in project trainning by fernandotomasio.

the class UserServiceSimpleImpl method updateUser.

@Override
@Transactional(readOnly = true)
public void updateUser(NetworkUserDTO user) {
    NetworkUserDAO userDAO = factory.getNetworkUserDAO();
    NetworkGroupDAO groupDAO = factory.getNetworkGroupDAO();
    OrganizacaoDAO organizacaoDAO = factory.getOrganizacaoDAO();
    try {
        NetworkUserDTO oldUser = userDAO.find(user.getLogin());
        userDAO.update(user);
        if (!oldUser.getOrganizacao().equals(user.getOrganizacao())) {
            // REMOVER DO GRUPO DA ORGANIZAÇÃO ANTIGA
            NetworkGroupDTO oldOrganizationGroup = groupDAO.findOrganization(oldUser.getOrganizacao());
            if (oldOrganizationGroup != null) {
                oldOrganizationGroup.getMembers().remove(oldUser.getId());
                if (oldOrganizationGroup.getMembers().size() > 0) {
                    groupDAO.update(oldOrganizationGroup);
                } else {
                    groupDAO.removeOrganization(oldUser.getOrganizacao());
                }
            }
            // ADICIONAR AO GRUPO DA ORGANIZAÇÃO NOVA
            Organizacao organizacao = organizacaoDAO.findBySigla(user.getOrganizacao());
            NetworkGroupDTO organizationGroup = groupDAO.findOrganization(organizacao.getSigla());
            if (organizationGroup == null) {
                organizationGroup = new NetworkGroupDTO();
                organizationGroup.setNome(organizacao.getSigla());
                organizationGroup.setDescricao(organizacao.getNome());
                organizationGroup.getMembers().add(user.getId());
                groupDAO.createOrganization(organizationGroup);
            } else {
                organizationGroup.getMembers().add(user.getId());
                groupDAO.update(organizationGroup);
            }
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de acesso ao serviço de diretórios: " + ex.getMessage());
    }
}
Also used : NetworkGroupDTO(com.tomasio.projects.trainning.dto.NetworkGroupDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) OrganizacaoDAO(com.tomasio.projects.trainning.dao.OrganizacaoDAO) NetworkUserDTO(com.tomasio.projects.trainning.dto.NetworkUserDTO) Organizacao(com.tomasio.projects.trainning.model.Organizacao) CoreException(com.tomasio.projects.trainning.exeption.CoreException) NetworkUserDAO(com.tomasio.projects.trainning.dao.NetworkUserDAO) NetworkGroupDAO(com.tomasio.projects.trainning.dao.NetworkGroupDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)643 CoreException (com.tomasio.projects.trainning.exeption.CoreException)388 Transactional (org.springframework.transaction.annotation.Transactional)385 HibernateException (org.hibernate.HibernateException)186 Session (org.hibernate.Session)186 ParseException (java.text.ParseException)112 Organizacao (com.tomasio.projects.trainning.model.Organizacao)77 ArrayList (java.util.ArrayList)57 Criteria (org.hibernate.Criteria)51 Pessoa (com.tomasio.projects.trainning.model.Pessoa)46 IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)37 OrganizacaoDTO (com.tomasio.projects.trainning.dto.OrganizacaoDTO)37 TurmaEfetiva (com.tomasio.projects.trainning.model.TurmaEfetiva)33 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)32 PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)30 StatusTurmaEfetiva (com.tomasio.projects.trainning.model.StatusTurmaEfetiva)30 Matricula (com.tomasio.projects.trainning.model.Matricula)29 SimpleDateFormat (java.text.SimpleDateFormat)28 MatriculaDAO (com.tomasio.projects.trainning.dao.MatriculaDAO)26 TurmaDAO (com.tomasio.projects.trainning.dao.TurmaDAO)26