@@ -0,0 +1,2487 @@
+package uk.ac.ebi.phenotype.dao;%0A%0Aimport java.sql.PreparedStatement;%0Aimport java.sql.ResultSet;%0Aimport java.sql.SQLException;%0Aimport java.util.HashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0Aimport org.hibernate.Session;%0Aimport org.hibernate.SessionFactory;%0Aimport org.hibernate.Transaction;%0Aimport org.springframework.transaction.annotation.Transactional;%0A%0Aimport uk.ac.ebi.phenotype.pojo.Population;%0A%0Apublic class PopulationDAOImpl extends HibernateDAOImpl implements PopulationDAO%7B%0A%0A%09/**%0A%09 * Creates a new Hibernate project data access manager.%0A%09 * @param sessionFactory the Hibernate session factory%0A%09 */%0A%09public PopulationDAOImpl(SessionFactory sessionFactory) %7B%0A%09%09this.sessionFactory = sessionFactory;%0A%09%7D%0A%09%0A%09@Transactional(readOnly = false)%0A%09public void deleteAllPopulations() %7B%0A%09%09%0A%09%09Session session = sessionFactory.openSession();%0A%09%09Transaction tx = session.beginTransaction();%0A%0A%09%09// Embeddable collections are not deleted with parent when%0A%09%09// doing a batch delete.  Must remove them manually.%0A%09%09// Since Synonyms are not actual hibernate entities, drop to SQL%0A%09%09// to empty the table.%0A%09%09String query = %22TRUNCATE population%22;%0A%09%09session.createSQLQuery( query ).executeUpdate();%0A%0A%09%09query = %22TRUNCATE observation_population%22;%0A%09%09session.createSQLQuery( query ).executeUpdate();%0A%0A%09%09tx.commit();%0A%09%09session.close();%0A%09%09%0A%09%7D%0A%09%0A%09@Transactional(readOnly = true)%0A%09@SuppressWarnings(%22unchecked%22)%0A%09public List%3CPopulation%3E getAllPopulations() %7B%0A%09%09return getCurrentSession().createQuery(%22from Population%22).list();%0A%09%7D%0A%09%0A%09@Transactional(readOnly = false)%0A%09public void savePopulation(Population population) %7B%0A%09%09getCurrentSession().saveOrUpdate(population);%0A%09%7D%0A%0A%09@Override%0A%09public Map%3CString, String%3E getDateOfExperimentAndTypeByObservation(Integer oid) throws SQLException %7B%0A%09%09Map%3CString,String%3E date= new HashMap%3CString,String%3E();%0A%0A%09%09String query = %22SELECT e.date_of_experiment, bs.sample_group%22%0A%09%09%09%09+ %22 FROM experiment e%22%0A%09%09%09%09+ %22 INNER JOIN experiment_observation eo ON e.id=eo.experiment_id%22%0A%09%09%09%09+ %22 INNER JOIN observation o ON eo.observation_id=o.id%22%0A%09%09%09%09+ %22 INNER JOIN biological_sample bs ON o.biological_sample_id=bs.id%22%0A%09%09%09%09+ %22 WHERE eo.observation_id=?%22;%0A%0A%09%09try (PreparedStatement statement = getConnection().prepareStatement(query))%7B%0A%09        statement.setInt(1, oid);%0A%09%09    ResultSet resultSet = statement.executeQuery();%0A%09%09%09while (resultSet.next()) %7B%0A%09%09%09%09date.put(resultSet.getString(%22date_of_experiment%22), resultSet.getString(%22sample_group%22));%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09return date;%0A%09%7D%0A%0A%0A%0A%09%0A%7D%0A

add method to get date of experiment by type and observation init commit