org.olat.course
Class CourseFactory

java.lang.Object
  extended by org.olat.course.CourseFactory

public class CourseFactory
extends java.lang.Object

Description:
Use the course factory to create course run and edit controllers or to load a course from disk Initial Date: Oct 12, 2004

Author:
Felix Jost

Field Summary
static java.lang.String COURSE_EDITOR_LOCK
           
 
Constructor Summary
CourseFactory()
           
 
Method Summary
static void archiveCourse(Identity archiveOnBehalfOf, ICourse course, java.lang.String charset, java.util.Locale locale, java.io.File exportDirectory, boolean isOLATAdmin, boolean... oresRights)
          visit all nodes in the specified course and make them archiving any data into the identity's export directory.
static void archiveCourse(OLATResourceable res, java.lang.String charset, java.util.Locale locale, Identity identity)
          visit all nodes in the specified course and make them archiving any data into the identity's export directory.
static void closeCourseEditSession(java.lang.Long resourceableId, boolean checkIfAnyAvailable)
          TODO: remove course from courseEditSessionMap at releaseLock
static OLATResourceable copyCourse(OLATResourceable sourceRes, UserRequest ureq)
          Copies a course.
static Controller createDisposedCourseRestartController(UserRequest ureq, WindowControl wControl, long resId)
           
static Controller createEditorController(UserRequest ureq, WindowControl wControl, OLATResourceable olatResource)
          Create an editor controller for the given course resourceable
static ICourse createEmptyCourse(OLATResourceable ores, java.lang.String shortTitle, java.lang.String longTitle, java.lang.String learningObjectives)
          Creates an empty course with a single root node.
static Controller createHelpCourseLaunchController(UserRequest ureq, WindowControl wControl)
          Create a user locale dependent help-course run controller
static MainLayoutController createLaunchController(UserRequest ureq, WindowControl wControl, OLATResourceable olatResource, java.lang.String initialViewIdentifier)
          Create a run controller for the given course resourceable
static void deleteCourse(OLATResourceable res)
          Delete a course including its course folder and all references to resources this course holds.
static RepositoryEntry deployCourseFromZIP(java.io.File exportedCourseZIPFile, int access)
          Deploys a course from an exported course ZIP file.
static void exportCourseToZIP(OLATResourceable sourceRes, java.io.File fTargetZIP)
          Exports an entire course to a zip file.
static void fireModifyCourseEvent(java.lang.Long resourceableId)
          Updates the course cache forcing other cluster nodes to reload this course.
static VFSItem getCourseBaseContainer(java.lang.Long resourceableId)
          the provided resourceableID must belong to a ICourse.getResourceableId(), otherwise you risk to use a wrong course base container.
static PersistingCourseImpl getCourseEditSession(java.lang.Long resourceableId)
          Provides the currently edited course object with this id.
static CustomCSS getCustomCourseCss(UserSession usess, CourseEnvironment courseEnvironment)
          Create a custom css object for the course layout.
static java.io.File getDataExportDirectory(Identity identity, java.lang.String courseName)
          Returns the data export directory.
static Component getDetailsComponent(OLATResourceable res, UserRequest ureq)
          Get a details form for a given course resourceable
static java.io.File getOrCreateDataExportDirectory(Identity identity, java.lang.String courseName)
          Returns the data export directory.
static java.io.File getOrCreateStatisticDirectory(Identity identity, java.lang.String courseName)
          Returns the data export directory.
static java.io.File getPersonalDirectory(Identity identity)
          Returns the personal folder of the given identity.
static ICourse importCourseFromZip(OLATResourceable ores, java.io.File zipFile)
          Import a course from a ZIP file.
static ICourse loadCourse(java.lang.Long resourceableId)
          Gets the course from cache if already there, or loads the course and puts it into cache.
static ICourse loadCourse(OLATResourceable olatResource)
          Load the course for the given course resourceable
static PersistingCourseImpl openCourseEditSession(java.lang.Long resourceableId)
          Loads the course or gets it from cache, and adds it to the courseEditSessionMap.
static void saveCourse(java.lang.Long resourceableId)
          Stores the editor tree model AND the run structure (both xml files).
