Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Matúš Valko
Online Gaming Management System
Commits
2de3023c
Commit
2de3023c
authored
May 20, 2022
by
Dominik Kozubík
Browse files
match fixes
parent
56720823
Pipeline
#141746
passed with stage
in 1 minute and 26 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gaming-service/src/main/java/cz/muni/fi/pa165/facade/MatchFacadeImpl.java
View file @
2de3023c
...
...
@@ -5,6 +5,8 @@ import cz.muni.fi.pa165.entity.MatchEntity;
import
cz.muni.fi.pa165.entity.TournamentEntity
;
import
cz.muni.fi.pa165.services.BeanMappingService
;
import
cz.muni.fi.pa165.services.match.MatchService
;
import
cz.muni.fi.pa165.services.team.TeamService
;
import
cz.muni.fi.pa165.services.tournament.TournamentService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -25,6 +27,11 @@ public class MatchFacadeImpl implements MatchFacade {
@Autowired
private
BeanMappingService
beanMappingService
;
@Autowired
private
TeamService
teamService
;
@Autowired
private
TournamentService
tournamentService
;
@Override
public
List
<
MatchDTO
>
findAllMatches
()
{
...
...
@@ -44,7 +51,7 @@ public class MatchFacadeImpl implements MatchFacade {
match
.
setPlayerList
(
matchDTO
.
getPlayerList
());
match
.
setPlayers
(
matchDTO
.
getPlayers
());
match
.
setTeams
(
matchDTO
.
getTeams
());
match
.
setTournament
(
matchDTO
.
getTournament
());
match
.
setTournament
(
tournamentService
.
findById
(
matchDTO
.
getTournament
()
.
getId
())
);
matchService
.
create
(
match
);
...
...
gaming-spring-mvc/src/main/java/cz/muni/fi/pa165/mvc/controllers/MatchController.java
View file @
2de3023c
...
...
@@ -37,7 +37,7 @@ public class MatchController {
private
TeamFacade
teamFacade
;
@ModelAttribute
(
"tournaments"
)
public
List
<
TournamentDTO
>
c
ou
ntrie
s
()
{
public
List
<
TournamentDTO
>
t
ou
rnament
s
()
{
return
tournamentFacade
.
findAllTournament
();
}
...
...
@@ -55,7 +55,7 @@ public class MatchController {
@RequestMapping
(
value
=
"/new"
,
method
=
RequestMethod
.
GET
)
public
String
newMatch
(
Model
model
)
{
model
.
addAttribute
(
"
createMatch
"
,
new
MatchDTO
());
model
.
addAttribute
(
"
matchCreate
"
,
new
MatchDTO
());
return
"match/new"
;
}
...
...
@@ -80,15 +80,12 @@ public class MatchController {
@RequestMapping
(
value
=
"/create"
,
method
=
RequestMethod
.
POST
)
public
String
create
(
@Valid
@ModelAttribute
(
"matchCreate"
)
MatchDTO
formBean
,
BindingResult
bindingResult
,
Model
model
,
RedirectAttributes
redirectAttributes
,
UriComponentsBuilder
uriBuilder
)
{
//in case of validation error forward back to the
the
form
//in case of validation error forward back to the form
if
(
bindingResult
.
hasErrors
())
{
System
.
err
.
println
(
"tu som 0"
);
return
"match/new"
;
}
//create tournament
System
.
err
.
println
(
"tu som 1"
);
//create match
String
uuid
=
matchFacade
.
createMatch
(
formBean
);
System
.
err
.
println
(
"tu som 2"
);
//report success
redirectAttributes
.
addFlashAttribute
(
"alert_success"
,
"Match "
+
uuid
+
" was created"
);
return
"redirect:"
+
uriBuilder
.
path
(
"/match/view/{id}"
).
buildAndExpand
(
uuid
).
encode
().
toUriString
();
...
...
gaming-spring-mvc/src/main/webapp/WEB-INF/jsp/match/new.jsp
View file @
2de3023c
...
...
@@ -9,13 +9,13 @@
<jsp:attribute
name=
"body"
>
<form:form
method=
"post"
action=
"
${
pageContext
.
request
.
contextPath
}
/match/create"
modelAttribute=
"
createMatch
"
cssClass=
"form-horizontal"
>
modelAttribute=
"
matchCreate
"
cssClass=
"form-horizontal"
>
<div
class=
"form-group"
>
<form:label
path=
"tournament"
cssClass=
"col-sm-2 control-label"
>
Tournament
</form:label>
<div
class=
"col-sm-10"
>
<form:select
path=
"tournament"
required=
"required"
cssClass=
"form-control"
>
<c:forEach
items=
"
${
tournaments
}
"
var=
"t
ournament
"
>
<form:option
value=
"
${
t
ournament
.
id
}
"
>
${tournamen
t.id}
</form:option>
<c:forEach
items=
"
${
tournaments
}
"
var=
"t"
>
<form:option
value=
"
${
t
}
"
>
${
t.id}
</form:option>
</c:forEach>
</form:select>
<form:errors
path=
"tournament"
cssClass=
"error"
/>
...
...
@@ -26,7 +26,7 @@
<div
class=
"col-sm-10"
>
<form:select
path=
"teams"
required=
"required"
cssClass=
"form-control"
>
<c:forEach
items=
"
${
teams
}
"
var=
"team"
>
<form:option
value=
"
${
team
.
name
}
"
>
${team.name}
</form:option>
<form:option
value=
"
${
team
}
"
>
${team.name}
</form:option>
</c:forEach>
</form:select>
<form:errors
path=
"teams"
cssClass=
"error"
/>
...
...
gaming-spring-mvc/src/main/webapp/WEB-INF/tags/pagetemplate.tag
View file @
2de3023c
...
...
@@ -52,7 +52,7 @@
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
><f:message
key=
"navigation.tournaments"
/><b
class=
"caret"
></b></a>
<ul
class=
"dropdown-menu"
>
<li><my:a
href=
"/tournament/list"
><f:message
key=
"navigation.tournaments"
/></my:a></li>
<li><my:a
href=
"/
tournament
/list"
><f:message
key=
"navigation.matches"
/></my:a></li>
<li><my:a
href=
"/
match
/list"
><f:message
key=
"navigation.matches"
/></my:a></li>
</ul>
</li>
</ul>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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