public static List<OrarForm> listareOrar(String numeGrupa, String data) {
List<Orar> o = new ArrayList<Orar>();
List<Grupa> gr = new ArrayList<Grupa>();
List<OrarForm> orar = new ArrayList<OrarForm>();
OrarForm obiectOrar;
EntityManagerFactory emf = Persistence
.createEntityManagerFactory("modul3L2");
em = emf.createEntityManager();
em.getTransaction().begin();
Query query = em.createQuery(
"SELECT g FROM Grupa g WHERE g.numeGrupa=:v")
.setParameter("v",numeGrupa);
gr = (List<Grupa>) query.getResultList();
SimpleDateFormat formatDate = new SimpleDateFormat("EEEE dd/MM/YYYY");
if (!gr.isEmpty()) {
o = gr.get(0).getOrar();
}
String numeObiect;
for (Orar oIndex : o) {
obiectOrar = new OrarForm();
if (formatDate.format(oIndex.getData()).equals(data)) {
numeObiect = (String) em
.createQuery(
"SELECT o.nume FROM Obiect o WHERE o.idObiect=:v")
.setParameter("v", oIndex.getIdObiect())
.getSingleResult();
obiectOrar.setNumeObiect(numeObiect);
obiectOrar.setData(formatDate.format(oIndex.getData()));
obiectOrar.setInterval(oIndex.getIntervalOrar());
obiectOrar.setSala(String.valueOf(oIndex.getSalaCurs()));
orar.add(obiectOrar);
}
}
em.getTransaction().commit();