Homework 3
CS520, Spring 2012


Due: Friday, April 27

Package all the source files of your project into a zip file as you did in Homework 1 and upload the zip file to CSNS. In addition to the zip file, also upload a text file hw3.txt which lists all the Java class you have created or modified. Note that file uploading will be disabled automatically after 11:59PM of the due date, so please turn in your work on time.


[Readings]

[Class Websites for CSNS2]

This quarter you are going to add class websites support to CSNS2, which will allow instructors to create and manage class websites.

[Model and ORM] (40pt)

Create new model classes and/or modify existing ones and map them to a relational schema using JPA annotations based on the following requirements:

A class website will need to show the following information (see CS520 class website for example)

A class website also has a number of sections like Annoucements and Lecture Notes. To avoid confusion with class sections, we will call the website sections blocks.

Each class website must have an Announcements block and an Assignments block. The Annoucements block shows the annoucements and the date of each annoucement. and the Assignments block lists the class assignments like homework and labs.

An instructor may add additional blocks to a class website. Each instructor-created block has a name and a list of items. Each item has a name and content. The content of an item could be a URL, a file, or a String. In other words, an instructor may provide the content of an item by entering a URL, uploading a file, or typing up the content directly.

Run Maven build mvn process-classes (or the equivalent in Eclipse) to generate a new src/main/scripts/csns.ddl file and check if the database schema is what you expect.

[Database Scripts] (20pt)

Based on the csns.ddl file generated in the previous exercise, modify the following database scripts to to add the class website support:

Read the database script src/main/scripts/csns-test-insert.sql, understand what it does, complete a quiz about the script on CSNS, and then modify the script as follows:

[Data Access] (20pt)

Add SiteDao to the csns.model.site.dao package and SiteDaoImpl to the csns.model.site.dao.jpa package. Use existing DaoImpl classes as examples to complete the methods in SiteDaoImpl.

[Testing]

Create a new package csns.model.site.dao under src/test/java and place SiteDaoTest in this package. Run the test code by using mvn test, or in Eclipse, right click on testng.xml under src/test/resources and select Run As -> TestNG Suite. In either case you should not see any errors.

[Subversion]

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