org.sakaiproject.component.section
Class SectionManagerHibernateImpl

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate3.support.HibernateDaoSupport
          extended by org.sakaiproject.component.section.SectionManagerHibernateImpl
All Implemented Interfaces:
SectionManager, org.springframework.beans.factory.InitializingBean

public class SectionManagerHibernateImpl
extends org.springframework.orm.hibernate3.support.HibernateDaoSupport
implements SectionManager

A standalone implementation of the Section Management API.

Author:
Josh Holtzman

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.sakaiproject.section.api.SectionManager
SectionManager.ExternalIntegrationConfig
 
Field Summary
protected  Authn authn
           
protected  Context context
           
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Fields inherited from interface org.sakaiproject.section.api.SectionManager
CONFIGURATION_KEY
 
Constructor Summary
SectionManagerHibernateImpl()
           
 
Method Summary
 CourseSection addSection(String courseUuid, String title, String category, Integer maxEnrollments, List meetings)
           
 CourseSection addSection(String courseUuid, String title, String category, Integer maxEnrollments, String location, Time startTime, Time endTime, boolean monday, boolean tuesday, boolean wednesday, boolean thursday, boolean friday, boolean saturday, boolean sunday)
          Adds a CourseSection with a single meeting time to a parent CourseSection.
 ParticipationRecord addSectionMembership(String userUid, Role role, String sectionUuid)
          Adds a user to a section under the specified role.
 Collection<CourseSection> addSections(String courseUuid, Collection<CourseSection> sections)
          Adds multiple sections at once.
 void disbandSection(String sectionUuid)
          Disbands a course section.
 void disbandSections(Set<String> sectionUuids)
          Disbands course sections.
 void dropEnrollmentFromCategory(String studentUid, String siteContext, String category)
          Removes the user from any enrollment to a section of the given category.
 void dropSectionMembership(String userUid, String sectionUuid)
          Removes a user from a section.
 List<EnrollmentRecord> findSiteEnrollments(String siteContext, String pattern)
          Finds a list of EnrollmentRecords belonging to the current site and whose sort name, display name, or display id start with the given string pattern.
 String getCategoryName(String categoryId, Locale locale)
          Gets the localized name of a given category.
 SectionManager.ExternalIntegrationConfig getConfiguration(Object obj)
          Gets the application-wide configuration setting.
 Course getCourse(String siteContext)
          Gets the course (whatever that means) associated with this site context.
 Map getEnrollmentCount(List sectionSet)
          Gets the enrollment size for a set of sections.
 CourseSection getSection(String sectionUuid)
          Gets a CourseSection by its uuid.
 List<String> getSectionCategories(String siteContext)
          Gets the list of section categories.
 List<EnrollmentRecord> getSectionEnrollments(String sectionUuid)
          Gets a list of EnrollmentRecords belonging to a section.
 Set<EnrollmentRecord> getSectionEnrollments(String userUid, String courseUuid)
          Gets all of the section enrollments for a user in a course.
 SectionEnrollments getSectionEnrollmentsForStudents(String siteContext, Set studentUids)
          Gets a SectionEnrollments data structure for the given students.
 List<CourseSection> getSections(String siteContext)
          Gets the sections associated with this site context.
 List<CourseSection> getSectionsInCategory(String siteContext, String categoryId)
          Lists the sections in this context that are a member of the given category.
 List<ParticipationRecord> getSectionTeachingAssistants(String sectionUuid)
          Gets a list of ParticipationRecords for all TAs in a section.
 Map<String,List<ParticipationRecord>> getSectionTeachingAssistantsMap(List sectionSet)
          Gets the list of Teaching Assistants for a set of sections
 User getSiteEnrollment(String siteContext, String studentUid)
          Gets a single User object for a student in a site.
 List<EnrollmentRecord> getSiteEnrollments(String siteContext)
          Gets a list of EnrollmentRecords belonging to the current site.
 List<ParticipationRecord> getSiteInstructors(String siteContext)
          Gets a list of ParticipationRecords for all instructors in the current site.
 List<ParticipationRecord> getSiteTeachingAssistants(String siteContext)
          Gets a list of ParticipationRecords for all TAs in the current site.
 int getTotalEnrollments(String learningContextUuid)
          Returns the total number of students enrolled in a learning context.
 Map getTotalEnrollmentsMap(String learningContextUuid)
          Returns the total number of students enrolled in a learning context by section role.
 List<EnrollmentRecord> getUnsectionedEnrollments(String courseUuid, String category)
          The Section Manager tool could use more specific queries on membership, such as this: getting all students in a primary section that are not enrolled in any secondary sections of a given type.
 boolean isExternallyManaged(String courseUuid)
          Determines whether a course is externally managed.
 boolean isSelfRegistrationAllowed(String courseUuid)
          Determines whether students can enroll themselves in a section.
 boolean isSelfSwitchingAllowed(String courseUuid)
          Determines whether students can switch sections once they are enrolled in a section of a given category (for instance, swapping one lab for another).
 EnrollmentRecord joinSection(String sectionUuid)
          Adds the current user to a section as a student.
 EnrollmentRecord joinSection(String sectionUuid, int maxSize)
          Adds the current user to a section as a student, enforcing a maximum permitted size.
 void setAuthn(Authn authn)
           
 void setContext(Context context)
           
 void setExternallyManaged(String courseUuid, boolean externallyManaged)
          Sets a course as externally or internally managed.
 void setJoinOptions(String courseUuid, boolean joinAllowed, boolean switchAllowed)
          Sets the join/switch options for a course.
 void setSectionMemberships(Set userUids, Role role, String sectionUuid)
          Defines the complete set of users that make up the members of a section in a given role.
 void switchSection(String newSectionUuid)
          Switches a student's currently assigned section.
 void switchSection(String newSectionUuid, int maxSize)
          Switches a student's currently assigned section, enforcing a maximum permitted size.
 void updateSection(String sectionUuid, String title, Integer maxEnrollments, List meetings)
          Updates a section and all of its meetings.
 void updateSection(String sectionUuid, String title, Integer maxEnrollments, String location, Time startTime, Time endTime, boolean monday, boolean tuesday, boolean wednesday, boolean thursday, boolean friday, boolean saturday, boolean sunday)
          Updates the persistent representation of the given CourseSection.
 
