Sie sind auf Seite 1von 25

CHAPTER IV: Technical Design and

Explaination
Main Structure and Process of
Application
USER

User Input
Application
Output

Graphic User InterfaceClasses

Get Data Get Data Get Data Get Data


Set Data Set Data Set Data Set Data

BEAN Obj BEAN Obj BEAN Obj BEAN Obj UtilityClasses

Set Data Set Data Set Data Set Data


Get Data Get Data Get Data Get Data

DAO Classes
(Create – Retrieve – Update - Delete)
APPLICATION

Executed Updates
Executed Queries

Database
(Employee
Transfer
Management
2010)
DATABASE
SERVER
In the Diagram above, you can see our Application has 4 (four) parts:

- BEAN classes: contain all data were got from Database in the application.

- DAO classes: Data Access Object – contains all methods which interact
directly with database.

- Graphic User Interface classes: are Jframes and its control which
interact directly with the User, then get/set data to/from BEAN object

- Utility classes: all the common functions like create & close connection,
cryptography tools, validate form tools etc. are stored in these classes.
Detail Classes Design
2.1 BEAN Classes
Bean Classes used to store all the data which has been got from Database,
or which has been input by user and will be inserted into database.

A Bean Class should store all the data in a respective table in database. It
also stores other necessary relative data.

In this application, a Bean class can be supposedly an instance of a table,


and a Bean Object can be supposedly a row in table.

A Bean class has to contain:

- Properties correspond with all fields of a table in database and also contain
other relative data.
- Constructors (Default/Full Parameters) and Get/Set Method for all the
properties in the class

There are six Bean Classes in the Application correspond with six tables in
the database: Location, Department, Project, Role, Employee,
Transfer.
2.1.1 Location Bean
This class stores all the data which from Locations table.

It has the entire fields in Locations in the database: locationID,


locationName, and locationAllowance.

It has three extra properties are: toTransferCount, fromTransferCount,


numberOfEmployees. These properties will be used to display in table to
User, or to check when delete a Location, or used in Reporting Funtions.

Class : Location

Property name Datatyp Get/S Description


e et

locationID Int Yes Store Locations.LocationID of a row in


database

locationName String Yes Store Locations.LocationName of a row


in database

locationAllowanc double Yes Store Locations.LocationAllowance of a


e row in database

numberOfEmplo Int Yes Store the number of Employee who


yees belong to this Location.
Count(Employees.LocationID)

toTransferCount Int Yes Store the number of Transfer which


has this location in ToLocation.
Count(Transfers.ToLocationID)

fromTransferCou Int Yes Store the number of Transfer which


nt has this this location in FromLocation.
Count(Transfers.FromLocationID)
.1.2 Department Bean
This class stores all the data which from Departments table.

It has all fields in Departments in the database: departmentID,


departmentName.

It has three extra properties are: toTransferCount, fromTransferCount,


numberOfEmployees. These properties will be used to display in table to
User, or to check when delete a Department, or used in Reporting Funtions.

Class : Department

Property name Dataty Get/S Description


pe et

departmentID Int Yes Store Departments.DepartmentID of a


row in database

departmentNam String Yes Store Departments.LocationName of a


e row in database

numberOfEmplo Int Yes Store the number of Employee who


yees belongs to this department.
Count(Employees.DepartmentID)

toTransferCount Int Yes Store the number of Transfer which


has this department in ToLocation.
Count(Transfers.ToDepartmentID)

fromTransferCou Int Yes Store the number of Transfer which


nt has this this location in FromLocation.
Count(Transfers.FromDepartmentID)
2.1.3 Project Bean
This class stores all the data which from Projects table.

It has all fields in Projects in the database: projectID, projectName.

It has three extra properties are: toTransferCount, fromTransferCount,


numberOfEmployees. These properties will be used to display in table to
User, or to check when delete a Project, or used in Reporting Funtions.

Class : Project

Property name Datatyp Get/S Description


e et

projectID Int Yes Store Projects. ProjectID of a row in


database

projectName String Yes Store Projects. ProjectName of a row in


database

numberOfEmplo Int Yes Store the number of Employee who


yees belongs to this Project.
Count(Employees. ProjectID)

