/*
 * 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.ArticuloSala;
import com.cosmodas.EntCosmos.Productosucursal;

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

/**
 * @author obper
 */
@Stateless
public class ArticuloSalaFacade extends AbstractFacade<ArticuloSala> implements ArticuloSalaFacadeLocal {

    @PersistenceContext(unitName = "wcosmodasPersistent")
    private EntityManager em;

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

    public ArticuloSalaFacade() {
        super(ArticuloSala.class);
    }

    @Override
    public List<Productosucursal> ObtenerArticulos(String premioCodigo, String sucursalCodigo) {
        List<Productosucursal> lsR = new ArrayList<>();
        lsR = em.createNativeQuery("{CALL valida_premio_productosucursal(?,?)}",
                Productosucursal.class)
                .setParameter(1, premioCodigo)
                .setParameter(2, sucursalCodigo).getResultList();
        return lsR;

    }
}