Methods inherited from class org.springframework.orm.hibernate3.support.HibernateDaoSupport
checkDaoConfig, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, setHibernateTemplate, setSessionFactory
 
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet, initDao
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

authn

protected Authn authn

context

protected Context context
Constructor Detail

SectionManagerHibernateImpl

public SectionManagerHibernateImpl()
Method Detail

getSections

public List<CourseSection> getSections(String siteContext)
Gets the sections associated with this site context.

Specified by:
getSections in interface SectionManager
Parameters:
siteContext - The site context
Returns:
The List of CourseSections associated with this site context.

getSectionsInCategory

public List<CourseSection> getSectionsInCategory(String siteContext,
                                                 String categoryId)
Lists the sections in this context that are a member of the given category.

Specified by:
getSectionsInCategory in interface SectionManager
Parameters:
siteContext - The site context
Returns:
A List of CourseSections

getSection

public CourseSection getSection(String sectionUuid)
Gets a CourseSection by its uuid.

Specified by:
getSection in interface SectionManager
Parameters:
sectionUuid - The uuid of a section
Returns:
A section

getSiteInstructors

public List<ParticipationRecord> getSiteInstructors(String siteContext)
Gets a list of ParticipationRecords for all instructors in the current site.

Specified by:
getSiteInstructors in interface SectionManager
Parameters:
siteContext - The current site context
Returns:
The instructors

getSiteTeachingAssistants

public List<ParticipationRecord> getSiteTeachingAssistants(String siteContext)
Gets a list of ParticipationRecords for all TAs in the current site.

