Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package br.com.dasa.hepic; import br.com.hibernate.entities.LabSistema; import br.com.hibernate.utils.OracleHelper; import br.com.hibernate.utils.SessionFactoriByDBName; import br.com.wservice.StaticsQuery; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.Transaction; import pt.first.hepic.ws.lab.Antibiogram; /** * * @author f12684146896 */ public class SqlDaoHepic { public List<ExameEnvioHepic> buscaExameHepic(LabSistema sistema, String strDbName) { Session session = null; Transaction tx = null; List<ExameEnvioHepic> listExameEnvioHepic = new ArrayList<ExameEnvioHepic>(); try { session = SessionFactoriByDBName.getCurrentSession4FacesByDbName(strDbName); tx = session.beginTransaction(); Query query = session.createSQLQuery(StaticsQuery.SQLHEPICEXAME); query.setString("uniStCodigo", sistema.getUniStCodigo().getUniStCodigo()); query.setString("sisStCodigo", sistema.getSisStCodigo()); List list = query.list(); tx.commit(); if (list != null && !list.isEmpty()) { for (int i = 0; i < list.size(); i++) { ExameEnvioHepic exameEnvioHepic = new ExameEnvioHepic(); Object[] tupla = (Object[]) list.get(i); exameEnvioHepic.setReqStCodigo((String) tupla[0]); exameEnvioHepic.setExaStCodigo((String) tupla[1]); exameEnvioHepic.setSeqStCodigo((String) tupla[2]); exameEnvioHepic.setExaStDescricao((String) tupla[3]); exameEnvioHepic.setDerDtEntradaMat((Date) tupla[4]); exameEnvioHepic.setReqStCodigoAlt((String) tupla[5]); exameEnvioHepic.setPacStNome((String) tupla[6]); exameEnvioHepic.setDerDtAssinatura((Date) tupla[7]); exameEnvioHepic.setMatStCodigo((String) tupla[8]); exameEnvioHepic.setMatStDescricao((String) tupla[9]); exameEnvioHepic.setPacStProntuario((String) tupla[10]); exameEnvioHepic.setReq_bl_infoauxiliar((String) tupla[11]); exameEnvioHepic.setDepStCodigo((String) tupla[12]); // exameEnvioHepic.setExaChGrupo((String) tupla[13]); exameEnvioHepic.setDerInCodigo((BigDecimal) tupla[14]); listExameEnvioHepic.add(exameEnvioHepic); } } } finally { if (session != null && session.isOpen()) { session.close(); } } return listExameEnvioHepic; } public List<AntibiogramaResultado> buscaResultadoTsa(String reqStCodigo, String strDbName) { List<AntibiogramaResultado> listResulTsa = null; Session session = null; Transaction tx = null; try { session = SessionFactoriByDBName.getCurrentSession4FacesByDbName(strDbName); tx = session.beginTransaction(); Query query = session.createSQLQuery(StaticsQuery.RESULTADOTSAHEPIC); query.setString("reqStCodigo", reqStCodigo); List list = query.list(); tx.commit(); if (list != null && !list.isEmpty()) { listResulTsa = new ArrayList<AntibiogramaResultado>(); for (int i = 0; i < list.size(); i++) { AntibiogramaResultado antibiogramaResultado = new AntibiogramaResultado(); Object[] tupla = (Object[]) list.get(i); antibiogramaResultado.setReqStCodigo((String) tupla[0]); antibiogramaResultado.setSeqStCodigo((String) tupla[1]); antibiogramaResultado.setResStIngresso((String) tupla[2]); antibiogramaResultado.setResStResultado((String) tupla[3]); listResulTsa.add(antibiogramaResultado); } } } finally { if (session != null && session.isOpen()) { session.close(); } } return listResulTsa; } }