package com.rjconsultores.ventaboletos.dao.hibernate;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import com.rjconsultores.ventaboletos.dao.GP_PricingImporteDAO;
import com.rjconsultores.ventaboletos.entidad.GP_Pricing;
import com.rjconsultores.ventaboletos.entidad.GP_PricingImporte;
import com.rjconsultores.ventaboletos.entidad.Moneda;

@Repository("gp_pricingImporteDAO")
public class GP_PricingImporteHibernateDAO extends GenericHibernateDAO<GP_PricingImporte, Integer>
		implements GP_PricingImporteDAO {

	@Autowired
	public GP_PricingImporteHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
		setSessionFactory(factory);
	}

	@Override
	public List<GP_PricingImporte> obtenerTodos() {
		Criteria c = getSession().createCriteria(getPersistentClass());
		c.add(Restrictions.eq(ACTIVO, GP_Pricing.ATIVO));

		return c.list();
	}

	public List<GP_PricingImporte> buscarMoneda(GP_PricingImporte pricingImporte, Moneda moneda) {
		Criteria c = getSession().createCriteria(getPersistentClass());
		c.add(Restrictions.eq(ACTIVO, GP_Pricing.ATIVO));
		c.add(Restrictions.eq("pricing", pricingImporte.getPricing()));
		c.add(Restrictions.eq("moneda", moneda));

		return c.list();
	}

	@Override
	public List<GP_PricingImporte> obtenerTodoPorPricing(GP_Pricing pricing) {
		Criteria c = getSession().createCriteria(getPersistentClass());
		c.add(Restrictions.eq("pricing.pricingId", pricing.getPricingId()));

		return c.list();
	}
}
