Search in sources :

Example 91 with DAOException

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

the class UserServiceSimpleImpl method createUser.

@Override
@Transactional(readOnly = true)
public void createUser(NetworkUserDTO user) {
    NetworkUserDAO userDAO = factory.getNetworkUserDAO();
    NetworkGroupDAO groupDAO = factory.getNetworkGroupDAO();
    OrganizacaoDAO organizacaoDAO = factory.getOrganizacaoDAO();
    try {
        userDAO.create(user);
        user = userDAO.find(user.getLogin());
        NetworkGroupDTO roleGroup = groupDAO.findRole("OperadorLocal");
        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);
        }
        roleGroup.getMembers().add(user.getId());
        groupDAO.update(roleGroup);
    } 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) 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)

Example 92 with DAOException

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

the class UserServiceSimpleImpl method createUser.

@Override
@Transactional(readOnly = true)
public void createUser(NetworkUserDTO user, String[] roles) {
    NetworkUserDAO userDAO = factory.getNetworkUserDAO();
    NetworkGroupDAO groupDAO = factory.getNetworkGroupDAO();
    OrganizacaoDAO organizacaoDAO = factory.getOrganizacaoDAO();
    try {
        userDAO.create(user);
        user = userDAO.find(user.getLogin());
        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);
        }
        if (roles != null) {
            for (String role : roles) {
                NetworkGroupDTO roleGroup = groupDAO.findRole(role);
                roleGroup.getMembers().add(user.getId());
                groupDAO.update(roleGroup);
            }
        }
    } 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) 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)

Example 93 with DAOException

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

the class UserServiceSimpleImpl method findAllRoleGroups.

@Override
public NetworkGroupDTO[] findAllRoleGroups() {
    NetworkGroupDAO dao = factory.getNetworkGroupDAO();
    NetworkGroupDTO[] groupsArray = null;
    try {
        List<NetworkGroupDTO> groups = dao.findAllRoles();
        if (groups != null) {
            groupsArray = new NetworkGroupDTO[groups.size()];
            groups.toArray(groupsArray);
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de acesso ao serviço de diretórios: " + ex.getMessage());
    }
    return groupsArray;
}
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 94 with DAOException

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

the class UserServiceSimpleImpl method authenticate.

@Override
public NetworkUserDTO authenticate(String uid, String password) {
    NetworkUserDAO dao = factory.getNetworkUserDAO();
    NetworkUserDTO user = null;
    try {
        user = dao.authenticate(uid, password);
    } catch (DAOException ex) {
        ex.printStackTrace();
    }
    return user;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) NetworkUserDTO(com.tomasio.projects.trainning.dto.NetworkUserDTO) NetworkUserDAO(com.tomasio.projects.trainning.dao.NetworkUserDAO)

Example 95 with DAOException

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

the class UserServiceSimpleImpl method findAllUsers.

@Override
public NetworkUserDTO[] findAllUsers() {
    NetworkUserDAO dao = factory.getNetworkUserDAO();
    NetworkUserDTO[] usersArray = null;
    try {
        List<NetworkUserDTO> users = dao.findAll();
        if (users != null) {
            usersArray = new NetworkUserDTO[users.size()];
            users.toArray(usersArray);
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de acesso ao serviço de diretórios: " + ex.getMessage());
    }
    return usersArray;
}
Also used : 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)

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