Homework 3
CS520, Summer 2008
Due: Thursday, July 10
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
- CSNS Source Code
- Model classes under src/csns/model
- Hibernate mapping files under src/hbm
[Calendar for CSNS]
Calendar 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 calendar allows users to add events and tasks, as shown in Figure 1 (click on the image to see a larger version).
- An event has a title, a
description (optional), a start time, and an end time. For example,
Figure 1 shows an event "CS520 Lecture" which starts at 1:30PM on 6/30
and ends at 3:10PM on 6/30. An event may also have file attachments,
which could be added to the event either before the event (e.g. a flyer
for a party) or after the event (e.g. the pictures taken at the party).
- An event can be public, section, or private. Any user can see the public events on their calendar, but only users who are in the same section [1] (i.e. the instructors and the students of the section) can see the section events for that section. A private event can only be seen by the user who created it.
- Only administrators can create public events, and only instructors can
create section events for the sections that they teach. Every user can
create private events.
- An email reminder will be sent to the users 24 hours before the start time of an event.
- A task has a title, and
is not associated with any particular time period. For example, Figure
1 shows a task "Go watch Kung Fu Panda" - it's simply something that
needs to be done, but it doesn't matter when it is done.
- A task is either open or completed. If a task is completed, the completion date must be recorded.
- A task is always private, i.e. there are no public or section tasks.
- A user can search for events and tasks based on their date, time, titles, and/or descriptions.
Figure 1. A Calendar with Two Events and Three Tasks
[Model] (30pt)
Design and implement the model classes for the calendar, e.g. Event and Task. You may also need to change existing classes. The classes should be placed under the package csns.model.calendar. 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 Event class must have some field to hold those file attachments [2].
[Hibernate Mapping] (30pt)
Create Hibernate mapping files for the classes you created in the previous exercise, and place these mapping files under src/hbm/calendar.
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 Scripts] (10pt)
Based on the csns.ddl file generated in the previous exercise, modify the following database scripts to support the calendar functions:
- db/csns-create.sql
- db/csns-drop.sql
[Subversion]
Commit all the changes to your Subversion repository, and
create a tag called cs520-hw3.
[Notes]
1. A course taught in a particular quarter is called a section in CSNS, represented by the csns.model.Section class. 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.
2. Please see csns.model.Message class for an example of an object that contains file attachments.