ProjectDescriptionx

infestationwatchSoftware and s/w Development

Oct 28, 2013 (3 years and 8 months ago)

79 views

Peter Plant
-
8217

AY 2010/11

1




Topo Base

Internet Technologies Project


Peter Plant

-

8217

AY 2010/11




Peter Plant
-
8217

AY 2010/11

2

Content:


Content:

................................
................................
................................
................................
................................
......................

2

Project outcome:
................................
................................
................................
................................
................................
.......

3

Functi onali ti es:

................................
................................
................................
................................
................................
..........

3

Rol es:

................................
................................
................................
................................
................................
......................

3

Regi ster:

................................
................................
................................
................................
................................
.................

3

Logi n:

................................
................................
................................
................................
................................
......................

4

Logout:

................................
................................
................................
................................
................................
...................

4

Add topo:

................................
................................
................................
................................
................................
...............

4

Modi fy/Del ete topo:
................................
................................
................................
................................
............................

4

Search:
................................
................................
................................
................................
................................
....................

4

Vi ew topo:

................................
................................
................................
................................
................................
.............

4

Comment topo:

................................
................................
................................
................................
................................
....

4

Rate topo:

................................
................................
................................
................................
................................
..............

5

Downl oad:

................................
................................
................................
................................
................................
.............

5

Change password:

................................
................................
................................
................................
................................

5

Del ete Accou
nt:

................................
................................
................................
................................
................................
....

5

Gi ve ri ghts (onl y for admi n):

................................
................................
................................
................................
..............

5

Del ete user topos (onl y for admi n):
................................
................................
................................
................................
..

5

Del ete comments (onl y for admi n):
................................
................................
................................
................................
..

5

Technol ogi es used:

................................
................................
................................
................................
................................
...

5

HTML:

................................
................................
................................
................................
................................
.....................

5

CSS:

................................
................................
................................
................................
................................
.........................

6

JavaScri pt:
................................
................................
................................
................................
................................
..............

6

JSTL & JEL:
................................
................................
................................
................................
................................
..............

6

JSP:

................................
................................
................................
................................
................................
..........................

6

Servl et:

................................
................................
................................
................................
................................
...................

6

Java Beans:

................................
................................
................................
................................
................................
............

6

JDBC:

................................
................................
................................
................................
................................
.......................

6

Database:

................................
................................
................................
................................
................................
...............

7

De
si gn:
................................
................................
................................
................................
................................
.........................

7

Database tabl es:

................................
................................
................................
................................
................................
...

7

ER
-
Di agram:
................................
................................
................................
................................
................................
...........

7

Procedure fl ows of

functi onali ti es:

................................
................................
................................
................................
...

8

Mai n classes and methods:

................................
................................
................................
................................
.....................

9

Major technical probl ems:
................................
................................
................................
................................
.....................

11

Peter Plant
-
8217

AY 2010/11

3

Project o
utcome:


The aim of the project is the development of a dynamic website
by combining
different
technologies like Html, CSS, JavaScript, Java Server Pages, Java Servlets, Beans and DBMS
access
through JDBC.

I’m a passionate rock climber for me this sport is not only about
climbing but also about discovering new areas or discov
ering existing areas. Usually the
topos* of small
/unknown

areas

or

are not published in rock climbing guides. That’s the
problem which

I want to solve with my website.

I want to give climbers which love to
discover and develop new areas a possibility to pu
blish th
eir topos
.

Naturally my
web
site is not reserved for small/
unknown areas

also topos which are published in rock
climbing guides are welcome.


*A topo is a description of the climbing area which contains information about journey, alignment, importa
nt hints
and the most important

are the

names, grades of the routes.


Functionalities
:


Roles:



External u
ser
:




Search topos



Comment topo



Rate topos



Download topos



Logged u
ser
:



Add topos




edit/delete its topos



Account deletion



Password change



Rights of
external users



Admin
:



Rights of external users



Rights of logged users



Give admin rights to accounts



Delete comments



Delete topos of other users


Register:

An external User has the possibility to become a member and to
get

logged
user rights by

a

registration.
If the registration was successful the user can login.



Peter Plant
-
8217

AY 2010/11

4

Login:

To get the rights
of a logged us
er a registered

user has to p
rovide its e
-
mail
address and
password. The login is done on the

top of the

home page.

The user has also
the possibility to save his login so every time (2 weeks long) he opens the page he is
automatically logged in if he uses the same browser.



Logout:

A logged user
can leaf by logging out. After logging out he has again external
user
rights.



Add topo:

Logged users have the possibility to add new topos to the database this is
done with a form which asks for general information about the topo, search tags and
also for the pdf file of it. After a successful upload the topo can be found
over the search
tags using the search function, on home page in the latest list until a few other topos are
uploaded or in the best list if the topo has a good rating.



Modify/Delete

topo
:

A topo can be deleted by the user which has uploaded (up
-
loader)
i
t or by the admin

users
. The deletion of a topo requires a confirmation. The up
-
loader