Specified by:
getSiteTeachingAssistants in interface SectionManager
Parameters:
siteContext - The current site context
Returns:
The TAs

getSiteEnrollments

public List<EnrollmentRecord> getSiteEnrollments(String siteContext)
Gets a list of EnrollmentRecords belonging to the current site.

Specified by:
getSiteEnrollments in interface SectionManager
Parameters:
siteContext - The current site context
Returns:
The enrollments

getEnrollmentCount

public Map getEnrollmentCount(List sectionSet)
Gets the enrollment size for a set of sections.

Specified by:
getEnrollmentCount in interface SectionManager
Returns:
A Map (sectionUuid, size)

getSectionTeachingAssistantsMap

public Map<String,List<ParticipationRecord>> getSectionTeachingAssistantsMap(List sectionSet)
Gets the list of Teaching Assistants for a set of sections

Specified by:
getSectionTeachingAssistantsMap in interface SectionManager
Returns:
A Map (sectionUuid, List ) of TAs for each section

getSectionTeachingAssistants

public List<ParticipationRecord> getSectionTeachingAssistants(String sectionUuid)
Gets a list of ParticipationRecords for all TAs in a section.

Specified by:
getSectionTeachingAssistants in interface SectionManager
Parameters:
sectionUuid - The section uuid
Returns:
The TAs

getSectionEnrollments

public List<EnrollmentRecord> getSectionEnrollments(String sectionUuid)
Gets a list of EnrollmentRecords belonging to a section.

Specified by:
getSectionEnrollments in interface SectionManager
Parameters:
sectionUuid - The section uuid
Returns:
The enrollments

findSiteEnrollments

public List<EnrollmentRecord> findSiteEnrollments(String siteContext,
                                                  String pattern)
Finds a list of EnrollmentRecords belonging to the current site and whose sort name, display name, or display id start with the given string pattern.

Specified by:
findSiteEnrollments in interface SectionManager
Parameters:
siteContext - The current site context
pattern - The pattern to match students names or ids
Returns:
The enrollments

getCategoryName

public String getCategoryName(String categoryId,
                              Locale locale)
Gets the localized name of a given category.

Specified by:
getCategoryName in interface SectionManager
Parameters:
categoryId - A string identifying the category
locale - The locale of the client
Returns:
An internationalized string to display for this category.

getSectionCategories

public List<String> getSectionCategories(String siteContext)
Gets the list of section categories. These are not configurable on a per-course or per-context bases.

Specified by:
getSectionCategories in interface SectionManager
Parameters:
siteContext - The site context (which is not used in the current implementation)
Returns:
A List of unique Strings that identify the available section categories.

getCourse

public Course getCourse(String siteContext)
Gets the course (whatever that means) associated with this site context.

Specified by:
getCourse in interface SectionManager
Parameters:
siteContext - The site context
Returns:
The course (whatever that means)

getSectionEnrollmentsForStudents

public SectionEnrollments getSectionEnrollmentsForStudents(String siteContext,
                                                           Set studentUids)
Gets a SectionEnrollments data structure for the given students.

Specified by:
getSectionEnrollmentsForStudents in interface SectionManager
Parameters:
siteContext - The site context
studentUids - The Set of userUids to include in the SectionEnrollments
Returns:

joinSection

public EnrollmentRecord joinSection(String sectionUuid,
                                    int maxSize)
Adds the current user to a section as a student, enforcing a maximum permitted size.

Specified by:
joinSection in interface SectionManager

joinSection

public EnrollmentRecord joinSection(String sectionUuid)
Adds the current user to a section as a student. This is a convenience method for addSectionMembership(currentUserId, Role.STUDENT, sectionId).

Specified by:
joinSection in interface SectionManager

switchSection

public void switchSection(String newSectionUuid,
                          int maxSize)
Switches a student's currently assigned section, enforcing a maximum permitted size. If the student is enrolled in another section of the same type, that enrollment will be dropped. This is a convenience method to allow a drop/add (a switch) in a single transaction.