toTransferCount Int Yes Store the number of Transfer which


has this location in ToProject.
Count(Transfers.ToProjectID)

fromTransferCou Int Yes Store the number of Transfer which


nt has this this location in FromProject.
Count(Transfers.FromProjectID)
2.1.4 Role Bean
This class stores all the data which from Roles table.

It has all fields in Roles in the database: roleID, roleName,


roleAllowance.

It has three extra properties are: numberOfEmployees. These properties


will be used to display in table to User, or to check when delete a Project, or
used in Reporting Funtions.

Class : Project

Property name Datatyp Get/S Description


e et

roleID Int Yes Store Roles. RoleID of a row in


database

roleName String Yes Store Roles. RoleName of a row in


database

roleAllowance double Yes Store Roles.RoleAllowance of a row in


database

numberOfEmplo Int Yes Store the number of Employee who


yees has this Role.
Count(Employees.RoleID)
2.1.5 Employee Bean
This class stores all the data which from Employees table.

It has all fields in Employees in the database: EmployeID,


EmployeeName, Username, Password, IsSystemAdmin, Role,
Department, Location, Project

It has an extra property is: numberOfTransfer. These properties will be


used to display in table to User, or to check when delete a Employee, or used
in Reporting Functions.

Class : Employee

Property Datatyp Get/S Description


name e et

EmployeeID Int Yes Store Employees.EmployeeID of a row


in database

EmployeeName String Yes Store Employees.EmployeeName of a


row in database

username String Yes Store Employees.Username of a row


in database

Password String Yes Store Employees.Password of a row in


database

IsSystemAdmin boolean Yes Store Employees.IsSystemAdmin of a


row in database

numberOfTransf Int Yes Store the number of Transfers which


er belong to a Employee.

Role Role Yes Store current Role info. of this


Employee. The type of this property is
Bean Class : Role

location Location Yes Store current location info. of this


Employee. The type of this property is
Bean Class : Location

department Departm Yes Store current Department info. of this


ent Employee. The type of this property is
Bean Class : Department

Project Project Yes Store current project info. of this


Employee. The type of this property is
Bean Class : Project
2.1.6 Transfer Bean
This class stores all the data which from Transfers table.

It has all fields in Transfers in the database: transferID, Employee,


isApproved, reason, totalAllowance, fromProject, toProject,
fromDepartment, toDepartment, fromLocation, toLocation,
transferRelievingDate, transferJoiningDate.

Class : Employee

Property name Datatype Get/S Description


et

transferID Int Yes Store Transfers.TransferID of a row


in database

Employee Employee Yes Store Transfers.Employee Info of this


Transfer. The type of this property is
Bean Class : Employee.

isApproved boolean Yes Store Transfers.IsApproved of a row


in database

Reason String Yes Store Transfers.Reason of a row in


database

totalAllowance double Yes Store Transfer.TotalAllowance of a


row in database

fromProject Project Yes Store From Project info. of this


transfer. The type of this property is
Bean Class : Project

toProject Project Yes Store To Project info. of this transfer.


The type of this property is Bean
Class : Project

fromDepartment Departme Yes Store From Department info. of this


nt transfer. The type of this property is
Bean Class : Department

toDepartment Departme Yes Store To Department info. of this


nt transfer. The type of this property is
Bean Class : Department
fromLocation Location Yes Store from Location info. of this
transfer. The type of this property is
Bean Class : Location

toLocation Location Yes Store from Location info. of this


transfer. The type of this property is
Bean Class : Location

transferRelieving Java.sql.D Yes Store Transfers.


Date ate TransferRelievingDate of a row in
database

transferJoiningDa Java.sql.D Yes Store Transfers. TransferJoiningDate


te ate of a row in database
2.2 DAO Classes
DAO is the acronym of Data Access Object. A DAO should contain methods
that use for Create – Read/Retrieve – Update – Delete (CRUD) database
objects.

In this Application, each DAO class executes CRUD functions for each
respective BEAN class. We have six Bean classes correspond six tables in
Database, and then we have to create six DAO classes to maintain CRUD
actions: LocationDAO, DepartmentDAO, ProjectDAO, RoleDAO,
EmployeeDAO, and TransferDAO.

