/*
 * 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 com.cosmodas.FacadeCosmos;

import com.cosmodas.EntCosmos.BitacorasWeb;

import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 * @author obper
 */
@Stateless
public class BitacorasWebFacade extends AbstractFacade<BitacorasWeb> implements BitacorasWebFacadeLocal {
    @PersistenceContext(unitName = "wcosmodasPersistent")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public BitacorasWebFacade() {
        super(BitacorasWeb.class);
    }

    @Override
    public List<BitacorasWeb> busquedaUsuarios(String usuarios) {

        Query q = em.createNamedQuery("BitacorasWeb.findByUsuarioCodigo");
        q.setParameter("usuarioCodigo", usuarios);
        List<BitacorasWeb> rs = q.getResultList();
        return rs;
    }

    @Override
    public List<BitacorasWeb> BitacorasPorFechas(Date fechaIn, Date fechaOut) {
        Query q = em.createNamedQuery("BitacorasWeb.findByFechasRagon");
        q.setParameter("fechaIn", fechaIn);
        q.setParameter("fechaOut", fechaOut);

        List<BitacorasWeb> rs = q.getResultList();

        return rs;
    }


}
