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;
}
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;
}
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"));
}
}
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;
}
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()]);
}
Aggregations