Commit 6ff1da55 by Tuukka Kivilahti

Game -> license and refactor

1 parent 875fb1f2
Showing with 285 additions and 402 deletions
......@@ -12,12 +12,12 @@ import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import fi.codecrew.moya.facade.GameCodeFacade;
import fi.codecrew.moya.facade.GameFacade;
import fi.codecrew.moya.facade.LicenseCodeFacade;
import fi.codecrew.moya.facade.LicenseTargetFacade;
import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Game;
import fi.codecrew.moya.model.GameCode;
import fi.codecrew.moya.model.LicenseTarget;
import fi.codecrew.moya.model.LicenseCode;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.Place;
......@@ -26,13 +26,13 @@ import fi.codecrew.moya.model.Place;
* Session Bean implementation class GameBean
*/
@Stateless
public class GameBean implements GameBeanLocal {
public class LicenseBean implements LicenseBeanLocal {
@EJB
GameCodeFacade gameCodeFacade;
LicenseCodeFacade gameCodeFacade;
@EJB
GameFacade gameFacade;
LicenseTargetFacade gameFacade;
@EJB
......@@ -41,34 +41,11 @@ public class GameBean implements GameBeanLocal {
@EJB
PlaceBeanLocal placeBean;
public GameCode getCode(Place place) {
List<GameCode> codes = place.getGameCodes();
if(codes.size() > 0) {
return codes.get(0);
}
return null;
}
public List<GameCode> findUserCodes(EventUser user) {
ArrayList<GameCode> returnCodes = new ArrayList<GameCode>();
// first get free gamecodes from user places
if(user.getCurrentPlaces() != null) {
for(GroupMembership memberShip : user.getGroupMemberships()) {
if(memberShip.getPlaceReservation() == null)
continue;
for(GameCode placeGameCode : memberShip.getPlaceReservation().getGameCodes()) {
if(placeGameCode.getUser() == null) {
returnCodes.add(placeGameCode);
}
}
}
}
public List<LicenseCode> findUserCodes(EventUser user) {
ArrayList<LicenseCode> returnCodes = new ArrayList<LicenseCode>();
for(GameCode userGameCode : user.getUser().getGameCodes()) {
for(LicenseCode userGameCode : user.getUser().getGameCodes()) {
returnCodes.add(userGameCode);
}
......@@ -80,7 +57,7 @@ public class GameBean implements GameBeanLocal {
*
* @param code
*/
private boolean generateCode(GameCode code) {
private boolean generateCode(LicenseCode code) {
if (code.getCode() == null || code.getCode().trim().equals("")) {
if (code.getGame().getCodeUrl() == null || code.getGame().getCodeUrl().trim().equals(""))
......@@ -122,7 +99,7 @@ public class GameBean implements GameBeanLocal {
return false;
}
public boolean accessCode(GameCode code, EventUser user) {
public boolean accessCode(LicenseCode code, EventUser user) {
if(code.getUser() != null)
return false;
......@@ -141,11 +118,11 @@ public class GameBean implements GameBeanLocal {
return true;
}
public List<Game> findAll(LanEvent event) {
public List<LicenseTarget> findAll(LanEvent event) {
return event.getGames();
}
public void saveOrCreateGame(Game game) {
public void saveOrCreateLicense(LicenseTarget game) {
if (game.getId() == null) {
game.setEvent(eventBean.getCurrentEvent());
eventBean.getCurrentEvent().getGames().add(game);
......@@ -160,27 +137,41 @@ public class GameBean implements GameBeanLocal {
/**
* Default constructor.
*/
public GameBean() {
public LicenseBean() {
// TODO Auto-generated constructor stub
}
@Override
public void generateCodesForAllPlaces(Game game) {
if(game == null)
return;
public List<LicenseTarget> findUserGames(EventUser user) {
LanEvent currentEvent = eventBean.getCurrentEvent();
ArrayList<LicenseTarget> returnLicenses = new ArrayList<LicenseTarget>();
for(EventMap map : currentEvent.getEventMaps()) {
for(Place place : map.getPlaces()) {
GameCode code = new GameCode(place, game);
gameCodeFacade.create(code);
code = gameCodeFacade.merge(code);
place.getGameCodes().add(code);
if(user.getCurrentPlaces() != null) {
for(GroupMembership memberShip : user.getGroupMemberships()) {
if(memberShip.getPlaceReservation() == null)
continue;
for(LicenseTarget license : memberShip.getPlaceReservation().getProduct().getLicenseTargets()) {
if(license.isActive())
returnLicenses.add(license);
}
}
}
return returnLicenses;
}
@Override
public List<LicenseTarget> findUnopenedUserGames(EventUser user) {
List<LicenseTarget> returnLicenses = findUserGames(user);
for(LicenseCode code : findUserCodes(user)) {
returnLicenses.remove(code);
}
return returnLicenses;
}
}
......@@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.enums.apps.CompoPermission;
import fi.codecrew.moya.enums.apps.ContentPermission;
import fi.codecrew.moya.enums.apps.GamePermission;
import fi.codecrew.moya.enums.apps.LicensePermission;
import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.enums.apps.PollPermission;
import fi.codecrew.moya.enums.apps.ShopPermission;
......@@ -295,8 +295,8 @@ public class MenuBean implements MenuBeanLocal {
foodwaveTopmenu.addPage(menuitemfacade.findOrCreate("/foodwave/ThanksForOrderingFromCounter"), ShopPermission.SHOP_FOODWAVE).setVisible(false);
MenuNavigation gameTopmenu = usernavi.addPage(null, null);
gameTopmenu.setKey("topnavi.game");
gameTopmenu.addPage(menuitemfacade.findOrCreate("/gamecode/viewCodes"), GamePermission.VIEW_OWN_CODES);
gameTopmenu.setKey("topnavi.license");
gameTopmenu.addPage(menuitemfacade.findOrCreate("/license/viewCodes"), LicensePermission.VIEW_OWN_CODES);
MenuNavigation pollTopmenu = usernavi.addPage(null, null);
......@@ -387,8 +387,8 @@ public class MenuBean implements MenuBeanLocal {
foodnavi.addPage(menuitemfacade.findOrCreate("/foodadmin/editTemplate"), ShopPermission.MANAGE_FOODWAVES).setVisible(false);
MenuNavigation gamenavi = adminnavi.addPage(null, null);
gamenavi.setKey("topnavi.game");
gamenavi.addPage(menuitemfacade.findOrCreate("/gamecode/manageCodes"), GamePermission.MANAGE);
gamenavi.setKey("topnavi.license");
gamenavi.addPage(menuitemfacade.findOrCreate("/license/manageCodes"), LicensePermission.MANAGE);
}
@Override
......
......@@ -17,7 +17,7 @@ import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.enums.apps.CompoPermission;
import fi.codecrew.moya.enums.apps.ContentPermission;
import fi.codecrew.moya.enums.apps.EventPermission;
import fi.codecrew.moya.enums.apps.GamePermission;
import fi.codecrew.moya.enums.apps.LicensePermission;
import fi.codecrew.moya.enums.apps.IAppPermission;
import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.enums.apps.PollPermission;
......@@ -93,8 +93,8 @@ import fi.codecrew.moya.model.User;
EventPermission.S_MANAGE_PRIVATE_PROPERTIES,
EventPermission.S_MANAGE_PROPERTIES,
GamePermission.S_MANAGE,
GamePermission.S_VIEW_OWN_CODES
LicensePermission.S_MANAGE,
LicensePermission.S_VIEW_OWN_CODES
})
@LocalBean
public class PermissionBean implements PermissionBeanLocal {
......
......@@ -2,6 +2,7 @@ package fi.codecrew.moya.beans;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.HashSet;
......@@ -19,6 +20,8 @@ import javax.ejb.Stateless;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.bortal.views.BillSummary;
import fi.codecrew.moya.enums.apps.ShopPermission;
import fi.codecrew.moya.facade.AccountEventFacade;
import fi.codecrew.moya.facade.BillLineFacade;
import fi.codecrew.moya.facade.DiscountFacade;
......@@ -26,13 +29,6 @@ import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.facade.InventoryEventFacade;
import fi.codecrew.moya.facade.ProductFacade;
import fi.codecrew.moya.facade.UserFacade;
import fi.codecrew.moya.beans.BillBeanLocal;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.bortal.views.BillSummary;
import fi.codecrew.moya.enums.apps.ShopPermission;
import fi.codecrew.moya.model.AccountEvent;
import fi.codecrew.moya.model.Discount;
import fi.codecrew.moya.model.EventUser;
......@@ -365,4 +361,18 @@ public class ProductBean implements ProductBeanLocal {
public List<Product> findProductsForEvent() {
return productFacade.findAll();
}
@Override
public List<Product> findPlaceProducts() {
ArrayList<Product> returnProducts = new ArrayList<Product>();
for(Product product : findProductsForEvent()) {
if(product.getPlaces() != null && product.getPlaces().size() > 0) {
returnProducts.add(product);
}
}
return returnProducts;
}
}
package fi.codecrew.moya.facade;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.GameCode;
import fi.codecrew.moya.model.GameCode_;
import fi.codecrew.moya.model.News;
import fi.codecrew.moya.model.Place;
@Stateless
@LocalBean
public class GameCodeFacade extends IntegerPkGenericFacade<GameCode> {
public GameCodeFacade() {
super(GameCode.class);
}
public GameCode findByPlace(Place place) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<GameCode> cq = cb.createQuery(GameCode.class);
Root<GameCode> root = cq.from(GameCode.class);
cq.where(cb.equal(root.get(GameCode_.place), place));
return getSingleNullableResult(getEm().createQuery(cq));
}
}
......@@ -3,15 +3,13 @@ package fi.codecrew.moya.facade;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.codecrew.moya.model.Game;
import fi.codecrew.moya.model.LicenseCode;
@Stateless
@LocalBean
public class GameFacade extends IntegerPkGenericFacade<Game> {
public class LicenseCodeFacade extends IntegerPkGenericFacade<LicenseCode> {
public GameFacade() {
super(Game.class);
public LicenseCodeFacade() {
super(LicenseCode.class);
}
}
package fi.codecrew.moya.facade;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.codecrew.moya.model.LicenseTarget;
@Stateless
@LocalBean
public class LicenseTargetFacade extends IntegerPkGenericFacade<LicenseTarget> {
public LicenseTargetFacade() {
super(LicenseTarget.class);
}
}
package fi.codecrew.moya.beans;
import java.util.List;
import javax.ejb.Local;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Game;
import fi.codecrew.moya.model.GameCode;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.Place;
@Local
public interface GameBeanLocal {
public GameCode getCode(Place place);
public boolean accessCode(GameCode code, EventUser user);
public List<Game> findAll(LanEvent event);
public void saveOrCreateGame(Game game);
public List<GameCode> findUserCodes(EventUser user);
public void generateCodesForAllPlaces(Game game);
}
package fi.codecrew.moya.beans;
import java.util.List;
import javax.ejb.Local;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.LicenseTarget;
import fi.codecrew.moya.model.LicenseCode;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.Place;
@Local
public interface LicenseBeanLocal {
public boolean accessCode(LicenseCode code, EventUser user);
public List<LicenseTarget> findAll(LanEvent event);
public void saveOrCreateLicense(LicenseTarget game);
public List<LicenseCode> findUserCodes(EventUser user);
public List<LicenseTarget> findUserGames(EventUser user);
public List<LicenseTarget> findUnopenedUserGames(EventUser user);
}
\ No newline at end of file
......@@ -55,5 +55,7 @@ public interface ProductBeanLocal {
void saveInventoryEvent(InventoryEvent ie);
List<Product> findProductsForEvent();
List<Product> findPlaceProducts();
}
......@@ -75,7 +75,7 @@ public class LanEvent extends GenericEntity {
private List<Compo> compos;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "event")
private List<Game> games;
private List<LicenseTarget> games;
@OneToMany(mappedBy = "event", cascade = CascadeType.ALL)
private List<CardTemplate> cardTemplates;
......@@ -284,13 +284,13 @@ public class LanEvent extends GenericEntity {
this.properties = properties;
}
public List<Game> getGames() {
public List<LicenseTarget> getGames() {
if(games == null)
games = new ArrayList<Game>();
games = new ArrayList<LicenseTarget>();
return games;
}
public void setGames(List<Game> games) {
public void setGames(List<LicenseTarget> games) {
this.games = games;
}
......
......@@ -21,28 +21,22 @@ import org.eclipse.persistence.annotations.OptimisticLockingType;
*
*/
@Entity
@Table(name = "gamecodes")
@Table(name = "licensecodes")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class GameCode extends GenericEntity {
public class LicenseCode extends GenericEntity {
private static final long serialVersionUID = 1L;
@Column(name = "accessed", nullable = true)
@Temporal(TemporalType.TIMESTAMP)
private Calendar accessed = null;
@Column(name = "code")
private String code;
@JoinColumn(name = "game_id", referencedColumnName = "id")
@ManyToOne
private Game game;
private LicenseTarget game;
@JoinColumn(name = "user_id", referencedColumnName = "id")
@ManyToOne
......@@ -54,12 +48,12 @@ public class GameCode extends GenericEntity {
public GameCode() {
public LicenseCode() {
super();
}
public GameCode(Place place, Game game) {
public LicenseCode(Place place, LicenseTarget game) {
this();
this.place = place;
this.game = game;
......@@ -94,13 +88,13 @@ public class GameCode extends GenericEntity {
public Game getGame() {
public LicenseTarget getGame() {
return game;
}
public void setGame(Game game) {
public void setGame(LicenseTarget game) {
this.game = game;
}
......
......@@ -4,6 +4,7 @@
*/
package fi.codecrew.moya.model;
import java.util.Calendar;
import java.util.List;
import javax.persistence.Column;
......@@ -14,6 +15,8 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
......@@ -22,14 +25,17 @@ import org.eclipse.persistence.annotations.OptimisticLockingType;
*
*/
@Entity
@Table(name = "games")
@Table(name = "licenseTargets")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class Game extends GenericEntity {
public class LicenseTarget extends GenericEntity {
private static final long serialVersionUID = 1L;
@Column(name = "active")
private boolean active = false;
@Column(name = "name")
private String name;
......@@ -41,7 +47,6 @@ public class Game extends GenericEntity {
@Column(name = "code_url")
private String codeUrl;
@JoinColumn(name = "event_id", referencedColumnName = "id")
@ManyToOne
......@@ -49,15 +54,13 @@ public class Game extends GenericEntity {
@OneToMany(mappedBy = "game", fetch = FetchType.LAZY)
@OrderBy()
private List<GameCode> gameCodes;
private List<LicenseCode> licenseCodes;
@JoinColumn(name = "product_id", referencedColumnName = "id")
@ManyToOne
private Product product;
public Game() {
public LicenseTarget() {
super();
}
......@@ -132,16 +135,55 @@ public class Game extends GenericEntity {
public List<GameCode> getGameCodes() {
return gameCodes;
public List<LicenseCode> getGameCodes() {
return licenseCodes;
}
public void setGameCodes(List<GameCode> gameCodes) {
this.gameCodes = gameCodes;
public void setGameCodes(List<LicenseCode> gameCodes) {
this.licenseCodes = gameCodes;
}
public Product getProduct() {
return product;
}
public void setProduct(Product product) {
this.product = product;
}
public boolean isActive() {
return active;
}
public boolean getActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public List<LicenseCode> getLicenseCodes() {
return licenseCodes;
}
public void setLicenseCodes(List<LicenseCode> licenseCodes) {
this.licenseCodes = licenseCodes;
}
}
......@@ -91,11 +91,6 @@ public class Place extends GenericEntity {
@JoinColumn(name = "current_eventuser_id", referencedColumnName = EventUser.ID_COLUMN)
@ManyToOne
private EventUser currentUser;
@OneToMany(mappedBy = "place", fetch = FetchType.LAZY)
@OrderBy()
private List<GameCode> gameCodes;
public Place() {
super();
......@@ -288,17 +283,4 @@ public class Place extends GenericEntity {
this.disabled = disabled;
}
public List<GameCode> getGameCodes() {
if(gameCodes == null) {
gameCodes = new ArrayList<GameCode>();
}
return gameCodes;
}
public void setGameCodes(List<GameCode> gameCodes) {
this.gameCodes = gameCodes;
}
}
......@@ -70,6 +70,11 @@ public class Product extends GenericEntity {
@Column(name = "barcode")
private String barcode;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "product")
private List<LicenseTarget> licenseTargets;
@Enumerated(EnumType.STRING)
@PrivateOwned
@ElementCollection()
......@@ -332,4 +337,12 @@ public class Product extends GenericEntity {
this.inventoryEvents = inventoryEvents;
}
public List<LicenseTarget> getLicenseTargets() {
return licenseTargets;
}
public void setLicenseTargets(List<LicenseTarget> licenseTargets) {
this.licenseTargets = licenseTargets;
}
}
......@@ -113,7 +113,7 @@ public class User extends GenericEntity implements IUser {
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
@OrderBy()
private List<GameCode> gameCodes;
private List<LicenseCode> gameCodes;
@Transient
private static final Logger logger = LoggerFactory.getLogger(User.class);
......@@ -361,14 +361,14 @@ public class User extends GenericEntity implements IUser {
}
public List<GameCode> getGameCodes() {
public List<LicenseCode> getGameCodes() {
if(gameCodes == null)
gameCodes = new ArrayList<GameCode>();
gameCodes = new ArrayList<LicenseCode>();
return gameCodes;
}
public void setGameCodes(List<GameCode> gameCodes) {
public void setGameCodes(List<LicenseCode> gameCodes) {
this.gameCodes = gameCodes;
}
......
......@@ -4,7 +4,7 @@ import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.enums.apps.CompoPermission;
import fi.codecrew.moya.enums.apps.ContentPermission;
import fi.codecrew.moya.enums.apps.EventPermission;
import fi.codecrew.moya.enums.apps.GamePermission;
import fi.codecrew.moya.enums.apps.LicensePermission;
import fi.codecrew.moya.enums.apps.IAppPermission;
import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.enums.apps.PollPermission;
......@@ -24,7 +24,7 @@ public enum BortalApplication {
SALESPOINT(SalespointPermission.class),
COMPO(CompoPermission.class),
EVENT(EventPermission.class),
GAME(GamePermission.class),
LICENSE(LicensePermission.class),
;
......
......@@ -2,28 +2,27 @@ package fi.codecrew.moya.enums.apps;
import fi.codecrew.moya.enums.BortalApplication;
public enum GamePermission implements IAppPermission {
public enum LicensePermission implements IAppPermission {
MANAGE,
VIEW_OWN_CODES,
;
public static final String S_MANAGE = "GAME/MANAGE";
public static final String S_VIEW_OWN_CODES = "GAME/VIEW_OWN_CODES";
public static final String S_MANAGE = "LICENSE/MANAGE";
public static final String S_VIEW_OWN_CODES = "LICENSE/VIEW_OWN_CODES";
private final String fullName;
private final String key;
private static final String I18N_HEADER = "bortalApplication.game.";
private static final String I18N_HEADER = "bortalApplication.license.";
private GamePermission() {
private LicensePermission() {
fullName = new StringBuilder().append(getParent().toString()).append(DELIMITER).append(toString()).toString();
key = I18N_HEADER + name();
}
@Override
public BortalApplication getParent() {
return BortalApplication.GAME;
return BortalApplication.LICENSE;
}
@Override
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:products="http://java.sun.com/jsf/composite/tools/products" xmlns:tools="http://java.sun.com/jsf/composite/tools" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{gameCodeView.initAdminView}" />
</f:metadata>
<ui:param name="thispage" value="page.gamecode.manageCodes" />
<ui:define name="content">
<h:form>
<p:dataTable border="1" id="games" value="#{gameCodeView.games}" var="game">
<p:column>
<f:facet name="header">
<h:outputText value="${i18n['game.name']}" />
</f:facet>
<h:outputText value="#{game.name}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="edit" />
</f:facet>
<p:commandButton value="muokkaa" update=":editgame" >
<f:setPropertyActionListener value="#{game}" target="#{gameCodeView.currentGame}" />
</p:commandButton>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="game.codecount" />
</f:facet>
<h:outputText value="#{game.gameCodes.size()}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="GENEROI" />
</f:facet>
<p:commandButton value="generoi kaikille paikoille" action="#{gameCodeView.generateSelectedToAllPlaces}">
<f:setPropertyActionListener value="#{game}" target="#{gameCodeView.currentGame}" />
</p:commandButton>
</p:column>
</p:dataTable>
</h:form>
<br /><br />
<h:form id="editgame" >
<p:panelGrid columns="2">
<f:facet name="header">
<h:outputLabel rendered="#{gameCodeView.currentGame.id == null}" value="#{i18n['game.create']}" />
<h:outputLabel rendered="#{gameCodeView.currentGame.id != null}" value="#{i18n['game.edit']}" />
</f:facet>
<h:outputLabel value="service" />
<p:inputText value="#{gameCodeView.currentGame.service}" />
<h:outputLabel value="name" />
<p:inputText value="#{gameCodeView.currentGame.name}" />
<h:outputLabel value="description" />
<p:inputText value="#{gameCodeView.currentGame.description}" />
<h:outputLabel value="url" />
<p:inputText value="#{gameCodeView.currentGame.codeUrl}" />
<p:commandButton action="#{gameCodeView.saveCurrentGame}" value="save" />
</p:panelGrid>
</h:form>
<h:form>
<p:commandButton id="cancelbtn" onclick="confirmation.show()" value="#{i18n['bill.cancel']}" />
<p:confirmDialog id="confirmDialog" message="#{i18n['generic.sure.message']}" header="#{i18n['generic.sure.header']}" severity="alert" widgetVar="confirmation">
<p:commandButton value="#{i18n['generic.sure.yes']}" onclick="confirmation.hide()" actionListener="#{billEditView.expireBill()}" ajax="false" />
<p:commandButton value="#{i18n['generic.sure.no']}" onclick="confirmation.hide()" type="button" />
</p:confirmDialog>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:products="http://java.sun.com/jsf/composite/tools/products" xmlns:tools="http://java.sun.com/jsf/composite/tools" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.gamecode.viewCodes" />
<f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{gameCodeView.initUserView}" />
</f:metadata>
<ui:define name="content">
<h:form>
<h:outputLabel rendered="#{gameCodeView.noGameCodes}" value="#{i18n['game.noGameCodes']}" />
<p:dataTable rendered="#{not gameCodeView.noGameCodes}" columnClasses="nowrap,numalign,numalign,nowrap,numalign" styleClass="bordertable" id="codes" value="#{gameCodeView.gameCodes}" var="code">
<p:column sortBy="#{code.game.service}">
<f:facet name="header">
<h:outputText value="#{i18n['game.service']}" />
</f:facet>
<h:outputText value="#{code.game.service}" />
</p:column>
<p:column sortBy="#{code.game.name}">
<f:facet name="header">
<h:outputText value="#{i18n['game.name']}" />
</f:facet>
<h:outputText value="#{code.game.name}" />
</p:column>
<p:column sortBy="#{code.game.description}">
<f:facet name="header">
<h:outputText value="#{i18n['game.description']}" />
</f:facet>
<h:outputText value="#{code.game.description}" />
</p:column>
<p:column sortBy="#{code.code}">
<f:facet name="header">
<h:outputText value="#{i18n['game.code']}" />
</f:facet>
<h:outputText rendered="#{not code.accessed}" value="ei avattu" />
<h:commandButton rendered="#{not code.accessed}" value="#{i18n['game.open']}" action="#{gameCodeView.openSelectedCode}" />
<h:outputText rendered="#{code.accessed}" value="#{code.code}" />
</p:column>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -41,17 +41,7 @@
<h:selectManyCheckbox id="permissions" layout="pageDirection" value="#{bapp.selected}">
<f:selectItems value="#{bapp.permissions}" var="per" itemLabel="#{i18n[per.i18nKey]}" />
</h:selectManyCheckbox>
<!-- <ui:repeat id="permDescs" var="perm" value="#{bapp.permissions}"> -->
<!-- <div>#{perm.name} / #{perm.description}</div> -->
<!-- </ui:repeat> -->
</h:column>
<!-- <h:column> -->
<!-- <ui:repeat id="permissions" var="perm" value="#{bapp.permissions}"> -->
<!-- <div> -->
<!-- <h:selectBooleanCheckbox value="#{perm.canHas}" /> -->
<!-- </div> -->
<!-- </ui:repeat> -->
<!-- </h:column> -->
</h:dataTable>
<h:commandButton id="save2" value="#{i18n['role.savePermissions']}" action="#{roleView.savePermissions}" />
......
......@@ -86,9 +86,12 @@ error.error = You have encountered an error.
eventorg.create = Create
game.create = Create
game.edit = Edit
game.out = Gamecodes are out, pleace contact administration
game.active = Aktiivinen
game.codecount = Avattuja
game.create = Create
game.edit = Edit
game.out = Gamecodes are out, pleace contact administration
game.product = Tuote
generic.sure.header = Confirmation
generic.sure.message = Are you sure?
......@@ -162,4 +165,6 @@ resetmailSent.header = Email sent
subnavi.cards = \u0009\u0009
topnavi.license = Lisenssikoodit
user.unauthenticated = Kirjautumaton
......@@ -277,7 +277,9 @@ foodwavetemplate.selectproducts = Products
foodwavetemplate.startTime = Foodwave time
foodwavetemplate.waveName = Wave name
game.active = Active
game.code = Code
game.codecount = Opened
game.create = Create
game.description = Description
game.edit = Edit
......@@ -286,6 +288,7 @@ game.name = Name
game.noGameCodes = You have no gamecodes
game.open = Open code
game.out = Please contact out customer service
game.product = Product
game.service = Game service
gamepoints = Gamepoints
......@@ -782,6 +785,7 @@ topnavi.event = Event
topnavi.foodwave = Food
topnavi.frontpage = Front page
topnavi.game = Gamecodes
topnavi.license = Licensecodes
topnavi.log = Log
topnavi.maps = Maps
topnavi.placemap = Map
......
......@@ -277,7 +277,9 @@ foodwavetemplate.selectproducts = Tuotteet
foodwavetemplate.startTime = Tilausaika
foodwavetemplate.waveName = Tilauksen nimi
game.active = Aktiivinen
game.code = Koodi
game.codecount = Avattuja
game.create = Luo
game.description = Kuvaus
game.edit = Muokkaa
......@@ -286,6 +288,7 @@ game.name = Nimi
game.noGameCodes = Sinulla ei ole pelikoodeja
game.open = Ota koodi k\u00E4ytt\u00F6\u00F6n
game.out = Ei voitu avata pelikoodia, ota yhteytt\u00E4 asiakaspalveluun.
game.product = Tuote
game.service = Pelipalvelu
gamepoints = Pelipisteit\u00E4
......@@ -767,6 +770,7 @@ topnavi.event = Tapahtuma
topnavi.foodwave = Ruokatilaus
topnavi.frontpage = Etusivu
topnavi.game = Pelikoodit
topnavi.license = Lisenssikoodit
topnavi.log = Logi
topnavi.maps = Kartat
topnavi.placemap = Paikkakartta
......
package fi.codecrew.moya.web.cdiview.game;
package fi.codecrew.moya.web.cdiview.license;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.model.ListDataModel;
import javax.inject.Inject;
import javax.inject.Named;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.GameBeanLocal;
import fi.codecrew.moya.enums.apps.BillPermission;
import fi.codecrew.moya.enums.apps.GamePermission;
import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.beans.LicenseBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.enums.apps.LicensePermission;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Game;
import fi.codecrew.moya.model.GameCode;
import fi.codecrew.moya.model.LicenseCode;
import fi.codecrew.moya.model.LicenseTarget;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.web.annotations.SelectedUser;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class GameCodeView extends GenericCDIView {
public class LicenseView extends GenericCDIView {
private static final long serialVersionUID = -8346420143750551402L;
......@@ -33,92 +33,93 @@ public class GameCodeView extends GenericCDIView {
EventBeanLocal eventBean;
@EJB
GameBeanLocal gameBean;
LicenseBeanLocal licenseBean;
@EJB
ProductBeanLocal productBean;
ListDataModel<Game> gamesDataModel;
ListDataModel<GameCode> gameCodesDataModel;
private ListDataModel<LicenseTarget> licenses;
private ListDataModel<LicenseCode> licenseCodes;
private Game currentGame;
private LicenseTarget currentLicense;
public void initAdminView() {
if (super.requirePermissions(GamePermission.MANAGE)) {
if (gamesDataModel == null) {
this.currentGame = new Game();
this.currentGame.setEvent(eventBean.getCurrentEvent());
this.gamesDataModel = new ListDataModel<Game>(gameBean.findAll(eventBean.getCurrentEvent()));
if (super.requirePermissions(LicensePermission.MANAGE)) {
if (licenses == null) {
this.currentLicense = new LicenseTarget();
this.currentLicense.setEvent(eventBean.getCurrentEvent());
this.licenses = new ListDataModel<LicenseTarget>(licenseBean.findAll(eventBean.getCurrentEvent()));
this.beginConversation();
}
}
}
public void initUserView() {
if (super.requirePermissions(GamePermission.VIEW_OWN_CODES)) {
if (gamesDataModel == null) {
this.gameCodesDataModel = new ListDataModel<GameCode>(gameBean.findUserCodes(user));
System.out.println("codecount: " + gameCodesDataModel.getRowCount());
if (super.requirePermissions(LicensePermission.VIEW_OWN_CODES)) {
if (licenses == null) {
this.licenseCodes = new ListDataModel<LicenseCode>(licenseBean.findUserCodes(user));
this.beginConversation();
}
}
}
public ListDataModel<Game> getGames() {
return gamesDataModel;
}
public ListDataModel<GameCode> getGameCodes() {
return gameCodesDataModel;
public String saveCurrentLicense() {
licenseBean.saveOrCreateLicense(currentLicense);
return null;
}
public Game getCurrentGame() {
return this.currentGame;
}
public void setCurrentGame(Game game) {
this.currentGame = game;
}
public String saveCurrentGame() {
gameBean.saveOrCreateGame(currentGame);
public String editSelected() {
return null;
}
public String generateSelectedToAllPlaces() {
if (gamesDataModel != null && gamesDataModel.isRowAvailable()) {
Game game = gamesDataModel.getRowData();
public String openSelectedCode() {
/*if (gameCodesDataModel != null && gameCodesDataModel.isRowAvailable()) {
LicenseCode code = gameCodesDataModel.getRowData();
gameBean.generateCodesForAllPlaces(game);
if (!licenseBean.accessCode(code, user)) {
this.addFaceMessage("game.out");
}
}
return null;
*/
return "todo";
}
public String editSelected() {
/*if (gamesDataModel != null && gamesDataModel.isRowAvailable()) {
currentGame = gamesDataModel.getRowData();
public boolean isNoGameCodes() {
//return (getGameCodes().getRowCount() <= 0);
return false;
}
}*/
public ListDataModel<LicenseCode> getLicenseCodes() {
return licenseCodes;
}
return null;
public void setLicenseCodes(ListDataModel<LicenseCode> licenseCodes) {
this.licenseCodes = licenseCodes;
}
public String openSelectedCode() {
if (gameCodesDataModel != null && gameCodesDataModel.isRowAvailable()) {
GameCode code = gameCodesDataModel.getRowData();
public ListDataModel<LicenseTarget> getLicenses() {
return licenses;
}
if (!gameBean.accessCode(code, user)) {
this.addFaceMessage("game.out");
}
}
public void setLicenses(ListDataModel<LicenseTarget> licenses) {
this.licenses = licenses;
}
return null;
public LicenseTarget getCurrentLicense() {
return currentLicense;
}
public boolean isNoGameCodes() {
return (getGameCodes().getRowCount() <= 0);
public void setCurrentLicense(LicenseTarget currentLicense) {
this.currentLicense = currentLicense;
}
public List<Product> getProductsForLicenses() {
return productBean.findPlaceProducts();
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!