/*
 * 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.RepartoEmpaque;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

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

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

    public RepartoEmpaqueFacade() {
        super(RepartoEmpaque.class);
    }

    @Override
    public RepartoEmpaque busquedaEtiqueta(String consultorCodigo, String programaCodigo) {
        try {
            Query q = em.createNamedQuery("RepartoEmpaque.findByConsultorCodigoAndPrograma");
            q.setParameter("consultorCodigo", consultorCodigo);
            q.setParameter("codigoPrograma", programaCodigo);
            return (RepartoEmpaque) q.getResultList().get(0);
        } catch (Exception e) {
            return null;
        }

    }


}