A DAO class has to contain at least: selectAll, update, insert, and delete
methods. It also has some extra methods to execute some related action to
respective BEAN class.

All methods in a DAO class should be marked [public static] to be accessed


directly from other classes.

In a method,

- Get a connection from EmpConnection class, in [etm2010.utilities]


package.

- Create Query string: use a StringBuilder object, and use


append(“something”) method of that object to append strings, instead
make string concatenation like: str1 += “something”; to improve the
performance of the application.

- Execute query: the method has to [throws Exceptions] to calling class,


instead has trycatch block inside it.

- After all: close Statements (using method in EmpConnection), close


connection, and return desire values.
2.2.1 Location DAO

Class : LocationDAO
Method Name Return type Agruments Description
selectAllLocation List<Location> Get a list of Location objects from
Locations table
insertLocation int Location obj Get data from obj agrument, append
to query string, and insert into
Locations table. Return the most
recently insert LocationID
updateLocation void Location obj Get data from obj agrument, include
LocationID, and update that Location
object to Locations table
deleteLocation Void int locID Delete a record in Locations table
which has LocationId = locID

2.2.2 Department DAO

Class : DepartmentDAO
Method Name Return type Agrument Description
s
selectAllDepartment List<Department> Get a list of Department objects
from Departments table
insertDepartment int Department Get data from obj agrument,
obj append to query string, and
insert into Departments table.
Return the most recently insert
DepartmentID
updateDepartment void Department Get data from obj agrument,
obj include DepartmentID, and
update that Department object
to Departments table
deleteDepartment Void int deptID Delete a record in Departments
table which has DepartmentID =
deptID
2.2.3 Project DAO

Class : ProjectDAO
Method Name Return type Agruments Description
selectAllProject List<Project> Get a list of Project objects from
Projects table
insertProject int Project obj Get data from obj agrument, append
to query string, and insert into
Projects table. Return the most
recently insert ProjectID
updateProject void Project obj Get data from obj agrument, include
ProjectID, and update that Project
object to Projects table
deleteProject Void int projID Delete a record from Projects table
which has Project ID = projID

2.2.4 Role DAO

Class : RoleDAO
Method Name Return type Agruments Description
selectAllRole List<Role> Get a list of Role objects from Roles
table
insertRole int Role obj Get data from obj agrument, append
to query string, and insert into Roles
table. Return the most recently
insert RoleID
updateRole void Role obj Get data from obj agrument, include
RoleID, and update that Role object
to Roles table
deleteRole Void int roleID Delete a record from Roles table
which has RoleID = projID
2.2.5 Employee DAO

Class : EmployeeDAO
Method Name Return Agrumen Description
type ts
selectAllEmployeeByCondition List String Get a list of Employee objects
<Employee> condition from Roles table base on
input condition
selectAllEmployee List selectAllEmployeeByConditio
<Employee> n() with condition string = “”
selectOneEmployeeByID Employee int EmpID selectAllEmployeeByConditio
n() with condition string =
“EmployeeID = ” + EmpID.
If the result has row,return
the first record, else return
null.
insertEmployee int Employee Get data from obj agrument,
obj append to query string, and
insert into Employees table.
Return the most recently
insert RoleID
updateEmployee void Employee Get data from obj agrument,
obj include EmployeeID, and
update that Employee object
to Employees table
deleteEmployee Void int empID Delete a record from Roles
table which has EmployeeID
= empID
2.2.6 Transfer DAO

Class : TransferDAO
Method Name Return Agrumen Description
type ts
selectAllTransferByCondition List String Get a list of Tranfer objects
<Transfer> condition from Transfers table base on
input condition
selectAllTransfer List selectAllTransferByCondition(
<Transfer> ) with condition string = “”
selectOneTransferByID Transfer int EmpID selectAllTransferByCondition(
) with condition string =
“EmployeeID = ” + EmpID.
If the result has row,return
the first record, else return
null.
insertTransfer int Transfer Get data from obj agrument,
obj append to query string, and
insert into Transfers table.
Return the most recently
insert TransferID
updateTransfer void Transfer Get data from obj agrument,
obj include TransferID, and
update that Transfer object
to Transfers table
deleteTransfer void int tranID Delete a record from
Transfers table which has
TransferID = empID
2.3 User Interface Classes
- In GUI, we should include 2 libraries: SwingX and QuaQua look and feel
to make our Application friendlier.