Specified by:
switchSection in interface SectionManager
Parameters:
newSectionUuid - The new section uuid to which the student should be assigned

switchSection

public void switchSection(String newSectionUuid)
Switches a student's currently assigned section. If the student is enrolled in another section of the same type, that enrollment will be dropped. This is a convenience method to allow a drop/add (a switch) in a single transaction.

Specified by:
switchSection in interface SectionManager
Parameters:
newSectionUuid - The new section uuid to which the student should be assigned

addSectionMembership

public ParticipationRecord addSectionMembership(String userUid,
                                                Role role,
                                                String sectionUuid)
                                         throws MembershipException
Adds a user to a section under the specified role. If a student is added to a section, s/he will be automatically removed from any other section of the same category in this site. So adding 'student1' to 'Lab1', for example, will automatically remove 'student1' from 'Lab2'. TAs may be added to multiple sections in a site regardless of category.

Specified by:
addSectionMembership in interface SectionManager
Throws:
MembershipException - Only students and TAs can be members of a section. Instructor roles are assigned only at the course level.

setSectionMemberships

public void setSectionMemberships(Set userUids,
                                  Role role,
                                  String sectionUuid)
Defines the complete set of users that make up the members of a section in a given role. This is useful when doing bulk modifications of section membership.

Specified by:
setSectionMemberships in interface SectionManager
Parameters:
userUids - The set of userUids as strings
sectionUuid - The sectionId

dropSectionMembership

public void dropSectionMembership(String userUid,
                                  String sectionUuid)
Removes a user from a section.

Specified by:
dropSectionMembership in interface SectionManager

dropEnrollmentFromCategory

public void dropEnrollmentFromCategory(String studentUid,
                                       String siteContext,
                                       String category)
Removes the user from any enrollment to a section of the given category.

Specified by:
dropEnrollmentFromCategory in interface SectionManager

getTotalEnrollments

public int getTotalEnrollments(String learningContextUuid)
Returns the total number of students enrolled in a learning context. Useful for comparing to the max number of enrollments allowed in a section.

Specified by:
getTotalEnrollments in interface SectionManager
Returns:

getTotalEnrollmentsMap

public Map getTotalEnrollmentsMap(String learningContextUuid)
Returns the total number of students enrolled in a learning context by section role. Useful for comparing to the max number of enrollments allowed in a section.

Specified by:
getTotalEnrollmentsMap in interface SectionManager
Returns:

addSection

public CourseSection addSection(String courseUuid,
                                String title,
                                String category,
                                Integer maxEnrollments,
                                String location,
                                Time startTime,
                                Time endTime,
                                boolean monday,
                                boolean tuesday,
                                boolean wednesday,
                                boolean thursday,
                                boolean friday,
                                boolean saturday,
                                boolean sunday)
Adds a CourseSection with a single meeting time to a parent CourseSection. This method is deprecated. Please use addSection(String courseUuid, String title, String category, Integer maxEnrollments, List meetings)

Specified by:
addSection in interface SectionManager
Returns:

addSection

public CourseSection addSection(String courseUuid,
                                String title,
                                String category,
                                Integer maxEnrollments,
                                List meetings)

updateSection

public void updateSection(String sectionUuid,
                          String title,
                          Integer maxEnrollments,
                          String location,
                          Time startTime,
                          Time endTime,
                          boolean monday,
                          boolean tuesday,
                          boolean wednesday,
                          boolean thursday,
                          boolean friday,
                          boolean saturday,
                          boolean sunday)
Updates the persistent representation of the given CourseSection. Once a section is created, its category is immutable. This method will remove all but one Meeting associated with this CourseSection. To update a CourseSection and all of its meetings, use updateSection(String sectionUuid, String title, Integer maxEnrollments, List meetings).

Specified by:
updateSection in interface SectionManager

updateSection

public void updateSection(String sectionUuid,
                          String title,
                          Integer maxEnrollments,
                          List meetings)
Description copied from interface: SectionManager
Updates a section and all of its meetings. Notice that you can not change a section's category once it's been created.

Specified by:
updateSection in interface SectionManager

disbandSection

public void disbandSection(String sectionUuid)
Disbands a course section. This does not affect enrollment records for the course.

Specified by:
disbandSection in interface SectionManager

disbandSections

public void disbandSections(Set<String> sectionUuids)
Disbands course sections. This does not affect enrollment records for the course.

Specified by:
disbandSections in interface SectionManager

isExternallyManaged

public boolean isExternallyManaged(String courseUuid)
Determines whether a course is externally managed.

Specified by:
isExternallyManaged in interface SectionManager
Returns:

setExternallyManaged

public void setExternallyManaged(String courseUuid,
                                 boolean externallyManaged)
Description copied from interface: SectionManager
Sets a course as externally or internally managed.

Specified by:
setExternallyManaged in interface SectionManager

isSelfRegistrationAllowed

public boolean isSelfRegistrationAllowed(String courseUuid)
Determines whether students can enroll themselves in a section.

Specified by:
isSelfRegistrationAllowed in interface SectionManager
Returns:

isSelfSwitchingAllowed

public boolean isSelfSwitchingAllowed(String courseUuid)
Determines whether students can switch sections once they are enrolled in a section of a given category (for instance, swapping one lab for another).

Specified by:
isSelfSwitchingAllowed in interface SectionManager
Returns:

getUnsectionedEnrollments

public List<EnrollmentRecord> getUnsectionedEnrollments(String courseUuid,
                                                        String category)
The Section Manager tool could use more specific queries on membership, such as this: getting all students in a primary section that are not enrolled in any secondary sections of a given type. For instance, 'Who are the students who are not enrolled in any lab?'

Specified by:
getUnsectionedEnrollments in interface SectionManager
Returns:
A List of EnrollmentRecords of students who are enrolled in the course but are not enrolled in a section of the given section category.

getSectionEnrollments

public Set<EnrollmentRecord> getSectionEnrollments(String userUid,
                                                   String courseUuid)
Gets all of the section enrollments for a user in a course. Useful for listing all of the sections in which a student is enrolled.

Specified by:
getSectionEnrollments in interface SectionManager
Returns:
A Set of EnrollmentRecords

getSiteEnrollment

public User getSiteEnrollment(String siteContext,
                              String studentUid)
Gets a single User object for a student in a site.

Specified by:
getSiteEnrollment in interface SectionManager
Parameters:
siteContext - Needed by the standalone implementation to find the user
Returns:
The User representing this student

getConfiguration

public SectionManager.ExternalIntegrationConfig getConfiguration(Object obj)
Description copied from interface: SectionManager
Gets the application-wide configuration setting.

Specified by:
getConfiguration in interface SectionManager
Parameters:
obj - An object to pass any necessary context information.
Returns:

setAuthn

public void setAuthn(Authn authn)

setContext

public void setContext(Context context)

setJoinOptions

public void setJoinOptions(String courseUuid,
                           boolean joinAllowed,
                           boolean switchAllowed)
Description copied from interface: SectionManager
Sets the join/switch options for a course.

Specified by:
setJoinOptions in interface SectionManager

addSections

public Collection<CourseSection> addSections(String courseUuid,
                                             Collection<CourseSection> sections)
Description copied from interface: SectionManager
Adds multiple sections at once. This should help address the inefficiencies described in http://bugs.sakaiproject.org/jira/browse/SAK-7503. Meeting times should be, but are not handled by an external calendar service. So, the added functionality of linking course sections to repeating events (meet every 2nd Tuesday of the month at 3pm) is currently out of scope. Instead, meetings are represented as a start time, end time, and seven booleans representing the days that the section meets.

Specified by:
addSections in interface SectionManager


Copyright © 2011 Sakai Project. All Rights Reserved.