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));
    }
}

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 org.springframework.transaction.annotation.Transactional;

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

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

    /**
    * Finds the population based on study and the population abbreviation
    *
    * @param  study the study which you want to search for the population
    * @param  abbreviation the abbreviation for the population
    * @return      the population that corresponds to the study and the abbreviation that was passed in
    */
    @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
     *
     * @param  study the study to return the populations from
     * @return populations retrieved from 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));
    }
}

Add javadoc to planned population dao.
Add javadoc to planned population dao.

git-svn-id: 4b387fe5ada7764508e2ca96c335714e4c1692c6@2432 0d517254-b314-0410-acde-c619094fa49f