has also the possibility to modify the
topo by changing the given data. For simplicity it is
not possible to change the pdf file only the information belonging to it can

be changed.



Search:

All users have the possibility to search topos by keywords and other search
options (e.g. by category boulder area/routes area). The found topos are

then arranged
in a list.



View topo:

Each topo has a kind of own space where the
information about it

(e.g. name,
rating, map etc.)

are shown and where the pdf file can be downloaded
.

Under the
description of the topo

all users can le
ave a comment and read comments of other users
in addition e
very user can leave also a rate.



Comment
topo:

All t
he users have the possibility to comment the topo. Under the topo
information there is a space for the com
ments where new comments can be
added
.
Logged users are leaving comments under the first name which is stored in their
account whereas
external users can give a name. If there was no name given by the
commenter the comment is stored under anonymous name.



Peter Plant
-
8217

AY 2010/11

5

Rate topo:

The users have als
o the possibility to rate topos with a mark between 1 and
5. T
he average and the
number of ratings are t
he criteria’s for

the best five topo list on
the home page.


Download
:

All t
he users have the possibility to download a pdf this is done by

clicking
on the download button.


Change password:

Logged users and admin users has also the possibility
to change
their password by providing the old password, the new password and the confirmation
of the new password.



Delete Account:

Logged users and admin users have the possibility to delete their
accounts. This is done by providing again the password (for security reasons). After a
successful deletion all topos of the deleted user are also deleted and again he/she gets
the rights of
a external user.





Give rights (only for admin):

The admin has the possibility to give other users admin
rights.

On the give rights page the user has a list of users which already have admin
rights and a list of logged users which don’t
have admin rights from this list the admin
user can select one user.



Delete user topos (only for admin):

The admin users have also the possibility to delete
topos of other users to keep the quality of uploaded topos on a adequate level (e.g.
empty topos,

topos which are containing racial slur or vile language).



Delete comments (only for admin):

The admin users are also allowed to delete
comments. This is done for the same reason as the delete user topos function. To keep
the website free of racial slur
and vile language.


Technologies used
:



HTML:

HTML

allows to
give my
webpage a form which means to split up different parts
of the page in DOM’s, creating some tables which are later dynamically filled and setting
up forms which are sending the input to
the servlets.


Peter Plant
-
8217

AY 2010/11

6

CSS:

The CSS gave my webpage the whole look and feel. Background colors, background
images, rounded edges, shadows and so on.


JavaScript:

I used it to check/validate some inputs which helped me to keep servlet
code simpler

and to give the user a good feedback of his compilation errors
.
One time I
used it to change the design of a container on a certain event and for the bonding of the
Google map I used JavaScript together with jQuery because I needed a kind of onload
functi
on for div.



JSTL & JEL:

The Java Standard Tag Library and the Java Expression Language
allowed
me to banish nasty java code (e.g. jsp scriptlets, jsp declarations and jsp expressions)
from my web page. JEL allowed me to access and use request attributes
which were
previously set by servlets or to access methods of beans. I mainly used the if, when
-
otherwise and foreach tags of the Java Standard Tag Library.



JSP:

The Java Server Pages was the place where JavaScript, HTML, CSS, JSTL & JEL came
together to

one unit. JSP allowed me also to split up the page in different files and so not
to have a big chunk of code in one file. By includes the whole page comes together in the
index.jsp.



Servlet:

The servlets are the controllers in the MVC architecture. All functionalities are
done over servlets.
They insert or select data over the query classes, they create new
beans, some of them are accessing also the file system to upload or download and in the

most cases I use them to set up request attributes (e.g error message, status, java beans)
and forward them over the request dispatcher. The forwarded requests can then be used
by the core tags.



Java Beans:

The Java Beans are the models in the MVC
architecture. They are used as a
kind of information container which are passed through servlets, java server pages and
used as session objects.



JDBC:


The java database connectivity is an API for java programming which
allows a
client to access a
database. I created a Connection class which connects with usage of
JDBC to the database to avoid dirty code in the servlets I decided to create another level
of abstraction the query classes. Now a servlet accesses to database by using a query
class which

again uses the connection class to access the database.


Peter Plant
-
8217

AY 2010/11

7


Database:

The database was created with postgres it contains all non
-
volatile
information which should not be lost after a user leaves. It consists of a few tables the
most important are the user_t
ab table and the topo table. Below the tables of the
database are explained in detail.


Design
:


Datab
a
se

t
ables:


user_tab:
The table user_tab contains all relevant information belonging to a user. One
user can insert as many topos he wants.

topo:

The topo table contains all relevant information belonging to a topo. One topo was
uploaded exactly by one user and it can have many comments, tags and ratings.

tag:

The tag table

contains the different tags which can belong to one or more topos.

c
omment
:

The comment table contains the information about a comment
. Each
comment must belong to one topo.

rate:

The rate is a weak entity it contains the
rate which is a number between 1 and 5.


ER
-
Diagram:



