Search in sources :

Example 1 with AreaDAO

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

the class TrainningServiceSimpleImpl method findArea.

@Override
@Transactional(readOnly = true)
public AreaDTO findArea(Long id) {
    AreaDAO dao = factory.getAreaDAO();
    Area area = null;
    try {
        area = dao.find(id);
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    if (!(area == null)) {
        return area.createDTO();
    } else {
        return null;
    }
}
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)

Example 2 with AreaDAO

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

the class TrainningServiceSimpleImpl method updateArea.

@Override
@Transactional
public void updateArea(AreaDTO area) {
    AreaDAO dao = factory.getAreaDAO();
    Area _area = new Area(area);
    try {
        dao.update(_area);
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
}
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)

Example 3 with AreaDAO

use of com.tomasio.projects.trainning.dao.AreaDAO 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 4 with AreaDAO

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

the class TrainningServiceSimpleImpl method findAllAreasExcept.

@Override
@Transactional(readOnly = true)
public AreaDTO[] findAllAreasExcept(Long areaId) {
    AreaDAO dao = factory.getAreaDAO();
    AreaDTO[] areasArray = null;
    try {
        List<Area> areas = dao.findAll();
        if (areas != null) {
            List<Area> filtered_areas = new ArrayList<Area>();
            for (Area area : areas) {
                if (!area.getId().equals(areaId)) {
                    filtered_areas.add(area);
                }
            }
            areasArray = new AreaDTO[filtered_areas.size()];
            for (int i = 0; i < filtered_areas.size(); i++) {
                areasArray[i] = filtered_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) ArrayList(java.util.ArrayList) AreaDTO(com.tomasio.projects.trainning.dto.AreaDTO) AreaDAO(com.tomasio.projects.trainning.dao.AreaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with AreaDAO

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

the class TrainningServiceSimpleImpl method findAllAreasByPlanejamentoId.

@Override
@Transactional(readOnly = true)
public AreaDTO[] findAllAreasByPlanejamentoId(Long planejamentoId) {
    AreaDAO dao = factory.getAreaDAO();
    AreaDTO[] areasArray = null;
    try {
        List<Area> areas = dao.findAllAreasByPlanejamento(planejamentoId);
        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)

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