Commit 6dcac4e2 by Antti Tonkyra

show gameids in tournament admin view

1 parent 1d261dd6
......@@ -118,6 +118,7 @@ public class MenuBean implements MenuBeanLocal {
userprofile.addPage(menuitemfacade.findOrCreate("/user/edit"), UserPermission.VIEW_SELF);
userprofile.addPage(menuitemfacade.findOrCreate("/user/changePassword"), UserPermission.VIEW_SELF);
userprofile.addPage(menuitemfacade.findOrCreate("/user/gameids"), TournamentPermission.VIEW);
userprofile.addPage(menuitemfacade.findOrCreate("/auth/logout"), UserPermission.LOGOUT);
MenuNavigation tournaments = usermenu.addPage(null, null);
......
......@@ -551,6 +551,12 @@ public class UserBean implements UserBeanLocal {
gi.getEventUser().getGameIDs().remove(gi);
gameIDFacade.remove(gi);
}
@Override
@RolesAllowed(SpecialPermission.S_USER)
public GameID getGameIDByGameAndUser(TournamentGame tg, EventUser user) {
return gameIDFacade.getGameIDByGame(tg, user);
}
@Override
public boolean userExists(String login) {
......
......@@ -13,9 +13,13 @@ import javax.persistence.criteria.Root;
import fi.codecrew.moya.enums.TournamentStatus;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GameID;
import fi.codecrew.moya.model.GameID_;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.Tournament;
import fi.codecrew.moya.model.TournamentGame;
import fi.codecrew.moya.model.TournamentParticipant;
import fi.codecrew.moya.model.TournamentRule;
import fi.codecrew.moya.model.TournamentRule_;
import fi.codecrew.moya.model.Tournament_;
import fi.codecrew.moya.model.User;
import fi.codecrew.moya.model.User_;
......@@ -25,6 +29,20 @@ import fi.codecrew.moya.model.User_;
public class GameIDFacade extends IntegerPkGenericFacade<GameID> {
public GameIDFacade() {
super(GameID.class);
}
public GameID getGameIDByGame(TournamentGame tg, EventUser user) {
// TODO Auto-generated method stub
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<GameID> cq = cb.createQuery(GameID.class);
Root<GameID> root = cq.from(GameID.class);
cq.where(cb.and(cb.equal(root.get(GameID_.game), tg), cb.equal(root.get(GameID_.eventUser), user)));
try {
return getEm().createQuery(cq).getSingleResult();
} catch(Exception e) {
return null;
}
}
}
......@@ -8,6 +8,7 @@ import javax.ejb.Local;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Feedback;
import fi.codecrew.moya.model.GameID;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.model.TournamentGame;
......@@ -96,4 +97,6 @@ public interface UserBeanLocal {
void removeGameIdById(Integer gameIdId);
GameID getGameIDByGameAndUser(TournamentGame tg, EventUser user);
}
......@@ -22,7 +22,7 @@
<f:facet name="header">
<h:outputText value="#{i18n['tournament.participant_gameid']}" />
</f:facet>
<h:outputText value="derp" />
<h:outputText value="#{tournamentParticipantsView.eventUserGameID[participant.participator.id]}" />
</p:column>
</p:dataTable>
</h:form>
......
......@@ -36,7 +36,7 @@
<ui:repeat var="member" value="#{participant.teamMembers}">
<li>
<h:outputText value="#{member.eventUser.nick}" />
(<h:outputText value="GAMEID" />)
(<h:outputText value="#{tournamentParticipantsView.eventUserGameID[member.eventUser.id]}" />)
</li>
</ui:repeat>
</ul>
......
......@@ -936,6 +936,7 @@ submenu.user.changePassword = Change password
submenu.user.create = Create new user
submenu.user.edit = My information
submenu.user.foodwave = Food
submenu.user.gameids = Set GameIDs
submenu.user.invite = Invite friends
submenu.user.manageuserlinks = Manage users
submenu.user.other = Other
......@@ -1010,6 +1011,7 @@ topnavi.usermgmt = Users
topnavi.userplaces = Computer Places
topnavi.usershop = Shop
tournament.admin.back_to_index = Back to tournament administration
tournament.admin.control = Control
tournament.admin.create = Create new tournament
tournament.admin.delete = Delete
......@@ -1028,6 +1030,7 @@ tournament.fillamount = Places taken
tournament.game = Game
tournament.name = Tournament name
tournament.not_within_participation_time = Not within the participation time for the tournament
tournament.participant_captain = Captain
tournament.participant_gameid = Game-ID
tournament.participant_nick = Nickname
tournament.participants = Participants
......
......@@ -919,6 +919,7 @@ submenu.user.create = Luo k\u00E4ytt\u00E4j\u00E4
submenu.user.createCardTemplate = Luo korttiryhm\u00E4
submenu.user.edit = Omat tiedot
submenu.user.foodwave = Ruoka
submenu.user.gameids = Aseta Peli-IDt
submenu.user.invite = Kutsu yst\u00E4vi\u00E4
submenu.user.list = Kaikki k\u00E4ytt\u00E4j\u00E4t
submenu.user.listCardTemplates = Korttiryhm\u00E4t
......@@ -995,6 +996,7 @@ topnavi.usermgmt = K\u00E4ytt\u00E4j\u00E4t
topnavi.userplaces = Konepaikat
topnavi.usershop = Kauppa
tournament.admin.back_to_index = Takaisin turnauksen yll\u00E4pitosivulle
tournament.admin.control = Hallitse
tournament.admin.create = Luo uusi turnaus
tournament.admin.delete = Poista
......@@ -1013,6 +1015,7 @@ tournament.fillamount = Osallistujaa i
tournament.game = Peli
tournament.name = Turnauksen nimi
tournament.not_within_participation_time = Turnauksen ilmoittautuminen ei ole aktiivinen
tournament.participant_captain = Kapteeni
tournament.participant_gameid = Peli-ID
tournament.participant_nick = Nimimerkki
tournament.participants = Osallistujat
......
package fi.codecrew.moya.web.cdiview.tournaments;
import java.util.HashMap;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import fi.codecrew.moya.beans.TournamentBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.model.GameID;
import fi.codecrew.moya.model.Tournament;
import fi.codecrew.moya.model.TournamentParticipant;
import fi.codecrew.moya.model.TournamentTeamMember;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
......@@ -13,12 +19,27 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
public class TournamentParticipantsView extends GenericCDIView {
private static final long serialVersionUID = -6066216858686165211L;
private HashMap<Integer, String> eventUserGameID = null;
@EJB private UserBeanLocal userBean;
@EJB private TournamentBeanLocal tournamentBean;
private Tournament tournament = null;
public String showView(Integer tournamentId) {
this.beginConversation();
this.setTournament(tournamentBean.getTournamentById(tournamentId));
if(eventUserGameID == null) {
this.setTournament(tournamentBean.getTournamentById(tournamentId));
this.beginConversation();
eventUserGameID = new HashMap<Integer, String>();
for(TournamentParticipant tp : tournament.getParticipants()) {
for(TournamentTeamMember ttm : tp.getTeamMembers()) {
GameID gid = userBean.getGameIDByGameAndUser(tournament.getTournamentGame(), ttm.getEventUser());
if(gid != null)
eventUserGameID.put(ttm.getEventUser().getId(), gid.getIdentifier());
else
eventUserGameID.put(ttm.getEventUser().getId(), "n/a");
}
}
}
if(this.tournament.getPlayersPerTeam() == 1)
return "/tournaments/admin/view_tournament_single.xhtml";
else
......@@ -38,5 +59,11 @@ public class TournamentParticipantsView extends GenericCDIView {
this.tournament = tournament;
}
public HashMap<Integer, String> getEventUserGameID() {
return eventUserGameID;
}
public void setEventUserGameID(HashMap<Integer, String> eventUserGameID) {
this.eventUserGameID = eventUserGameID;
}
}
package fi.codecrew.moya.web.cdiview.user;
import java.util.HashMap;
import java.util.List;
import javax.ejb.EJB;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!