Peter Plant
-
8217

AY 2010/11

8

Procedure flows of functionalities:


The procedure
flow for the functionalities is for the big part of the functions always the
same. A page calls a servlet over a form or a link the servlet takes all information which
is needed to proceed from the request. Servlet processes the function (e.g. insert user,

delete user) in all cases the database is involved. If there occurred an error or the input
of the user was not accepted the servlets sets up a request attribute and forwards the
request. If everything was fine and data was fetched form or inserted to the

database the
servlet sets up a request attribute which contains either a status message or a bean
object. Also in this case the request is forwarded. In the most cases the request is
forwarded to the origin page in other cases the request is forwarded to
another servlet
or another page. The destination page fetches the attributes from the request and
according to the attribute content it shows the right content.





In the case below we comment a topo and to store and show the new comment we have
a flow l
ike this one.





Peter Plant
-
8217

AY 2010/11

9

Main classes and methods:


The main classes are: Connection, UserQuery, TopoQuery, TopoBaseQuery, UserBean,
TopoBean and TopoBaseBean. I decided not to have dirty SQL code in my classes that’s
the reason why I have this structure of
Connection and Query classes. The three *Query
classes are doing exactly the same thing but they contain different queries I differentiate
them because I didn’t wanted to have one big Query class now all queries which are
belonging to a topo are in the To
poQuery class, all queries which are belonging to users
are in the UserQuery class and so on.



Connection:

The connection class is a kind of interface between the Database and the
Query classes. When it is instantiated the constructor calls the method set
Driver() which
sets up the driver. Before the query classes can access the database the method
setConnection() has to be called. This method tries to set up a connection to the
database by providing all the necessary credentials. Another important method i
s shown
below:


public PreparedStatement prepareStatement(String query) throws SQLException
{



return conn.prepareStatement(query);

}


This method gets the query and returns the prepared statement which is then executed.
After each query the connection to the database is closed with the method close().



TopoBaseQuery, TopoQuery & UserQuery:

These three methods are accessing the
database with insert and select queries. When one of this classes is instantiated the
constructor of the class instantiates the Connection class and calls the method
setConnection().

An example of a query is shown belo
w this method was extracted from
the TopoQuery class:


public void deleteTopo(int topoid){


String query ="DELETE FROM topo WHERE topoid = ?;";




try {



PreparedStatement stmt = dbConn.prepareStatement(query);



stmt.setInt
(1, topoid);



stmt.executeUpdate();




} catch (SQLException ex) {



Logger.getLogger(TopoQuery.class.getName()).log(Level.SEVERE, null, ex);




} finally{



this.dbConn.close();




}

}

Peter Plant
-
8217

AY 2010/11

10


This method shows

how a topo is deleted
first the query is set up than it is given to the
preapareStatment() method which returns a prepared statement of the query. After that
the prepared statement can be executed by calling the method executeUpdate() or
executeQuery() de
pending on the type of the query. The last step is to close the
connection to the database over the close() method.



UserBean:

The UserBean class contains all relevant information about a user. This
information can be accessed over the getter and setter methods of the class. In addition
there are some getter methods which return data which has first be fetched from the
database. A
n example of such a class is the
method shown below:


public Vector<String> getTopoNamesOfUser(){

TopoQuery qry = new TopoQuery();



Vector<String> nameList = qry.getToposOfUser(this.userid);




if(nameList.size() <= 0){




nameList.add("No topos in db");



}



return nameList;

}


This method is returning a list of all names of topos which a user has uploaded this
information is fetched from the database. Another special method of the this class is this:


public

static synchronized UserBean rememberUser(String email){

UserQuery qry = new UserQuery();



UserBean oldUser = qry.findUser(email);



return oldUser;

}


If the user has saved his login the email address which is stored in a cookie is used to

get
a object of UserBean which contains all the information about the returning user. This
way is not the best one to remember a login but for usage of the project it should be fine.



TopoBean:

The TopoBean class contains all relevant information about a

topo. The
information can be accessed over the getter and setter methods
of the class.



TopoBaseBean:

I’m not sure if I can say that the TopoBaseBean class is really a Java
Bean because the TopoBaseBean class contains only getter methods which are
forwarding data from the query classes. An example of such a method is:



Peter Plant
-
8217

AY 2010/11

11

public Vector<TopoBean> getLatestList(){

TopoBaseQuery newQry = new TopoBaseQuery();



Vector<TopoBean> list = newQry.fetchLatestList();



return list;

}


This method
fetches the last five added topos from a Query class and returns them.


Major technical problems
:


I have to say that I had no big problems during my work on the project. The only
problem was to find a good way to bring all this technologies together in way they work
well and
build up a solid unit
. Another problem was to differentiate the functionalitie
s of
the page because the range of possible things which can be implemented and integrated
is so huge and the time to realize this project so short. I tried to implement the big part
of the required functionalities and in additi
on I tried to integrate for
example a Google
map

to give the whole thing a special touch.