org.sakaiproject.component.section
Class SectionManagerHibernateImpl

java.lang.Object
  extended byorg.springframework.dao.support.DaoSupport
      extended byorg.springframework.orm.hibernate.support.HibernateDaoSupport
          extended byorg.sakaiproject.component.section.SectionManagerHibernateImpl
All Implemented Interfaces:
InitializingBean, SectionManager

public class SectionManagerHibernateImpl
extends HibernateDaoSupport
implements SectionManager

A standalone implementation of the Section Management API.

Author:
Josh Holtzman

Field Summary
protected  Authn authn
           
protected  Context context
           
protected  UuidManager uuidManager
           
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
SectionManagerHibernateImpl()
           
 
Method Summary
 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 to a parent CourseSection.
 ParticipationRecord addSectionMembership(String userUid, Role role, String sectionUuid)
          Adds a user to a section under the specified role.
 void disbandSection(String sectionUuid)
          Disbands a course section.
 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 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.
 Course getCourse(String siteContext)
          Gets the course (whatever that means) associated with this site context.
 CourseSection getSection(String sectionUuid)
          Gets a CourseSection by its uuid.
 List getSectionCategories(String siteContext)
          Gets the list of section categories.
 List getSectionEnrollments(String sectionUuid)
          Gets a list of EnrollmentRecords belonging to a section.
 Set 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 getSections(String siteContext)
          Gets the sections associated with this site context.
 List getSectionsInCategory(String siteContext, String categoryId)
          Lists the sections in this context that are a member of the given category.
 List getSectionTeachingAssistants(String sectionUuid)
          Gets a list of ParticipationRecords for all TAs in a section.
 User getSiteEnrollment(String siteContext, String studentUid)
          Gets a single User object for a student in a site.
 List getSiteEnrollments(String siteContext)
          Gets a list of EnrollmentRecords belonging to the current site.
 List getSiteInstructors(String siteContext)
          Gets a list of ParticipationRecords for all instructors in the current site.
 List 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.
 List 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 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.
 void setAuthn(Authn authn)
           
 void setContext(Context context)
           
 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 setSelfRegistrationAllowed(String courseUuid, boolean allowed)
          Sets the "self registration" status of a section.
 void setSelfSwitchingAllowed(String courseUuid, boolean allowed)
          Sets the "student switching" status of a primary section.
 void setUuidManager(UuidManager uuidManager)
           
 void switchSection(String newSectionUuid)
          Switches a student's currently assigned section.
 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.hibernate.support.HibernateDaoSupport
checkDaoConfig, closeSessionIfNecessary, 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

uuidManager

protected UuidManager uuidManager

authn

protected Authn authn

context

protected Context context
Constructor Detail

SectionManagerHibernateImpl

public SectionManagerHibernateImpl()
Method Detail

getSections

public List getSections(String siteContext)
Description copied from interface: SectionManager
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 getSectionsInCategory(String siteContext,
                                  String categoryId)
Description copied from interface: SectionManager
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
categoryId -
Returns:
A List of CourseSections

getSection

public CourseSection getSection(String sectionUuid)
Description copied from interface: SectionManager
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 getSiteInstructors(String siteContext)
Description copied from interface: SectionManager
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 getSiteTeachingAssistants(String siteContext)
Description copied from interface: SectionManager
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 getSiteEnrollments(String siteContext)
Description copied from interface: SectionManager
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

getSectionTeachingAssistants

public List getSectionTeachingAssistants(String sectionUuid)
Description copied from interface: SectionManager
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 getSectionEnrollments(String sectionUuid)
Description copied from interface: SectionManager
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 findSiteEnrollments(String siteContext,
                                String pattern)
Description copied from interface: SectionManager
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)
Description copied from interface: SectionManager
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 getSectionCategories(String siteContext)
Description copied from interface: SectionManager
Gets the list of section categories. In sakai 2.1, there will be only a single set of categories. They will not be 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. These should be internationalized for display using getCategoryName.

