Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 86aba504
authored
Apr 14, 2013
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GameCodes
1 parent
5b2d2f0c
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
104 additions
and
36 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/GameBean.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/GameBeanLocal.java
code/MoyaDatabase/src/fi/codecrew/moya/model/Game.java
code/MoyaDatabase/src/fi/codecrew/moya/model/GameCode.java
code/MoyaDatabase/src/fi/codecrew/moya/model/GroupMembership.java
code/MoyaWeb/WebContent/gamecode/manageCodes.xhtml
code/MoyaWeb/WebContent/gamecode/viewCodes.xhtml
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n.properties
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n_en.properties
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n_fi.properties
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/game/GameCodeView.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/GameBean.java
View file @
86aba50
...
...
@@ -18,6 +18,7 @@ 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.GroupMembership
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.Place
;
...
...
@@ -55,8 +56,11 @@ public class GameBean implements GameBeanLocal {
// first get free gamecodes from user places
if
(
user
.
getCurrentPlaces
()
!=
null
)
{
for
(
Place
place
:
user
.
getCurrentPlaces
())
{
for
(
GameCode
placeGameCode
:
place
.
getGameCodes
())
{
for
(
GroupMembership
memberShip
:
user
.
getGroupMemberships
())
{
if
(
memberShip
.
getPlaceReservation
()
==
null
)
continue
;
for
(
GameCode
placeGameCode
:
memberShip
.
getPlaceReservation
().
getGameCodes
())
{
if
(
placeGameCode
.
getUser
()
==
null
)
{
returnCodes
.
add
(
placeGameCode
);
}
...
...
@@ -76,11 +80,11 @@ public class GameBean implements GameBeanLocal {
*
* @param code
*/
private
void
generateCode
(
GameCode
code
)
{
private
boolean
generateCode
(
GameCode
code
)
{
if
(
code
.
getCode
()
==
null
||
code
.
getCode
().
trim
().
equals
(
""
))
{
if
(
code
.
getGame
().
getCodeUrl
()
==
null
||
code
.
getGame
().
getCodeUrl
().
trim
().
equals
(
""
))
return
;
return
false
;
try
{
URL
url
=
new
URL
(
code
.
getGame
().
getCodeUrl
());
...
...
@@ -94,35 +98,47 @@ public class GameBean implements GameBeanLocal {
String
tmpLine
;
while
((
tmpLine
=
in
.
readLine
())
!=
null
)
{
if
(!
code
.
equals
(
""
))
{
if
(!
code
String
.
equals
(
""
))
{
codeString
+=
"\n"
;
}
codeString
+=
tmpLine
;
}
if
(
codeString
.
trim
().
equals
(
"0"
)
||
codeString
.
trim
().
equals
(
""
))
{
return
false
;
}
code
.
setCode
(
codeString
);
code
=
gameCodeFacade
.
merge
(
code
);
return
true
;
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
return
false
;
}
public
void
accessCode
(
GameCode
code
,
EventUser
user
)
{
public
boolean
accessCode
(
GameCode
code
,
EventUser
user
)
{
if
(
code
.
getUser
()
!=
null
)
return
;
return
false
;
if
(!
generateCode
(
code
))
{
return
false
;
}
generateCode
(
code
);
if
(!
code
.
isAccessed
())
{
code
.
setAccessed
(
Calendar
.
getInstance
());
code
.
setUser
(
user
.
getUser
());
code
=
gameCodeFacade
.
merge
(
code
);
user
.
getUser
().
getGameCodes
().
add
(
code
);
}
return
true
;
}
public
List
<
Game
>
findAll
(
LanEvent
event
)
{
...
...
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/GameBeanLocal.java
View file @
86aba50
...
...
@@ -13,7 +13,7 @@ import fi.codecrew.moya.model.Place;
@Local
public
interface
GameBeanLocal
{
public
GameCode
getCode
(
Place
place
);
public
void
accessCode
(
GameCode
code
,
EventUser
user
);
public
boolean
accessCode
(
GameCode
code
,
EventUser
user
);
public
List
<
Game
>
findAll
(
LanEvent
event
);
public
void
saveOrCreateGame
(
Game
game
);
public
List
<
GameCode
>
findUserCodes
(
EventUser
user
);
...
...
code/MoyaDatabase/src/fi/codecrew/moya/model/Game.java
View file @
86aba50
...
...
@@ -28,6 +28,9 @@ public class Game extends GenericEntity {
@Column
(
name
=
"name"
)
private
String
name
;
@Column
(
name
=
"service"
)
private
String
service
;
@Column
(
name
=
"description"
)
private
String
description
;
...
...
@@ -104,4 +107,18 @@ public class Game extends GenericEntity {
}
public
String
getService
()
{
return
service
;
}
public
void
setService
(
String
service
)
{
this
.
service
=
service
;
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/GameCode.java
View file @
86aba50
...
...
@@ -30,9 +30,9 @@ public class GameCode extends GenericEntity {
@Column
(
name
=
"accessed"
,
nullable
=
fals
e
)
@Column
(
name
=
"accessed"
,
nullable
=
tru
e
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Calendar
accessed
=
Calendar
.
getInstance
()
;
private
Calendar
accessed
=
null
;
...
...
code/MoyaDatabase/src/fi/codecrew/moya/model/GroupMembership.java
View file @
86aba50
...
...
@@ -59,6 +59,7 @@ public class GroupMembership extends GenericEntity {
private
Place
placeReservation
;
@JoinColumn
(
name
=
EVENTUSER_ID
,
referencedColumnName
=
EventUser
.
ID_COLUMN
)
@ManyToOne
private
EventUser
user
;
...
...
code/MoyaWeb/WebContent/gamecode/manageCodes.xhtml
View file @
86aba50
<!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"
>
<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>
...
...
@@ -13,38 +13,46 @@
<ui:define
name=
"content"
>
<h:form>
<h
:dataTable
border=
"1"
id=
"games"
value=
"#{gameCodeView.games}"
var=
"game"
>
<h
:column>
<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}"
/>
</h
:column>
<h
:column>
</p
:column>
<p
:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"edit"
/>
</f:facet>
<h:commandButton
value=
"muokkaa"
action=
"#{gameCodeView.editSelected}"
/>
</h
:column>
<h
:column>
</p
:column>
<p
:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"GENEROI"
/>
</f:facet>
<h:commandButton
value=
"generoi kaikille paikoille"
action=
"#{gameCodeView.generateSelectedToAllPlaces}"
/>
HOX: ei vielä valmis, älä paina, oikeasti!
</h:column>
</h:dataTable>
</p:column>
</p:dataTable>
</h:form>
<br
/><br
/>
<h:form>
<p:panelGrid
columns=
"2"
>
<f:facet
name=
"header"
>
<h:outputLabel
rendered=
"#{gameCodeView.currentGame.id == null}"
value=
"#{i18n['gamecode.create']}"
/>
<h:outputLabel
rendered=
"#{gameCodeView.currentGame.id != null}"
value=
"#{i18n['gamecode.edit']}"
/>
</f:facet>
<h:outputLabel
value=
"service"
/>
<p:inputText
value=
"#{gameCodeView.currentGame.service}"
/>
<h:outputLabel
value=
"name"
/>
<h
:inputText
value=
"#{gameCodeView.currentGame.name}"
/>
<p
:inputText
value=
"#{gameCodeView.currentGame.name}"
/>
<h:outputLabel
value=
"description"
/>
<h
:inputText
value=
"#{gameCodeView.currentGame.description}"
/>
<p
:inputText
value=
"#{gameCodeView.currentGame.description}"
/>
<h:outputLabel
value=
"url"
/>
<h
:inputText
value=
"#{gameCodeView.currentGame.codeUrl}"
/>
<p
:inputText
value=
"#{gameCodeView.currentGame.codeUrl}"
/>
<h:commandButton
action=
"#{gameCodeView.saveCurrentGame}"
value=
"save"
/>
</p:panelGrid>
</h:form>
</ui:define>
</ui:composition>
...
...
code/MoyaWeb/WebContent/gamecode/viewCodes.xhtml
View file @
86aba50
<!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"
>
<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"
/>
...
...
@@ -17,27 +17,34 @@
<h:outputLabel
rendered=
"#{gameCodeView.noGameCodes}"
value=
"#{i18n['game.noGameCodes']}"
/>
<h:dataTable
rendered=
"#{not gameCodeView.noGameCodes}"
border=
"1"
id=
"codes"
value=
"#{gameCodeView.gameCodes}"
var=
"code"
>
<h:column>
<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}"
/>
</
h
:column>
<
h:column
>
</
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}"
/>
</
h
:column>
<
h:column
>
</
p
:column>
<
p:column
sortBy=
"#{code.code}"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"#{i18n['gamecode.code']}"
/>
</f:facet>
<h:outputText
rendered=
"#{not code.accessed}"
value=
"ei avattu"
/>
<h:commandButton
rendered=
"#{not code.accessed}"
value=
"#{i18n['gamecode.open']}"
action=
"#{gameCodeView.openSelectedCode}"
/>
<h:outputText
rendered=
"#{code.accessed}"
value=
"#{code.code}"
/>
</
h
:column>
</
h
:dataTable>
</
p
:column>
</
p
:dataTable>
</h:form>
</ui:define>
...
...
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n.properties
View file @
86aba50
...
...
@@ -136,6 +136,6 @@ resetMail.username = Username
resetmailSent.body
=
Email has been sent containing a link where you can change the password.
resetmailSent.header
=
Email sent
subnavi.cards
=
\
t\t
subnavi.cards
=
\
u0009\u0009
user.unauthenticated
=
Kirjautumaton
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n_en.properties
View file @
86aba50
...
...
@@ -270,7 +270,13 @@ foodwavetemplate.selectproducts = Products
foodwavetemplate.startTime
=
Foodwave time
foodwavetemplate.waveName
=
Wave name
game.code
=
Code
game.description
=
Description
game.gamepoints
=
Game points
game.name
=
Name
game.noGameCodes
=
You have no gamecodes
game.open
=
Open code
game.service
=
Game service
gamepoints
=
Gamepoints
...
...
@@ -759,6 +765,7 @@ topnavi.createuser = Create user
topnavi.event
=
Event
topnavi.foodwave
=
Food
topnavi.frontpage
=
Front page
topnavi.game
=
Gamecodes
topnavi.log
=
Log
topnavi.maps
=
Maps
topnavi.placemap
=
Map
...
...
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n_fi.properties
View file @
86aba50
...
...
@@ -270,7 +270,13 @@ foodwavetemplate.selectproducts = Tuotteet
foodwavetemplate.startTime
=
Tilausaika
foodwavetemplate.waveName
=
Tilauksen nimi
game.code
=
Koodi
game.description
=
Kuvaus
game.gamepoints
=
Insomnia Game pisteet:
game.name
=
Nimi
game.noGameCodes
=
Sinulla ei ole pelikoodeja
game.open
=
Ota koodi k
\u
00E4ytt
\u
00F6
\u
00F6n
game.service
=
Pelipalvelu
gamepoints
=
Pelipisteit
\u
00E4
...
...
@@ -742,6 +748,7 @@ topnavi.createuser = Luo k\u00E4ytt\u00E4j\u00E4
topnavi.event
=
Tapahtuma
topnavi.foodwave
=
Ruokatilaus
topnavi.frontpage
=
Etusivu
topnavi.game
=
Pelikoodit
topnavi.log
=
Logi
topnavi.maps
=
Kartat
topnavi.placemap
=
Paikkakartta
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/game/GameCodeView.java
View file @
86aba50
...
...
@@ -2,6 +2,8 @@ package fi.codecrew.moya.web.cdiview.game;
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
;
...
...
@@ -50,6 +52,7 @@ public class GameCodeView extends GenericCDIView {
public
void
initUserView
()
{
if
(
gamesDataModel
==
null
)
{
this
.
gameCodesDataModel
=
new
ListDataModel
<
GameCode
>(
gameBean
.
findUserCodes
(
user
));
System
.
out
.
println
(
"codecount: "
+
gameCodesDataModel
.
getRowCount
());
this
.
beginConversation
();
}
}
...
...
@@ -97,7 +100,9 @@ public class GameCodeView extends GenericCDIView {
if
(
gameCodesDataModel
!=
null
&&
gameCodesDataModel
.
isRowAvailable
())
{
GameCode
code
=
gameCodesDataModel
.
getRowData
();
gameBean
.
accessCode
(
code
,
user
);
if
(!
gameBean
.
accessCode
(
code
,
user
))
{
this
.
addFaceMessage
(
"gamecode.out"
);
}
}
return
null
;
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment