org.sakaiproject.component.gradebook
Class BaseHibernateManager

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate3.support.HibernateDaoSupport
          extended by org.sakaiproject.component.gradebook.BaseHibernateManager
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
GradebookExternalAssessmentServiceImpl, GradebookFrameworkServiceImpl, GradebookPermissionServiceImpl, GradebookServiceHibernateImpl

public abstract class BaseHibernateManager
extends org.springframework.orm.hibernate3.support.HibernateDaoSupport

Provides methods which are shared between service business logic and application business logic, but not exposed to external callers.


Field Summary
protected  Authn authn
           
protected  EventTrackingService eventTrackingService
           
static int MAX_NUMBER_OF_SQL_PARAMETERS_IN_LIST
           
protected  Map propertiesMap
           
protected  SectionAwareness sectionAwareness
           
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
BaseHibernateManager()
           
 
Method Summary
 Long addPermission(Long gradebookId, String userId, String function, Long categoryId, String groupId)
           
protected  Double calculateEquivalentPercent(Double doublePointsPossible, Double doublePointsEarned)
           
protected  Double calculateEquivalentPointValueForPercent(Double doublePointsPossible, Double doublePercentEarned)
           
protected  List convertPointsToLetterGrade(Gradebook gradebook, List studentRecordsFromDB)
          Converts points to letter grade for the given AssignmentGradeRecords
protected  List convertPointsToPercentage(Gradebook gradebook, List studentRecordsFromDB)
          Converts points to percentage for the given AssignmentGradeRecords
 Long createAssignment(Long gradebookId, String name, Double points, Date dueDate, Boolean isNotCounted, Boolean isReleased)
           
 Long createAssignmentForCategory(Long gradebookId, Long categoryId, String name, Double points, Date dueDate, Boolean isNotCounted, Boolean isReleased)
           
 Long createCategory(Long gradebookId, String name, Double weight, int drop_lowest)
           
 void createDefaultLetterGradePercentMapping(Map gradeMap)
           
 void createOrUpdateDefaultLetterGradePercentMapping(Map gradeMap)
           
 Long createUngradedAssignment(Long gradebookId, String name, Date dueDate, Boolean isNotCounted, Boolean isReleased)
           
 Long createUngradedAssignmentForCategory(Long gradebookId, Long categoryId, String name, Date dueDate, Boolean isNotCounted, Boolean isReleased)
           
 void deletePermission(Permission perm)
           
protected  List filterGradeRecordsByStudents(Collection gradeRecords, Collection studentUids)
          Oracle has a low limit on the maximum length of a parameter list in SQL queries of the form "WHERE tbl.col IN (:paramList)".
protected  void finalizeNullGradeRecords(Gradebook gradebook)
           
protected  Set getAllStudentUids(String gradebookUid)
           
 Assignment getAssignment(Long gradableObjectId)
           
protected  AssignmentGradeRecord getAssignmentGradeRecord(Assignment assignment, String studentUid, org.hibernate.Session session)
           
protected  List getAssignments(Long gradebookId, org.hibernate.Session session)
           
 List getAssignmentsForCategory(Long categoryId)
           
protected  Assignment getAssignmentWithoutStats(String gradebookUid, Long assignmentId, org.hibernate.Session session)
           
protected  Assignment getAssignmentWithoutStats(String gradebookUid, String assignmentName, org.hibernate.Session session)
           
 Authn getAuthn()
           
 List getCategories(Long gradebookId)
           
 List getCategoriesWithAssignments(Long gradebookId)
           
 Category getCategory(Long categoryId)
           
 List getComments(Assignment assignment, Collection studentIds)
           
protected  List getCountedStudentGradeRecords(Long gradebookId, String studentId, org.hibernate.Session session)
           
 CourseGrade getCourseGrade(Long gradebookId)
           
protected  CourseGradeRecord getCourseGradeRecord(Gradebook gradebook, String studentId, org.hibernate.Session session)
          Gets the course grade record for a student, or null if it does not yet exist.
 LetterGradePercentMapping getDefaultLetterGradePercentMapping()
           
