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 c3aff761
authored
Apr 14, 2013
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gameCodes' into devel
2 parents
10307592
86aba504
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
845 additions
and
50 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/GameBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PermissionBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/UserBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/GameCodeFacade.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/GameFacade.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/GameBeanLocal.java
code/MoyaDatabase/src/fi/codecrew/moya/model/AccountEvent.java
code/MoyaDatabase/src/fi/codecrew/moya/model/EventUser.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/MoyaDatabase/src/fi/codecrew/moya/model/LanEvent.java
code/MoyaDatabase/src/fi/codecrew/moya/model/Place.java
code/MoyaDatabase/src/fi/codecrew/moya/model/User.java
code/MoyaUtilities/src/fi/codecrew/moya/enums/BortalApplication.java
code/MoyaUtilities/src/fi/codecrew/moya/enums/apps/GamePermission.java
code/MoyaUtilities/src/fi/codecrew/moya/utilities/jpa/GenericFacade.java
code/MoyaWeb/WebContent/gamecode/manageCodes.xhtml
code/MoyaWeb/WebContent/gamecode/viewCodes.xhtml
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 @
c3aff76
package
fi
.
codecrew
.
moya
.
beans
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.ejb.Stateless
;
import
fi.codecrew.moya.facade.NewsGroupFacade
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.GameBeanLocal
;
import
fi.codecrew.moya.facade.GameCodeFacade
;
import
fi.codecrew.moya.facade.GameFacade
;
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
;
/**
* Session Bean implementation class GameBean
...
...
@@ -14,10 +29,133 @@ import fi.codecrew.moya.beans.GameBeanLocal;
public
class
GameBean
implements
GameBeanLocal
{
@EJB
private
EventBeanLocal
eventbean
;
GameCodeFacade
gameCodeFacade
;
@EJB
private
NewsGroupFacade
ngfacade
;
GameFacade
gameFacade
;
@EJB
EventBeanLocal
eventBean
;
@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
);
}
}
}
}
for
(
GameCode
userGameCode
:
user
.
getUser
().
getGameCodes
())
{
returnCodes
.
add
(
userGameCode
);
}
return
returnCodes
;
}
/**
* Check, and if needed generate code for gamecode.
*
* @param 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
false
;
try
{
URL
url
=
new
URL
(
code
.
getGame
().
getCodeUrl
());
URLConnection
uc
;
uc
=
url
.
openConnection
();
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
uc
.
getInputStream
()));
String
codeString
=
""
;
String
tmpLine
;
while
((
tmpLine
=
in
.
readLine
())
!=
null
)
{
if
(!
codeString
.
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
boolean
accessCode
(
GameCode
code
,
EventUser
user
)
{
if
(
code
.
getUser
()
!=
null
)
return
false
;
if
(!
generateCode
(
code
))
{
return
false
;
}
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
)
{
return
event
.
getGames
();
}
public
void
saveOrCreateGame
(
Game
game
)
{
if
(
game
.
getId
()
==
null
)
{
game
.
setEvent
(
eventBean
.
getCurrentEvent
());
eventBean
.
getCurrentEvent
().
getGames
().
add
(
game
);
gameFacade
.
create
(
game
);
game
=
gameFacade
.
merge
(
game
);
}
else
{
game
=
gameFacade
.
merge
(
game
);
}
}
/**
* Default constructor.
...
...
@@ -26,4 +164,23 @@ public class GameBean implements GameBeanLocal {
// TODO Auto-generated constructor stub
}
@Override
public
void
generateCodesForAllPlaces
(
Game
game
)
{
if
(
game
==
null
)
return
;
LanEvent
currentEvent
=
eventBean
.
getCurrentEvent
();
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
);
}
}
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
View file @
c3aff76
...
...
@@ -14,6 +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.MapPermission
;
import
fi.codecrew.moya.enums.apps.PollPermission
;
import
fi.codecrew.moya.enums.apps.ShopPermission
;
...
...
@@ -259,6 +260,7 @@ public class MenuBean implements MenuBeanLocal {
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/accountEvents"
),
UserPermission
.
VIEW_SELF
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/place/myGroups"
),
UserPermission
.
VIEW_SELF
);
userTopnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/sendPicture"
),
UserPermission
.
VIEW_SELF
);
MenuNavigation
placemapTopmenu
=
usernavi
.
addPage
(
null
,
null
);
placemapTopmenu
.
setKey
(
"topnavi.placemap"
);
...
...
@@ -291,6 +293,11 @@ public class MenuBean implements MenuBeanLocal {
// ShopPermission.SHOP_FOODWAVE);
foodwaveTopmenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/foodwave/listProducts"
),
ShopPermission
.
SHOP_FOODWAVE
).
setVisible
(
false
);
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
);
MenuNavigation
pollTopmenu
=
usernavi
.
addPage
(
null
,
null
);
pollTopmenu
.
setKey
(
"topnavi.poll"
);
...
...
@@ -379,6 +386,9 @@ public class MenuBean implements MenuBeanLocal {
foodnavi
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/foodadmin/createTemplate"
),
ShopPermission
.
MANAGE_FOODWAVES
);
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
);
}
@Override
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/PermissionBean.java
View file @
c3aff76
...
...
@@ -17,6 +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.IAppPermission
;
import
fi.codecrew.moya.enums.apps.MapPermission
;
import
fi.codecrew.moya.enums.apps.PollPermission
;
...
...
@@ -91,7 +92,9 @@ import fi.codecrew.moya.model.User;
EventPermission
.
S_MANAGE_PRIVATE_PROPERTIES
,
EventPermission
.
S_MANAGE_PROPERTIES
,
GamePermission
.
S_MANAGE
,
GamePermission
.
S_VIEW_OWN_CODES
})
@LocalBean
public
class
PermissionBean
implements
PermissionBeanLocal
{
...
...
@@ -113,11 +116,6 @@ public class PermissionBean implements PermissionBeanLocal {
@EJB
private
EventBeanLocal
eventbean
;
//
// @Override
// public boolean hasPermission(String perm) {
// return context.isCallerInRole(perm);
// }
@Override
public
boolean
hasPermission
(
IAppPermission
perm
)
{
...
...
@@ -130,36 +128,7 @@ public class PermissionBean implements PermissionBeanLocal {
}
// @Override
// public boolean fatalPermission(IAppPermission permission, Object...
// failmessage) {
// boolean ret = hasPermission(permission);
// if (!ret) {
// StringBuilder message = new
// StringBuilder().append(" permission: ").append(permission);
// if (failmessage == null || failmessage.length == 0) {
// message.append(" MSG: SessionHandler mbean permission exception: Permission: ")
// .append(permission);
// } else {
// for (Object part : failmessage) {
// message.append(part == null ? "NULL" : part.toString());
// }
// }
// // throw new SecurityException("Foobar");
//
// throw new PermissionDeniedException(loggingbean, getCurrentUser(),
// message.toString());
// }
// return true;
// }
//
// @Override
// public void fatalNotLoggedIn() throws PermissionDeniedException {
// if (!isLoggedIn()) {
// throw new PermissionDeniedException(loggingbean, getCurrentUser(),
// "User is not logged in!");
// }
// }
@Override
public
boolean
isCurrentUser
(
User
user
)
{
...
...
@@ -178,8 +147,6 @@ public class PermissionBean implements PermissionBeanLocal {
// logger.info("Checking principal {} against anon: {}", principal,
// ret);
return
ret
;
// return !getAnonEventUser().equals(getCurrentUser()) ||
// getCurrentUser().getUser().isSuperadmin();
}
@Override
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/UserBean.java
View file @
c3aff76
...
...
@@ -272,7 +272,6 @@ public class UserBean implements UserBeanLocal {
public
void
createNewUser
(
EventUser
user
,
String
password
)
{
user
.
getUser
().
resetPassword
(
password
);
// todo add barcode
user
.
setEvent
(
eventBean
.
getCurrentEvent
());
// Tallennetaan olio kantaan...
eventUserFacade
.
create
(
user
);
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/GameCodeFacade.java
0 → 100644
View file @
c3aff76
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
));
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/GameFacade.java
0 → 100644
View file @
c3aff76
package
fi
.
codecrew
.
moya
.
facade
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
fi.codecrew.moya.model.Game
;
@Stateless
@LocalBean
public
class
GameFacade
extends
IntegerPkGenericFacade
<
Game
>
{
public
GameFacade
()
{
super
(
Game
.
class
);
}
}
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/GameBeanLocal.java
View file @
c3aff76
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
);
}
code/MoyaDatabase/src/fi/codecrew/moya/model/AccountEvent.java
View file @
c3aff76
...
...
@@ -61,7 +61,7 @@ public class AccountEvent extends GenericEntity {
private
Calendar
delivered
;
@Column
(
name
=
"delivered_count"
,
nullable
=
false
,
precision
=
24
,
scale
=
4
)
private
BigDecimal
deliveredCount
;
private
BigDecimal
deliveredCount
=
new
BigDecimal
(
0
)
;
/**
* If this AccountEvent is a product in foodwace, this field is a reference
...
...
code/MoyaDatabase/src/fi/codecrew/moya/model/EventUser.java
View file @
c3aff76
...
...
@@ -104,6 +104,9 @@ public class EventUser extends GenericEntity {
@Temporal
(
TemporalType
.
TIMESTAMP
)
@Column
(
name
=
"createtime"
,
nullable
=
false
,
updatable
=
false
)
private
Date
eventuserCreated
;
public
EventUser
getCreator
()
{
return
creator
;
...
...
@@ -443,4 +446,5 @@ public class EventUser extends GenericEntity {
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/Game.java
0 → 100644
View file @
c3aff76
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package
fi
.
codecrew
.
moya
.
model
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.Table
;
import
org.eclipse.persistence.annotations.OptimisticLocking
;
import
org.eclipse.persistence.annotations.OptimisticLockingType
;
/**
*
*/
@Entity
@Table
(
name
=
"games"
)
@OptimisticLocking
(
type
=
OptimisticLockingType
.
CHANGED_COLUMNS
)
public
class
Game
extends
GenericEntity
{
private
static
final
long
serialVersionUID
=
1L
;
@Column
(
name
=
"name"
)
private
String
name
;
@Column
(
name
=
"service"
)
private
String
service
;
@Column
(
name
=
"description"
)
private
String
description
;
@Column
(
name
=
"code_url"
)
private
String
codeUrl
;
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"id"
)
@ManyToOne
private
LanEvent
event
;
public
Game
()
{
super
();
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
String
getCodeUrl
()
{
return
codeUrl
;
}
public
void
setCodeUrl
(
String
codeUrl
)
{
this
.
codeUrl
=
codeUrl
;
}
public
LanEvent
getEvent
()
{
return
event
;
}
public
void
setEvent
(
LanEvent
event
)
{
this
.
event
=
event
;
}
public
String
getService
()
{
return
service
;
}
public
void
setService
(
String
service
)
{
this
.
service
=
service
;
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/GameCode.java
0 → 100644
View file @
c3aff76
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package
fi
.
codecrew
.
moya
.
model
;
import
java.util.Calendar
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.Table
;
import
javax.persistence.Temporal
;
import
javax.persistence.TemporalType
;
import
org.eclipse.persistence.annotations.OptimisticLocking
;
import
org.eclipse.persistence.annotations.OptimisticLockingType
;
/**
*
*/
@Entity
@Table
(
name
=
"gamecodes"
)
@OptimisticLocking
(
type
=
OptimisticLockingType
.
CHANGED_COLUMNS
)
public
class
GameCode
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
;
@JoinColumn
(
name
=
"user_id"
,
referencedColumnName
=
"id"
)
@ManyToOne
private
User
user
;
@JoinColumn
(
name
=
"place_id"
,
referencedColumnName
=
"id"
)
@ManyToOne
private
Place
place
;
public
GameCode
()
{
super
();
}
public
GameCode
(
Place
place
,
Game
game
)
{
this
();
this
.
place
=
place
;
this
.
game
=
game
;
}
public
boolean
isAccessed
()
{
return
(
accessed
!=
null
);
}
public
Calendar
getAccessed
()
{
return
accessed
;
}
public
void
setAccessed
(
Calendar
accessed
)
{
this
.
accessed
=
accessed
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
Game
getGame
()
{
return
game
;
}
public
void
setGame
(
Game
game
)
{
this
.
game
=
game
;
}
public
User
getUser
()
{
return
user
;
}
public
void
setUser
(
User
user
)
{
this
.
user
=
user
;
}
public
Place
getPlace
()
{
return
place
;
}
public
void
setPlace
(
Place
place
)
{
this
.
place
=
place
;
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/GroupMembership.java
View file @
c3aff76
...
...
@@ -58,6 +58,7 @@ public class GroupMembership extends GenericEntity {
private
Place
placeReservation
;
@JoinColumn
(
name
=
EVENTUSER_ID
,
referencedColumnName
=
EventUser
.
ID_COLUMN
)
@ManyToOne
private
EventUser
user
;
...
...
code/MoyaDatabase/src/fi/codecrew/moya/model/LanEvent.java
View file @
c3aff76
...
...
@@ -73,6 +73,9 @@ public class LanEvent extends GenericEntity {
@OneToMany
(
cascade
=
CascadeType
.
ALL
,
mappedBy
=
"event"
)
private
List
<
Compo
>
compos
;
@OneToMany
(
cascade
=
CascadeType
.
ALL
,
mappedBy
=
"event"
)
private
List
<
Game
>
games
;
@OneToMany
(
mappedBy
=
"event"
,
cascade
=
CascadeType
.
ALL
)
private
List
<
CardTemplate
>
cardTemplates
;
...
...
@@ -281,4 +284,14 @@ public class LanEvent extends GenericEntity {
this
.
properties
=
properties
;
}
public
List
<
Game
>
getGames
()
{
if
(
games
==
null
)
games
=
new
ArrayList
<
Game
>();
return
games
;
}
public
void
setGames
(
List
<
Game
>
games
)
{
this
.
games
=
games
;
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/Place.java
View file @
c3aff76
package
fi
.
codecrew
.
moya
.
model
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.List
;
import
javax.persistence.CascadeType
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.FetchType
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.Lob
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.OneToMany
;
import
javax.persistence.OneToOne
;
import
javax.persistence.OrderBy
;
import
javax.persistence.Table
;
import
javax.persistence.Temporal
;
import
javax.persistence.TemporalType
;
...
...
@@ -86,6 +91,11 @@ 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
();
...
...
@@ -278,4 +288,17 @@ 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
;
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/User.java
View file @
c3aff76
package
fi
.
codecrew
.
moya
.
model
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -9,6 +10,7 @@ import javax.persistence.Column;
import
javax.persistence.Entity
;
import
javax.persistence.EnumType
;
import
javax.persistence.Enumerated
;
import
javax.persistence.FetchType
;
import
javax.persistence.JoinColumn
;
import
javax.persistence.OneToMany
;
import
javax.persistence.OneToOne
;
...
...
@@ -108,6 +110,10 @@ public class User extends GenericEntity implements IUser {
@OrderBy
@PrivateOwned
private
List
<
UserImage
>
userImageList
;
@OneToMany
(
mappedBy
=
"user"
,
fetch
=
FetchType
.
LAZY
)
@OrderBy
()
private
List
<
GameCode
>
gameCodes
;
@Transient
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
User
.
class
);
...
...
@@ -353,5 +359,17 @@ public class User extends GenericEntity implements IUser {
}
return
isAnon
;
}
public
List
<
GameCode
>
getGameCodes
()
{
if
(
gameCodes
==
null
)
gameCodes
=
new
ArrayList
<
GameCode
>();
return
gameCodes
;
}
public
void
setGameCodes
(
List
<
GameCode
>
gameCodes
)
{
this
.
gameCodes
=
gameCodes
;
}
}
code/MoyaUtilities/src/fi/codecrew/moya/enums/BortalApplication.java
View file @
c3aff76
...
...
@@ -4,6 +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.IAppPermission
;
import
fi.codecrew.moya.enums.apps.MapPermission
;
import
fi.codecrew.moya.enums.apps.PollPermission
;
...
...
@@ -23,6 +24,7 @@ public enum BortalApplication {
SALESPOINT
(
SalespointPermission
.
class
),
COMPO
(
CompoPermission
.
class
),
EVENT
(
EventPermission
.
class
),
GAME
(
GamePermission
.
class
),
;
...
...
code/MoyaUtilities/src/fi/codecrew/moya/enums/apps/GamePermission.java
0 → 100644
View file @
c3aff76
package
fi
.
codecrew
.
moya
.
enums
.
apps
;
import
fi.codecrew.moya.enums.BortalApplication
;
public
enum
GamePermission
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"
;
private
final
String
fullName
;
private
final
String
key
;
private
static
final
String
I18N_HEADER
=
"bortalApplication.game."
;
private
GamePermission
()
{
fullName
=
new
StringBuilder
().
append
(
getParent
().
toString
()).
append
(
DELIMITER
).
append
(
toString
()).
toString
();
key
=
I18N_HEADER
+
name
();
}
@Override
public
BortalApplication
getParent
()
{
return
BortalApplication
.
GAME
;
}
@Override
public
String
getFullName
()
{
return
fullName
;
}
@Override
public
String
getI18nKey
()
{
return
key
;
}
}
code/MoyaUtilities/src/fi/codecrew/moya/utilities/jpa/GenericFacade.java
View file @
c3aff76
...
...
@@ -52,8 +52,8 @@ public abstract class GenericFacade<C extends ModelInterface> {
}
public
void
refresh
(
C
usr
)
{
getEm
().
refresh
(
usr
);
public
void
refresh
(
C
entity
)
{
getEm
().
refresh
(
entity
);
}
public
C
find
(
Integer
id
)
{
...
...
code/MoyaWeb/WebContent/gamecode/manageCodes.xhtml
0 → 100644
View file @
c3aff76
<!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>
<h:commandButton
value=
"muokkaa"
action=
"#{gameCodeView.editSelected}"
/>
</p:column>
<p:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"GENEROI"
/>
</f:facet>
<h:commandButton
value=
"generoi kaikille paikoille"
action=
"#{gameCodeView.generateSelectedToAllPlaces}"
/>
</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"
/>
<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}"
/>
<h:commandButton
action=
"#{gameCodeView.saveCurrentGame}"
value=
"save"
/>
</p:panelGrid>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/MoyaWeb/WebContent/gamecode/viewCodes.xhtml
0 → 100644
View file @
c3aff76
<!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['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}"
/>
</p:column>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n_en.properties
View file @
c3aff76
...
...
@@ -276,7 +276,13 @@ foodwavetemplate.selectproducts = Products
foodwavetemplate.startTime
=
Foodwave time
foodwavetemplate.waveName
=
Wave name
game.gamepoints
=
Game points
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
...
...
@@ -771,6 +777,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 @
c3aff76
...
...
@@ -276,7 +276,13 @@ foodwavetemplate.selectproducts = Tuotteet
foodwavetemplate.startTime
=
Tilausaika
foodwavetemplate.waveName
=
Tilauksen nimi
game.gamepoints
=
Insomnia Game pisteet:
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
...
...
@@ -756,6 +762,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
0 → 100644
View file @
c3aff76
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
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.GameBeanLocal
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.Game
;
import
fi.codecrew.moya.model.GameCode
;
import
fi.codecrew.moya.web.annotations.SelectedUser
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
@Named
@ConversationScoped
public
class
GameCodeView
extends
GenericCDIView
{
private
static
final
long
serialVersionUID
=
-
8346420143750551402L
;
@Inject
@SelectedUser
private
EventUser
user
;
@EJB
EventBeanLocal
eventBean
;
@EJB
GameBeanLocal
gameBean
;
ListDataModel
<
Game
>
gamesDataModel
;
ListDataModel
<
GameCode
>
gameCodesDataModel
;
private
Game
currentGame
;
public
void
initAdminView
()
{
if
(
gamesDataModel
==
null
)
{
this
.
currentGame
=
new
Game
();
this
.
currentGame
.
setEvent
(
eventBean
.
getCurrentEvent
());
this
.
gamesDataModel
=
new
ListDataModel
<
Game
>(
gameBean
.
findAll
(
eventBean
.
getCurrentEvent
()));
this
.
beginConversation
();
}
}
public
void
initUserView
()
{
if
(
gamesDataModel
==
null
)
{
this
.
gameCodesDataModel
=
new
ListDataModel
<
GameCode
>(
gameBean
.
findUserCodes
(
user
));
System
.
out
.
println
(
"codecount: "
+
gameCodesDataModel
.
getRowCount
());
this
.
beginConversation
();
}
}
public
ListDataModel
<
Game
>
getGames
()
{
return
gamesDataModel
;
}
public
ListDataModel
<
GameCode
>
getGameCodes
()
{
return
gameCodesDataModel
;
}
public
Game
getCurrentGame
()
{
return
this
.
currentGame
;
}
public
String
saveCurrentGame
()
{
gameBean
.
saveOrCreateGame
(
currentGame
);
return
null
;
}
public
String
generateSelectedToAllPlaces
()
{
if
(
gamesDataModel
!=
null
&&
gamesDataModel
.
isRowAvailable
())
{
Game
game
=
gamesDataModel
.
getRowData
();
gameBean
.
generateCodesForAllPlaces
(
game
);
}
return
null
;
}
public
String
editSelected
()
{
if
(
gamesDataModel
!=
null
&&
gamesDataModel
.
isRowAvailable
())
{
currentGame
=
gamesDataModel
.
getRowData
();
}
return
null
;
}
public
String
openSelectedCode
()
{
if
(
gameCodesDataModel
!=
null
&&
gameCodesDataModel
.
isRowAvailable
())
{
GameCode
code
=
gameCodesDataModel
.
getRowData
();
if
(!
gameBean
.
accessCode
(
code
,
user
))
{
this
.
addFaceMessage
(
"gamecode.out"
);
}
}
return
null
;
}
public
boolean
isNoGameCodes
()
{
return
(
getGameCodes
().
getRowCount
()
<=
0
);
}
}
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