2.3.1 Login GUI


Login Frame

Connection Configurator Username Textfield

Password PasswordField
Server Textfield

Button Login Button Clear


Port Textfield

Action Performed :
Username Textfield Solve Connection Prolems
ButtonConfig

Password PasswordField

Action Performed &


Button Test Button Save Button Clear Login Successfully

Sidebar Details Area

MainFrame

When the application run, the first frame display is Login Frame, the user
input username and password. Login Frame gets an object has type
Employee from EmployeeDAO. If object is not null, its mean valid user, then
the Login Frame will disappear, and MainFrame will display.
At the Login Frame, when the user click on Config button (if he/she gets
connection prolems) , the Connection Configurator will display, allow the
user can change Connection String, test new connection, and save it to file.
2.3.2 Main Frame

FUNTIONAL
PANELS
Sidebar Details Area (Respective Panel
will be included on
events created by
User)

Sidebar for Sidebar for


NORMAL USER ADMINISTRATOR

When user login successfully, an Employee object will be got and pass into
the constructor of MainFrame. The MainFrame will display. MainFrame
splitted into 2 areas: the left one is Sidebar, the right one is Details Area
(most of tasks will be processed on this area).

There are 2 sidebars in MainFrame: one for NORMAL USER, one for
ADMINISTRATOR.
The Sidebar of MainFrame base on the Current User is System Admin or not,
then it display the respective sidebar.

Details Area will include components, which are derived from Jpanel
component. Each component has its own design and execute specified task
like: Employees Manage, Department Manage… correspond the required
functions.
Utility Classes
Utilitiy classes are the classes contain common methods which can be used
many times in other classes.

In the application, we have there common classes: EmpConnection,


CryptoTools, and ValidateFormTools

3.1 EmpConnection
This class maintains all tasks relate to the database connection like: open,
close, test…

Every exception has to throwed to calling classes, instead using trycatch


inside each method.

Class : EmpConecction

Method Name Return Agrum Description


type ents

readConnectionStr String Read all agrument stored in


ing connection.dat file (which created
by ConnectionConfigFrame) then
create connection string. Private.

getConnection java.sql Get connection string from


.Connect readConnectionString(), then
ion getClass
com.microsoft.sqlserver.jdbc.SQLS
erverDriver then create
connection.
If connection can be created,
return that Connection object. Else
return null.

closeConnection void Java.sql. If the agrument was passed in not


Connect null, close it.
ion

testConnection boolean Try to open the connection using


getConnection method, if get null
then return false, else if get a
correct Connection object return
true.

closePreparedStat Java.sql. If the agrument was passed not


ement Prepare null, close it.
d
Stateme
nt

closeCallableState Java.sql. If the agrument was passed not


ment Callable null, close it.
Stateme
nt
3.2 CryptoTools
This class stores methods use for Crytography function, include one-way
cryptography and decryptable cryptography.

Class : EmpConecction

Method Name Return Agrumen Description


type ts

makeKey Key Create common Key for


encrypt/decrypt task

encryptString String String raw Encrypt input String using the


Key which got from makeKey()

decryptString String String Decrypt input Encrypted String


encStr using the Key which got from
makeKey()

3.3 ValidateFormTools
This class use to check a Text Field contains data or not, check 2
JpasswordField have the exactly same string, or check a string can be
converted into number(int, double) or not.

Class : EmpConecction

Method Name Return Agrument Description


type s

isFilledTextField boolean JtextField tf, If trim = true, trim the text of


boolean Text Field.
trim
If the text of Text Field is empty
string return false, else return
true.

isSamePassword boolean JPasswordFi Return true if the text in 2


eld p1, JpasswordField components is
JPasswordFi exactly the same. Else, return
eld p2 false.

isInteger Integer String Return Integer object if input


number String is a integer, else return
null

isDouble Double String Return Double object if input


number String is a double, else return
null

Das könnte Ihnen auch gefallen