static void saveCourseEditorTreeModel(java.lang.Long resourceableId)
          Stores ONLY the editor tree model (e.g.
static void setCourseConfig(java.lang.Long resourceableId, CourseConfig cc)
          Save courseConfig and update cache.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COURSE_EDITOR_LOCK

public static final java.lang.String COURSE_EDITOR_LOCK
See Also:
Constant Field Values
Constructor Detail

CourseFactory

public CourseFactory()
Method Detail

createLaunchController

public static MainLayoutController createLaunchController(UserRequest ureq,
                                                          WindowControl wControl,
                                                          OLATResourceable olatResource,
                                                          java.lang.String initialViewIdentifier)
Create a run controller for the given course resourceable

Parameters:
ureq -
wControl -
olatResource -
initialViewIdentifier - if null the default view will be started, otherwise a controllerfactory type dependant view will be activated (subscription subtype)
Returns:
run controller for the given course resourceable

createEditorController

public static Controller createEditorController(UserRequest ureq,
                                                WindowControl wControl,
                                                OLATResourceable olatResource)
Create an editor controller for the given course resourceable

Parameters:
ureq -
wControl -
olatResource -
Returns:
editor controller for the given course resourceable; if the editor is already locked, it returns a controller with a lock message

createEmptyCourse

public static ICourse createEmptyCourse(OLATResourceable ores,
                                        java.lang.String shortTitle,
                                        java.lang.String longTitle,
                                        java.lang.String learningObjectives)
Creates an empty course with a single root node. The course is linked to the resourceable ores.

Parameters:
ores -
shortTitle - Short title of root node
longTitle - Long title of root node
learningObjectives - Learning objectives of root node
Returns:
an empty course with a single root node.

loadCourse

public static ICourse loadCourse(java.lang.Long resourceableId)
Gets the course from cache if already there, or loads the course and puts it into cache. To be called for the "CourseRun" model.

Parameters:
resourceableId -
Returns:
the course with the given id (the type is always CourseModule.class.toString())

loadCourse

public static ICourse loadCourse(OLATResourceable olatResource)
Load the course for the given course resourceable

Parameters:
olatResource -
Returns:
the course for the given course resourceable

deleteCourse

public static void deleteCourse(OLATResourceable res)
Delete a course including its course folder and all references to resources this course holds.

Parameters:
res -

copyCourse

public static OLATResourceable copyCourse(OLATResourceable sourceRes,
                                          UserRequest ureq)
Copies a course. More specifically, the run and editor structures and the course folder will be copied to create a new course.

Parameters:
sourceRes -
ureq -
Returns:
copy of the course.

exportCourseToZIP

public static void exportCourseToZIP(OLATResourceable sourceRes,
                                     java.io.File fTargetZIP)
Exports an entire course to a zip file.

Parameters:
sourceRes -
fTargetZIP -

importCourseFromZip

public static ICourse importCourseFromZip(OLATResourceable ores,
                                          java.io.File zipFile)
Import a course from a ZIP file.

Parameters:
ores -
zipFile -
Returns:
New Course.

deployCourseFromZIP

public static RepositoryEntry deployCourseFromZIP(java.io.File exportedCourseZIPFile,
                                                  int access)
Deploys a course from an exported course ZIP file. This process is unatended and therefore relies on some default assumptions on how to setup the entry and add any referenced resources to the repository.

Parameters:
exportedCourseZIPFile -

getDetailsComponent

public static Component getDetailsComponent(OLATResourceable res,
                                            UserRequest ureq)
Get a details form for a given course resourceable

Parameters:
res -
ureq -
Returns:
details component displaying details of the course.

createHelpCourseLaunchController

public static Controller createHelpCourseLaunchController(UserRequest ureq,
                                                          WindowControl wControl)
Create a user locale dependent help-course run controller

Parameters:
ureq - The user request
wControl - The current window controller
Returns:
The help-course run controller

archiveCourse

public static void archiveCourse(OLATResourceable res,
                                 java.lang.String charset,
                                 java.util.Locale locale,
                                 Identity identity)
visit all nodes in the specified course and make them archiving any data into the identity's export directory.

Parameters:
res -
charset -
locale -
identity -

archiveCourse

public static void archiveCourse(Identity archiveOnBehalfOf,
                                 ICourse course,
                                 java.lang.String charset,
                                 java.util.Locale locale,
                                 java.io.File exportDirectory,
                                 boolean isOLATAdmin,
                                 boolean... oresRights)
visit all nodes in the specified course and make them archiving any data into the identity's export directory.

Parameters:
res -
charset -
locale -
identity -

getOrCreateDataExportDirectory

public static java.io.File getOrCreateDataExportDirectory(Identity identity,
                                                          java.lang.String courseName)
Returns the data export directory. If the directory does not yet exist the directory will be created

Parameters:
ureq - The user request
courseName - The course name or title. Will be used as directory name
Returns:
The file representing the dat export directory

getDataExportDirectory

public static java.io.File getDataExportDirectory(Identity identity,
                                                  java.lang.String courseName)
Returns the data export directory.

Parameters:
ureq - The user request
courseName - The course name or title. Will be used as directory name
Returns:
The file representing the dat export directory

getPersonalDirectory

public static java.io.File getPersonalDirectory(Identity identity)
Returns the personal folder of the given identity.

The idea of this method is to match the first part of what getOrCreateDataExportDirectory() returns.

Parameters:
identity -
Returns:

getOrCreateStatisticDirectory

public static java.io.File getOrCreateStatisticDirectory(Identity identity,
                                                         java.lang.String courseName)
Returns the data export directory. If the directory does not yet exist the directory will be created

Parameters:
ureq - The user request
courseName - The course name or title. Will be used as directory name
Returns:
The file representing the dat export directory

saveCourse

public static void saveCourse(java.lang.Long resourceableId)
Stores the editor tree model AND the run structure (both xml files). Called at publish.

Parameters:
resourceableId -

saveCourseEditorTreeModel

public static void saveCourseEditorTreeModel(java.lang.Long resourceableId)
Stores ONLY the editor tree model (e.g. at course tree editing - add/remove/move course nodes).

Parameters:
resourceableId -

fireModifyCourseEvent

public static void fireModifyCourseEvent(java.lang.Long resourceableId)
Updates the course cache forcing other cluster nodes to reload this course.
This is triggered after the course editor is closed.
It also removes the courseEditSession for this course.

Parameters:
resourceableId -

createDisposedCourseRestartController

public static Controller createDisposedCourseRestartController(UserRequest ureq,
                                                               WindowControl wControl,
                                                               long resId)

getCustomCourseCss

public static CustomCSS getCustomCourseCss(UserSession usess,
                                           CourseEnvironment courseEnvironment)
Create a custom css object for the course layout. This can then be set on a MainLayoutController to activate the course layout

Parameters:
usess - The user session
courseEnvironment - the course environment
Returns:
The custom course css or NULL if no course css is available

getCourseBaseContainer

public static VFSItem getCourseBaseContainer(java.lang.Long resourceableId)
the provided resourceableID must belong to a ICourse.getResourceableId(), otherwise you risk to use a wrong course base container.

Parameters:
resourceableId -
Returns:

setCourseConfig

public static void setCourseConfig(java.lang.Long resourceableId,
                                   CourseConfig cc)
Save courseConfig and update cache.

Parameters:
resourceableId -
cc -

openCourseEditSession

public static PersistingCourseImpl openCourseEditSession(java.lang.Long resourceableId)
Loads the course or gets it from cache, and adds it to the courseEditSessionMap.
It guarantees that the returned value is never null.
The courseEditSession object should live between acquire course lock and release course lock. TODO: remove course from courseEditSessionMap at close course editor

Parameters:
resourceableId -
Returns:

getCourseEditSession

public static PersistingCourseImpl getCourseEditSession(java.lang.Long resourceableId)
Provides the currently edited course object with this id.
It guarantees that the returned value is never null if the openCourseEditSession was called first.
The CourseEditSession object should live between acquire course lock and release course lock. TODO: remove course from courseEditSessionMap at close course editor

Parameters:
resourceableId -
Returns:

closeCourseEditSession

public static void closeCourseEditSession(java.lang.Long resourceableId,
                                          boolean checkIfAnyAvailable)
TODO: remove course from courseEditSessionMap at releaseLock

Parameters:
resourceableId -