Homework 3
CS520, Spring 2008

Due: Thursday, April 17

Package all the source files of your project into a zip file using the zip Ant target you developed in Homework 1, and upload the zip file to CSNS. Note that file uploading will be disabled automatically after 11:59PM of the due date, so please turn in your work on time.


[Bulletin Board for CSNS]

Bulletin Board is a new component of CSNS which you will develop in this quarter. In this assignment you are going to implement the model classes and the database schema based on the following requirements:

[Model] (30pt)

Design and implement the model classes for the bulletin board, e.g. Forum, Topic, and Reply. You may also need to change existing classes such as User and Subscription. The classes should be placed under the package csns.model.bulletinboard, and the Forum and Topic class must implement the csns.model.Subscribable interface. To receive full credit for this exercise, your classes must be sufficient to support the features described above, which you will implement in subsequent assignments. For example, to support the file attachment feature, your Topic and Reply class must have some field to hold those file attachments [5].

[Hibernate Mapping] (30pt)

Create Hibernate mapping files for the classes you created in the previous exercise, and place these mapping files under src/hbm/bulletinboard. If you have changed any existing classes in the previous exercise, you need to modify their Hibernate mapping files accordingly.

Run the hbm2ddl Ant task to generate a new db/csns.ddl file and check if the database schema is what you expect.

[Database Script] (30pt)

Based on the csns.ddl file generated in the previous exercise, modify the following database scripts to support the bulletin board functions:
In particular, in csns-test-insert.sql, you must create a course forum for each course - there are 200 courses so it's recommended that you use a PL/pgSQL function to do it, and three general forums: Announcements, General Discussion, and Job Postings.


Commit all the changes to your Subversion repository, and create a tag called cs520-hw3.


1. The information about courses is stored in the courses table. Please see db/csns-insert-courses.sql for some examples.

2. CSNS uses role-based security, so "instructors in CSNS" means the users with the role ROLE_INSTRUCTOR. Please see db/csns-insert-users.sql for some examples.

3. Each course has a coordinator, who coordinates the curriculum matters for the course, e.g. selecting textbook and the topics to be covered in the course. The courses table has a field cooridinator_id, which is the user id of the coordinator. Please see db/csns-insert-courses.sql for some examples.

4. A course taught in a particular quarter is called a section in CSNS, and the information about sections is stored in the sections table. A section may have more than one instructor, and this information is stored in the instructors table, from which you can obtain the instructors who is teaching or has taught a particular course. Please see db/csns-create.sql for details.

5. Please see csns.model.mailinglist.Message class for an example of supporting file attachments.