protected  EventTrackingService getEventTrackingService()
           
 Gradebook getGradebook(String uid)
           
 String getGradebookUid(Long id)
           
 LetterGradePercentMapping getLetterGradePercentMapping(Gradebook gradebook)
           
 List getPermissionsForGB(Long gradebookId)
           
 List getPermissionsForGBForCategoryIds(Long gradebookId, List cateIds)
           
 List getPermissionsForUser(Long gradebookId, String userId)
           
 List getPermissionsForUserAnyCategory(Long gradebookId, String userId)
           
 List getPermissionsForUserAnyGroup(Long gradebookId, String userId)
           
 List getPermissionsForUserAnyGroupAnyCategory(Long gradebookId, String userId)
           
 List getPermissionsForUserAnyGroupForCategory(Long gradebookId, String userId, List cateIds)
           
 List getPermissionsForUserForCategory(Long gradebookId, String userId, List cateIds)
           
 List getPermissionsForUserForGoupsAnyCategory(Long gradebookId, String userId, List groupIds)
           
 List getPermissionsForUserForGroup(Long gradebookId, String userId, List groupIds)
           
protected  Map getPropertiesMap()
           
 String getPropertyValue(String name)
           
protected  SectionAwareness getSectionAwareness()
           
protected  String getUserUid()
           
 boolean isAssignmentDefined(Long gradableObjectId)
           
 boolean isExplicitlyEnteredCourseGradeRecords(Long gradebookId)
           
 boolean isGradebookDefined(String gradebookUid)
           
 void postEvent(String message, String objectReference)
           
 void removeCategory(Long categoryId)
           
 void saveOrUpdateLetterGradePercentMapping(Map gradeMap, Gradebook gradebook)
           
 void setAuthn(Authn authn)
           
 void setEventTrackingService(EventTrackingService eventTrackingService)
           
 void setPropertyValue(String name, String value)
           
 void setSectionAwareness(SectionAwareness sectionAwareness)
           
protected  void updateAssignment(Assignment assignment, org.hibernate.Session session)
           
 void updateCategory(Category category)
           
 void updateGradebook(Gradebook gradebook)
           
 void updatePermission(Collection perms)
           
 void updatePermission(Permission perm)
           
protected  boolean validateLetterGradeMapping(Map gradeMap)
           
 
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

MAX_NUMBER_OF_SQL_PARAMETERS_IN_LIST

public static int MAX_NUMBER_OF_SQL_PARAMETERS_IN_LIST

sectionAwareness

protected SectionAwareness sectionAwareness

authn

protected Authn authn

eventTrackingService

protected EventTrackingService eventTrackingService

propertiesMap

protected Map propertiesMap
Constructor Detail

BaseHibernateManager

public BaseHibernateManager()
Method Detail

getGradebook

public Gradebook getGradebook(String uid)
                       throws GradebookNotFoundException
Throws:
GradebookNotFoundException

isGradebookDefined

public boolean isGradebookDefined(String gradebookUid)

getAssignments

protected List getAssignments(Long gradebookId,
                              org.hibernate.Session session)
                       throws org.hibernate.HibernateException
Throws:
org.hibernate.HibernateException

getCountedStudentGradeRecords

protected List getCountedStudentGradeRecords(Long gradebookId,
                                             String studentId,
                                             org.hibernate.Session session)
                                      throws org.hibernate.HibernateException
Throws:
org.hibernate.HibernateException

getCourseGrade

public CourseGrade getCourseGrade(Long gradebookId)

getCourseGradeRecord

protected CourseGradeRecord getCourseGradeRecord(Gradebook gradebook,
                                                 String studentId,
                                                 org.hibernate.Session session)
                                          throws org.hibernate.HibernateException
Gets the course grade record for a student, or null if it does not yet exist.

Parameters:
studentId - The student ID
session - The hibernate session
Returns:
A List of grade records
Throws:
org.hibernate.HibernateException

getGradebookUid

public String getGradebookUid(Long id)

getAllStudentUids

protected Set getAllStudentUids(String gradebookUid)

getPropertiesMap

protected Map getPropertiesMap()

getPropertyValue

public String getPropertyValue(String name)

setPropertyValue

public void setPropertyValue(String name,
                             String value)

filterGradeRecordsByStudents

protected List filterGradeRecordsByStudents(Collection gradeRecords,
                                            Collection studentUids)
Oracle has a low limit on the maximum length of a parameter list in SQL queries of the form "WHERE tbl.col IN (:paramList)". Since enrollment lists can sometimes be very long, we've replaced such queries with full selects followed by filtering. This helper method filters out unwanted grade records. (Typically they're not wanted because they're either no longer officially enrolled in the course or they're not members of the selected section.)


getAssignmentWithoutStats

protected Assignment getAssignmentWithoutStats(String gradebookUid,
                                               String assignmentName,
                                               org.hibernate.Session session)
                                        throws org.hibernate.HibernateException
Throws:
org.hibernate.HibernateException

getAssignmentWithoutStats