getCourse

public Course getCourse(String siteContext)
Description copied from interface: SectionManager
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)
Description copied from interface: SectionManager
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)
Description copied from interface: SectionManager
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
Parameters:
sectionUuid -

switchSection

public void switchSection(String newSectionUuid)
Description copied from interface: SectionManager
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
Description copied from interface: SectionManager
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
Parameters:
userUid -
role -
sectionUuid -
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)
Description copied from interface: SectionManager
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)
Description copied from interface: SectionManager
Removes a user from a section.

Specified by:
dropSectionMembership in interface SectionManager
Parameters:
userUid -
sectionUuid -

dropEnrollmentFromCategory

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

Specified by:
dropEnrollmentFromCategory in interface SectionManager
Parameters:
studentUid -
siteContext -
category -

getTotalEnrollments

public int getTotalEnrollments(String learningContextUuid)
Description copied from interface: SectionManager
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:

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)
Description copied from interface: SectionManager
Adds a CourseSection to a parent CourseSection. This assumes that meeting times will not be handled by an external service. The added functionality of linking course sections to repeating events (meet every 2nd Tuesday of the month at 3pm) is currently out of scope, so meetingTimes is represented as a start time, end time, and seven booleans representing the days that the section meets.

Specified by:
addSection in interface SectionManager
Parameters:
courseUuid -
title -
category -
maxEnrollments -
location -
startTime -
endTime -
monday -
tuesday -
wednesday -
thursday -
friday -
saturday -
sunday -
Returns:

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)
Description copied from interface: SectionManager
Updates the persistent representation of the given CourseSection. Once a section is created, its category is immutable.

Specified by:
updateSection in interface SectionManager
Parameters:
sectionUuid -
title -
maxEnrollments -
location -
startTime -
endTime -
monday -
tuesday -
wednesday -
thursday -
friday -
saturday -
sunday -

disbandSection

public void disbandSection(String sectionUuid)
Description copied from interface: SectionManager
Disbands a course section. This does not affect enrollment records for the course.

Specified by:
disbandSection in interface SectionManager
Parameters:
sectionUuid -

isSelfRegistrationAllowed

public boolean isSelfRegistrationAllowed(String courseUuid)
Description copied from interface: SectionManager
Determines whether students can enroll themselves in a section.

Specified by:
isSelfRegistrationAllowed in interface SectionManager
Parameters:
courseUuid -
Returns:

setSelfRegistrationAllowed

public void setSelfRegistrationAllowed(String courseUuid,
                                       boolean allowed)
Description copied from interface: SectionManager
Sets the "self registration" status of a section.

Specified by:
setSelfRegistrationAllowed in interface SectionManager
Parameters:
courseUuid -
allowed -

isSelfSwitchingAllowed

public boolean isSelfSwitchingAllowed(String courseUuid)
Description copied from interface: SectionManager
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
Parameters:
courseUuid -
Returns:

setSelfSwitchingAllowed

public void setSelfSwitchingAllowed(String courseUuid,
                                    boolean allowed)
Description copied from interface: SectionManager
Sets the "student switching" status of a primary section.

Specified by:
setSelfSwitchingAllowed in interface SectionManager
Parameters:
allowed -

getUnsectionedEnrollments

public List getUnsectionedEnrollments(String courseUuid,
                                      String category)
Description copied from interface: SectionManager
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 getSectionEnrollments(String userUid,
                                 String courseUuid)
Description copied from interface: SectionManager
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
Parameters:
userUid -
courseUuid -
Returns:
A Set of EnrollmentRecords

getSiteEnrollment

public User getSiteEnrollment(String siteContext,
                              String studentUid)
Description copied from interface: SectionManager
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
studentUid -
Returns:
The User representing this student

setAuthn

public void setAuthn(Authn authn)

setUuidManager

public void setUuidManager(UuidManager uuidManager)

setContext

public void setContext(Context context)