Search in sources :

Example 1 with Campo

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

the class TeachingDocumentsServiceSimpleImpl method findCampo.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public CampoDTO findCampo(Long id) {
    CampoDAO dao = factory.getCampoDAO();
    Campo campo = null;
    try {
        campo = 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 (campo != null) {
        return campo.createDTO();
    } else {
        return null;
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Campo(com.tomasio.projects.trainning.model.Campo) 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 2 with Campo

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

the class TeachingDocumentsServiceSimpleImpl method createCampo.

@Override
@Transactional
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public Long createCampo(CampoDTO campo) {
    CampoDAO dao = factory.getCampoDAO();
    Campo model = new Campo(campo);
    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) Campo(com.tomasio.projects.trainning.model.Campo) 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 3 with Campo

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

the class TeachingDocumentsServiceSimpleImpl method updateCampo.

@Override
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
@Transactional
public void updateCampo(CampoDTO campo) {
    CampoDAO dao = factory.getCampoDAO();
    Campo model = new Campo(campo);
    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) Campo(com.tomasio.projects.trainning.model.Campo) 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 4 with Campo

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

the class TeachingDocumentsServiceSimpleImpl method findAllCampos.

@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public CampoDTO[] findAllCampos() {
    CampoDAO dao = factory.getCampoDAO();
    CampoDTO[] camposArray = null;
    try {
        List<Campo> campos = dao.findAll();
        camposArray = new CampoDTO[campos.size()];
        for (int i = 0; i < camposArray.length; i++) {
            camposArray[i] = campos.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.toString());
    }
    return camposArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Campo(com.tomasio.projects.trainning.model.Campo) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CampoDTO(com.tomasio.projects.trainning.dto.CampoDTO) 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)4 CoreException (com.tomasio.projects.trainning.exeption.CoreException)4 Campo (com.tomasio.projects.trainning.model.Campo)4 Transactional (org.springframework.transaction.annotation.Transactional)4 CampoDTO (com.tomasio.projects.trainning.dto.CampoDTO)1