Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Wendys Racing Horses
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
tu-wien
Wendys Racing Horses
Commits
8e373684
Commit
8e373684
authored
Apr 05, 2020
by
Ivaylo Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
US01, US03: Fix bug where all whitespaces were considered valid input on horse create and update
parent
a01405e3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
8 deletions
+8
-8
backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/persistence/impl/HorseJdbcDao.java
.../assignment/individual/persistence/impl/HorseJdbcDao.java
+2
-2
backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/util/Validator.java
.../ac/tuwien/sepm/assignment/individual/util/Validator.java
+2
-2
frontend/wendys-friends/src/app/component/add-horse/add-horse.component.html
...ends/src/app/component/add-horse/add-horse.component.html
+2
-2
frontend/wendys-friends/src/app/component/update-horse/update-horse.component.html
...rc/app/component/update-horse/update-horse.component.html
+2
-2
No files found.
backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/persistence/impl/HorseJdbcDao.java
View file @
8e373684
...
@@ -131,7 +131,7 @@ public class HorseJdbcDao implements HorseDao {
...
@@ -131,7 +131,7 @@ public class HorseJdbcDao implements HorseDao {
int
changes
=
jdbcTemplate
.
update
(
connection
->
{
int
changes
=
jdbcTemplate
.
update
(
connection
->
{
PreparedStatement
ps
=
connection
.
prepareStatement
(
sql
,
PreparedStatement
.
RETURN_GENERATED_KEYS
);
PreparedStatement
ps
=
connection
.
prepareStatement
(
sql
,
PreparedStatement
.
RETURN_GENERATED_KEYS
);
ps
.
setString
(
1
,
horse
.
getName
());
ps
.
setString
(
1
,
horse
.
getName
()
.
trim
()
);
ps
.
setString
(
2
,
horse
.
getDescription
());
ps
.
setString
(
2
,
horse
.
getDescription
());
ps
.
setInt
(
3
,
horse
.
getScore
());
ps
.
setInt
(
3
,
horse
.
getScore
());
ps
.
setDate
(
4
,
horse
.
getBirthday
());
ps
.
setDate
(
4
,
horse
.
getBirthday
());
...
@@ -179,7 +179,7 @@ public class HorseJdbcDao implements HorseDao {
...
@@ -179,7 +179,7 @@ public class HorseJdbcDao implements HorseDao {
int
changes
=
jdbcTemplate
.
update
(
connection
->
{
int
changes
=
jdbcTemplate
.
update
(
connection
->
{
PreparedStatement
ps
=
connection
.
prepareStatement
(
sql
);
PreparedStatement
ps
=
connection
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
horse
.
getName
());
ps
.
setString
(
1
,
horse
.
getName
()
.
trim
()
);
ps
.
setString
(
2
,
horse
.
getDescription
());
ps
.
setString
(
2
,
horse
.
getDescription
());
ps
.
setInt
(
3
,
horse
.
getScore
());
ps
.
setInt
(
3
,
horse
.
getScore
());
ps
.
setDate
(
4
,
horse
.
getBirthday
());
ps
.
setDate
(
4
,
horse
.
getBirthday
());
...
...
backend/src/main/java/at/ac/tuwien/sepm/assignment/individual/util/Validator.java
View file @
8e373684
...
@@ -33,7 +33,7 @@ public class Validator {
...
@@ -33,7 +33,7 @@ public class Validator {
}
}
public
void
validateNewHorse
(
Horse
horse
)
throws
ValidationException
{
public
void
validateNewHorse
(
Horse
horse
)
throws
ValidationException
{
if
(
horse
.
getName
()
==
null
||
horse
.
getScore
()
==
0
||
horse
.
getBirthday
()
==
null
||
horse
.
getRace
()
==
null
||
horse
.
getImagePath
()
==
null
){
if
(
horse
.
getName
()
==
null
||
horse
.
get
Name
().
isEmpty
()
||
horse
.
getName
().
isBlank
()
||
horse
.
get
Score
()
==
0
||
horse
.
getBirthday
()
==
null
||
horse
.
getRace
()
==
null
||
horse
.
getImagePath
()
==
null
){
throw
new
ValidationException
(
"All or some required values missing: name, score, birthday, race, imagePath"
);
throw
new
ValidationException
(
"All or some required values missing: name, score, birthday, race, imagePath"
);
}
}
if
(
horse
.
getScore
()
>
5
||
horse
.
getScore
()
<
1
)
{
if
(
horse
.
getScore
()
>
5
||
horse
.
getScore
()
<
1
)
{
...
@@ -48,7 +48,7 @@ public class Validator {
...
@@ -48,7 +48,7 @@ public class Validator {
if
(
horse
.
getId
()
==
null
||
horse
.
getId
()
==
0
)
{
if
(
horse
.
getId
()
==
null
||
horse
.
getId
()
==
0
)
{
throw
new
ValidationException
(
"Horse Id cannot be null or 0"
);
throw
new
ValidationException
(
"Horse Id cannot be null or 0"
);
}
}
if
(
horse
.
getName
()
==
null
||
horse
.
getScore
()
==
0
||
horse
.
getBirthday
()
==
null
||
horse
.
getRace
()
==
null
||
horse
.
getImagePath
()
==
null
){
if
(
horse
.
getName
()
==
null
||
horse
.
get
Name
().
isEmpty
()
||
horse
.
getName
().
isBlank
()
||
horse
.
get
Score
()
==
0
||
horse
.
getBirthday
()
==
null
||
horse
.
getRace
()
==
null
||
horse
.
getImagePath
()
==
null
){
throw
new
ValidationException
(
"All or some required values missing: name, score, birthday, race. imagePath"
);
throw
new
ValidationException
(
"All or some required values missing: name, score, birthday, race. imagePath"
);
}
}
if
(
horse
.
getScore
()
>
5
||
horse
.
getScore
()
<
1
)
{
if
(
horse
.
getScore
()
>
5
||
horse
.
getScore
()
<
1
)
{
...
...
frontend/wendys-friends/src/app/component/add-horse/add-horse.component.html
View file @
8e373684
...
@@ -17,12 +17,12 @@
...
@@ -17,12 +17,12 @@
<form
(ngSubmit)=
"addHorse()"
#horseForm
="
ngForm
"
>
<form
(ngSubmit)=
"addHorse()"
#horseForm
="
ngForm
"
>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"name"
>
Name
</label>
<label
for=
"name"
>
Name
</label>
<input
type=
"text"
class=
"form-control"
name=
"name"
[(ngModel)]=
"horse.name"
required
>
<input
type=
"text"
class=
"form-control"
name=
"name"
pattern=
"\S+.*"
[(ngModel)]=
"horse.name"
required
>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"description"
>
Description
</label>
<label
for=
"description"
>
Description
</label>
<textarea
class=
"form-control"
name=
"description"
[(ngModel)]=
"horse.description"
value=
""
></textarea>
<textarea
class=
"form-control"
name=
"description"
pattern=
"\S+.*"
[(ngModel)]=
"horse.description"
value=
""
></textarea>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
...
...
frontend/wendys-friends/src/app/component/update-horse/update-horse.component.html
View file @
8e373684
...
@@ -17,12 +17,12 @@
...
@@ -17,12 +17,12 @@
<form
(ngSubmit)=
"updateHorse()"
#horseForm
="
ngForm
"
>
<form
(ngSubmit)=
"updateHorse()"
#horseForm
="
ngForm
"
>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"name"
>
Name
</label>
<label
for=
"name"
>
Name
</label>
<input
type=
"text"
class=
"form-control"
name=
"name"
[(ngModel)]=
"horse.name"
required
>
<input
type=
"text"
class=
"form-control"
name=
"name"
[(ngModel)]=
"horse.name"
pattern=
"\S+.*"
required
>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"description"
>
Description
</label>
<label
for=
"description"
>
Description
</label>
<textarea
class=
"form-control"
name=
"description"
[(ngModel)]=
"horse.description"
></textarea>
<textarea
class=
"form-control"
name=
"description"
pattern=
"\S+.*"
[(ngModel)]=
"horse.description"
></textarea>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment