package com.atrium.hibernate.dao.ext;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.atrium.hibernate.Recetas;
import com.atrium.hibernate.dao.RecetasDAO;

@Component(value = "recetas_dao")
@Scope(value = "prototype")

public class Recetas_DAOEXT extends RecetasDAO{
	
	private Recetas recetas;
	
	public List<Recetas> consultar_RecetasPorIngredientes(String ingrediente1,
		String ingrediente2,String ingrediente3,String ingrediente4,String ingrediente5,
		String ingrediente6,String ingrediente7,String ingrediente8,String ingrediente9
		,String ingrediente10,String ingrediente11,String ingrediente12,String ingrediente13
		,String ingrediente14,String ingrediente15){
		
		DetachedCriteria consulta = DetachedCriteria.forClass(Recetas.class);
		recetas = new Recetas();
		
		consulta.add(Restrictions.like("ingrediente1", "%"+ingrediente1+"%"));
		//Repetir lo anterior paara los demás ingredientes
		/*consulta.add(Restrictions.like(ingrediente1, recetas.getIngrediente2()));
		consulta.add(Restrictions.like(ingrediente1, recetas.getIngrediente3()));
		consulta.add(Restrictions.like(ingrediente1, recetas.getIngrediente4()));
		consulta.add(Restrictions.like(ingrediente1, recetas.getIngrediente5()));
		consulta.add(Restrictions.like(ingrediente1, recetas.getIngrediente6()));
		consulta.add(Restrictions.like(ingrediente2, recetas.getIngrediente1()));
		consulta.add(Restrictions.like(ingrediente2, recetas.getIngrediente2()));
		consulta.add(Restrictions.like(ingrediente2, recetas.getIngrediente3()));
		consulta.add(Restrictions.like(ingrediente2, recetas.getIngrediente4()));
		consulta.add(Restrictions.like(ingrediente2, recetas.getIngrediente5()));
		consulta.add(Restrictions.like(ingrediente2, recetas.getIngrediente6()));
		consulta.add(Restrictions.like(ingrediente3, recetas.getIngrediente1()));
		consulta.add(Restrictions.like(ingrediente3, recetas.getIngrediente2()));
		consulta.add(Restrictions.like(ingrediente3, recetas.getIngrediente3()));
		consulta.add(Restrictions.like(ingrediente3, recetas.getIngrediente4()));
		consulta.add(Restrictions.like(ingrediente3, recetas.getIngrediente5()));
		consulta.add(Restrictions.like(ingrediente3, recetas.getIngrediente6()));
		consulta.add(Restrictions.like(ingrediente4, recetas.getIngrediente1()));
		consulta.add(Restrictions.like(ingrediente4, recetas.getIngrediente2()));
		consulta.add(Restrictions.like(ingrediente4, recetas.getIngrediente3()));
		consulta.add(Restrictions.like(ingrediente4, recetas.getIngrediente4()));
		consulta.add(Restrictions.like(ingrediente4, recetas.getIngrediente5()));
		consulta.add(Restrictions.like(ingrediente4, recetas.getIngrediente6()));
		consulta.add(Restrictions.like(ingrediente5, recetas.getIngrediente1()));
		consulta.add(Restrictions.like(ingrediente5, recetas.getIngrediente2()));
		consulta.add(Restrictions.like(ingrediente5, recetas.getIngrediente3()));
		consulta.add(Restrictions.like(ingrediente5, recetas.getIngrediente4()));
		consulta.add(Restrictions.like(ingrediente5, recetas.getIngrediente5()));
		consulta.add(Restrictions.like(ingrediente5, recetas.getIngrediente6()));
		consulta.add(Restrictions.like(ingrediente6, recetas.getIngrediente1()));
		consulta.add(Restrictions.like(ingrediente6, recetas.getIngrediente2()));
		consulta.add(Restrictions.like(ingrediente6, recetas.getIngrediente3()));
		consulta.add(Restrictions.like(ingrediente6, recetas.getIngrediente4()));
		consulta.add(Restrictions.like(ingrediente6, recetas.getIngrediente5()));
		consulta.add(Restrictions.like(ingrediente6, recetas.getIngrediente6()));
		
		*/
		
		List<Recetas> lista_recetas = getHibernateTemplate().findByCriteria(consulta);
		
		return lista_recetas;
	}
	
}