protected Assignment getAssignmentWithoutStats(String gradebookUid,
                                               Long assignmentId,
                                               org.hibernate.Session session)
                                        throws org.hibernate.HibernateException
Throws:
org.hibernate.HibernateException

updateAssignment

protected void updateAssignment(Assignment assignment,
                                org.hibernate.Session session)
                         throws ConflictingAssignmentNameException,
                                org.hibernate.HibernateException
Throws:
ConflictingAssignmentNameException
org.hibernate.HibernateException

getAssignmentGradeRecord

protected AssignmentGradeRecord getAssignmentGradeRecord(Assignment assignment,
                                                         String studentUid,
                                                         org.hibernate.Session session)
                                                  throws org.hibernate.HibernateException
Throws:
org.hibernate.HibernateException

createAssignment

public Long createAssignment(Long gradebookId,
                             String name,
                             Double points,
                             Date dueDate,
                             Boolean isNotCounted,
                             Boolean isReleased)
                      throws ConflictingAssignmentNameException,
                             StaleObjectModificationException
Throws:
ConflictingAssignmentNameException
StaleObjectModificationException

updateGradebook

public void updateGradebook(Gradebook gradebook)
                     throws StaleObjectModificationException
Throws:
StaleObjectModificationException

isExplicitlyEnteredCourseGradeRecords

public boolean isExplicitlyEnteredCourseGradeRecords(Long gradebookId)

getAuthn

public Authn getAuthn()

setAuthn

public void setAuthn(Authn authn)

getUserUid

protected String getUserUid()

getSectionAwareness

protected SectionAwareness getSectionAwareness()

setSectionAwareness

public void setSectionAwareness(SectionAwareness sectionAwareness)

getEventTrackingService

protected EventTrackingService getEventTrackingService()

setEventTrackingService

public void setEventTrackingService(EventTrackingService eventTrackingService)

postEvent

public void postEvent(String message,
                      String objectReference)

createCategory

public Long createCategory(Long gradebookId,
                           String name,
                           Double weight,
                           int drop_lowest)
                    throws ConflictingCategoryNameException,
                           StaleObjectModificationException
Throws:
ConflictingCategoryNameException
StaleObjectModificationException

getCategories

public List getCategories(Long gradebookId)
                   throws org.hibernate.HibernateException
Throws:
org.hibernate.HibernateException

getCategoriesWithAssignments

public List getCategoriesWithAssignments(Long gradebookId)

createAssignmentForCategory

public Long createAssignmentForCategory(Long gradebookId,
                                        Long categoryId,
                                        String name,
                                        Double points,
                                        Date dueDate,
                                        Boolean isNotCounted,
                                        Boolean isReleased)
                                 throws ConflictingAssignmentNameException,
                                        StaleObjectModificationException,
                                        IllegalArgumentException
Throws:
ConflictingAssignmentNameException
StaleObjectModificationException
IllegalArgumentException

getAssignmentsForCategory

public List getAssignmentsForCategory(Long categoryId)
                               throws org.hibernate.HibernateException
Throws:
org.hibernate.HibernateException

getCategory

public Category getCategory(Long categoryId)
                     throws org.hibernate.HibernateException
Throws:
org.hibernate.HibernateException

updateCategory

public void updateCategory(Category category)
                    throws ConflictingCategoryNameException,
                           StaleObjectModificationException
Throws:
ConflictingCategoryNameException
StaleObjectModificationException

removeCategory

public void removeCategory(Long categoryId)
                    throws StaleObjectModificationException
Throws:
StaleObjectModificationException

getDefaultLetterGradePercentMapping

public LetterGradePercentMapping getDefaultLetterGradePercentMapping()

createOrUpdateDefaultLetterGradePercentMapping

public void createOrUpdateDefaultLetterGradePercentMapping(Map gradeMap)

createDefaultLetterGradePercentMapping

public void createDefaultLetterGradePercentMapping(Map gradeMap)

getLetterGradePercentMapping

public LetterGradePercentMapping getLetterGradePercentMapping(Gradebook gradebook)

saveOrUpdateLetterGradePercentMapping

public void saveOrUpdateLetterGradePercentMapping(Map gradeMap,
                                                  Gradebook gradebook)

validateLetterGradeMapping

protected boolean validateLetterGradeMapping(Map gradeMap)

createUngradedAssignment

public Long createUngradedAssignment(Long gradebookId,
                                     String name,
                                     Date dueDate,
                                     Boolean isNotCounted,
                                     Boolean isReleased)
                              throws ConflictingAssignmentNameException,
                                     StaleObjectModificationException
Throws:
ConflictingAssignmentNameException
StaleObjectModificationException

