List of usage examples for javax.persistence EntityManagerFactory createEntityManager
public EntityManager createEntityManager();
EntityManager
. From source file:Logica.Usuario.java
@Override public ArrayList<Integer> numerosDeOrdenRecibidas() throws RemoteException { EntityManagerFactory emf = Persistence.createEntityManagerFactory("Biot_ServerPU"); EntityManager em = emf.createEntityManager(); Query q = em.createNamedQuery("Recepcion.findAllOrdenes"); List<Ordencompra> resultList = q.getResultList(); ArrayList<Integer> numorden = new ArrayList<>(); for (Ordencompra r : resultList) { numorden.add(r.getNumOrden().intValue()); }//w w w. ja v a2 s.co m return numorden; }
From source file:Logica.Usuario.java
/** * * @param numorden/* w ww . j ava 2s . c o m*/ * @return * @throws RemoteException */ @Override public evProv getEvaluacionProv(double numorden) throws RemoteException { EntityManagerFactory emf = Persistence.createEntityManagerFactory("Biot_ServerPU"); EntityManager em = emf.createEntityManager(); Query q = em.createNamedQuery("Evaluacionprov.findByNumorden"); q.setParameter("numorden", numorden); List<Evaluacionprov> resultList = q.getResultList(); evProv ev = null; for (Evaluacionprov e : resultList) { ev = new evProv(e.getNitProv(), e.getNumorden(), e.getEv1(), e.getEv2(), e.getEv3(), e.getEv4(), e.getEv5(), e.getEv6(), e.getEv7(), e.getEv8()); } emf.close(); return ev; }
From source file:Logica.Usuario.java
/** * * @param numSol// ww w .j a v a 2 s. c om * @param cinterno * @return * @throws RemoteException */ @Override public String getCantAprobada(String numSol, String cinterno) throws RemoteException { EntityManagerFactory emf = Persistence.createEntityManagerFactory("Biot_ServerPU"); EntityManager em = emf.createEntityManager(); ItemJpaController itm = new ItemJpaController(emf); Item findItem = itm.findItem(cinterno); Query q = em.createNamedQuery("Itxsol.findSol_Item"); q.setParameter("numSol", new BigDecimal(numSol)); q.setParameter("cinterno", findItem); List<Itxsol> resultList = q.getResultList(); for (Itxsol r : resultList) { System.out.println(r.getCinterno().getCinterno()); } emf.close(); return resultList.get(0).getCantidadaprobada().toString(); }
From source file:Logica.Usuario.java
@Override public Double buscarPrecio(ItemInventario i, String proveedor) throws RemoteException { EntityManagerFactory emf = Persistence.createEntityManagerFactory("Biot_ServerPU"); EntityManager em = emf.createEntityManager(); Query q = em.createNamedQuery("Itmxorden.findByAllParameters3"); q.setParameter("numsol", new Double(i.getNumSolAsociado())); q.setParameter("nit", new ProveedorJpaController(emf).findProveedor(proveedor)); q.setParameter("caprobada", i.getCantidadAprobada()); q.setParameter("cinterno", new ItemJpaController(emf).findItem(i.getNumero())); List<Itmxorden> resultList = q.getResultList(); double precio = 0; if (!resultList.isEmpty() && resultList != null) { precio = resultList.get(0).getPrecioU(); }//from w w w .j a v a2s . c o m emf.close(); return new Double(precio); }
From source file:Logica.Usuario.java
@Override public int buscarOcompra(ItemInventario i, String proveedor) throws RemoteException { EntityManagerFactory emf = Persistence.createEntityManagerFactory("Biot_ServerPU"); EntityManager em = emf.createEntityManager(); Query q = em.createNamedQuery("Itmxorden.findByAllParameters2"); q.setParameter("numsol", new Double(i.getNumSolAsociado())); q.setParameter("nit", new ProveedorJpaController(emf).findProveedor(proveedor)); q.setParameter("caprobada", i.getCantidadAprobada()); q.setParameter("precio", i.getPrecio()); q.setParameter("cinterno", new ItemJpaController(emf).findItem(i.getNumero())); List<Itmxorden> resultList = q.getResultList(); double numorden = -1; if (!resultList.isEmpty() && resultList != null) { numorden = resultList.get(0).getNumorden(); }/* w w w . j a va 2 s . co m*/ emf.close(); return new Double(numorden).intValue(); }
From source file:Logica.Usuario.java
@Override public int buscarOrdenByNumSol(ItemInventario i, String proveedor, String numSol) throws RemoteException { EntityManagerFactory emf = Persistence.createEntityManagerFactory("Biot_ServerPU"); EntityManager em = emf.createEntityManager(); Query q = em.createNamedQuery("Itmxorden.findByAllParameters2"); q.setParameter("nit", new ProveedorJpaController(emf).findProveedor(proveedor)); q.setParameter("caprobada", i.getCantidadAprobada()); q.setParameter("precio", i.getPrecio()); q.setParameter("cinterno", new ItemJpaController(emf).findItem(i.getNumero())); q.setParameter("numsol", new Double(numSol)); List<Itmxorden> resultList = q.getResultList(); double numorden = -1; if (resultList != null && !resultList.isEmpty() && resultList.get(0) != null) { numorden = resultList.get(0).getNumorden(); }//from w w w.j a v a 2 s.co m emf.close(); return new Double(numorden).intValue(); }
From source file:Logica.Usuario.java
/** * * @param e/*from w w w . j ava 2s.c om*/ * @throws RemoteException */ @Override public void borrarEvaluacion(evProv e) throws RemoteException { EntityManagerFactory emf = Persistence.createEntityManagerFactory("Biot_ServerPU"); EntityManager em = emf.createEntityManager(); Query q = em.createNamedQuery("Evaluacionprov.findByNumorden"); q.setParameter("numorden", e.getNumorden()); List<Evaluacionprov> ev = q.getResultList(); EvaluacionprovJpaController contr = new EvaluacionprovJpaController(emf); for (Evaluacionprov ee : ev) { try { contr.destroy(ee.getId()); } catch (NonexistentEntityException ex) { Logger.getLogger(Usuario.class.getName()).log(Level.SEVERE, null, ex); } } emf.close(); }
From source file:Logica.Usuario.java
/** * * @param descripcion/*from w w w . j a v a 2s. c om*/ * @param presentacion * @param inv * @return * @throws RemoteException */ @Override public ArrayList<ItemInventario> busquedaItem(String descripcion, String presentacion, String inv) throws RemoteException { EntityManagerFactory emf = Persistence.createEntityManagerFactory("Biot_ServerPU"); EntityManager em = emf.createEntityManager(); Query q = em.createNamedQuery("Item.busqueda"); q.setParameter("descripcion", "%" + descripcion + "%"); q.setParameter("presentacion", "%" + presentacion + "%"); q.setParameter("inv", "%" + inv + "%"); List<Item> resultList = q.getResultList(); if (resultList == null) { emf.close(); return new ArrayList<>(); } else { ArrayList<ItemInventario> lstRetorno = new ArrayList<>(); for (Item i : resultList) { lstRetorno.add(i.EntityToItem(i)); } emf.close(); return lstRetorno; } }
From source file:Logica.Usuario.java
/** * * @param parametro = nombre o id/* ww w .j a v a 2s .c om*/ * @param valor = cadena de entrada para realizar la bsqueda * @return ArrayList * @throws RemoteException * * Busca todos los usuarios que tienen un "valor" parecido o igual al * ingresado */ @Override public ArrayList<BuscarUsuario> buscarEmpleado(String parametro, String valor) throws RemoteException { EntityManagerFactory emf = Persistence.createEntityManagerFactory("Biot_ServerPU"); EntityManager em = emf.createEntityManager(); Query qNombre = em.createNamedQuery("Usuario.findByNombre"); Query qId = em.createNamedQuery("Usuario.findById"); ArrayList<BuscarUsuario> lista = new ArrayList<>(); if (parametro.equalsIgnoreCase("nombre")) { qNombre.setParameter("nombre", "%" + valor + "%"); List<Entities.Usuario> resultList = qNombre.getResultList(); for (Entities.Usuario u : resultList) { lista.add(u.UsuarioToBuscarUsuario(u)); } } else if (parametro.equalsIgnoreCase("id")) { qId.setParameter("id", "%" + valor + "%"); List<Entities.Usuario> resultList = qId.getResultList(); for (Entities.Usuario u : resultList) { lista.add(u.UsuarioToBuscarUsuario(u)); } } emf.close(); return lista; }
From source file:Logica.Usuario.java
@Override public ArrayList<ItemInventario> getItemxProveedorSolicitudes(String proveedor, String generado) throws RemoteException { EntityManagerFactory emf = Persistence.createEntityManagerFactory("Biot_ServerPU"); EntityManager em = emf.createEntityManager(); Query q = em.createNamedQuery("Itxsol.findItemByProveedor"); q.setParameter("nit", proveedor); List<Itxsol> resultList = q.getResultList(); ArrayList<ItemInventario> listaItems = new ArrayList<>(); for (Itxsol i : resultList) { if (i.getGenerado().equalsIgnoreCase(generado)) { Item cinterno = i.getCinterno(); ItemInventario EntityToItem = cinterno.EntityToItem(cinterno); EntityToItem.setNumSolAsociado(Double.toString(i.getNumSol())); EntityToItem.setCantidadAprobada(i.getCantidadaprobada().floatValue()); listaItems.add(EntityToItem); }/*from w w w. ja va 2 s . co m*/ } if (!resultList.isEmpty()) { emf.close(); return listaItems; } else { emf.close(); return null; } }