Search in sources :

Example 1 with ResponsavelArea

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

the class PlanningServiceSimpleImpl method createResponsavelArea.

@Override
@Transactional
public Long createResponsavelArea(ResponsavelAreaDTO responsavelArea) {
    ResponsavelAreaDAO dao = factory.getResponsavelAreaDAO();
    ResponsavelArea _responsavelArea = new ResponsavelArea(responsavelArea);
    Long id = null;
    try {
        id = dao.create(_responsavelArea);
    } 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) ResponsavelArea(com.tomasio.projects.trainning.model.ResponsavelArea) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with ResponsavelArea

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

the class PlanningServiceSimpleImpl method findAllResponsaveisAreas.

@Override
@Transactional(readOnly = true)
public ResponsavelAreaDTO[] findAllResponsaveisAreas() {
    ResponsavelAreaDAO dao = factory.getResponsavelAreaDAO();
    ResponsavelAreaDTO[] responsaveisAreasArray = null;
    try {
        List<ResponsavelArea> responsaveisAreas = dao.findAll();
        if (responsaveisAreas != null) {
            responsaveisAreasArray = new ResponsavelAreaDTO[responsaveisAreas.size()];
            for (int i = 0; i < responsaveisAreas.size(); i++) {
                responsaveisAreasArray[i] = responsaveisAreas.get(i).createDTO();
            }
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    return responsaveisAreasArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) ResponsavelArea(com.tomasio.projects.trainning.model.ResponsavelArea) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with ResponsavelArea

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

the class HibernateResponsavelAreaDAO method remove.

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

Example 4 with ResponsavelArea

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

the class PlanningServiceSimpleImpl method findAllResponsaveisAreas.

@Override
@Transactional(readOnly = true)
public ResponsavelAreaDTO[] findAllResponsaveisAreas(Long planejamentoId) {
    ResponsavelAreaDAO dao = factory.getResponsavelAreaDAO();
    ResponsavelAreaDTO[] responsaveisAreasArray = null;
    try {
        List<ResponsavelArea> responsaveisAreas = dao.findAllByPlanejamento(planejamentoId);
        if (responsaveisAreas != null) {
            responsaveisAreasArray = new ResponsavelAreaDTO[responsaveisAreas.size()];
            for (int i = 0; i < responsaveisAreas.size(); i++) {
                responsaveisAreasArray[i] = responsaveisAreas.get(i).createDTOWithoutDependencies();
            }
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    return responsaveisAreasArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) ResponsavelArea(com.tomasio.projects.trainning.model.ResponsavelArea) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with ResponsavelArea

use of com.tomasio.projects.trainning.model.ResponsavelArea 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)6 ResponsavelArea (com.tomasio.projects.trainning.model.ResponsavelArea)6 Transactional (org.springframework.transaction.annotation.Transactional)5 CoreException (com.tomasio.projects.trainning.exeption.CoreException)3 Area (com.tomasio.projects.trainning.model.Area)2 ArrayList (java.util.ArrayList)2 HibernateException (org.hibernate.HibernateException)1 Session (org.hibernate.Session)1