createUngradedAssignmentForCategory

public Long createUngradedAssignmentForCategory(Long gradebookId,
                                                Long categoryId,
                                                String name,
                                                Date dueDate,
                                                Boolean isNotCounted,
                                                Boolean isReleased)
                                         throws ConflictingAssignmentNameException,
                                                StaleObjectModificationException,
                                                IllegalArgumentException
Throws:
ConflictingAssignmentNameException
StaleObjectModificationException
IllegalArgumentException

addPermission

public Long addPermission(Long gradebookId,
                          String userId,
                          String function,
                          Long categoryId,
                          String groupId)
                   throws IllegalArgumentException
Throws:
IllegalArgumentException

getPermissionsForGB

public List getPermissionsForGB(Long gradebookId)
                         throws IllegalArgumentException
Throws:
IllegalArgumentException

updatePermission

public void updatePermission(Collection perms)

updatePermission

public void updatePermission(Permission perm)
                      throws IllegalArgumentException
Throws:
IllegalArgumentException

deletePermission

public void deletePermission(Permission perm)
                      throws IllegalArgumentException
Throws:
IllegalArgumentException

getPermissionsForUser

public List getPermissionsForUser(Long gradebookId,
                                  String userId)
                           throws IllegalArgumentException
Throws:
IllegalArgumentException

getPermissionsForUserForCategory

public List getPermissionsForUserForCategory(Long gradebookId,
                                             String userId,
                                             List cateIds)
                                      throws IllegalArgumentException
Throws:
IllegalArgumentException

getPermissionsForUserAnyCategory

public List getPermissionsForUserAnyCategory(Long gradebookId,
                                             String userId)
                                      throws IllegalArgumentException
Throws:
IllegalArgumentException

getPermissionsForUserAnyGroup

public List getPermissionsForUserAnyGroup(Long gradebookId,
                                          String userId)
                                   throws IllegalArgumentException
Throws:
IllegalArgumentException

getPermissionsForUserAnyGroupForCategory

public List getPermissionsForUserAnyGroupForCategory(Long gradebookId,
                                                     String userId,
                                                     List cateIds)
                                              throws IllegalArgumentException
Throws:
IllegalArgumentException

getPermissionsForGBForCategoryIds

public List getPermissionsForGBForCategoryIds(Long gradebookId,
                                              List cateIds)
                                       throws IllegalArgumentException
Throws:
IllegalArgumentException

getPermissionsForUserAnyGroupAnyCategory

public List getPermissionsForUserAnyGroupAnyCategory(Long gradebookId,
                                                     String userId)
                                              throws IllegalArgumentException
Throws:
IllegalArgumentException

getPermissionsForUserForGoupsAnyCategory

public List getPermissionsForUserForGoupsAnyCategory(Long gradebookId,
                                                     String userId,
                                                     List groupIds)
                                              throws IllegalArgumentException
Throws:
IllegalArgumentException

getPermissionsForUserForGroup

public List getPermissionsForUserForGroup(Long gradebookId,
                                          String userId,
                                          List groupIds)
                                   throws IllegalArgumentException
Throws:
IllegalArgumentException

isAssignmentDefined

public boolean isAssignmentDefined(Long gradableObjectId)

getAssignment

public Assignment getAssignment(Long gradableObjectId)
Parameters:
gradableObjectId -
Returns:
the Assignment object with the given id

calculateEquivalentPercent

protected Double calculateEquivalentPercent(Double doublePointsPossible,
                                            Double doublePointsEarned)
Parameters:
doublePointsPossible -
doublePointsEarned -
Returns:
the % equivalent for the given points possible and points earned

convertPointsToPercentage

protected List convertPointsToPercentage(Gradebook gradebook,
                                         List studentRecordsFromDB)
Converts points to percentage for the given AssignmentGradeRecords

Parameters:
gradebook -
studentRecordsFromDB -
Returns:

convertPointsToLetterGrade

protected List convertPointsToLetterGrade(Gradebook gradebook,
                                          List studentRecordsFromDB)
Converts points to letter grade for the given AssignmentGradeRecords

Parameters:
gradebook -
studentRecordsFromDB -
Returns:

calculateEquivalentPointValueForPercent

protected Double calculateEquivalentPointValueForPercent(Double doublePointsPossible,
                                                         Double doublePercentEarned)

getComments

public List getComments(Assignment assignment,
                        Collection studentIds)

finalizeNullGradeRecords

protected void finalizeNullGradeRecords(Gradebook gradebook)


Copyright © 2011 Sakai Project. All Rights Reserved.