CSI5389 E-Commerce Project - Part B
Original Author: Istvan T. Hernadvolgyi
Modified by: Saeid Nourian
Course Professor: Dr. Liam Peyton
You are required to develop an online diary application. A diary consists of entries which are dated. The user of the diary may share certain entries with other users, not necessarily with one user. Users who are diary pals can also post message in each others diaries.
When persistence is required, the application must also have a well thought out data model. Therefore the first milestone is the design of a database schema. A good schema requires normalized tables, primary keys for each table and foreign keys for relations. For very complex systems the careful selection of indices (hash columns) is also essential, but in out case it is not relevant. It must be understood, however that any design error at this stage will carry over to the modules that depend on this. Therefore, we have to pay due attention even to this simple schema.
We require representation of the following entities and relations:
Due to the simplicity of the problem at hand, the model solution schema is as follows (primary keys are underline and foreign keys are italicitized).
users |
|
user |
Password |
jill |
awatto |
monica |
xafilah |
jake |
ontnorot |
entries |
||||||
id |
user |
sender |
subject |
sent |
active |
message |
1 |
jill |
jake |
hi |
2001/10/23 |
2001/10/25 |
hi jill! |
2 |
jake |
jill |
hello |
2001/10/25 |
2001/10/26 |
hello jake! |
share |
|
id |
user |
1 |
jill |
1 |
jake |
1 |
monica |
2 |
jake |
2 |
jill |
pals |
|
user |
pal |
jill |
jake |
jake |
jill |
monica |
jill |
In this example, there are three authorized users: jill, monica and jake. Jake sent a message to jill on 2001/10/23 which is to appear in jill’s diary on 2001/10/25. He could do this, because jill designate jake as a diary pal. Similarly, jake received a message jill on 2001/10/25. jill was so happy about this message that she shared this entry with monica (the message with id 1 in the shares table). Jill and jake can send each other message because they are diary pals. Jill can also send message to monica but monica was not granted this privilege from jill.
It is also important to understand that this is a data model and other than primary and foreign key constraints, higher level restrictions will be enforced by the layers built on top of this data model.
The access to the above SQL database is done through JDBC. In a well-designed e-commerce application, the details of database communication must be hidden from the business components. Therefore this project requires that a single Java class (namely DBAgent) take responsibility of handling all JDBC interface calls and provide the business components with relative information.
Below we list the operations which the agent must perform and also the command prompt test that verifies it:
In addition to providing these functionalities through its interface, DBAgent should also be implemented efficiently and handle simultaneous connections:
The solution to above is connection pooling and sensible design. Many databases support it by default, but still have to be configured appropriately. Our model solution explicitly implements a pool of agents which serve requests on behalf of multiple clients. Pay attention to the synchronization of critical code sections.
EC applications can exchange and utilize complex structures data if the data is layed out according to a formal specification and if it is represented in a standard format. XML is a standard markup for structured data and there is standard way of describing its layout. We follow this very paradigm by specifying the date structure of a diary.
<?xml version=”1.0” encoding=”UTF-8”?>
<!ELEMENT Diary (Year)> <!--
Year entry, only one -->
<!ELEMENT Year (Month+)> <!--
The month requested -->
<!ELEMENT Month (Week+)> <!--
Week of the month -->
<!ELEMENT Week (Day+)> <!--
Days of the week -->
<!ELEMENT Day (Entry*)> <!--
Days of the week -->
<!-- Every entry had a subject and a message -->
<!ELEMENT Entry (Subject, Message)>
<!ELEMENT Subject (#PCDATA)>
<!ELEMENT Message (#PCDATA)>
<!--Every
diary has an owner and a user (the one who is looking at
diary). They can be the same
person. -->
<!ATTLIST Diary
owner CDATA
#REQUIRED
user CDATA
#REQUIRED
>
<!--The
value attribute is the actual year (like 2002) -->
<!ATTLIST Year
value CDATA
#REQUIRED
>
<!--The
value attribute is the month of the year (1 for January) -->
<!ATTLIST Month
value
(1|2|3|4|5|6|7|8|9|10|11|12) #REQUIRED
>
<!--The
value attribute is the week of the month (1 for 1st week).
The firstDay attribute
designates what day the first day of the week falls on: 1 for Sunday, 2 for
Tuesday,...) -->
<!ATTLIST Week
value
(1|2|3|4|5|6) #REQUIRED
firstDay (1|2|3|4|5|6|7) #REQUIRED
>
<!--The
ofMonth attribute is the day of this month -->
<!ATTLIST Day
ofMonth
(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|181|9|20|21|22|23|24|25|26|27|28|29|30|31)
#REQUIRED
>
<!--from:
sender of message
sent: date the message was sent
id: the id of this message
which can be used to retrieve the message -->
<!ATTLIST Entry
from CDATA
#REQUIRED
sent CDATA
#REQUIRED
id CDATA #REQUIRED
>
This is very intuitive since a diary inherently chronological and we have months embedded in years, weeks embedded in months, days in weeks and finally the entries themselves inside the particular day when they supposed to appear.
The duty of the XML agent, therefore, is to fetch the entries for the requested time period and format it according to the above specifications; to produce a well-formed structured XML document.
Most modern browsers support the XSLT style-sheet transformation operation. This means that the browser retrieving an XML document which has a URL pointing to an XSLT style-sheet, the browser will perform the XSLT commands on the XML document. If it is a browser, it is expected that the result of the transformation is an HTML document. Of course, XSLT is more general and can be used in other context as well.
Here the requirements are only that the XSLT style-sheets produce legible, user-friendly HTML documents transforming the output of the XML agent.
The user interface is composed of HTML documents and Java servlets. They are almost entirely user interface issues since the database logic and even the request-response format has been solved for previous milestones. However, it is the task of the servlets to perform session tracking. HTTP and HTTPS are session-less protocols and therefore the servlet must identify and protect individual user sessions.
While this milestone requires the most amount of code, it is also the most straight forward to write.
Login
o type
in user id and password / or register as a new user
Display Diary
o displays
the entries for the diary of a particular user for a given time period (start
day, end day)
o if the diary is a pal, one only sees the entries they have permission to see
o by
default today's entries for the diary of the logged in user
o user
can:
o set
different start day, end day
o choose
diary of any user they are a pal of
o add/remove
a pal (their diary only)
o add
an entry (their diary or any diary they are a pal of)
o edit
a message (messages in their diary only)
o logout
o Add
Entry
o Create
the message.
o Edit
Entry
o Give
permission to another user to see it, by sharing it.
o Remove
permission from another user to see it.
o Delete
message (prompt for confirmation)