Search in sources :

Example 1 with Area

use of com.tomasio.projects.trainning.model.Area 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 Area

use of com.tomasio.projects.trainning.model.Area 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 Area

use of com.tomasio.projects.trainning.model.Area 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 Area

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

the class HibernateAreaDAO method remove.

@Override
public void remove(Long id) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    Area area = (Area) session.get(Area.class, id);
    try {
        session.delete(area);
    } catch (HibernateException e) {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("areas.remove.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Area(com.tomasio.projects.trainning.model.Area) HibernateException(org.hibernate.HibernateException) Session(org.hibernate.Session)

Example 5 with Area

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

the class PlanningServiceSimpleImpl method findAllResponsaveisAnalise.

@Override
@Transactional(readOnly = true)
public ResponsavelAreaDTO[] findAllResponsaveisAnalise(Long planejamentoId, Long areaId) {
    AreaDAO areaDAO = factory.getAreaDAO();
    Area area = null;
    try {
        area = areaDAO.find(areaId);
    } catch (DAOException ex) {
        Logger.getLogger(PlanningServiceSimpleImpl.class.getName()).log(Level.SEVERE, null, ex);
    }
    List<AreaDTO> areasAnalise = this.arrangeAreasByHierarchyUp(area.createDTO());
    ResponsavelAreaDTO[] responsaveisAreas = findAllResponsaveisAreas(planejamentoId);
    List<ResponsavelAreaDTO> responsaveisAnalise = new ArrayList<ResponsavelAreaDTO>();
    for (AreaDTO areaAnalise : areasAnalise) {
        for (ResponsavelAreaDTO responsavelArea : responsaveisAreas) {
            if (responsavelArea.getArea().equals(areaAnalise)) {
                responsaveisAnalise.add(responsavelArea);
            // break;
            }
        }
    }
    return responsaveisAnalise.toArray(new ResponsavelAreaDTO[responsaveisAnalise.size()]);
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) ResponsavelArea(com.tomasio.projects.trainning.model.ResponsavelArea) Area(com.tomasio.projects.trainning.model.Area) ArrayList(java.util.ArrayList) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)10 Area (com.tomasio.projects.trainning.model.Area)10 Transactional (org.springframework.transaction.annotation.Transactional)9 AreaDAO (com.tomasio.projects.trainning.dao.AreaDAO)7 CoreException (com.tomasio.projects.trainning.exeption.CoreException)7 AreaDTO (com.tomasio.projects.trainning.dto.AreaDTO)4 ArrayList (java.util.ArrayList)3 ResponsavelArea (com.tomasio.projects.trainning.model.ResponsavelArea)2 HibernateException (org.hibernate.HibernateException)1 Session (org.hibernate.Session)1