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.
[Reading]
- Hibernate Book (Java
Persistence with Hibernate)
- Chapter 1-6 (or corresponding chapters in Hibernate in Action).
You may skip anything related to XDoclet,
Annotation, JPA, and EJB.
- Hibernate
Documentation
- PostgreSQL Documentation
- CSNS Source Code
- Model classes under src/csns/model
- Hibernate mapping files under src/hbm
[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:
- A bulletin board consists of a number of forums. There are two types of forums: course forums and general forums. Each course in CSNS [1]
should have a course forum associated with it, and the name of the
course forum is the course code concatenated with the course name, e.g.
the name of the forum for CS520 would be "CS520 Web Programming".
General forums are not associated with any course and can have any name.
- A user may create topics in a forum. A topic includes a subject, content, and optionally, file attachments. Users can post replies
to existing topics. Useful information about topics and replies such as
the time when the topic/reply is posted and the number of times a topic
is viewed should be recorded.
- Each forum is moderated by a number of moderators.
A moderator for a forum can edit or delete any topic or reply in the
forum. For general forums, the moderators are the instructors [2], and for a course forum, the moderators are the coordinator [3] and the instructors for the course [4].
- A user can subscribe to a forum. There are two types of subscriptions: regular and daily digest.
Under regular subscription, a user will receive an email notification
whenever a new topic/reply is posted in the forum; under daily digest
subscription, a user will receive one email notification per day
(or none if no new topic/reply was posted), which includes links to all
the topics and replies posted in the forum on that day.
- A user can also subscribe to a topic, and receive an email
notification whenever a new reply is posted to the topic. A user who
posts a reply to a topic is automatically subscribed to that topic
until the user explicitly unsubscribe. There is no daily digest option
for topic subscription.
- A user can of course unsubscribe from any forum or topic.
[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:
- db/csns-create.sql
- db/csns-drop.sql
- db/csns-test-insert.sql
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.
[Subversion]
Commit all the changes to your Subversion repository, and
create a tag called cs520-hw3.
[Notes]
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.