package edu.northwestern.bioinformatics.studycalendar.dao;

import edu.northwestern.bioinformatics.studycalendar.domain.Population;
import edu.northwestern.bioinformatics.studycalendar.domain.Study;
import edu.nwu.bioinformatics.commons.CollectionUtils;

import java.util.Set;
import java.util.HashSet;

import org.springframework.transaction.annotation.Transactional;

/**
 * @author Rhett Sutphin
 */
@Transactional(readOnly = true)
public class PopulationDao extends StudyCalendarMutableDomainObjectDao<Population> {
    @Override
    public Class<Population> domainClass() {
        return Population.class;
    }

    @SuppressWarnings({ "unchecked" })
    public Population getByAbbreviation(Study study, String abbreviation) {
        return (Population) CollectionUtils.firstElement(getHibernateTemplate().find(
            "from Population p where p.abbreviation = ? and p.study = ?",
            new Object[] { abbreviation, study }));
    }

    /**
     * Collects and returns all the abbreviations for populations in the given study
     */
    @SuppressWarnings({ "unchecked" })
    public Set<String> getAbbreviations(Study study) {
        return new HashSet<String>(getHibernateTemplate().find(
            "select p.abbreviation from Population p where p.study = ?", study));
    }
}

@@ -251,58 +251,8 @@
 ls;%0A
-%0Aimport java.util.Set;%0Aimport java.util.HashSet;%0A%0A
 impo
@@ -313,16 +313,65 @@
 ional;%0A%0A
+import java.util.HashSet;%0Aimport java.util.Set;%0A%0A
 /**%0A * @
@@ -607,24 +607,360 @@
 ass;%0A    %7D%0A%0A
+    /**%0A    * Finds the population based on study and the population abbreviation%0A    *%0A    * @param  study the study which you want to search for the population%0A    * @param  abbreviation the abbreviation for the population%0A    * @return      the population that corresponds to the study and the abbreviation that was passed in%0A    */%0A
     @Suppres
@@ -1374,16 +1374,143 @@
 n study%0A
+     *%0A     * @param  study the study to return the populations from%0A     * @return populations retrieved from the given study%0A
      */%0A

Add javadoc to planned population dao.