use of com.tomasio.projects.trainning.model.Referencia in project trainning by fernandotomasio.
the class TeachingDocumentsServiceSimpleImpl method findReferencia.
@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public ReferenciaDTO findReferencia(Long id) {
ReferenciaDAO dao = factory.getReferenciaDAO();
Referencia referencia = null;
try {
referencia = dao.find(id);
} catch (DAOException ex) {
throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
} catch (Exception ex) {
throw new CoreException("Erro de sistema: " + ex.getMessage());
}
if (referencia != null) {
return referencia.createDTO();
} else {
return null;
}
}
use of com.tomasio.projects.trainning.model.Referencia in project trainning by fernandotomasio.
the class TeachingDocumentsServiceSimpleImpl method updateReferencia.
@Override
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
@Transactional
public void updateReferencia(ReferenciaDTO referencia) {
ReferenciaDAO dao = factory.getReferenciaDAO();
Referencia model = new Referencia(referencia);
try {
dao.update(model);
} catch (DAOException ex) {
throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
} catch (Exception ex) {
throw new CoreException("Erro de sistema: " + ex.getMessage());
}
}
use of com.tomasio.projects.trainning.model.Referencia in project trainning by fernandotomasio.
the class TeachingDocumentsServiceSimpleImpl method createReferencia.
@Override
@Transactional
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public Long createReferencia(ReferenciaDTO referencia) {
ReferenciaDAO dao = factory.getReferenciaDAO();
Referencia model = new Referencia(referencia);
Long id = null;
try {
id = dao.create(model);
} catch (DAOException ex) {
throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
} catch (Exception ex) {
throw new CoreException("Erro de sistema: " + ex.getMessage());
}
return id;
}
use of com.tomasio.projects.trainning.model.Referencia in project trainning by fernandotomasio.
the class TeachingDocumentsServiceSimpleImpl method findAllReferenciasByDisciplina.
@Override
@Transactional(readOnly = true)
@SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch" })
public ReferenciaDTO[] findAllReferenciasByDisciplina(Long disciplinaId) {
ReferenciaDAO dao = factory.getReferenciaDAO();
ReferenciaDTO[] referenciasArray = null;
try {
List<Referencia> referencias = dao.findAll(disciplinaId);
referenciasArray = new ReferenciaDTO[referencias.size()];
for (int i = 0; i < referenciasArray.length; i++) {
referenciasArray[i] = referencias.get(i).createDTO();
}
} catch (DAOException ex) {
throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
} catch (Exception ex) {
throw new CoreException("Erro de sistema: " + ex.toString());
}
return referenciasArray;
}
use of com.tomasio.projects.trainning.model.Referencia in project trainning by fernandotomasio.
the class HibernateReferenciaDAO method findAll.
@Override
public List<Referencia> findAll(Long disciplinaId) throws DAOException {
Session session = sessionFactory.getCurrentSession();
try {
Criteria criteria = session.createCriteria(Referencia.class);
criteria.add(Restrictions.eq("disciplina.id", disciplinaId));
@SuppressWarnings("unchecked") List<Referencia> referencias = criteria.list();
return referencias;
} catch (HibernateException e) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, e);
throw new DAOException(MessageHelper.getMessage("referencias.find.list.error"));
}
}
Aggregations