You are on page 1of 61

A Database for a Car Rental Software System

Project for the class Databases 2


in the Summer Term 2010
Software Technology (Master)
The following persons hae contribute! to this project"
#a!hi$a Mohan Priya Swaminathan
Matthias #us%ala &le'an!er (eic$mann
1 Data Model for the Car Rental System Database
1.1 Explanation of the Data and the Application
)ur software can manage !ifferent agencies that are able to proi!e cars to customers*
+ustomers can rent cars for a gien time perio!*
The releant !ata contains information about the customers, the boo$ings, a!!resses,
agencies, cars, branches of agencies an! logging*
1.2 The Data Model
1.2.1 ER Model
1.2.2 UML Model
2 Relational Desin
2.1 Table Schemas
See 1*2*1
2.2 !ormali"ation
Table# Aency
This table is in Third !ormal $orm (-./) where the ID is the primary $ey an! the other
attribute is the Name*
0ere the !ata is !epen!ent only on the primary $ey* 0ence, 1./ is satisfie!* There are no
concatenate!1composite primary $eys an! the other is the non2$ey attribute of the table
which !epen!s wholly on the primary $ey* 0ence 2

./ is also satisfie!* Moreoer, there
are no transitie !epen!encies on other tables*
Table# C%stomer
This table is in Third !ormal $orm (-./) where the Customer_ID is the primary $ey an!
it aoi!s transitie !epen!encies* This eliminates !uplication across multiple rows* 3t also
satisfies 2./*
Table# C%stomer&Address
Since it has two primary $eys cannot !etermine the normal form44
Table# 'oo(in
This table is in Third !ormal $orm (-./) where the Booking_Number_ID is the primary
$ey an! booking _date an! the return _date cannot e'ist in!epen!ently* There are also
foreign $ey attributes that come from another table to aoi! !uplication of !ata*
Table# Car
This table is in Second !ormal $orm (2./) where !ata store! in a table must be
!epen!ent only on the primary $ey an! not on any other fiel! in the table* 0ere we hae
!eclare! foreign $eys which help establish another table 5+arType5*
Table# CarType
This table is in Third !ormal $orm (-./) where !ata store! in a table is !epen!ent only
on the primary $ey an! not on any other fiel! in the table* 0ere all the non2$ey attributes in
the table are fully !etermine! by the primary $ey*
Table# 'ranch
This table is in Third !ormal $orm (-./) where the 6ranch73! is the primary $ey an!
!ata of the a!!ress is store! in a !ifferent table to aoi! re!un!ancy* #eason same as
aboe for -./"
Table# Address#
This table is in Third !ormal $orm (-./) where the ID is the primary $ey* This eliminates
!uplication across multiple rows* 3t also satisfies 2./*
2.) *nterity Constraints
Table Constraint +n Delete Rationale
+8ST)M9#7&DD#9SS +asca!e 9ach a!!ress entry is boun! to a
specific customer by the phone
number* 3t:s lifetime is therefore
boun! to the lifetime the customer it
belongs to*
6));3.< #estrict This applies to all - foreign $eys*
Since an or!er is a central piece of
information for a car rental system it
shoul! not be able to be !elete!
acci!entally (casca!e) by !eleting
either of the associate! customer,
car or agency* 6efore any of these
can be !one outstan!ing or!ers
hae to be resole! first*
6#&.+07&DD#9SS +asca!e Same rationale as for table
+8ST)M9#7&DD#9SS
+&# #estrict This applies to both foreign $eys* &
specific car shoul! obiously not be
!elete! when its !etails are !elete!*
&lso cars shoul! not be !elete!
automatically when the associate!
branch is !elete! as cars coul! be
reassigne! to other branches
beforehan!*
) System Re,%irements
/or this project a MyS=> ?*1 !atabase was use!*
Since the 0/T !i! not manage to set up a !atabase for us an! we !o not hae a serer
aailable, each !eeloper ha! to set up a local !atabase on his computer* That lea! to a
lot of !ifferent operating systems in use, e*g* M&+ )S, (in!ows @P an! (in!ows A also
!iffering in -2bit to BCbit architecture*
&!!itionally, the +ar #ental System reDuires an installe! Eaa #untime 9nironment B*
- .se Cases / Transactions / Triers
-.1 .se Cases
0oin
& customer may log in to the system* /or this he nee!s to proi!e his user name*
Show c%rrent boo(ins
& customer may reiew his current boo$ings* The current boo$ings are liste! in a table
showing the most important information*
Cancel boo(in
& customer may cancel each in!ii!ual boo$ing at any time* /or this he proi!es the
boo$ing number of the boo$ing to cancel*
Search cars
& customer may search for cars that he:s intereste! in renting* & table shows all the search
results*
'oo( car
& customer may boo$ a car* (hen !oing so, the car is resere! for a gien time perio! for
that customer*
Edit personal data
& customer may e!it his personal !ata* This inclu!es changing his email a!!ress an!
a!!ing an! e!iting personal a!!resses*
-.2 Transactions
9'planation of the transactions not necessary as state! in the Database 2 lecture of
10*0B*2010*
)ur Dueries can be foun! in section A*2 =uery 9'amples an! Transactions howeer*
-.) Triers
4.3.1 Logging
(hen !oing any !atabase action li$e inserting a new boo$ing or canceling a boo$ing this
action is logge! as a log entry in a special table shortly !escribing the transaction*
/ires upon" 3.S9#T 1 D9>9T9
Table" 6oo$ings
4.3.2 Server Timestamps
(hen a!!ing a new boo$ing a boo$ing, the current time stamp shoul! be inserte! into the
!atabase entry* This time stamp shall correspon! to the serer cloc$, not to the client
cloc$*
/ires upon" 3.S9#T
Table" 6oo$ings
1 2hysical Desin
The +ar #ental !atabase consists of the following tables"
1. +ustomer Table 2 +ontains information about the customers
2. +ustomer7&!!ress Table 2 +ontains the foreign $eys customer7i! an! a!!ress7i!
to lin$ the customer an! a!!ress tables
&!!ress Table 2 +ontains information about the a!!ress !etails of the customer*
6oo$ing Table 2 +ontains the customer boo$ing !etails for cars*
&gency Table 2 +ontains the information about car rental agencies
6ranch Table 2 +ontains the information about the !ifferent agencies at arious branch
locations*
+ar Table 2 +ontains the information about the cars an! agencies associate! with cars*
+ar7Type Table 2 +ontains the information about the types of car aailable*
This table below lists some columns in the car rental !atabase"
Table .ame +olumns Data type Details
+ustomer 3D 3.T Primary ;ey,.ot null,
&uto 3ncremente!
>ogin7.ame,9mail,.
ame
Farchar(length)
D)6 Date
Passwor! 4
9ery table has columns an! has a !ata type associate! with it* /or e'ample, in the
+ustomer table we choose the !ata type 3.T for +ustomer7i! (primary $ey)G by choosing
3.T 2 the column can hae numeric alues which are uniDue for eery customer*
+olumns li$e .ame, 9mail can hae any length of aluesG to effectiely use the !is$ space
we use the !atatype Farchar
Missin 3al%es" +ertain columns cannot hol! missing alues an! hence those are a!!e!
a .ot .ull constraint*
4%antity of Data" (e assume each table will hol! 100 recor!s initially*
Types of access" The !atabase supports the following types of access" 3nsert,8p!ate,
Mo!ify an! Delete for all tables*
9'amples"
1* +reating a new customer will insert new customer recor!s into the customer table*
2* 8p!ating the a!!ress !etails of a e'isting customer will access the customer an!
a!!ress tables*
/ile )rgani%ations"
=uery1" To list the current boo$ings for a gien customer*
S9>9+T
6));3.<*6));3.<7.8M69#, 6));3.<*6));3.<7D&T9,
6));3.<*#9T8#.7D&T9, &<9.+H*.&M9, +&#*#9<3ST#&T3).7.8M69#,
+&#7THP9*.&M9
/#)M
6));3.<
E)3. &<9.+H ).
6));3.<*&<9.+H73D I &<9.+H*3D
E)3. +&# ).
+&#*3D I 6));3.<*+&#73D
E)3. +&#7THP9 ).
+&#7THP9*3D I +&#*+&#7THP973D
(09#9
6));3.<*+8ST)M9#73D I 4
The aboe Duery inoles !ata access from many tables an! hence a E)3. between the
tables an! setting in!e'es on the primary $ey columns will help in fast !ata retrieal*
5 0ist of References
.o a!!itional references were use!*
6 Appendix
6.1 Database Tables with Data
7.1.1 AGEN!
7.1.2 "##$%NG
7.1.3 "RAN&
7.1.4 "RAN&'A((RESS
7.1.) AR
3D &<9.+H73D .&M9
1 1 Spain
2 1 <ermany
- 2 <ermany
C 2 8S&
6#&.+073D ST#99T7.&M9 +3TH7.&M9 ST#99T7.8M69# P)ST&>7+)D9 +)8.T#H P0).97.8M69#
1 Spain Street Ma!ri! -2 CC-020S Spain 2020 1 2-JJ
2 .ew Street 0amburg C- -C-02- <ermany J0-C0-
- )ther Street /ran$furt --a JC02 <ermany 2-2-J-
C >iberty Street .ew Hor$ ?-a 12--CC 8S& KC-JK
3D +&#7THP973D 6#&.+073D #9<3ST#&T3).7.8M69# +)>)# D&T97)/7M&.8/&+T8#3.< 6&S97P#3+97P9#7D&H
1 1 1 @2-22-C green 01*02*JJ 20
2 2 2 6+2-C- re! 21*02*02 1?
- - - T(2C-? blue 11*0-*01 2-
C C C 2-22CCC pin$ 0-*0C*C? 100
6));3.<7.8M69# +8ST)M9#73D &<9.+H73D +&#73D 6));3.<7D&T9 #9T8#.7D&T9 T3M97ST&MP
1 1 1 1 01*01*02 01*02*02 1?*0B*10 20"10
2 2 1 2 22*0C*0J 2-*0C*0J 1?*0B*10 20"10
- - 2 1 02*02*0- 20*02*0- 1?*0B*10 20"10
C C 2 2 20*0?*C? 21*0?*C? 1?*0B*10 20"10
K 1 1 C 0-*02*00 0-*0-*02 1?*0B*10 20"10
J 1 2 - 02*02*02 0-*02*02 1?*0B*10 20"10
10 1 2 C 0-*02*02 0C*02*02 1?*0B*10 20"12
3D .&M9
1 /irst &gency
2 &gency 6on!
7.1.* AR'T!+E
7.1.7 UST#MER
7.1., UST#MER'A((RESS
7.1.- L#GG%NG
6.2 4%ery Examples and Transactions
7.2.1 List all availa.le /ars 0or a given date and lo/ation
S9>9+T +&#7THP9*.&M9, +&#7THP9*THP9, +&#*6&S97P#3+97P9#7D&H,
+&#*#9<3ST#&T3).7.8M69#, &<9.+H*.&M9 &S &<9.+H7.&M9, 6#&.+0*.&M9 &S
6#&.+07.&M9
/#)M +&#
E)3. +&#7THP9 ). +&#7THP9*3D I +&#*+&#7THP973D
E)3. 6#&.+0 ). 6#&.+0*3D I +&#*6#&.+073D
E)3. 6#&.+07&DD#9SS ). 6#&.+07&DD#9SS*6#&.+073D I 6#&.+0*3D
E)3. &<9.+H ). &<9.+H*3D I 6#&.+0*&<9.+H73D
(09#9 +&#*3D .)T 3.
(S9>9+T 6));3.<*+&#73D /#)M 6));3.< (09#9 6));3.<*6));3.<7D&T9 LI :20022
02201: &.D 6));3.<*#9T8#.7D&T9 MI :20022022-0:)
&.D 6#&.+07&DD#9SS*+3TH7.&M9 I :.ew Hor$:
3D .&M9 P#)D8+9# THP9 &8T)M&T3+
1 ;aefer F( P;( 0
2 9J0 6M( P;( 1
- /iesta /or! P;( 0
C Tan$ &rmy Military 0
3D ST#99T7.&M9 +3TH7.&M9 ST#99T7.8M69# P)ST&>7+)D9 +)8.T#H P0).97.8M69# +8ST)M9#73D
2 Matthias Street Matthias +ity 11 -2?C <ermany 2-CC- 2
- Priya Street Priya +ity 2- -CABKA 3n!ia BC-B?CA -
C #a!hi$a Street #a!hi$a +ity CC- KBA- 3n!ia ?C-C C
? 0/T Street 0/T +ity -2a B-C2 <ermany -C2- 1 -C-2 ?
A &le' Street &le' Town CJ CJ0- &le' +ountry J0-C0 1
3D >)<3.7.&M9 #9<3ST9#7D&T9 9M&3> +8ST)M9#7THP9 /3#ST7.&M9 S8#.&M9 D&T97)/763#T0 P&SS()#D +)MP&.H7.&M9
1 &le' 0B*0B*10 ale'Nhft*!e priate &le'an!er (eic$mann 01*01*00 none
2 Matthias 02*02*0K mat%eNhft*!e priate Matthias #us%ala 02*01*00 none
- Priya 0-*0B*JJ priyaNhft*com priate Priya S 0?*0-*JJ none
C #a!hi$a 0?*0C*0- ra!hi$aNhft*com priate #a!hi$a Mohan 22*0C*-K none
? 0/T 0C*02*01 hftNstuttgart*!e company none 0/T Stuttgart
3D M9SS&<9
1 6oo$ing was !elete!*
2 .ew boo$ing was inserte!*
- .ew boo$ing was inserte!*
.&M9 THP9 6&S97P#3+97P9#7D&H #9<3ST#&T3).7.8M69# &<9.+H7.&M9 6#&.+07.&M9
Tan$ Military 100 2-22CCC &gency 6on! 8S&
7.2.2 List all /1rrent .oo2ings 0or a given /1stomer
S9>9+T 6));3.<*6));3.<7.8M69#, 6));3.<*6));3.<7D&T9,
6));3.<*#9T8#.7D&T9, &<9.+H*.&M9, +&#*#9<3ST#&T3).7.8M69#,
+&#7THP9*.&M9
/#)M 6));3.<
E)3. &<9.+H ). 6));3.<*&<9.+H73D I &<9.+H*3D
E)3. +&# ). +&#*3D I 6));3.<*+&#73D
E)3. +&#7THP9 ). +&#7THP9*3D I +&#*+&#7THP973D
(09#9 6));3.<*+8ST)M9#73D I :1:
7.2.3 Retrieve details 0or a given /1stomer
S9>9+T O /#)M +8ST)M9# (09#9 +8ST)M9#*3D I 1
7.2.4 List all addresses 0or a given /1stomer
S9>9+T +8ST)M9#*/3#ST7.&M9, +8ST)M9#*S8#.&M9,
+8ST)M9#7&DD#9SS*ST#99T7.&M9, +8ST)M9#7&DD#9SS*ST#99T7.8M69#
/#)M +8ST)M9#
E)3. +8ST)M9#7&DD#9SS ). +8ST)M9#7&DD#9SS*+8ST)M9#73D I +8ST)M9#*3D
(09#9 +8ST)M9#*3D I 1
7.2.) List all /ar t3pes
S9>9+T +&#7THP9*.&M9, +&#7THP9*P#)D8+9#
/#)M +&#7THP9
6));3.<7.8M69# 6));3.<7D&T9 #9T8#.7D&T9 .&M9 #9<3ST#&T3).7.8M69# .&M9
1 01*01*02 01*02*02 /irst &gency @2-22-C ;aefer
K 0-*02*00 0-*0-*02 /irst &gency 2-22CCC Tan$
J 02*02*02 0-*02*02 &gency 6on! T(2C-? /iesta
10 0-*02*02 0C*02*02 &gency 6on! 2-22CCC Tan$
3D >)<3.7.&M9 #9<3ST9#7D&T9 9M&3> +8ST)M9#7THP9 /3#ST7.&M9 S8#.&M9 D&T97)/763#T0 P&SS()#D +)MP&.H7.&M9
1 &le' 0B*0B*10 ale'Nhft*!e priate &le'an!er (eic$mann 01*01*00 none
.&M9 P#)D8+9#
;aefer F(
9J0 6M(
/iesta /or!
Tan$ &rmy
/3#ST7.&M9 S8#.&M9 ST#99T7.&M9 ST#99T7.8M69#
&le'an!er (eic$mann &le' Street CJ
7.2.* List all agen/ies
S9>9+T &<9.+H*.&M9
/#)M &<9.+H
7.2.7 List all .oo2ings 0or a given date and .ran/4
S9>9+T +&#*#9<3ST#&T3).7.8M69#, +8ST)M9#*/3#ST7.&M9, +8ST)M9#*S8#.&M9,
+8ST)M9#*9M&3>, 6));3.<*6));3.<7D&T9, 6));3.<*#9T8#.7D&T9
/#)M 6));3.<
E)3. +8ST)M9# ). 6));3.<*+8ST)M9#73D I +8ST)M9#*3D
E)3. +&# ). 6));3.<*+&#73D I +&#*3D
E)3. 6#&.+0 ). +&#*6#&.+073D I 6#&.+0*3D
(09#9 6#&.+0*3D I 1 &.D 6));3.<*6));3.<7D&T9 I :2002201201:
6.) Description of the Application and .ser *nterface
7.3.1 SessionManager.5ava
package de.hft.carrental.database;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.hibernate.Session;
import org.hibernate.SessionFactor;
import org.hibernate.cfg.!nnotationConfig"ration;
#$$
$ %he session &anager is a singleton that enables clients to retrieve sessions
$ fro& ever'here in the code.
$
$ @author !lexander (eic)&ann
$#
public final class SessionManager *
private static final SessionManager instance + new SessionManager,-;
private final !nnotationConfig"ration config"ration;
private final SessionFactor sessionFactor;
private Session session;
private SessionManager,- *
config"ration + new !nnotationConfig"ration,-
.config"re,.hibernate.cfg.x&l.-;
sessionFactor + config"ration.b"ildSessionFactor,-;
.&M9
/irst &gency
&gency 6on!
#9<3ST#&T3).7.8M69# /3#ST7.&M9 S8#.&M9 9M&3> 6));3.<7D&T9 #9T8#.7D&T9
@2-22-C &le'an!er (eic$mann ale'Nhft*!e 01*01*02 01*02*02
openSession,-;
/
public static SessionManager get0nstance,- *
return instance;
/
public Session openSession,- *
if ,,session ++ null- 11 2session.is3pen,-- *
if ,2,isDatabaseConnection!vailable,--- *
return null;
/
session + sessionFactor.openSession,-;
/
return session;
/
public void closeSession,- *
if ,session ++ null- *
return;
/
session.fl"sh,-;
session.close,-;
session + null;
/
public void dispose,- *
sessionFactor.close,-;
/
private boolean isDatabaseConnection!vailable,- *
String "rl + config"ration.get4ropert,.hibernate.connection."rl.-;
String db"ser + config"ration
.get4ropert,.hibernate.connection."serna&e.-;
String dbpass'ord + config"ration
.get4ropert,.hibernate.connection.pass'ord.-;
try *
Connection connection + DriverManager.getConnection,"rl5
db"ser5
dbpass'ord-;
return ,connection ++ null- 6 false 7 true;
/ catch ,SQLException e- *
return false;
/
/
/
7.3.2 Agen/3.5ava
package de.hft.carrental.do&ain;
import java."til.Set;
import javax.persistence.Cascade%pe;
import javax.persistence.Col"&n;
import javax.persistence.Entit;
import javax.persistence.8enerated9al"e;
import javax.persistence.0d;
import javax.persistence.3ne%oMan;
import javax.persistence.%able;
:Entit
:%able,na&e + .!8E;C<.-
public final class !genc *
private 0nteger id;
private String na&e;
private Set=>ranch? branches;
private Set=>oo)ing? boo)ings;
:0d
:8enerated9al"e
:Col"&n,na&e + .0D.5 "pdatable + false5 n"llable + false5 length + @A-
public 0nteger get0d,- *
return id;
/
:Col"&n,na&e + .;!ME.5 "pdatable + true5 n"llable + false-
public String get;a&e,- *
return na&e;
/
:3ne%oMan,cascade + Cascade%pe.ALL5 &apped> + .agenc.5 orphanBe&oval +
true5 targetEntit + >ranch.class-
public Set=>ranch? get>ranches,- *
return branches;
/
:3ne%oMan,cascade + Cascade%pe.ALL5 &apped> + .agenc.5 orphanBe&oval +
true5 targetEntit + >oo)ing.class-
public Set=>oo)ing? get>oo)ings,- *
return boo)ings;
/
public void set0d,0nteger id- *
this.id + id;
/
public void set;a&e,String na&e- *
this.na&e + na&e;
/
public void set>ranches,Set=>ranch? branches- *
this.branches + branches;
/
public void set>oo)ings,Set=>oo)ing? boo)ings- *
this.boo)ings + boo)ings;
/
/
7.3.3 "oo2ing.5ava
package de.hft.carrental.do&ain;
import java."til.Date;
import javax.persistence.Col"&n;
import javax.persistence.Entit;
import javax.persistence.8enerated9al"e;
import javax.persistence.0d;
import javax.persistence.CoinCol"&n;
import javax.persistence.Man%o3ne;
import javax.persistence.%able;
:Entit
:%able,na&e + .>33D0;8.-
public final class >oo)ing *
private Date boo)ingDate;
private 0nteger boo)ing;"&ber;
private Date ret"rnDate;
private C"sto&er c"sto&er;
private !genc agenc;
private Car car;
:Col"&n,na&e + .>33D0;8ED!%E.5 "pdatable + true5 n"llable + false-
public Date get>oo)ingDate,- *
return boo)ingDate;
/
:0d
:8enerated9al"e
:Col"&n,na&e + .>33D0;8E;FM>EB.5 "pdatable + false5 n"llable + false-
public 0nteger get>oo)ing;"&ber,- *
return boo)ing;"&ber;
/
:Col"&n,na&e + .BE%FB;ED!%E.5 "pdatable + true5 n"llable + false-
public Date getBet"rnDate,- *
return ret"rnDate;
/
:Man%o3ne,optional + false5 targetEntit + C"sto&er.class-
:CoinCol"&n,na&e + .CFS%3MEBE0D.5 "pdatable + false5 n"llable + false5
referencedCol"&n;a&e + .0D.-
public C"sto&er getC"sto&er,- *
return c"sto&er;
/
:Man%o3ne,optional + false5 targetEntit + !genc.class-
:CoinCol"&n,na&e + .!8E;C<E0D.5 "pdatable + false5 n"llable + false5
referencedCol"&n;a&e + .0D.-
public !genc get!genc,- *
return agenc;
/
:Man%o3ne,optional + false5 targetEntit + Car.class-
:CoinCol"&n,na&e + .C!BE0D.5 "pdatable + false5 n"llable + false5
referencedCol"&n;a&e + .0D.-
public Car getCar,- *
return car;
/
public void set>oo)ingDate,Date boo)ingDate- *
this.boo)ingDate + boo)ingDate;
/
public void set>oo)ing;"&ber,0nteger boo)ing;"&ber- *
this.boo)ing;"&ber + boo)ing;"&ber;
/
public void setBet"rnDate,Date ret"rnDate- *
this.ret"rnDate + ret"rnDate;
/
public void setC"sto&er,C"sto&er c"sto&er- *
this.c"sto&er + c"sto&er;
/
public void set!genc,!genc agenc- *
this.agenc + agenc;
/
public void setCar,Car car- *
this.car + car;
/
/
7.3.4 "ran/4.5ava
package de.hft.carrental.do&ain;
import javax.persistence.Cascade%pe;
import javax.persistence.Col"&n;
import javax.persistence.Entit;
import javax.persistence.8enerated9al"e;
import javax.persistence.0d;
import javax.persistence.CoinCol"&n;
import javax.persistence.Man%o3ne;
import javax.persistence.3ne%o3ne;
import javax.persistence.%able;
:Entit
:%able,na&e + .>B!;CG.-
public final class >ranch *
private 0nteger id;
private String na&e;
private !genc agenc;
private >ranch!ddress branch!ddress;
:0d
:8enerated9al"e
:Col"&n,na&e + .0D.5 "pdatable + false5 n"llable + false-
public 0nteger get0d,- *
return id;
/
:Col"&n,na&e + .;!ME.5 "pdatable + true5 n"llable + false5 length + @A-
public String get;a&e,- *
return na&e;
/
:Man%o3ne,optional + false5 targetEntit + !genc.class-
:CoinCol"&n,na&e + .!8E;C<E0D.5 "pdatable + false5 n"llable + false5
referencedCol"&n;a&e + .0D.-
public !genc get!genc,- *
return agenc;
/
:3ne%o3ne,cascade + Cascade%pe.ALL5 &apped> + .branch.5 optional +
false5 orphanBe&oval + true5 targetEntit + >ranch!ddress.class-
public >ranch!ddress get>ranch!ddress,- *
return branch!ddress;
/
public void set0d,0nteger id- *
this.id + id;
/
public void set;a&e,String na&e- *
this.na&e + na&e;
/
public void set!genc,!genc agenc- *
this.agenc + agenc;
/
public void set>ranch!ddress,>ranch!ddress address- *
branch!ddress + address;
/
/
7.3.) "ran/4Address.5ava
package de.hft.carrental.do&ain;
import javax.persistence.Cascade%pe;
import javax.persistence.Col"&n;
import javax.persistence.Entit;
import javax.persistence.8enerated9al"e;
import javax.persistence.0d;
import javax.persistence.CoinCol"&n;
import javax.persistence.3ne%o3ne;
import javax.persistence.%able;
:Entit
:%able,na&e + .>B!;CGE!DDBESS.-
public final class >ranch!ddress *
private String cit;a&e;
private String co"ntr;
private 0nteger id;
private String phone;"&ber;
private String postalCode;
private String street;a&e;
private String street;"&ber;
private >ranch branch;
:Col"&n,na&e + .C0%<E;!ME.5 "pdatable + false5 n"llable + false5 length +
@A-
public String getCit;a&e,- *
return cit;a&e;
/
:Col"&n,na&e + .C3F;%B<.5 "pdatable + false5 n"llable + false5 length +
@A-
public String getCo"ntr,- *
return co"ntr;
/
:0d
:8enerated9al"e
:Col"&n,na&e + .>B!;CGE0D.5 "pdatable + false5 n"llable + false-
public 0nteger get0d,- *
return id;
/
:Col"&n,na&e + .4G3;EE;FM>EB.5 "pdatable + true5 n"llable + false5 length
+ @A-
public String get4hone;"&ber,- *
return phone;"&ber;
/
:Col"&n,na&e + .43S%!LEC3DE.5 "pdatable + true5 n"llable + false5 length +
HI-
public String get4ostalCode,- *
return postalCode;
/
:Col"&n,na&e + .S%BEE%E;!ME.5 "pdatable + true5 n"llable + false5 length +
@A-
public String getStreet;a&e,- *
return street;a&e;
/
:Col"&n,na&e + .S%BEE%E;FM>EB.5 "pdatable + true5 n"llable + false5 length
+ A-
public String getStreet;"&ber,- *
return street;"&ber;
/
:3ne%o3ne,cascade + Cascade%pe.ALL5 optional + false5 targetEntit +
>ranch.class-
:CoinCol"&n,na&e + .>B!;CGE0D.5 "niq"e + true5 "pdatable + false5 n"llable
+ false-
public >ranch get>ranch,- *
return branch;
/
public void setCit;a&e,String cit;a&e- *
this.cit;a&e + cit;a&e;
/
public void setCo"ntr,String co"ntr- *
this.co"ntr + co"ntr;
/
public void set0d,0nteger id- *
this.id + id;
/
public void set4hone;"&ber,String phone;"&ber- *
this.phone;"&ber + phone;"&ber;
/
public void set4ostalCode,String postalCode- *
this.postalCode + postalCode;
/
public void setStreet;a&e,String street;a&e- *
this.street;a&e + street;a&e;
/
public void setStreet;"&ber,String street;"&ber- *
this.street;"&ber + street;"&ber;
/
public void set>ranch,>ranch branch- *
this.branch + branch;
/
/
7.3.* ar.5ava
package de.hft.carrental.do&ain;
import java."til.Date;
import java."til.Set;
import javax.persistence.Cascade%pe;
import javax.persistence.Col"&n;
import javax.persistence.Entit;
import javax.persistence.8enerated9al"e;
import javax.persistence.0d;
import javax.persistence.CoinCol"&n;
import javax.persistence.Man%o3ne;
import javax.persistence.3ne%oMan;
import javax.persistence.%able;
:Entit
:%able,na&e + .C!B.-
public final class Car *
private Float base4rice4erDa;
private String color;
private Date date3fMan"fact"ring;
private 0nteger id;
private String registration;"&ber;
private Car%pe car%pe;
private >ranch branch;
private Set=>oo)ing? boo)ings;
:Col"&n,na&e + .>!SEE4B0CEE4EBED!<.5 "pdatable + true5 n"llable + false-
public Float get>ase4rice4erDa,- *
return base4rice4erDa;
/
:Col"&n,na&e + .C3L3B.5 "pdatable + true5 n"llable + false5 length + JI-
public String getColor,- *
return color;
/
:Col"&n,na&e + .D!%EE3FEM!;FF!C%FB0;8.5 "pdatable + false5 n"llable +
false-
public Date getDate3fMan"fact"ring,- *
return date3fMan"fact"ring;
/
:0d
:8enerated9al"e
:Col"&n,na&e + .0D.5 "pdatable + false5 n"llable + false-
public 0nteger get0d,- *
return id;
/
:Col"&n,na&e + .BE80S%B!%03;E;FM>EB.5 "pdatable + false5 n"llable + false-
public String getBegistration;"&ber,- *
return registration;"&ber;
/
:Man%o3ne,optional + false5 targetEntit + Car%pe.class-
:CoinCol"&n,na&e + .C!BE%<4EE0D.5 "pdatable + false5 n"llable + false5
referencedCol"&n;a&e + .0D.-
public Car%pe getCar%pe,- *
return car%pe;
/
:Man%o3ne,optional + false5 targetEntit + >ranch.class-
:CoinCol"&n,na&e + .>B!;CGE0D.5 "pdatable + true5 n"llable + false5
referencedCol"&n;a&e + .0D.-
public >ranch get>ranch,- *
return branch;
/
:3ne%oMan,cascade + Cascade%pe.ALL5 &apped> + .car.5 targetEntit +
>oo)ing.class-
public Set=>oo)ing? get>oo)ings,- *
return boo)ings;
/
public void set>ase4rice4erDa,Float base4rice4erDa- *
this.base4rice4erDa + base4rice4erDa;
/
public void setColor,String color- *
this.color + color;
/
public void setDate3fMan"fact"ring,Date date3fMan"fact"ring- *
this.date3fMan"fact"ring + date3fMan"fact"ring;
/
public void set0d,0nteger id- *
this.id + id;
/
public void setBegistration;"&ber,String registration;"&ber- *
this.registration;"&ber + registration;"&ber;
/
public void setCar%pe,Car%pe car%pe- *
this.car%pe + car%pe;
/
public void set>ranch,>ranch branch- *
this.branch + branch;
/
public void set>oo)ings,Set=>oo)ing? boo)ings- *
this.boo)ings + boo)ings;
/
/
7.3.7 arT3pe.5ava
package de.hft.carrental.do&ain;
import javax.persistence.Col"&n;
import javax.persistence.Entit;
import javax.persistence.8enerated9al"e;
import javax.persistence.0d;
import javax.persistence.%able;
:Entit
:%able,na&e + .C!BE%<4E.-
public final class Car%pe *
private >oolean a"to&atic;
private 0nteger id;
private String na&e;
private String prod"cer;
private String tpe;
:Col"&n,na&e + .!F%3M!%0C.5 "pdatable + true5 n"llable + false-
public >oolean get!"to&atic,- *
return a"to&atic;
/
:0d
:8enerated9al"e
:Col"&n,na&e + .0D.5 "pdatable + false5 n"llable + false-
public 0nteger get0d,- *
return id;
/
:Col"&n,na&e + .;!ME.5 "pdatable + true5 n"llable + false-
public String get;a&e,- *
return na&e;
/
:Col"&n,na&e + .4B3DFCEB.5 "pdatable + true5 n"llable + false-
public String get4rod"cer,- *
return prod"cer;
/
:Col"&n,na&e + .%<4E.5 "pdatable + true5 n"llable + false-
public String get%pe,- *
return tpe;
/
public void set!"to&atic,>oolean a"to&atic- *
this.a"to&atic + a"to&atic;
/
public void set0d,0nteger id- *
this.id + id;
/
public void set;a&e,String na&e- *
this.na&e + na&e;
/
public void set4rod"cer,String prod"cer- *
this.prod"cer + prod"cer;
/
public void set%pe,String tpe- *
this.tpe + tpe;
/
/
7.3., 1stomer.5ava
package de.hft.carrental.do&ain;
import java."til.Date;
import java."til.Set;
import javax.persistence.Cascade%pe;
import javax.persistence.Col"&n;
import javax.persistence.Entit;
import javax.persistence.8enerated9al"e;
import javax.persistence.0d;
import javax.persistence.3ne%oMan;
import javax.persistence.%able;
:Entit
:%able,na&e + .CFS%3MEB.-
public final class C"sto&er *
public static final String CUSTOMER_TYPE_PRIVATE + .private.;
public static final String CUSTOMER_TYPE_COMPANY + .co&pan.;
private String co&pan;a&e;
private String c"sto&er%pe;
private Date date3f>irth;
private String e&ail;
private String first;a&e;
private 0nteger id;
private String login;a&e;
private String pass'ord;
private Date registerDate;
private String s"rna&e;
private Set=C"sto&er!ddress? c"sto&er!ddresses;
private Set=>oo)ing? boo)ings;
:Col"&n,na&e + .C3M4!;<E;!ME.5 "pdatable + true5 n"llable + true-
public String getCo&pan;a&e,- *
return co&pan;a&e;
/
:Col"&n,na&e + .CFS%3MEBE%<4E.5 "pdatable + true5 n"llable + false-
public String getC"sto&er%pe,- *
return c"sto&er%pe;
/
:Col"&n,na&e + .D!%EE3FE>0B%G.5 "pdatable + true5 n"llable + true-
public Date getDate3f>irth,- *
return date3f>irth;
/
:Col"&n,na&e + .EM!0L.5 "pdatable + true5 n"llable + false5 length + @A-
public String getE&ail,- *
return e&ail;
/
:Col"&n,na&e + .F0BS%E;!ME.5 "pdatable + true5 n"llable + true5 length +
@A-
public String getFirst;a&e,- *
return first;a&e;
/
:0d
:8enerated9al"e
:Col"&n,na&e + .0D.5 "pdatable + false5 n"llable + false-
public 0nteger get0d,- *
return id;
/
:Col"&n,na&e + .L380;E;!ME.5 "pdatable + false5 n"llable + false5 length +
@A-
public String getLogin;a&e,- *
return login;a&e;
/
:Col"&n,na&e + .4!SS(3BD.5 "pdatable + true5 n"llable + false5 length +
@A-
public String get4ass'ord,- *
return pass'ord;
/
:Col"&n,na&e + .BE80S%EBED!%E.5 "pdatable + false5 n"llable + false-
public Date getBegisterDate,- *
return registerDate;
/
:Col"&n,na&e + .SFB;!ME.5 "pdatable + true5 n"llable + true5 length + @A-
public String getS"rna&e,- *
return s"rna&e;
/
:3ne%oMan,cascade + Cascade%pe.ALL5 &apped> + .c"sto&er.5 orphanBe&oval
+ true5 targetEntit + C"sto&er!ddress.class-
public Set=C"sto&er!ddress? getC"sto&er!ddresses,- *
return c"sto&er!ddresses;
/
:3ne%oMan,cascade + Cascade%pe.ALL5 &apped> + .c"sto&er.5 orphanBe&oval
+ true5 targetEntit + >oo)ing.class-
public Set=>oo)ing? get>oo)ings,- *
return boo)ings;
/
public void setCo&pan;a&e,String co&pan;a&e- *
this.co&pan;a&e + co&pan;a&e;
/
public void setC"sto&er%pe,String c"sto&er%pe- *
this.c"sto&er%pe + c"sto&er%pe;
/
public void setDate3f>irth,Date date3f>irth- *
this.date3f>irth + date3f>irth;
/
public void setE&ail,String e&ail- *
this.e&ail + e&ail;
/
public void setFirst;a&e,String first;a&e- *
this.first;a&e + first;a&e;
/
public void set0d,0nteger id- *
this.id + id;
/
public void setLogin;a&e,String login;a&e- *
this.login;a&e + login;a&e;
/
public void set4ass'ord,String pass'ord- *
this.pass'ord + pass'ord;
/
public void setBegisterDate,Date registerDate- *
this.registerDate + registerDate;
/
public void setS"rna&e,String s"rna&e- *
this.s"rna&e + s"rna&e;
/
public void set>oo)ings,Set=>oo)ing? boo)ings- *
if ,this.boo)ings ++ null- *
this.boo)ings + boo)ings;
/ else *
this.boo)ings.clear,-;
this.boo)ings.add!ll,boo)ings-;
/
/
public void setC"sto&er!ddresses,Set=C"sto&er!ddress? c"sto&er!ddresses- *
if ,this.c"sto&er!ddresses ++ null- *
this.c"sto&er!ddresses + c"sto&er!ddresses;
/ else *
this.c"sto&er!ddresses.clear,-;
this.c"sto&er!ddresses.add!ll,c"sto&er!ddresses-;
/
/
/
7.3.- 1stomerAddress.5ava
package de.hft.carrental.do&ain;
import javax.persistence.Col"&n;
import javax.persistence.Entit;
import javax.persistence.8enerated9al"e;
import javax.persistence.0d;
import javax.persistence.CoinCol"&n;
import javax.persistence.Man%o3ne;
import javax.persistence.%able;
:Entit
:%able,na&e + .CFS%3MEBE!DDBESS.-
public final class C"sto&er!ddress *
private String cit;a&e;
private String co"ntr;
private 0nteger id;
private String phone;"&ber;
private String postalCode;
private String street;"&ber;
private String street;a&e;
private C"sto&er c"sto&er;
:Col"&n,na&e + .C0%<E;!ME.5 "pdatable + true5 n"llable + false5 length +
@A-
public String getCit;a&e,- *
return cit;a&e;
/
:Col"&n,na&e + .C3F;%B<.5 "pdatable + true5 n"llable + false5 length + @A-
public String getCo"ntr,- *
return co"ntr;
/
:0d
:8enerated9al"e
:Col"&n,na&e + .0D.5 "pdatable + false5 n"llable + false-
public 0nteger get0d,- *
return id;
/
:Col"&n,na&e + .4G3;EE;FM>EB.5 "pdatable + true5 n"llable + false5 length
+ @A-
public String get4hone;"&ber,- *
return phone;"&ber;
/
:Col"&n,na&e + .43S%!LEC3DE.5 "pdatable + true5 n"llable + false5 length +
HI-
public String get4ostalCode,- *
return postalCode;
/
:Col"&n,na&e + .S%BEE%E;!ME.5 "pdatable + true5 n"llable + false5 length +
@A-
public String getStreet;a&e,- *
return street;a&e;
/
:Col"&n,na&e + .S%BEE%E;FM>EB.5 "pdatable + true5 n"llable + false5 length
+ A-
public String getStreet;"&ber,- *
return street;"&ber;
/
:Man%o3ne,optional + false5 targetEntit + C"sto&er.class-
:CoinCol"&n,na&e + .CFS%3MEBE0D.5 "pdatable + false5 n"llable + false5
referencedCol"&n;a&e + .0D.-
public C"sto&er getC"sto&er,- *
return c"sto&er;
/
public void setCit;a&e,String cit;a&e- *
this.cit;a&e + cit;a&e;
/
public void setCo"ntr,String co"ntr- *
this.co"ntr + co"ntr;
/
public void set0d,0nteger id- *
this.id + id;
/
public void set4hone;"&ber,String phone;"&ber- *
this.phone;"&ber + phone;"&ber;
/
public void set4ostalCode,String postalCode- *
this.postalCode + postalCode;
/
public void setStreet;"&ber,String street;"&ber- *
this.street;"&ber + street;"&ber;
/
public void setStreet;a&e,String street;a&e- *
this.street;a&e + street;a&e;
/
public void setC"sto&er,C"sto&er c"sto&er- *
this.c"sto&er + c"sto&er;
/
/
7.3.16 Main.5ava
package de.hft.carrental.&ain;
import de.hft.carrental."i.splash.Splash(indo';
#$$
$ %his class contains the &ain &ethod allo'ing the progra& to be exec"ted.
$
$ @author !lexander (eic)&ann
$#
public final class Main *
#$$
$ %his &ain &ethod opens "p the splash 'indo'.
$#
public static void &ain,StringKL args- *
new Splash(indo',-;
/
/
7.3.11 7indo8.5ava
package de.hft.carrental."i;
import java.a't.Di&ension;
import java.a't.8rid>agConstraints;
import java.a't.8rid>agLao"t;
import java.a't.0nsets;
import java.a't.%ool)it;
import javax.s'ing.CFra&e;
import javax.s'ing.F0Manager;
import javax.s'ing.Fns"pportedLoo)!ndFeelException;
import de.hft.carrental."i."til.8rid>agFtil;
#$$
$ %his class represents an application 'indo'. 0n addition to a nor&al
$ *:lin) CFra&e/ it "ses the native loo) and feel of the "sed 3S. %he 'indo'
$ 'ill also be positioned in the center of the screen b defa"lt. %he title of
$ the 'indo' as 'ell as the defa"lt close operation 'ill be alread set.
$ =p?
$ F"rther&ore5 a grid lao"t is assigned to the 'indo'. ! convenience &ethod is
$ offered to s"bclasses that enables rapid creation of
$ *:lin) 8rid>agConstraints/.
$ =p?
$ !lso5 the concept of a c"rrent *:lin) (indo'4age/ is introd"ced. Fsing the
$ &ethod *:lin) Ms'itch4age%o,(indo'4age-/ s"bclasses can s'itch to another
$ 'indo' page at an ti&e.
$
$ @author !lexander (eic)&ann
$#
public abstract class (indo' extends CFra&e *
private static final String WINDOW_TITLE + .Car Bental Sste&.;
private static final long serialVersionUID + AIAIHNA@IJNNNOPQ@J@L;
#$$
$ %he *:lin) (indo'4age/ that is c"rrentl displaed.
$#
private (indo'4age c"rrent4age;
protected (indo',- *
set;ativeLoo)!ndFeel,-;
setDefa"ltClose3peration,EXIT_ON_CLOSE-;
set%itle,WINDOW_TITLE-;
center3nScreen,-;
createLao"t,-;
/
private void center3nScreen,- *
%ool)it toolDit + %ool)it.getDefaltTool!it,-;
Di&ension screenSiRe + toolDit.getScreenSiRe,-;
int screenGeight + screenSiRe.height;
int screen(idth + screenSiRe.'idth;
int x + ,screen(idth # S- T ,getMin(idth,- # S-;
int + ,screenGeight # S- T ,getMinGeight,- # S-;
setMini&"&SiRe,new Di&ension,getMin(idth,-5 getMinGeight,---;
setLocation,x5 -;
/
private void createLao"t,- *
8rid>agLao"t lao"t + new 8rid>agLao"t,-;
setLao"t,lao"t-;
/
#$$
$ S'itches to the provided *:lin) (indo'4age/. Ca"ses the 'indo' to be
$ repainted so the contents of the ne' page are sho'n i&&ediatel.
$
$ @param page
$ %he *:lin) (indo'4age/ to s'itch to.
$#
protected final void s'itch4age%o,(indo'4age page- *
if ,c"rrent4age 2+ null- *
re&ove,c"rrent4age-;
/
add,page5 8rid>agFtil.create"ri#$agConstraints,I5 H5 H5 H5
8rid>agConstraints.$OT%5 new 0nsets,HI5 I5 I5 I-5
8rid>agConstraints.&IRST_LINE_START5 I5 I--;
c"rrent4age + page;
c"rrent4age.refresh,-;
validate,-;
repaint,-;
/
#$$
$ M"st ret"rn the &ini&"& 'idth this 'indo' shall have.
$#
protected abstract int getMin(idth,-;
#$$
$ M"st ret"rn the &ini&"& height this 'indo' shall have.
$#
protected abstract int getMinGeight,-;
private void set;ativeLoo)!ndFeel,- *
try *
F0Manager.setLoo!An#&eel,F0Manager.getS'ste(Loo!An#&eelClassNa(e,--;
/ catch ,Class;otFo"ndException e- *
e.printStac)%race,-;
/ catch ,0nstantiationException e- *
e.printStac)%race,-;
/ catch ,0llegal!ccessException e- *
e.printStac)%race,-;
/ catch ,Fns"pportedLoo)!ndFeelException e- *
e.printStac)%race,-;
/
/
/
7.3.12 7indo8+age.5ava
package de.hft.carrental."i;
import java.a't.Container;
import java.a't.8ridLao"t;
import java."til.!rraList;
import java."til.List;
#$$
$ (indo' pages are "sed b the class *:lin) (indo'/. 3ne 'indo' page b"ndles
$ together a n"&ber of *:lin) (indo'4ageSection/s. For exa&ple5 there co"ld
$ exist a 'indo' page 'ith t'o 'indo' page sections. 3ne section sho's a search
$ for&"la5 'hile the second section sho's a table 'ith the search res"lts.
$
$ @see (indo'
$
$ @author !lexander (eic)&ann
$#
public abstract class (indo'4age extends Container *
private static final long serialVersionUID + TOJOHHQSQOPANSHQSOAIL;
#$$ %he *:lin) (indo'/ this 'indo' page belongs to. $#
private final (indo' 'indo';
private final List=(indo'4ageSection? sections;
#$$
$ @param 'indo'
$ %he *:lin) (indo'/ this 'indo' page 'ill belong to.
$ @param lao"tBo's
$ Specifies the n"&ber of ho' &an ro's the pageUs grid lao"t
$ consists of.
$ @param lao"tCol"&ns
$ Specifies the n"&ber of ho' &an col"&ns the pageUs grid
$ lao"t consists of.
$#
protected (indo'4age,(indo' 'indo'5 int lao"tBo's5 int lao"tCol"&ns- *
super,-;
this.'indo' + 'indo';
sections + new !rraList=(indo'4ageSection?,-;
createLao"t,lao"tBo's5 lao"tCol"&ns-;
addSections,-;
/
private void createLao"t,int ro's5 int col"&ns- *
8ridLao"t lao"t + new 8ridLao"t,ro's5 col"&ns-;
setLao"t,lao"t-;
/
#$$
$ Besponsible for adding the necessar *:lin) (indo'4ageSection/s to this
$ page.
$#
protected abstract void addSections,-;
#$$
$ !dds the given *:lin) (indo'4ageSection/ to this 'indo' page.
$
$ @param section
$ %he 'indo' page section to add.
$#
protected final void addSection,(indo'4ageSection section- *
add,section-;
sections.add,section-;
/
#$$
$ Bet"rns the *:lin) (indo'/ this 'indo' page belongs to.
$#
public final (indo' get(indo',- *
return 'indo';
/
#$$
$ Befreshes the contents of this page b refreshing all of itUs sections.
$#
public final void refresh,- *
for ,(indo'4ageSection section 7 sections- *
section.refresh,-;
/
/
/
7.3.13 7indo8+ageSe/tion.5ava
package de.hft.carrental."i;
import java.a't.Font;
import javax.s'ing.>orderFactor;
import javax.s'ing.C4anel;
import javax.s'ing.border.%itled>order;
#$$
$ %his class is li)e a *:lin) C4anel/. 0n addition5 it has a title and a
$ border. %he title is displaed at the top left of the border. ! 'indo' page
$ section al'as belongs to a specific *:lin) (indo'4age/. %he contents of the
$ section can be refreshed "sing the &ethod *:lin) Mrefresh,-/.
$
$ @author !lexander (eic)&ann
$#
public abstract class (indo'4ageSection extends C4anel *
private static final long serialVersionUID + OSJOOIAQISQPJIJHNQJL;
#$$
$ %he *:lin) (indo'4age/ this 'indo' page section belongs to.
$#
private final (indo'4age 'indo'4age;
#$$
$ @param 'indo'4age
$ %he *:lin) (indo'4age/ this 'indo' page sections belongs to.
$ @param title
$ %he title of this 'indo' page section that 'ill be displaed
$ at the top left of the sectionUs border.
$#
protected (indo'4ageSection,(indo'4age 'indo'4age5 String title- *
this.'indo'4age + 'indo'4age;
create>order,title-;
/
private void create>order,String title- *
%itled>order border + >orderFactor.createTitle#$or#er,title V .7.-;
border.set%itleFont,new Font,.!rial.5 Font.$OLD5 HH--;
set>order,border-;
/
#$$
$ Bet"rns the *:lin) (indo'4age/ this 'indo' page section belongs to.
$#
public final (indo'4age get(indo'4age,- *
return 'indo'4age;
/
#$$
$ Befreshes the contents of this 'indo' page section.
$#
protected abstract void refresh,-;
/
7.3.14 Main7indo8.5ava
package de.hft.carrental."i.&ain;
import java.a't.8rid>agConstraints;
import java.a't.0nsets;
import java.a't.event.!ctionEvent;
import java.a't.event.!ctionListener;
import javax.s'ing.0&age0con;
import javax.s'ing.C>"tton;
import javax.s'ing.C4anel;
import de.hft.carrental.database.SessionManager;
import de.hft.carrental.do&ain.C"sto&er;
import de.hft.carrental."i.(indo';
import de.hft.carrental."i.&ain.boo)ings.C"rrent>oo)ings4age;
import de.hft.carrental."i.&ain.cars.Cars4age;
import de.hft.carrental."i.&ain.personal.4ersonal4age;
import de.hft.carrental."i.splash.Splash(indo';
import de.hft.carrental."i."til.8rid>agFtil;
#$$
$ %he &ain 'indo' is the applicationUs 'indo' that appears after the login 'as
$ s"ccessf"l. 0t provides a &en" at the top of the 'indo' 'hich allo's
$ navigating to the different "se cases. 0n addition5 it provides a h"ge area
$ of space belo' that &en"5 'here the contents of the c"rrent 'indo' page are
$ displaed.
$
$ @author !lexander (eic)&ann
$#
public final class Main(indo' extends (indo' implements !ctionListener *
private static final long serialVersionUID + THIP@SAQAH@ON@HSNNIAL;
private static final int MINIMUM_WIDT% + Q@I;
private static final int MINIMUM_%EI"%T + @II;
#$$ %his action co&&and triggers the UC"rrent >oo)ingsU "se case. $#
private static final String AC_CURRENT_$OO)IN"S + .c"rrentEboo)ings.;
#$$ %his action co&&and triggers the USearch CarsU "se case. $#
private static final String AC_SEARC%_CARS + .searchEcars.;
#$$ %his action co&&and triggers the UEdit 4ersonal DataU "se case. $#
private static final String AC_EDIT_PERSONAL_DATA + .editEpersonalEdata.;
#$$ %his action co&&and triggers the logo"t. $#
private static final String AC_LO"OUT + .logo"t.;
private final C"rrent>oo)ings4age c"rrent>oo)ings4age;
private final Cars4age searchCars4age;
private final 4ersonal4age edit4ersonalData4age;
private final C"sto&er logged0nFser;
public Main(indo',C"sto&er "ser- *
super,-;
logged0nFser + "ser;
String title + get%itle,-;
set%itle,title V . Klogged in as7 . V "ser.getLogin;a&e,- V .L.-;
c"rrent>oo)ings4age + new C"rrent>oo)ings4age,this-;
searchCars4age + new Cars4age,this-;
edit4ersonalData4age + new 4ersonal4age,this-;
createMen",-;
sho'C"rrent>oo)ings4age,-;
set9isible,true-;
/
#$$
$ Creates the &en" that is sho'n at the top of the 'indo'.
$#
private void createMen",- *
C4anel &en"4anel + new C4anel,-;
C>"tton c"rrent>oo)ings>"tton + new C>"tton,.C"rrent >oo)ings.-;
c"rrent>oo)ings>"tton.set!ctionCo&&and,AC_CURRENT_$OO)IN"S-;
c"rrent>oo)ings>"tton.add!ctionListener,this-;
c"rrent>oo)ings>"tton.set0con,new 0&age0con,
.i&ages#c"rrentEboo)ings.png.--;
&en"4anel.add,c"rrent>oo)ings>"tton-;
C>"tton searchCars>"tton + new C>"tton,.Search Cars.-;
searchCars>"tton.set!ctionCo&&and,AC_SEARC%_CARS-;
searchCars>"tton.add!ctionListener,this-;
searchCars>"tton.set0con,new 0&age0con,.i&ages#searchEcars.png.--;
&en"4anel.add,searchCars>"tton-;
C>"tton edit4ersonalData>"tton + new C>"tton,.Edit 4ersonal Data.-;
edit4ersonalData>"tton.set!ctionCo&&and,AC_EDIT_PERSONAL_DATA-;
edit4ersonalData>"tton.add!ctionListener,this-;
edit4ersonalData>"tton.set0con,new 0&age0con,
.i&ages#editEpersonalEdata.png.--;
&en"4anel.add,edit4ersonalData>"tton-;
C>"tton logo"t>"tton + new C>"tton,.Logo"t.-;
logo"t>"tton.set!ctionCo&&and,AC_LO"OUT-;
logo"t>"tton.add!ctionListener,this-;
logo"t>"tton.set0con,new 0&age0con,.i&ages#logo"t.png.--;
&en"4anel.add,logo"t>"tton-;
add,&en"4anel5 8rid>agFtil.create"ri#$agConstraints,I5 I5 H5 I5
8rid>agConstraints.$OT%5 new 0nsets,I5 I5 I5 I-5
8rid>agConstraints.&IRST_LINE_START5 I5 I--;
/
public void sho'C"rrent>oo)ings4age,- *
s'itch4age%o,c"rrent>oo)ings4age-;
/
public void sho'SearchCars4age,- *
s'itch4age%o,searchCars4age-;
/
public void sho'Edit4ersonalData4age,- *
s'itch4age%o,edit4ersonalData4age-;
/
:3verride
protected int getMinGeight,- *
return MINIMUM_%EI"%T;
/
:3verride
protected int getMin(idth,- *
return MINIMUM_WIDT%;
/
:3verride
public void action4erfor&ed,!ctionEvent e- *
String co&&and + e.get!ctionCo&&and,-;
if ,co&&and.eq"als,AC_CURRENT_$OO)IN"S-- *
sho'C"rrent>oo)ings4age,-;
/ else if ,co&&and.eq"als,AC_SEARC%_CARS-- *
sho'SearchCars4age,-;
/ else if ,co&&and.eq"als,AC_EDIT_PERSONAL_DATA-- *
sho'Edit4ersonalData4age,-;
/ else if ,co&&and.eq"als,AC_LO"OUT-- *
logo"t,-;
/
/
public C"sto&er getLogged0nFser,- *
return logged0nFser;
/
#$$
$ Logs the c"rrent "ser o"t and sho's the login screen et again.
$#
private void logo"t,- *
SessionManager.getInstance,-.closeSession,-;
set9isible,false-;
new Splash(indo',-;
/
/
7.3.1) Main7indo8+age.5ava
package de.hft.carrental."i.&ain;
import de.hft.carrental.do&ain.C"sto&er;
import de.hft.carrental."i.(indo'4age;
#$$
$ ! page belonging to the *:lin) Main(indo'/. 0n addition to a nor&al 'indo'
$ page5 this class provides a &ethod to retrieve the c"rrentl logged in "ser.
$
$ @author !lexander (eic)&ann
$#
public abstract class Main(indo'4age extends (indo'4age *
private static final long serialVersionUID + SPASPSQOIPSOAHHIHHIL;
protected Main(indo'4age,Main(indo' &ain(indo'5 int lao"tBo's5
int lao"tCol"&ns- *
super,&ain(indo'5 lao"tBo's5 lao"tCol"&ns-;
/
protected final C"sto&er getLogged0nFser,- *
return ,,Main(indo'- get(indo',--.getLogged0nFser,-;
/
/
7.3.1* Main7indo8+ageSe/tion.5ava
package de.hft.carrental."i.&ain;
import de.hft.carrental.do&ain.C"sto&er;
import de.hft.carrental."i.(indo'4ageSection;
#$$
$ ! 'indo' page section that belongs to a *:lin) Main(indo'4age/. 0n addition
$ to a nor&al page it offers a &ethod that enables s"bclasses to retrieve the
$ c"rrentl logged in "ser.
$
$ @author !lexander (eic)&ann
$#
public abstract class Main(indo'4ageSection extends (indo'4ageSection *
private static final long serialVersionUID + THSI@HNSAAQQP@SPJI@NL;
protected Main(indo'4ageSection,Main(indo'4age &ain(indo'4age5 String
title- *
super,&ain(indo'4age5 title-;
/
protected final C"sto&er getLogged0nFser,- *
return ,,Main(indo'4age- get(indo'4age,--.getLogged0nFser,-;
/
/
7.3.17 Ta.leSe/tion.5ava
package de.hft.carrental."i.&ain;
import java.a't.8rid>agConstraints;
import java.a't.8rid>agLao"t;
import java.a't.0nsets;
import javax.s'ing.C%able;
import javax.s'ing.table.Defa"lt%ableModel;
import javax.s'ing.table.C%ableGeader;
import de.hft.carrental."i."til.8rid>agFtil;
#$$
$ %his abstract class provides a section that contains a table. %his table can
$ be config"red as necessar b s"bclasses5 for exa&ple 'hich col"&ns the table
$ has.
$
$ @author !lexander (eic)&ann
$#
public abstract class %ableSection extends Main(indo'4ageSection *
private static final long serialVersionUID + NONQ@IJJNJQNIA@PPHSL;
#$$ %he S'ing table F0 'idget. $#
private C%able table;
#$$ %he table &odel that &anages the data of the table. $#
private Defa"lt%ableModel tableModel;
#$$
$ @param page
$ %he 'indo' page this section belongs to.
$ @param title
$ %he title for this section that 'ill be sho'n in the title
$ area of the section.
$ @param col"&n;a&es
$ %he na&es of the col"&ns this table shall have.
$ @param col"&n(idths
$ %he 'idth of each col"&n.
$#
protected %ableSection,Main(indo'4age page5 String title5
StringKL col"&n;a&es5 intKL col"&n(idths- *
super,page5 title-;
createLao"t,-;
beforeCreate%able,-;
create%able,col"&n;a&es5 col"&n(idths-;
/
protected void beforeCreate%able,- *
## E&pt defa"lt i&ple&entation.
/
private void create%able,StringKL col"&n;a&es5 intKL col"&n(idths- *
tableModel + new Defa"lt%ableModel,-;
for ,String col"&n;a&e 7 col"&n;a&es- *
tableModel.addCol"&n,col"&n;a&e-;
/
table + new C%able,tableModel-;
int col"&nMargin + A;
table.getCol"&nModel,-.setCol"&nMargin,col"&nMargin-;
for ,int i + I; i = col"&n(idths.length; iVV- *
table.getCol"&n,col"&n;a&esKiL-.set4referred(idth,col"&n(idthsKiL-;
/
C%ableGeader tableGeader + table.get%ableGeader,-;
tableGeader.getCol"&nModel,-.setCol"&nMargin,col"&nMargin-;
add,tableGeader5 8rid>agFtil.create"ri#$agConstraints,I5 H5 H5 I5
8rid>agConstraints.%ORI*ONTAL5 new 0nsets,I5 I5 I5 I-5
8rid>agConstraints.&IRST_LINE_START5 I5 I--;
add,table5 8rid>agFtil.create"ri#$agConstraints,I5 S5 H5 H5
8rid>agConstraints.%ORI*ONTAL5 new 0nsets,I5 I5 I5 I-5
8rid>agConstraints.&IRST_LINE_START5 I5 I--;
/
protected void createLao"t,- *
8rid>agLao"t lao"t + new 8rid>agLao"t,-;
setLao"t,lao"t-;
/
#$$
$ Clears the table b re&oving all data fro& the table so that it is
e&pt
$ after a call to this operation.
$#
protected final void clear%able,- *
tableModel.getData9ector,-.clear,-;
/
#$$
$ !dds one ro' of data to the table.
$
$ @param ro'Data
$ %he arra containing the ro' data.
$#
protected final void addDataBo',3bjectKL ro'Data- *
tableModel.addBo',ro'Data-;
/
/
7.3.1, 1rrent"oo2ings+age.5ava
package de.hft.carrental."i.&ain.boo)ings;
import de.hft.carrental."i.&ain.Main(indo';
import de.hft.carrental."i.&ain.Main(indo'4age;
#$$
$ %his page belongs to the *:lin) Main(indo'/ and enables the "ser to revie'
$ his c"rrent boo)ings.
$
$ @author !lexander (eic)&ann
$#
public final class C"rrent>oo)ings4age extends Main(indo'4age *
private static final long serialVersionUID + AJQS@POSH@SHJSP@S@JL;
public C"rrent>oo)ings4age,Main(indo' &ain(indo'- *
super,&ain(indo'5 H5 H-;
/
:3verride
protected void addSections,- *
addSection,new C"rrent>oo)ings%ableSection,this--;
/
/
7.3.1- 1rrent"oo2ingsTa.leSe/tion.5ava
package de.hft.carrental."i.&ain.boo)ings;
import java.a't.Flo'Lao"t;
import java.a't.Font;
import java.a't.8rid>agConstraints;
import java.a't.0nsets;
import java.a't.event.!ctionEvent;
import java.a't.event.!ctionListener;
import java.a't.event.Foc"sEvent;
import java.a't.event.Foc"sListener;
import java.a't.event.DeEvent;
import java.a't.event.DeListener;
import java."til.Date;
import java."til.0terator;
import java."til.Set;
import javax.s'ing.C>"tton;
import javax.s'ing.CLabel;
import javax.s'ing.C4anel;
import javax.s'ing.C%extField;
import org.hibernate.Session;
import org.hibernate.%ransaction;
import de.hft.carrental.database.SessionManager;
import de.hft.carrental.do&ain.>oo)ing;
import de.hft.carrental.do&ain.>ranch!ddress;
import de.hft.carrental."i.&ain.%ableSection;
import de.hft.carrental."i."til.8rid>agFtil;
#$$
$ %his section belongs to the *:lin) C"rrent>oo)ings4age/. 0t sho's a table
$ 'ith all the infor&ation relevant to the "serUs c"rrent boo)ings.
$
$ @author !lexander (eic)&ann
$#
public final class C"rrent>oo)ings%ableSection extends %ableSection implements
!ctionListener *
private static final long serialVersionUID + PIQQHSQJQPN@@PQQSNNL;
private static final String AC_CANCEL + .Cancel.;
private static final intKL COLUMN_WIDT%S + new intKL * AA5 PA5 PA5 NI5 QI5
QI5 HPI /;
private static final StringKL COLUMN_NAMES + new StringKL * .>oo)ing ;r..5
.>oo)ing Date.5 .Bet"rn Date.5 .Car %pe.5 .Begistration
;"&ber.5
.!genc.5 .Location. /;
private C%extField cancelField;
#$$
$ @param c"rrent>oo)ings4age
$ %he *:lin) C"rrent>oo)ings4age/ this section belongs to.
$#
protected C"rrent>oo)ings%ableSection,
C"rrent>oo)ings4age c"rrent>oo)ings4age- *
super,c"rrent>oo)ings4age5 .C"rrent >oo)ings.5 COLUMN_NAMES5
COLUMN_WIDT%S-;
/
:3verride
protected void refresh,- *
clear%able,-;
fill%able(ithData,-;
/
:3verride
protected void beforeCreate%able,- *
C4anel cancel4anel + new C4anel,-;
cancel4anel.setLao"t,new Flo'Lao"t,--;
CLabel cancelLabel + new CLabel,.Cancel >oo)ing7 .-;
cancelLabel.setFont,new Font,.!rial.5 Font.$OLD5 HH--;
cancel4anel.add,cancelLabel-;
cancelField + new C%extField,HI-;
cancelField.set%ext,.>oo)ing ;r..-;
cancelField.addFoc"sListener,new Foc"sListener,- *
:3verride
public void foc"s8ained,Foc"sEvent e- *
cancelField.set%ext,..-;
/
:3verride
public void foc"sLost,Foc"sEvent e- *
if ,cancelField.get%ext,-.length,- ++ I- *
cancelField.set%ext,.>oo)ing ;r..-;
/
/
/-;
cancelField.addDeListener,new DeListener,- *
:3verride
public void )e4ressed,DeEvent e- *
## ;othing to do.
/
:3verride
public void )eBeleased,DeEvent e- *
if ,e.getDeCode,- ++ DeEvent.V)_ENTER- *
cancel>oo)ing,-;
/
/
:3verride
public void )e%ped,DeEvent e- *
## ;othing to do.
/
/-;
cancel4anel.add,cancelField-;
C>"tton cancel>"tton + new C>"tton,.Cancel2.-;
cancel>"tton.add!ctionListener,this-;
cancel>"tton.set!ctionCo&&and,AC_CANCEL-;
cancel4anel.add,cancel>"tton-;
add,cancel4anel5 8rid>agFtil.create"ri#$agConstraints,I5 I5 H5 I5
8rid>agConstraints.$OT%5 new 0nsets,I5 I5 I5 I-5
8rid>agConstraints.&IRST_LINE_START5 I5 I--;
/
private void fill%able(ithData,- *
0terator=>oo)ing? it + getLogged0nFser,-.get>oo)ings,-.iterator,-;
for ,int i + I; it.has;ext,-; iVV- *
3bjectKL ro'Data + new 3bjectKOL;
>oo)ing boo)ing + it.next,-;
ro'DataKIL + boo)ing.get>oo)ing;"&ber,-;
Date boo)ingDate + boo)ing.get>oo)ingDate,-;
String boo)ingDateString + boo)ingDate.toString,-;
ro'DataKHL + boo)ingDateString.s"bstring,I5 boo)ingDateString
.index3f,. .--;
Date ret"rnDate + boo)ing.getBet"rnDate,-;
String ret"rnDateString + ret"rnDate.toString,-;
ro'DataKSL + ret"rnDateString.s"bstring,I5 ret"rnDateString
.index3f,. .--;
ro'DataKJL + boo)ing.getCar,-.getCar%pe,-.get;a&e,-;
ro'DataK@L + boo)ing.getCar,-.getBegistration;"&ber,-;
ro'DataKAL + boo)ing.get!genc,-.get;a&e,-;
>ranch!ddress branch!ddress + boo)ing.getCar,-.get>ranch,-
.get>ranch!ddress,-;
ro'DataKPL + branch!ddress.get4ostalCode,- V . .
V branch!ddress.getCit;a&e,- V .5 .
V branch!ddress.getStreet;a&e,- V . .
V branch!ddress.getStreet;"&ber,-;
addDataBo',ro'Data-;
/
/
:3verride
public void action4erfor&ed,!ctionEvent e- *
String co&&and + e.get!ctionCo&&and,-;
if ,co&&and.eq"als,AC_CANCEL-- *
cancel>oo)ing,-;
/
/
private void cancel>oo)ing,- *
String nr%oCancel + cancelField.get%ext,-;
for ,Character c 7 nr%oCancel.toChar!rra,-- *
if ,2,Character.isDigit,c--- *
return;
/
/
0nteger boo)ing;"&ber + 0nteger.+aleOf,nr%oCancel-;
>oo)ing toDelete + null;
Set=>oo)ing? boo)ings + getLogged0nFser,-.get>oo)ings,-;
for ,>oo)ing boo)ing 7 boo)ings- *
if ,boo)ing.get>oo)ing;"&ber,-.eq"als,boo)ing;"&ber-- *
toDelete + boo)ing;
break;
/
/
if ,toDelete ++ null- *
return;
/
boo)ings.re&ove,toDelete-;
Session session + SessionManager.getInstance,-.openSession,-;
%ransaction transaction + session.begin%ransaction,-;
session.delete,toDelete-;
transaction.co&&it,-;
refresh,-;
/
/
7.3.26 ars+age.5ava
package de.hft.carrental."i.&ain.cars;
import de.hft.carrental."i.&ain.Main(indo';
import de.hft.carrental."i.&ain.Main(indo'4age;
## TODO BM5 4S7 Class et to be i&ple&ented.
public final class Cars4age extends Main(indo'4age *
private static final long serialVersionUID + N@HPJQONAAOOHOAQAIJL;
public Cars4age,Main(indo' &ain(indo'- *
super,&ain(indo'5 S5 H-;
/
:3verride
protected void addSections,- *
addSection,new SearchCarsSection,this--;
addSection,new Cars%ableSection,this--;
/
/
7.3.21 arsTa.leSe/tion.5ava
package de.hft.carrental."i.&ain.cars;
import de.hft.carrental."i.&ain.Main(indo'4age;
import de.hft.carrental."i.&ain.%ableSection;
public final class Cars%ableSection extends %ableSection *
private static final long serialVersionUID + PQSJI@PAI@@@QHHJPHNL;
protected Cars%ableSection,Main(indo'4age page- *
super,page5 .0;SEB% %0%LE.5 new StringKL */5 new intKL */-;
/
:3verride
protected void refresh,- *
## TODO BM5 4S7 Method et to be i&ple&ented.
/
/
7.3.22 Sear/4arsSe/tion.5ava
package de.hft.carrental."i.&ain.cars;
import javax.s'ing.C>"tton;
import javax.s'ing.CLabel;
import javax.s'ing.C%extField;
import de.hft.carrental."i.&ain.Main(indo'4ageSection;
##TODO BM5 4S7 Class et to be i&ple&ented.
public final class SearchCarsSection extends Main(indo'4ageSection *
private static final long serial9ersionF0D + TNPIOS@@OJO@@J@OP@NL;
## Labels for search page
private final CLabel Car;a&e + new CLabel,.Car ;a&e7.-;
private final CLabel 4ic)"p + new CLabel,.4ic) "p Location7.-;
private final CLabel Fro&Date + new CLabel,.Fro&7.-;
private final CLabel %oDate + new CLabel,.%o7.-;
## %extfields for search page
private final C%extField Car;a&eField + new C%extField,-;
private final C%extField 4ic)"pField + new C%extField,-;
private final C%extField Fro&DateField + new C%extField,-;
private final C%extField %oDateField + new C%extField,-;
## >"tton for search
private final C>"tton search>"tton + new C>"tton,.Search.-;
protected SearchCarsSection,Cars4age cars4age- *
super,cars4age5 .Search Cars.-;
/
:3verride
protected void refresh,- *
## Car;a&eField.set%ext,"ser.getCar;a&e,--;
## 4ic)"pField.set%ext,"ser.get4ic)"p,--;
## Fro&DateField.set%ext,"ser.getFro&Date,--;
## %oDateField.set%ext,"ser.get%oDate,--;
##
## DateFor&at df + DateFor&at.get0nstance,-;
## Fro&DateField.set%ext,df.for&at,"ser.getFro&Date,---;
## %oDateField.set%ext,df.for&at,"ser.get%oDate,---;
## search>"tton.setEnabled,false-;
/
private void addListeners,- *
## search>"tton.add!ctionListener,this-;
/
## :3verride
## p"blic void action4erfor&ed,!ctionEvent e- *
## search>"tton.setEnabled,%r"e-;
## Cars%ableSection,-;
## /
/
7.3.23 AddAddress(ialog.5ava
package de.hft.carrental."i.&ain.personal;
import java.a't.%ool)it;
import java.a't.event.!ctionEvent;
import java.a't.event.!ctionListener;
import java.a't.event.DeEvent;
import java.a't.event.DeListener;
import javax.s'ing.C>"tton;
import de.hft.carrental.do&ain.C"sto&er;
import de.hft.carrental.do&ain.C"sto&er!ddress;
public class !dd!ddressDialog extends >ase!ddressDialog implements DeListener5
!ctionListener *
private static final long serialVersionUID + HL;
private C>"tton add>"tton + new C>"tton,.!dd.-;
private C>"tton close>"tton + new C>"tton,.Close.-;
private boolean address!dded + false;
private C"sto&er c"sto&er;
private static final String AC_ADD_ADDRESS + .addEaddress.;
private static final String AC_CLOSE_DIALO" + .closeEdialog.;
public !dd!ddressDialog,C"sto&er c"sto&er- *
this.c"sto&er + c"sto&er;
set%itle,.!dd ne' address7.-;
add>"ttons,-;
addListeners,-;
pac),-;
int posW + %ool)it.getDefaltTool!it,-.getScreenSiRe,-.'idth # S
T get(idth,- # S;
int pos< + %ool)it.getDefaltTool!it,-.getScreenSiRe,-.height # S
T getGeight,- # S;
setLocation,posW5 pos<-;
add>"tton.setEnabled,false-;
set9isible,true-;
/
public C"sto&er!ddress get;e'C"sto&er!ddress,- *
C"sto&er!ddress ne'!ddress + new C"sto&er!ddress,-;
ne'!ddress.setStreet;a&e,streetField.get%ext,--;
ne'!ddress.setStreet;"&ber,n"&berField.get%ext,--;
ne'!ddress.set4ostalCode,postalField.get%ext,--;
ne'!ddress.setCit;a&e,citField.get%ext,--;
ne'!ddress.setCo"ntr,co"ntrField.get%ext,--;
ne'!ddress.set4hone;"&ber,phoneField.get%ext,--;
ne'!ddress.setC"sto&er,c"sto&er-;
return ne'!ddress;
/
public boolean address!dded,- *
return address!dded;
/
private void add>"ttons,- *
add,add>"tton5 .align left.-;
add,close>"tton5 .align right.-;
/
private void addListeners,- *
add>"tton.set!ctionCo&&and,AC_ADD_ADDRESS-;
add>"tton.add!ctionListener,this-;
close>"tton.set!ctionCo&&and,AC_CLOSE_DIALO"-;
close>"tton.add!ctionListener,this-;
streetField.addDeListener,this-;
n"&berField.addDeListener,this-;
postalField.addDeListener,this-;
citField.addDeListener,this-;
co"ntrField.addDeListener,this-;
phoneField.addDeListener,this-;
/
:3verride
public void )e4ressed,DeEvent e- *
#$ nothing to do $#
/
:3verride
public void )eBeleased,DeEvent e- *
#$ nothing to do $#
/
:3verride
public void )e%ped,DeEvent e- *
if ,allFieldsFilled,-- *
add>"tton.setEnabled,true-;
/ else *
add>"tton.setEnabled,false-;
/
/
:3verride
public void action4erfor&ed,!ctionEvent e- *
String actionCo&&and + e.get!ctionCo&&and,-;
if ,actionCo&&and.eq"als,AC_ADD_ADDRESS-- *
address!dded + true;
set9isible,false-;
/ else if ,actionCo&&and.eq"als,AC_CLOSE_DIALO"-- *
set9isible,false-;
/
/
/
7.3.24 AddressesSe/tion.5ava
package de.hft.carrental."i.&ain.personal;
import java.a't.event.!ctionEvent;
import java.a't.event.!ctionListener;
import java."til.GashSet;
import java."til.Set;
import javax.s'ing.C>"tton;
import org.hibernate.Session;
import org.hibernate.%ransaction;
import de.hft.carrental.database.SessionManager;
import de.hft.carrental.do&ain.C"sto&er!ddress;
import de.hft.carrental."i.&ain.Main(indo'4age;
import de.hft.carrental."i.&ain.%ableSection;
public final class !ddressesSection extends %ableSection implements
!ctionListener *
private static final String AC_ADD_ADDRESS + .addEaddress.;
private static final String AC_EDIT_ADDRESS + .editEaddress.;
private static final long serialVersionUID + THPSONQ@OI@NQOJ@NNA@L;
private static final StringKL COLUMN_NAMES + * .Street.5 .;"&ber.5
.4ostal code.5 .Cit.5 .Co"ntr.5 .4hone n"&ber.
/;
private static final intKL COLUMN_WIDT%S + new intKL * HHI5 HII5 HII5 HJI5
H@I5 HAI /;
private C>"tton add + new C>"tton,.!dd.-;
private C>"tton edit + new C>"tton,.Edit.-;
protected !ddressesSection,Main(indo'4age page- *
super,page5 .!ddress,es-.5 COLUMN_NAMES5 COLUMN_WIDT%S-;
add,add-;
add,edit-;
addListeners,-;
/
:3verride
protected void refresh,- *
clear%able,-;
fill%able,-;
/
private void addListeners,- *
add.set!ctionCo&&and,AC_ADD_ADDRESS-;
add.add!ctionListener,this-;
edit.set!ctionCo&&and,AC_EDIT_ADDRESS-;
edit.add!ctionListener,this-;
/
private void fill%able,- *
for ,C"sto&er!ddress address 7
getLogged0nFser,-.getC"sto&er!ddresses,-- *
3bjectKL ro' + new 3bjectKPL;
ro'KIL + address.getStreet;a&e,-;
ro'KHL + address.getStreet;"&ber,-;
ro'KSL + address.get4ostalCode,-;
ro'KJL + address.getCit;a&e,-;
ro'K@L + address.getCo"ntr,-;
ro'KAL + address.get4hone;"&ber,-;
addDataBo',ro'-;
/
/
:3verride
public void action4erfor&ed,!ctionEvent e- *
String actionCo&&and + e.get!ctionCo&&and,-;
if ,actionCo&&and.eq"als,AC_ADD_ADDRESS-- *
!dd!ddressDialog ad + new !dd!ddressDialog,getLogged0nFser,--;
if ,ad.address!dded,-- *
Session session +
SessionManager.getInstance,-.openSession,-;
%ransaction transaction + session.begin%ransaction,-;
getLogged0nFser,-.getC"sto&er!ddresses,-.add,
ad.get;e'C"sto&er!ddress,--;
session.save,getLogged0nFser,--;
transaction.co&&it,-;
refresh,-;
/
/ else if ,actionCo&&and.eq"als,AC_EDIT_ADDRESS-- *
Edit!ddressDialog ed + new Edit!ddressDialog,getLogged0nFser,-
.getC"sto&er!ddresses,--;
if ,ed.get!ddresses,-.siRe,- ++ getLogged0nFser,-
.getC"sto&er!ddresses,-.siRe,-- *
Session session +
SessionManager.getInstance,-.openSession,-;
%ransaction transaction + session.begin%ransaction,-;
getLogged0nFser,-.setC"sto&er!ddresses,ed.get!ddresses,--;
transaction.co&&it,-;
/ else *
Session session +
SessionManager.getInstance,-.openSession,-;
%ransaction transaction + session.begin%ransaction,-;
Set=C"sto&er!ddress? c"sto&er!ddresses + new
GashSet=C"sto&er!ddress?,
getLogged0nFser,-.getC"sto&er!ddresses,--;
c"sto&er!ddresses.re&ove!ll,ed.get!ddresses,--;
C"sto&er!ddressKL arra + c"sto&er!ddresses
.to!rra,new C"sto&er!ddressKHL-;
C"sto&er!ddress address + arraKIL;
getLogged0nFser,-.getC"sto&er!ddresses,-.re&ove,address-;
transaction.co&&it,-;
/
refresh,-;
/
/
/
7.3.2) "aseAddress(ialog.5ava
package de.hft.carrental."i.&ain.personal;
import javax.s'ing.CDialog;
import javax.s'ing.CLabel;
import javax.s'ing.C%extField;
import net.&iginfoco&.s'ing.MigLao"t;
public abstract class >ase!ddressDialog extends CDialog *
private static final long serialVersionUID + HL;
private CLabel streetLabel + new CLabel,.Street7.-;
private CLabel n"&berLabel + new CLabel,.Street ;"&ber7.-;
private CLabel postalLabel + new CLabel,.4ostal code7.-;
private CLabel citLabel + new CLabel,.Cit7.-;
private CLabel co"ntrLabel + new CLabel,.Co"ntr7.-;
private CLabel phoneLabel + new CLabel,.4hone n"&ber.-;
protected C%extField streetField + new C%extField,@A-;
protected C%extField n"&berField + new C%extField,A-;
protected C%extField postalField + new C%extField,HI-;
protected C%extField citField + new C%extField,@A-;
protected C%extField co"ntrField + new C%extField,@A-;
protected C%extField phoneField + new C%extField,@A-;
protected >ase!ddressDialog,- *
setModalit%pe,Modalit%pe.APPLICATION_MODAL-;
b"ildLao"t,-;
/
private void b"ildLao"t,- *
setLao"t,new MigLao"t,..5 .KLKgro'L.--;
add,streetLabel-;
add,streetField5 .gro'x5 'rap.-;
add,n"&berLabel-;
add,n"&berField5 .gro'x5 'rap.-;
add,postalLabel-;
add,postalField5 .gro'x5 'rap.-;
add,citLabel-;
add,citField5 .gro'x5 'rap.-;
add,co"ntrLabel-;
add,co"ntrField5 .gro'x5 'rap.-;
add,phoneLabel-;
add,phoneField5 .gro'x5 'rap.-;
/
protected boolean allFieldsFilled,- *
if ,,streetField.get%ext,-.length,- ++ I-
11 ,n"&berField.get%ext,-.length,- ++ I-
11 ,postalField.get%ext,-.length,- ++ I-
11 ,citField.get%ext,-.length,- ++ I-
11 ,co"ntrField.get%ext,-.length,- ++ I-
11 ,phoneField.get%ext,-.length,- ++ I-- *
return false;
/
return true;
/
/
7.3.2* EditAddress(ialog.5ava
package de.hft.carrental."i.&ain.personal;
import java.a't.%ool)it;
import java.a't.event.!ctionEvent;
import java.a't.event.!ctionListener;
import java.a't.event.DeEvent;
import java.a't.event.DeListener;
import java."til.!rraList;
import java."til.GashSet;
import java."til.List;
import java."til.Set;
import javax.s'ing.C>"tton;
import de.hft.carrental.do&ain.C"sto&er!ddress;
public class Edit!ddressDialog extends >ase!ddressDialog implements
!ctionListener5 DeListener *
private static final long serialVersionUID + HL;
private C>"tton close + new C>"tton,.Close.-;
private C>"tton previo"s + new C>"tton,.4revio"s.-;
private C>"tton next + new C>"tton,.;ext.-;
private C>"tton save + new C>"tton,.Save.-;
private C>"tton delete + new C>"tton,.Delete.-;
private static final String AC_CLOSE_DIALO" + .closeEdialog.;
private static final String AC_PREVIOUS_ADDRESS + .previo"sEaddress.;
private static final String AC_NEXT_ADDRESS + .nextEaddress.;
private static final String AC_SAVE_C%AN"ES + .saveEchanges.;
private static final String AC_DELETE_ADDRESS + .deleteEaddress.;
private List=C"sto&er!ddress? addressList + new
!rraList=C"sto&er!ddress?,-;
private int pos + I;
public Edit!ddressDialog,Set=C"sto&er!ddress? addresses- *
addressList.add!ll,addresses-;
set%itle,.Edit address details7.-;
add>"ttons,-;
addListeners,-;
fillFields,pos-;
if ,addressList.siRe,- ++ H- *
delete.setEnabled,false-;
/
pac),-;
int posW + %ool)it.getDefaltTool!it,-.getScreenSiRe,-.'idth # S
T get(idth,- # S;
int pos< + %ool)it.getDefaltTool!it,-.getScreenSiRe,-.height # S
T getGeight,- # S;
setLocation,posW5 pos<-;
save.setEnabled,false-;
set9isible,true-;
/
public Set=C"sto&er!ddress? get!ddresses,- *
Set=C"sto&er!ddress? t&p + new GashSet=C"sto&er!ddress?,-;
t&p.add!ll,addressList-;
return t&p;
/
private void add>"ttons,- *
add,previo"s5 .split S5 align left.-;
add,next-;
add,save5 .split J5 align right.-;
add,delete-;
add,close-;
/
private void fillFields,int pos- *
streetField.set%ext,addressList.get,pos-.getStreet;a&e,--;
n"&berField.set%ext,addressList.get,pos-.getStreet;"&ber,--;
postalField.set%ext,addressList.get,pos-.get4ostalCode,--;
citField.set%ext,addressList.get,pos-.getCit;a&e,--;
co"ntrField.set%ext,addressList.get,pos-.getCo"ntr,--;
phoneField.set%ext,addressList.get,pos-.get4hone;"&ber,--;
chec)4revio"s;ext,-;
/
private void chec)4revio"s;ext,- *
if ,pos T H = I- *
previo"s.setEnabled,false-;
/ else *
previo"s.setEnabled,true-;
/
if ,pos V H ++ addressList.siRe,-- *
next.setEnabled,false-;
/ else *
next.setEnabled,true-;
/
/
private void addListeners,- *
close.set!ctionCo&&and,AC_CLOSE_DIALO"-;
close.add!ctionListener,this-;
previo"s.set!ctionCo&&and,AC_PREVIOUS_ADDRESS-;
previo"s.add!ctionListener,this-;
next.set!ctionCo&&and,AC_NEXT_ADDRESS-;
next.add!ctionListener,this-;
save.set!ctionCo&&and,AC_SAVE_C%AN"ES-;
save.add!ctionListener,this-;
delete.set!ctionCo&&and,AC_DELETE_ADDRESS-;
delete.add!ctionListener,this-;
streetField.addDeListener,this-;
n"&berField.addDeListener,this-;
postalField.addDeListener,this-;
citField.addDeListener,this-;
co"ntrField.addDeListener,this-;
phoneField.addDeListener,this-;
/
:3verride
public void action4erfor&ed,!ctionEvent e- *
String actionCo&&and + e.get!ctionCo&&and,-;
if ,actionCo&&and.eq"als,AC_CLOSE_DIALO"-- *
set9isible,false-;
/ else if ,actionCo&&and.eq"als,AC_DELETE_ADDRESS-- *
addressList.re&ove,pos-;
set9isible,false-;
/ else if ,actionCo&&and.eq"als,AC_NEXT_ADDRESS-- *
fillFields,VVpos-;
/ else if ,actionCo&&and.eq"als,AC_PREVIOUS_ADDRESS-- *
fillFields,TTpos-;
/ else if ,actionCo&&and.eq"als,AC_SAVE_C%AN"ES-- *
addressList.get,pos-.setStreet;a&e,streetField.get%ext,--;
addressList.get,pos-.setStreet;"&ber,n"&berField.get%ext,--;
addressList.get,pos-.set4ostalCode,postalField.get%ext,--;
addressList.get,pos-.setCit;a&e,citField.get%ext,--;
addressList.get,pos-.setCo"ntr,co"ntrField.get%ext,--;
addressList.get,pos-.set4hone;"&ber,phoneField.get%ext,--;
save.setEnabled,false-;
/
/
:3verride
public void )e4ressed,DeEvent e- *
#$ nothing to do $#
/
:3verride
public void )eBeleased,DeEvent e- *
#$ nothing to do $#
/
:3verride
public void )e%ped,DeEvent e- *
if ,allFieldsFilled,-- *
save.setEnabled,true-;
/ else *
save.setEnabled,false-;
/
/
/
7.3.27 General%n0oSe/tion.5ava
package de.hft.carrental."i.&ain.personal;
import java.a't.0&age;
import java.a't.event.!ctionEvent;
import java.a't.event.!ctionListener;
import java.a't.event.DeEvent;
import java.a't.event.DeListener;
import java.text.DateFor&at;
import javax.s'ing.0&age0con;
import javax.s'ing.C>"tton;
import javax.s'ing.CLabel;
import javax.s'ing.C%extField;
import net.&iginfoco&.s'ing.MigLao"t;
import org.hibernate.Session;
import org.hibernate.%ransaction;
import de.hft.carrental.database.SessionManager;
import de.hft.carrental.do&ain.C"sto&er;
import de.hft.carrental."i.&ain.Main(indo'4age;
import de.hft.carrental."i.&ain.Main(indo'4ageSection;
public final class 8eneral0nfoSection extends Main(indo'4ageSection implements
!ctionListener5 DeListener *
private static final long serial9ersionF0D + SQSHN@HPNJN@NH@QNNHL;
private final CLabel loginLabel + new CLabel,.Login na&e7.-;
private final CLabel registerDateLabel + new CLabel,.Begister date7.-;
private final CLabel e&ailLabel + new CLabel,.E&ail7.-;
private final CLabel first;a&eLabel + new CLabel,.First na&e7.-;
private final CLabel s"r;a&eLabel + new CLabel,.S"rna&e7.-;
private final CLabel birthDateLabel + new CLabel,.Date of birth7.-;
private final CLabel co&pan;a&eLabel + new CLabel,.Co&pan na&e7 .-;
private final C%extField loginField + new C%extField,-;
private final C%extField registerField + new C%extField,-;
private final C%extField e&ailField + new C%extField,-;
private final C%extField first;a&eField + new C%extField,-;
private final C%extField s"r;a&eField + new C%extField,-;
private final C%extField birthDateField + new C%extField,-;
private final C%extField co&pan;a&eField + new C%extField,-;
private final C>"tton saveChanges>"tton + new C>"tton,.Save changes.-;
private static final String !CES!9EECG!;8ES + .saveEchanges.;
private final C"sto&er "ser;
protected 8eneral0nfoSection,Main(indo'4age page- *
super,page5 .4ersonal details.-;
setLao"t,new MigLao"t,..5 .KLKgro'LKLKgro'L.5 ..--;
"ser + getLogged0nFser,-;
if ,"ser.getC"sto&er%pe,-.eq"als,C"sto&er.CFS%3MEBE%<4EE4B09!%E-- *
create4rivateFserContents,-;
/ else *
createCo&panFserContents,-;
/
addListeners,-;
0&age i&age + new 0&age0con,.i&ages#save.png.-.get0&age,-;
i&age + i&age.getScaled0nstance,SI5 SI5 0&age.SC!LEESM33%G-;
saveChanges>"tton.set0con,new 0&age0con,i&age--;
/
:3verride
protected void refresh,- *
loginField.set%ext,"ser.getLogin;a&e,--;
first;a&eField.set%ext,"ser.getFirst;a&e,--;
s"r;a&eField.set%ext,"ser.getS"rna&e,--;
co&pan;a&eField.set%ext,"ser.getCo&pan;a&e,--;
e&ailField.set%ext,"ser.getE&ail,--;
DateFor&at df + DateFor&at.get0nstance,-;
registerField.set%ext,df.for&at,"ser.getBegisterDate,---;
birthDateField.set%ext,df.for&at,"ser.getDate3f>irth,---;
saveChanges>"tton.setEnabled,false-;
/
private void create4rivateFserContents,- *
add,loginLabel-;
add,loginField5 .gro'x.-;
loginField.setEditable,false-;
add,first;a&eLabel-;
add,first;a&eField5 .gro'x5 'rap.-;
first;a&eField.setEditable,false-;
add,registerDateLabel-;
add,registerField5 .gro'x.-;
registerField.setEditable,false-;
add,s"r;a&eLabel-;
add,s"r;a&eField5 .gro'x5 'rap.-;
s"r;a&eField.setEditable,false-;
add,e&ailLabel-;
add,e&ailField5 .gro'x.-;
add,birthDateLabel-;
add,birthDateField5 .gro'x5 'rap.-;
birthDateField.setEditable,false-;
add,saveChanges>"tton5 .span @5 align right.-;
/
private void createCo&panFserContents,- *
add,loginLabel5 .span H J5 gro'x.-;
add,loginField-;
loginField.setEditable,false-;
add,registerDateLabel-;
add,registerField5 .gro'x.-;
registerField.setEditable,false-;
add,e&ailLabel-;
add,e&ailField5 .gro'x5 'rap.-;
add,co&pan;a&eLabel-;
add,co&pan;a&eField5 .gro'x.-;
co&pan;a&eField.setEditable,false-;
/
private void addListeners,- *
saveChanges>"tton.set!ctionCo&&and,!CES!9EECG!;8ES-;
saveChanges>"tton.add!ctionListener,this-;
e&ailField.addDeListener,this-;
/
:3verride
public void action4erfor&ed,!ctionEvent e- *
String actionCo&&and + e.get!ctionCo&&and,-;
if ,actionCo&&and.eq"als,!CES!9EECG!;8ES-- *
Session session + SessionManager.get0nstance,-.openSession,-;
%ransaction transaction + session.begin%ransaction,-;
"ser.setE&ail,e&ailField.get%ext,--;
session.save,"ser-;
transaction.co&&it,-;
saveChanges>"tton.setEnabled,false-;
/
/
:3verride
public void )e4ressed,DeEvent e- *
#$ nothing to do $#
/
:3verride
public void )eBeleased,DeEvent e- *
#$ nothing to do $#
/
:3verride
public void )e%ped,DeEvent e- *
saveChanges>"tton.setEnabled,true-;
/
/
7.3.2, +ersonal+age.5ava
package de.hft.carrental."i.&ain.personal;
import de.hft.carrental."i.&ain.Main(indo';
import de.hft.carrental."i.&ain.Main(indo'4age;
public final class 4ersonal4age extends Main(indo'4age *
private static final long serialVersionUID + TASHANOP@JIPIJH@SPH@L;
public 4ersonal4age,Main(indo' &ain(indo'- *
super,&ain(indo'5 S5 H-;
/
:3verride
protected void addSections,- *
addSection,new 8eneral0nfoSection,this--;
addSection,new !ddressesSection,this--;
/
/
7.3.2- Splas47indo8.5ava
package de.hft.carrental."i.splash;
import de.hft.carrental."i.(indo';
import de.hft.carrental."i.splash.login.Login4age;
#$$
$ %he splash 'indo' is the application 'indo' that is sho'n right after the
$ progra& starts. >asicall it allo's the "ser to login.
$
$ @author !lexander (eic)&ann
$#
public final class Splash(indo' extends (indo' *
private static final long serialVersionUID + TASHIONQNJAS@PIPOPN@L;
private static final int MINIMUM_WIDT% + JII;
private static final int MINIMUM_%EI"%T + HSI;
private Login4age login4age;
public Splash(indo',- *
super,-;
login4age + new Login4age,this-;
sho'Login4age,-;
set9isible,true-;
/
public void sho'Login4age,- *
s'itch4age%o,login4age-;
/
:3verride
protected int getMinGeight,- *
return MINIMUM_%EI"%T;
/
:3verride
protected int getMin(idth,- *
return MINIMUM_WIDT%;
/
/
7.3.36 Login+age.5ava
package de.hft.carrental."i.splash.login;
import de.hft.carrental."i.(indo'4age;
import de.hft.carrental."i.splash.Splash(indo';
#$$
$ %his page is "sed b the *:lin) Splash(indo'/ to enable the "ser to login.
$
$ @author !lexander (eic)&ann
$#
public final class Login4age extends (indo'4age *
private static final long serialVersionUID + TSAQIPHQSNAQSHQAOPJJL;
#$$
$ @param splash(indo'
$ %he *:lin) Splash(indo'/ this page belongs to.
$#
public Login4age,Splash(indo' splash(indo'- *
super,splash(indo'5 H5 H-;
/
:3verride
protected void addSections,- *
addSection,new LoginSection,this--;
/
/
7.3.31 LoginSe/tion.5ava
package de.hft.carrental."i.splash.login;
import java.a't.%ool)it;
import java.a't.Dialog.Modalit%pe;
import java.a't.event.!ctionEvent;
import java.a't.event.!ctionListener;
import java.a't.event.DeEvent;
import java.a't.event.DeListener;
import javax.s'ing.0&age0con;
import javax.s'ing.C>"tton;
import javax.s'ing.CDialog;
import javax.s'ing.CLabel;
import javax.s'ing.C%extField;
import net.&iginfoco&.s'ing.MigLao"t;
import org.hibernate.Session;
import org.hibernate.%ransaction;
import de.hft.carrental.database.SessionManager;
import de.hft.carrental.do&ain.C"sto&er;
import de.hft.carrental."i.(indo'4ageSection;
import de.hft.carrental."i.&ain.Main(indo';
#$$
$ %his section contains a text field allo'ing the "ser to tpe in his login
$ na&e. 0t also sho's a b"tton that allo's the "ser to event"all perfor& the
$ login.
$
$ @author !lexander (eic)&ann
$#
public final class LoginSection extends (indo'4ageSection implements
!ctionListener *
private static final long serialVersionUID + HIP@ASHHHQOJAPA@@JOL;
private static final String TITLE + .Login.;
#$$ !ction co&&and that is triggered "pon activation of the login b"tton.
$#
private static final String AC_LO"IN + .login.;
private C%extField login%extField;
#$$
$ @param login4age
$ %he *:lin) Login4age/ this section belongs to.
$#
public LoginSection,Login4age login4age- *
super,login4age5 TITLE-;
createContents,-;
/
private void createContents,- *
login%extField + new C%extField,HN-;
login%extField.req"estFoc"s0n(indo',-;
login%extField.addDeListener,new DeListener,- *
:3verride
public void )e4ressed,DeEvent e- *
## ;othing to do.
/
:3verride
public void )eBeleased,DeEvent e- *
if ,e.getDeCode,- ++ DeEvent.V)_ENTER- *
perfor&Login,-;
/
/
:3verride
public void )e%ped,DeEvent e- *
## ;othing to do.
/
/-;
add,login%extField-;
C>"tton login>"tton + new C>"tton,.Login2.-;
login>"tton.set!ctionCo&&and,AC_LO"IN-;
login>"tton.add!ctionListener,this-;
login>"tton.set0con,new 0&age0con,.i&ages#login.png.--;
add,login>"tton-;
/
:3verride
public void action4erfor&ed,!ctionEvent e- *
String co&&and + e.get!ctionCo&&and,-;
if ,co&&and.eq"als,AC_LO"IN-- *
perfor&Login,-;
/
/
#$$
$ 4erfor&s the login. Sho's the &ain 'indo' on s"ccess and displas an
$ appropriate error &essage on fail"re.
$#
private void perfor&Login,- *
C"sto&er "ser + null;
String "serna&e + login%extField.get%ext,-;
Session session + SessionManager.getInstance,-.openSession,-;
if ,session ++ null- *
sho'ErrorDialog,.;o connection to database..-;
return;
/
%ransaction tr + session.begin%ransaction,-;
String q"er + .fro& C"sto&er 'here login;a&e + U. V "serna&e V .U.;
3bject res"lt + session.createQ"er,q"er-."niq"eBes"lt,-;
if ,res"lt ++ null- *
sho'ErrorDialog,.Fserna&e not fo"nd..-;
return;
/
"ser + ,C"sto&er- res"lt;
tr.co&&it,-;
get(indo'4age,-.get(indo',-.set9isible,false-;
new Main(indo',"ser-;
/
:3verride
protected void refresh,- *
## ;othing to do.
/
private void sho'ErrorDialog,String error%ext- *
final CDialog errorDialog + new CDialog,-;
errorDialog.set%itle,.Error.-;
MigLao"t lao"t + new MigLao"t,..5 .KcenterL.5 .KcenterL.-;
errorDialog.setLao"t,lao"t-;
errorDialog.setModalit%pe,Modalit%pe.APPLICATION_MODAL-;
CLabel errorLabel + new CLabel,error%ext-;
errorDialog.add,errorLabel5 .spanx5 'rap.-;
final C>"tton close>"tton + new C>"tton,.3).-;
close>"tton.add!ctionListener,new !ctionListener,- *
:3verride
public void action4erfor&ed,!ctionEvent e- *
errorDialog.set9isible,false-;
/
/-;
errorDialog.add,close>"tton-;
errorDialog.pac),-;
errorDialog.setBesiRable,false-;
int posW + %ool)it.getDefaltTool!it,-.getScreenSiRe,-.'idth # S;
int pos< + %ool)it.getDefaltTool!it,-.getScreenSiRe,-.height # S;
errorDialog.setLocation,posW5 pos<-;
errorDialog.set9isible,true-;
login%extField.set%ext,..-;
login%extField.req"estFoc"s,-;
/
/
7.3.32 Grid"agUtil.5ava
package de.hft.carrental."i."til;
import java.a't.8rid>agConstraints;
import java.a't.0nsets;
#$$
$
$
$ @author !lexander (eic)&ann
$#
public final class 8rid>agFtil *
#$$
$ Convenience &ethod provided to s"bclasses allo'ing for rapid
$ *:lin) 8rid>agConstraints/ creation.
$
$ @param gridx
$ %he ReroTbased xTposition of the co&ponent inside the grid.
$ @param grid
$ %he ReroTbased Tposition of the co&ponent inside the grid.
$ @param 'eightx
$ 9al"e bet'een I.I and H.I indicating ho' &"ch priorit the
$ co&ponent has 'hen it co&es to filling "p e&pt horiRontal
$ space.
$ @param 'eight
$ 9al"e bet'een I.I and H.I indicating ho' &"ch priorit the
$ co&ponent has 'hen it co&es to filling "p e&pt vertical
$ space.
$ @param fill
$ 0ndicates 'hether additional space sho"ld be "sed b the
$ co&ponent ,both5 horiRontal5 vertical or none-.
$ @param insets
$ Specifies the external padding of the co&ponent.
$ @param anchor
$ Specifies 'here to anchor the co&ponent.
$ @param ipadx
$ Specifies the internal padding in x direction.
$ @param ipad
$ Specifies the internal padding in direction.
$#
public static 8rid>agConstraints create8rid>agConstraints,int gridx5
int grid5 int 'eightx5 int 'eight5 int fill5 0nsets insets5
int anchor5 int ipadx5 int ipad- *
8rid>agConstraints constraints + new 8rid>agConstraints,-;
constraints.gridx + gridx;
constraints.grid + grid;
constraints.'eightx + 'eightx;
constraints.'eight + 'eight;
constraints.fill + fill;
constraints.insets + insets;
constraints.anchor + anchor;
constraints.ipadx + ipadx;
constraints.ipad + ipad;
return constraints;
/
/
7.3.33 4i.ernate./0g.9ml
=2D3C%<4E hibernateTconfig"ration 4F>L0C
.T##Gibernate#Gibernate Config"ration D%D J.I##E;.
.http7##hibernate.so"rceforge.net#hibernateTconfig"rationTJ.I.dtd.?
=hibernateTconfig"ration?
=sessionTfactor?
=&apping class+.de.hft.carrental.do&ain.!genc. #?
=&apping class+.de.hft.carrental.do&ain.>oo)ing. #?
=&apping class+.de.hft.carrental.do&ain.>ranch. #?
=&apping class+.de.hft.carrental.do&ain.>ranch!ddress. #?
=&apping class+.de.hft.carrental.do&ain.Car. #?
=&apping class+.de.hft.carrental.do&ain.Car%pe. #?
=&apping class+.de.hft.carrental.do&ain.C"sto&er. #?
=&apping class+.de.hft.carrental.do&ain.C"sto&er!ddress. #?
=#sessionTfactor?
=#hibernateTconfig"ration?
7.3.34 4i.ernate.properties
hibernate.dialectorg.hibernate.dialect.MSQL0nnoD>Dialect
hibernate.connection.driverEclass co&.&sql.jdbc.Driver
hibernate.connection."rl jdbc7&sql7###carrental
hibernate.connection."serna&e root
hibernate.connection.pass'ord root
hibernate.sho'Esql tr"e
hibernate.cache.providerEclass org.hibernate.cache.GashtableCache4rovider
6.- 7oole Code So%rce Repository .R0
https"11co!e*google*com1p1carrentalhft1

You might also like