Search in sources :

Example 6 with AreaDAO

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

the class TrainningServiceSimpleImpl method searchArea.

@Override
@Transactional(readOnly = true)
public AreaDTO[] searchArea(String term) {
    AreaDAO dao = factory.getAreaDAO();
    AreaDTO[] areasArray = null;
    try {
        List<Area> areas = dao.search(term);
        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 7 with AreaDAO

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

the class TrainningServiceSimpleImpl method createArea.

@Override
@Transactional
public Long createArea(AreaDTO dto) {
    AreaDAO dao = factory.getAreaDAO();
    Area _area = new Area(dto);
    Long id = null;
    try {
        id = dao.create(_area);
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    return id;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Area(com.tomasio.projects.trainning.model.Area) CoreException(com.tomasio.projects.trainning.exeption.CoreException) AreaDAO(com.tomasio.projects.trainning.dao.AreaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AreaDAO (com.tomasio.projects.trainning.dao.AreaDAO)7 DAOException (com.tomasio.projects.trainning.exception.DAOException)7 CoreException (com.tomasio.projects.trainning.exeption.CoreException)7 Area (com.tomasio.projects.trainning.model.Area)7 Transactional (org.springframework.transaction.annotation.Transactional)7 AreaDTO (com.tomasio.projects.trainning.dto.AreaDTO)4 ArrayList (java.util.ArrayList)1