<commit_before>package edu.northwestern.bioinformatics.studycalendar.dao;

import edu.northwestern.bioinformatics.studycalendar.domain.ScheduledActivity;
import edu.northwestern.bioinformatics.studycalendar.domain.ScheduledCalendar;
import edu.northwestern.bioinformatics.studycalendar.domain.PlannedActivity;

import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;

/**
 * @author <NAME>
 */
public class ScheduledActivityDao extends StudyCalendarMutableDomainObjectDao<ScheduledActivity> {
    @Override public Class<ScheduledActivity> domainClass() { return ScheduledActivity.class; }

    @SuppressWarnings({ "unchecked" })
    public Collection<ScheduledActivity> getEventsByDate(ScheduledCalendar calendar, Date start, Date end) {
        StringBuilder builder = new StringBuilder("from ScheduledActivity e where e.scheduledStudySegment.scheduledCalendar = ?");
        List<Object> params = new ArrayList<Object>(3);
        params.add(calendar);
        if (start != null) {
            builder.append(" and e.currentState.date >= ?");
            params.add(start);
        }
        if (end != null) {
            builder.append(" and e.currentState.date <= ?");
            params.add(end);
        }
        return getHibernateTemplate().find(builder.toString(), params.toArray());
    }

    @SuppressWarnings({ "unchecked" })
    public Collection<ScheduledActivity> getEventsFromPlannedActivity(
        PlannedActivity source, ScheduledCalendar calendar
    ) {
        return getHibernateTemplate().find(
            "from ScheduledActivity e where e.plannedActivity = ? and e.scheduledStudySegment.scheduledCalendar = ?",
            new Object[] { source, calendar });
    }
}<commit_msg>Add javadoc to scheduled activity dao.<commit_after>package edu.northwestern.bioinformatics.studycalendar.dao;

import edu.northwestern.bioinformatics.studycalendar.domain.PlannedActivity;
import edu.northwestern.bioinformatics.studycalendar.domain.ScheduledActivity;
import edu.northwestern.bioinformatics.studycalendar.domain.ScheduledCalendar;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;

/**
 * @author <NAME>
 */
public class ScheduledActivityDao extends StudyCalendarMutableDomainObjectDao<ScheduledActivity> {
    @Override public Class<ScheduledActivity> domainClass() { return ScheduledActivity.class; }

    /**
    * Finds all the scheduled activities for a given calendar by the start date and end date given.
    *
    * @param  calendar the calendar to retrieve the scheduled activities from
    * @param  start the start date of the time span search
    * @param  end the end date of the time span search
    * @return      a list of scheduled activities for the criteria specified
    */
    @SuppressWarnings({ "unchecked" })
    public Collection<ScheduledActivity> getEventsByDate(ScheduledCalendar calendar, Date start, Date end) {
        StringBuilder builder = new StringBuilder("from ScheduledActivity e where e.scheduledStudySegment.scheduledCalendar = ?");
        List<Object> params = new ArrayList<Object>(3);
        params.add(calendar);
        if (start != null) {
            builder.append(" and e.currentState.date >= ?");
            params.add(start);
        }
        if (end != null) {
            builder.append(" and e.currentState.date <= ?");
            params.add(end);
        }
        return getHibernateTemplate().find(builder.toString(), params.toArray());
    }

    /**
    * Finds all the scheduled activities for the given calendar and planned activity
    *
    * @param  source the planned activity to search for in the scheduled activities
    * @param  calendar the calendar to search through for all the scheduled activities
    * @return      a list of all the scheduled activities that meet the criteria specified
    */
    @SuppressWarnings({ "unchecked" })
    public Collection<ScheduledActivity> getEventsFromPlannedActivity(
        PlannedActivity source, ScheduledCalendar calendar
    ) {
        return getHibernateTemplate().find(
            "from ScheduledActivity e where e.plannedActivity = ? and e.scheduledStudySegment.scheduledCalendar = ?",
            new Object[] { source, calendar });
    }
}
{'fraction_non_alphanumeric': 0.09410668530165385, 'fraction_numerical': 0.0004658746797111577, 'mean_word_length': 3.5974304068522485, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '380997', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1088, 'n_words': 293}