package org.sakaiproject.wontovlab.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.sakaiproject.wontovlab.dao.ExperimentDao;
import org.sakaiproject.wontovlab.model.Drug;
import org.sakaiproject.wontovlab.model.Equipment;
import org.sakaiproject.wontovlab.model.Experiment;
import org.sakaiproject.wontovlab.model.Material;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 * Implementations of any specialized DAO methods from the specialized DAO 
 * that allows the developer to extend the functionality of the generic dao package
 * @author Sakai App Builder -AZ
 */
public class ExperimentDaoImpl 
	extends HibernateDaoSupport 
		implements ExperimentDao {

	private static Log log = LogFactory.getLog(ExperimentDaoImpl.class);

	public void init() {
		log.debug("init");
	}
	
	public List findAllExperiments() {
		//List teste = getHibernateTemplate().find("from Materials");
		return getHibernateTemplate().find("from Experiment");
	}
	
	public List findExperimentByExperimentName(String experimentName) {
		return getHibernateTemplate().find("from Experiment e where e.name=?", experimentName);
	}
	
	public List findExperimentByExperimentId(Long experimentId) {
		return getHibernateTemplate().find("from Experiment e where e.experimentId=?", experimentId);
	}
	

	
	public boolean saveExperiment(Experiment l) {
		getHibernateTemplate().saveOrUpdate(l);
		return true;
	}
	

	public boolean deleteExperiment(Experiment l)
	{
		getHibernateTemplate().delete(l);
		return true;
	}
	
	/*public List findByLocation(String locationId)
	{
		return getHibernateTemplate().find("from WebLab w where w.locationId = ?", locationId);
	}*/

}
