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
13f8d941
Commit
13f8d941
authored
May 20, 2022
by
Adrián Piaček
Browse files
Fixed delete funcitonality on players
parent
fda2af20
Pipeline
#141692
passed with stage
in 1 minute and 24 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gaming-persistence/src/main/java/cz/muni/fi/pa165/dao/BaseDaoImpl.java
View file @
13f8d941
...
...
@@ -63,11 +63,7 @@ public class BaseDaoImpl<Entity extends BaseEntity> implements BaseDao<Entity> {
@Override
public
void
remove
(
Entity
entity
)
{
try
{
var
attached
=
findById
(
entity
.
getId
());
if
(
attached
==
null
)
{
throw
new
IllegalArgumentException
(
"Cannot delete a record. Given entity does not exist."
);
}
em
.
remove
(
entity
);
em
.
remove
(
findById
(
entity
.
getId
()));
}
catch
(
Exception
e
)
{
throw
new
DaoDataAccessException
(
e
.
getMessage
(),
e
);
}
...
...
gaming-persistence/src/main/java/cz/muni/fi/pa165/entity/PlayerEntity.java
View file @
13f8d941
...
...
@@ -37,7 +37,7 @@ public class PlayerEntity extends PersonEntity {
public
PlayerEntity
()
{
}
public
PlayerEntity
(
String
name
){
super
(
name
);
public
PlayerEntity
(
String
id
){
super
(
id
);
}
}
gaming-service/src/main/java/cz/muni/fi/pa165/facade/PlayerFacadeImpl.java
View file @
13f8d941
...
...
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.Optional
;
@Service
@Transactional
...
...
gaming-spring-mvc/src/main/java/cz/muni/fi/pa165/mvc/controllers/PlayerController.java
View file @
13f8d941
...
...
@@ -50,8 +50,7 @@ public class PlayerController {
@ModelAttribute
(
"teams"
)
public
List
<
TeamDTO
>
teams
()
{
List
<
TeamDTO
>
teams
=
teamFacade
.
findAllTeams
();
return
teams
;
return
teamFacade
.
findAllTeams
();
}
@RequestMapping
(
value
=
"/view/{id}"
,
method
=
RequestMethod
.
GET
)
public
String
view
(
@PathVariable
String
id
,
Model
model
)
{
...
...
@@ -80,7 +79,7 @@ public class PlayerController {
playerFacade
.
delete
(
uuid
);
redirectAttributes
.
addFlashAttribute
(
"alert_success"
,
"Player \""
+
player
.
getId
()
+
"\" was deleted."
);
}
catch
(
Exception
ex
)
{
redirectAttributes
.
addFlashAttribute
(
"alert_danger"
,
"Player \""
+
player
.
getId
()
+
"\" cannot be deleted."
);
redirectAttributes
.
addFlashAttribute
(
"alert_danger"
,
"Player \""
+
player
.
getId
()
+
"\" cannot be deleted."
+
ex
.
getMessage
()
);
}
return
"redirect:"
+
uriBuilder
.
path
(
"/player/list"
).
toUriString
();
}
...
...
gaming-spring-mvc/src/main/webapp/WEB-INF/jsp/player/list.jsp
View file @
13f8d941
...
...
@@ -31,10 +31,18 @@
<td><c:out
value=
"
${
player
.
id
}
"
/></td>
<td><c:out
value=
"
${
player
.
name
}
"
/></td>
<td><c:out
value=
"
${
player
.
country
}
"
/></td>
<td><c:out
value=
"
${
player
.
team
.
name
}
"
/></td
<td><c:out
value=
"
${
player
.
team
.
name
}
"
/></td
>
<td><c:out
value=
"
${
player
.
killStat
}
"
/></td>
<td><c:out
value=
"
${
player
.
deathStat
}
"
/></td>
<td><c:out
value=
"
${
player
.
assistStat
}
"
/></td>
<td>
<my:a
href=
"/player/view/${player.id}"
class=
"btn btn-primary"
>
View
</my:a>
</td>
<td>
<form
method=
"post"
action=
"${pageContext.request.contextPath}/player/delete/${player.id}"
>
<button
type=
"submit"
class=
"btn btn-primary"
>
Delete
</button>
</form>
</td>
</tr>
</c:forEach>
</tbody>
...
...
gaming-spring-mvc/src/main/webapp/WEB-INF/tags/pagetemplate.tag
View file @
13f8d941
...
...
@@ -37,6 +37,7 @@
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
><f:message
key=
"navigation.teams"
/><b
class=
"caret"
></b></a>
<ul
class=
"dropdown-menu"
>
<li><my:a
href=
"/team/list"
><f:message
key=
"navigation.teams"
/></my:a></li>
<li><my:a
href=
"/team/list"
><f:message
key=
"navigation.coaches"
/></my:a></li>
<li><my:a
href=
"/team/list"
><f:message
key=
"navigation.ranklist.teams"
/></my:a></li>
</ul>
</li>
...
...
@@ -44,7 +45,6 @@
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
><f:message
key=
"navigation.players"
/><b
class=
"caret"
></b></a>
<ul
class=
"dropdown-menu"
>
<li><my:a
href=
"/player/list"
><f:message
key=
"navigation.players"
/></my:a></li>
<li><my:a
href=
"/player/list"
><f:message
key=
"navigation.coaches"
/></my:a></li>
<li><my:a
href=
"/player/list"
><f:message
key=
"navigation.ranklist.players"
/></my:a></li>
</ul>
</li>
...
...
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