The creation of such scripts requires a working knowledge of the UniTime's source code and the Hibernate model. There is no comprehensive development documentation at the moment, except of the source code itself. The Hibernate model (i.e., the *.hbm.xml files in JavaSource folder) is a good place to start. Please contact us at firstname.lastname@example.org if you need a help with development of a particular script.
Users with Scripts permission can open the Scripts page, however, each script may require a particular permission for the user to be able to select and execute the script. To create, modify, or delete a script permission Script Edit is required.
To add a new script click on the Add New button. To edit an existing script, select the script in the drop down and click on Edit button. A script can be deleted from the Edit Script dialog, by clicking on the Delete button.
A script has a name and a description. A particular engine has to be selected as well (the list of available scripting engines is in the Engine drop down). The Permission drop down allows to select a permission that the user must have to be able to execute the script (or to be even able to see it in the drop down of available scripts). A script can have one or more parameters. A parameter has a name (and it is referred by this name from the script), a label that is visible to the user, a type (various types are supported, see the example below) and it may have a default value.
Besides of the parameters, it can access a hibernate session (parameter hibSession of org.hibernate.Session class), current academic session (parameter session, of Session class) and the object running the script (parameter log, of ScriptExecution class). The hibernate session is opened with a transaction started. This transaction is committed when the script finishes fine, it is rollbacked otherwise. The log can be used to print debug, info, warn, and error message; to control script status and progress; and to create an output file.
The parameters can be of various types. Basic types are string, boolean, int, long, double, float, short, and byte. There can be a drop down selection of one or multiple departments (type department or departments of class Department or List<Department>), one or multiple subject areas (type subject or subjects of class SubjectArea or List<SubjectArea>), one or multiple buildings (type building or buildings of class Building or List<Building>), one or more locations (type location or locations of class Location or List<Location>), or one or more rooms (type room or rooms of class Room or List<Room>). It can also be an input file (type file). A selection of one of given strings (type enum) or a value from a reference table (type reference(RefTableEntry), where RefTableEntry is a model class inherited from RefTableEntry, the result is a string with the value of the reference column of the selected item) are also accepted.
If a user has a department dependent role (e.g., departmental schedule manager), only associated departments, subject areas, rooms, and buildings will be available in the drop downs.
To allow python scripting, the standalone jar version of Jython (e.g., jython-standalone-2.5.3.jar, see Jython downloads) needs to be put in Tomcat/libs folder. After Tomcat is restarted, python should appear as an available engine. Here is an example script (same as the one above) written using python: