Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 645a13c0
authored
May 10, 2013
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lisensecodes
1 parent
5d83d6a4
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
154 additions
and
119 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/LicenseBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/UserFacade.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/LicenseBeanLocal.java
code/MoyaDatabase/src/fi/codecrew/moya/model/LicenseCode.java
code/MoyaDatabase/src/fi/codecrew/moya/model/LicenseTarget.java
code/MoyaDatabase/src/fi/codecrew/moya/model/User.java
code/MoyaUtilities/src/fi/codecrew/moya/utilities/jpa/GenericFacade.java
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/license/LicenseView.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/LicenseBean.java
View file @
645a13c
...
@@ -12,15 +12,18 @@ import java.util.List;
...
@@ -12,15 +12,18 @@ import java.util.List;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.ejb.Stateless
;
import
javax.ejb.Stateless
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.facade.LicenseCodeFacade
;
import
fi.codecrew.moya.facade.LicenseCodeFacade
;
import
fi.codecrew.moya.facade.LicenseTargetFacade
;
import
fi.codecrew.moya.facade.LicenseTargetFacade
;
import
fi.codecrew.moya.
model.EventMap
;
import
fi.codecrew.moya.
facade.UserFacade
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.LicenseTarget
;
import
fi.codecrew.moya.model.LicenseCode
;
import
fi.codecrew.moya.model.GroupMembership
;
import
fi.codecrew.moya.model.GroupMembership
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.Place
;
import
fi.codecrew.moya.model.LicenseCode
;
import
fi.codecrew.moya.model.LicenseTarget
;
import
fi.codecrew.moya.model.User
;
/**
/**
* Session Bean implementation class GameBean
* Session Bean implementation class GameBean
...
@@ -29,10 +32,13 @@ import fi.codecrew.moya.model.Place;
...
@@ -29,10 +32,13 @@ import fi.codecrew.moya.model.Place;
public
class
LicenseBean
implements
LicenseBeanLocal
{
public
class
LicenseBean
implements
LicenseBeanLocal
{
@EJB
@EJB
LicenseCodeFacade
gam
eCodeFacade
;
LicenseCodeFacade
licens
eCodeFacade
;
@EJB
@EJB
LicenseTargetFacade
gameFacade
;
UserFacade
userFacade
;
@EJB
LicenseTargetFacade
licenseTargetFacade
;
@EJB
@EJB
...
@@ -41,30 +47,22 @@ public class LicenseBean implements LicenseBeanLocal {
...
@@ -41,30 +47,22 @@ public class LicenseBean implements LicenseBeanLocal {
@EJB
@EJB
PlaceBeanLocal
placeBean
;
PlaceBeanLocal
placeBean
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
LicenseBean
.
class
);
public
List
<
LicenseCode
>
findUserCodes
(
EventUser
user
)
{
ArrayList
<
LicenseCode
>
returnCodes
=
new
ArrayList
<
LicenseCode
>();
for
(
LicenseCode
userGameCode
:
user
.
getUser
().
getGameCodes
())
{
returnCodes
.
add
(
userGameCode
);
}
return
returnCodes
;
}
/**
/**
* Check, and if needed generate code for gamecode.
* Check, and if needed generate code for gamecode.
*
*
* @param code
* @param code
*/
*/
private
boolean
generateCode
(
LicenseCode
code
)
{
private
LicenseCode
generateCode
(
LicenseCode
code
)
throws
GenerationException
{
if
(
code
.
getCode
()
==
null
||
code
.
getCode
().
trim
().
equals
(
""
))
{
if
(
code
.
getCode
()
==
null
||
code
.
getCode
().
trim
().
equals
(
""
))
{
if
(
code
.
getGame
().
getCodeUrl
()
==
null
||
code
.
getGame
().
getCodeUrl
().
trim
().
equals
(
""
))
if
(
code
.
getLicenseTarget
().
getCodeUrl
()
==
null
||
code
.
getLicenseTarget
().
getCodeUrl
().
trim
().
equals
(
""
))
{
return
false
;
throw
new
GenerationException
(
"Code generate failed"
);
}
try
{
try
{
URL
url
=
new
URL
(
code
.
get
Game
().
getCodeUrl
());
URL
url
=
new
URL
(
code
.
get
LicenseTarget
().
getCodeUrl
());
URLConnection
uc
;
URLConnection
uc
;
...
@@ -82,55 +80,50 @@ public class LicenseBean implements LicenseBeanLocal {
...
@@ -82,55 +80,50 @@ public class LicenseBean implements LicenseBeanLocal {
}
}
if
(
codeString
.
trim
().
equals
(
"0"
)
||
codeString
.
trim
().
equals
(
""
))
{
if
(
codeString
.
trim
().
equals
(
"0"
)
||
codeString
.
trim
().
equals
(
""
))
{
return
false
;
throw
new
GenerationException
(
"Code generate failed"
)
;
}
}
code
.
setCode
(
codeString
);
code
.
setCode
(
codeString
);
code
=
gam
eCodeFacade
.
merge
(
code
);
code
=
licens
eCodeFacade
.
merge
(
code
);
return
tru
e
;
return
cod
e
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
logger
.
warn
(
"Code generate failed"
,
e
);
e
.
printStackTrace
(
);
throw
new
GenerationException
(
"Code generate failed"
);
}
}
}
}
return
false
;
throw
new
RuntimeException
(
"LOL, what?"
)
;
}
}
public
boolean
accessCode
(
LicenseCode
code
,
EventUser
user
)
{
public
LicenseCode
accessCode
(
LicenseCode
code
)
throws
GenerationException
{
if
(
code
.
getUser
()
!=
null
)
return
false
;
if
(!
generateCode
(
code
))
{
code
=
generateCode
(
code
);
return
false
;
}
if
(!
code
.
isAccessed
())
{
if
(!
code
.
isAccessed
())
{
code
.
setAccessed
(
Calendar
.
getInstance
());
code
.
setAccessed
(
Calendar
.
getInstance
());
code
.
setUser
(
user
.
getUser
());
code
=
gameCodeFacade
.
merge
(
code
);
code
=
licenseCodeFacade
.
merge
(
code
);
user
.
getUser
().
getGameCodes
().
add
(
code
);
}
}
return
tru
e
;
return
cod
e
;
}
}
public
List
<
LicenseTarget
>
findAll
(
LanEvent
event
)
{
public
List
<
LicenseTarget
>
findAll
(
LanEvent
event
)
{
return
event
.
getGames
();
return
event
.
getGames
();
}
}
public
void
saveOrCreateLicense
(
LicenseTarget
game
)
{
public
void
saveOrCreateLicense
(
LicenseTarget
target
)
{
if
(
game
.
getId
()
==
null
)
{
if
(
target
.
getId
()
==
null
)
{
game
.
setEvent
(
eventBean
.
getCurrentEvent
());
target
.
setEvent
(
eventBean
.
getCurrentEvent
());
eventBean
.
getCurrentEvent
().
getGames
().
add
(
game
);
eventBean
.
getCurrentEvent
().
getGames
().
add
(
target
);
gameFacade
.
create
(
game
);
licenseTargetFacade
.
create
(
target
);
game
=
gameFacade
.
merge
(
game
);
target
=
licenseTargetFacade
.
merge
(
target
);
}
}
else
{
else
{
game
=
gameFacade
.
merge
(
game
);
target
=
licenseTargetFacade
.
merge
(
target
);
}
}
}
}
...
@@ -146,17 +139,19 @@ public class LicenseBean implements LicenseBeanLocal {
...
@@ -146,17 +139,19 @@ public class LicenseBean implements LicenseBeanLocal {
ArrayList
<
LicenseTarget
>
returnLicenses
=
new
ArrayList
<
LicenseTarget
>();
ArrayList
<
LicenseTarget
>
returnLicenses
=
new
ArrayList
<
LicenseTarget
>();
if
(
user
.
get
CurrentPlace
s
()
!=
null
)
{
if
(
user
.
get
GroupMembership
s
()
!=
null
)
{
for
(
GroupMembership
memberShip
:
user
.
getGroupMemberships
())
{
for
(
GroupMembership
memberShip
:
user
.
getGroupMemberships
())
{
if
(
memberShip
.
getPlaceReservation
()
==
null
)
if
(
memberShip
.
getPlaceReservation
()
==
null
)
continue
;
continue
;
for
(
LicenseTarget
license
:
memberShip
.
getPlaceReservation
().
getProduct
().
getLicenseTargets
())
{
for
(
LicenseTarget
license
:
memberShip
.
getPlaceReservation
().
getProduct
().
getLicenseTargets
())
{
if
(
license
.
isActive
())
if
(
license
.
isActive
())
{
returnLicenses
.
add
(
license
);
returnLicenses
.
add
(
license
);
}
}
}
}
}
}
}
return
returnLicenses
;
return
returnLicenses
;
}
}
...
@@ -167,11 +162,42 @@ public class LicenseBean implements LicenseBeanLocal {
...
@@ -167,11 +162,42 @@ public class LicenseBean implements LicenseBeanLocal {
List
<
LicenseTarget
>
returnLicenses
=
findUserGames
(
user
);
List
<
LicenseTarget
>
returnLicenses
=
findUserGames
(
user
);
for
(
LicenseCode
code
:
findUserCodes
(
user
))
{
for
(
LicenseCode
code
:
user
.
getUser
().
getLicenseCodes
(
))
{
returnLicenses
.
remove
(
code
);
returnLicenses
.
remove
(
code
.
getLicenseTarget
()
);
}
}
return
returnLicenses
;
return
returnLicenses
;
}
}
@Override
public
LicenseCode
createAndAccessCode
(
LicenseTarget
target
,
User
user
)
throws
GenerationException
{
user
=
userFacade
.
reload
(
user
);
LicenseCode
code
=
new
LicenseCode
(
target
);
user
.
getLicenseCodes
().
add
(
code
);
code
.
setUser
(
user
);
licenseCodeFacade
.
create
(
code
);
code
=
accessCode
(
code
);
return
code
;
}
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/UserFacade.java
View file @
645a13c
...
@@ -88,9 +88,9 @@ public class UserFacade extends IntegerPkGenericFacade<User> {
...
@@ -88,9 +88,9 @@ public class UserFacade extends IntegerPkGenericFacade<User> {
// }
// }
@Override
@Override
public
void
create
(
User
user
)
{
public
User
create
(
User
user
)
{
user
.
setLogin
(
user
.
getLogin
().
toLowerCase
().
trim
());
user
.
setLogin
(
user
.
getLogin
().
toLowerCase
().
trim
());
super
.
create
(
user
);
return
super
.
create
(
user
);
}
}
@Override
@Override
...
...
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/LicenseBeanLocal.java
View file @
645a13c
...
@@ -2,22 +2,39 @@ package fi.codecrew.moya.beans;
...
@@ -2,22 +2,39 @@ package fi.codecrew.moya.beans;
import
java.util.List
;
import
java.util.List
;
import
javax.ejb.ApplicationException
;
import
javax.ejb.Local
;
import
javax.ejb.Local
;
import
fi.codecrew.moya.model.EventUser
;
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.LanEvent
;
import
fi.codecrew.moya.model.Place
;
import
fi.codecrew.moya.model.LicenseCode
;
import
fi.codecrew.moya.model.LicenseTarget
;
import
fi.codecrew.moya.model.User
;
@Local
@Local
public
interface
LicenseBeanLocal
{
public
interface
LicenseBeanLocal
{
public
boolean
accessCode
(
LicenseCode
code
,
EventUser
user
)
;
public
LicenseCode
accessCode
(
LicenseCode
code
)
throws
GenerationException
;
public
List
<
LicenseTarget
>
findAll
(
LanEvent
event
);
public
List
<
LicenseTarget
>
findAll
(
LanEvent
event
);
public
void
saveOrCreateLicense
(
LicenseTarget
game
);
public
void
saveOrCreateLicense
(
LicenseTarget
game
);
public
List
<
LicenseCode
>
findUserCodes
(
EventUser
user
);
public
List
<
LicenseTarget
>
findUserGames
(
EventUser
user
);
public
List
<
LicenseTarget
>
findUserGames
(
EventUser
user
);
public
List
<
LicenseTarget
>
findUnopenedUserGames
(
EventUser
user
);
public
List
<
LicenseTarget
>
findUnopenedUserGames
(
EventUser
user
);
public
LicenseCode
createAndAccessCode
(
LicenseTarget
target
,
User
user
)
throws
GenerationException
;
@ApplicationException
(
rollback
=
true
)
public
static
class
GenerationException
extends
Exception
{
public
GenerationException
()
{
super
();
}
public
GenerationException
(
String
message
)
{
super
(
message
);
}
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
}
}
}
\ No newline at end of file
code/MoyaDatabase/src/fi/codecrew/moya/model/LicenseCode.java
View file @
645a13c
...
@@ -36,16 +36,12 @@ public class LicenseCode extends GenericEntity {
...
@@ -36,16 +36,12 @@ public class LicenseCode extends GenericEntity {
@JoinColumn
(
name
=
"game_id"
,
referencedColumnName
=
"id"
)
@JoinColumn
(
name
=
"game_id"
,
referencedColumnName
=
"id"
)
@ManyToOne
@ManyToOne
private
LicenseTarget
game
;
private
LicenseTarget
licenseTarget
;
@JoinColumn
(
name
=
"user_id"
,
referencedColumnName
=
"id"
)
@JoinColumn
(
name
=
"user_id"
,
referencedColumnName
=
"id"
)
@ManyToOne
@ManyToOne
private
User
user
;
private
User
user
;
@JoinColumn
(
name
=
"place_id"
,
referencedColumnName
=
"id"
)
@ManyToOne
private
Place
place
;
public
LicenseCode
()
{
public
LicenseCode
()
{
...
@@ -53,10 +49,9 @@ public class LicenseCode extends GenericEntity {
...
@@ -53,10 +49,9 @@ public class LicenseCode extends GenericEntity {
}
}
public
LicenseCode
(
Place
place
,
LicenseTarget
game
)
{
public
LicenseCode
(
LicenseTarget
target
)
{
this
();
this
();
this
.
place
=
place
;
this
.
licenseTarget
=
target
;
this
.
game
=
game
;
}
}
...
@@ -80,46 +75,25 @@ public class LicenseCode extends GenericEntity {
...
@@ -80,46 +75,25 @@ public class LicenseCode extends GenericEntity {
return
code
;
return
code
;
}
}
public
void
setCode
(
String
code
)
{
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
this
.
code
=
code
;
}
}
public
LicenseTarget
getGame
()
{
return
game
;
}
public
void
setGame
(
LicenseTarget
game
)
{
this
.
game
=
game
;
}
public
User
getUser
()
{
public
User
getUser
()
{
return
user
;
return
user
;
}
}
public
void
setUser
(
User
user
)
{
public
void
setUser
(
User
user
)
{
this
.
user
=
user
;
this
.
user
=
user
;
}
}
public
LicenseTarget
getLicenseTarget
()
{
return
licenseTarget
;
public
Place
getPlace
()
{
return
place
;
}
}
public
void
setLicenseTarget
(
LicenseTarget
licenseTarget
)
{
public
void
setPlace
(
Place
place
)
{
this
.
licenseTarget
=
licenseTarget
;
this
.
place
=
place
;
}
}
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/LicenseTarget.java
View file @
645a13c
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
*/
*/
package
fi
.
codecrew
.
moya
.
model
;
package
fi
.
codecrew
.
moya
.
model
;
import
java.util.Calendar
;
import
java.util.List
;
import
java.util.List
;
import
javax.persistence.Column
;
import
javax.persistence.Column
;
...
@@ -15,8 +14,6 @@ import javax.persistence.ManyToOne;
...
@@ -15,8 +14,6 @@ import javax.persistence.ManyToOne;
import
javax.persistence.OneToMany
;
import
javax.persistence.OneToMany
;
import
javax.persistence.OrderBy
;
import
javax.persistence.OrderBy
;
import
javax.persistence.Table
;
import
javax.persistence.Table
;
import
javax.persistence.Temporal
;
import
javax.persistence.TemporalType
;
import
org.eclipse.persistence.annotations.OptimisticLocking
;
import
org.eclipse.persistence.annotations.OptimisticLocking
;
import
org.eclipse.persistence.annotations.OptimisticLockingType
;
import
org.eclipse.persistence.annotations.OptimisticLockingType
;
...
@@ -52,7 +49,7 @@ public class LicenseTarget extends GenericEntity {
...
@@ -52,7 +49,7 @@ public class LicenseTarget extends GenericEntity {
@ManyToOne
@ManyToOne
private
LanEvent
event
;
private
LanEvent
event
;
@OneToMany
(
mappedBy
=
"
game
"
,
fetch
=
FetchType
.
LAZY
)
@OneToMany
(
mappedBy
=
"
licenseTarget
"
,
fetch
=
FetchType
.
LAZY
)
@OrderBy
()
@OrderBy
()
private
List
<
LicenseCode
>
licenseCodes
;
private
List
<
LicenseCode
>
licenseCodes
;
...
...
code/MoyaDatabase/src/fi/codecrew/moya/model/User.java
View file @
645a13c
...
@@ -113,7 +113,7 @@ public class User extends GenericEntity implements IUser {
...
@@ -113,7 +113,7 @@ public class User extends GenericEntity implements IUser {
@OneToMany
(
mappedBy
=
"user"
,
fetch
=
FetchType
.
LAZY
)
@OneToMany
(
mappedBy
=
"user"
,
fetch
=
FetchType
.
LAZY
)
@OrderBy
()
@OrderBy
()
private
List
<
LicenseCode
>
gam
eCodes
;
private
List
<
LicenseCode
>
licens
eCodes
;
@Transient
@Transient
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
User
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
User
.
class
);
...
@@ -361,15 +361,15 @@ public class User extends GenericEntity implements IUser {
...
@@ -361,15 +361,15 @@ public class User extends GenericEntity implements IUser {
}
}
public
List
<
LicenseCode
>
get
Gam
eCodes
()
{
public
List
<
LicenseCode
>
get
Licens
eCodes
()
{
if
(
gam
eCodes
==
null
)
if
(
licens
eCodes
==
null
)
gam
eCodes
=
new
ArrayList
<
LicenseCode
>();
licens
eCodes
=
new
ArrayList
<
LicenseCode
>();
return
gam
eCodes
;
return
licens
eCodes
;
}
}
public
void
set
GameCodes
(
List
<
LicenseCode
>
gameC
odes
)
{
public
void
set
LicenseCodes
(
List
<
LicenseCode
>
c
odes
)
{
this
.
gameCodes
=
gameC
odes
;
this
.
licenseCodes
=
c
odes
;
}
}
}
}
code/MoyaUtilities/src/fi/codecrew/moya/utilities/jpa/GenericFacade.java
View file @
645a13c
...
@@ -38,8 +38,10 @@ public abstract class GenericFacade<C extends ModelInterface> {
...
@@ -38,8 +38,10 @@ public abstract class GenericFacade<C extends ModelInterface> {
protected
abstract
EntityManager
getEm
();
protected
abstract
EntityManager
getEm
();
public
void
create
(
C
entity
)
{
public
C
create
(
C
entity
)
{
getEm
().
persist
(
entity
);
getEm
().
persist
(
entity
);
return
entity
;
}
}
public
void
remove
(
C
entity
)
{
public
void
remove
(
C
entity
)
{
...
...
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n.properties
View file @
645a13c
...
@@ -88,6 +88,8 @@ eventorg.create = Create
...
@@ -88,6 +88,8 @@ eventorg.create = Create
game.active
=
Aktiivinen
game.active
=
Aktiivinen
game.codecount
=
Avattuja
game.codecount
=
Avattuja
game.codes.available
=
Lisenssikoodit
game.codes.opened
=
Avatut lisenssikoodit
game.create
=
Create
game.create
=
Create
game.edit
=
Edit
game.edit
=
Edit
game.out
=
Gamecodes are out, pleace contact administration
game.out
=
Gamecodes are out, pleace contact administration
...
...
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n_en.properties
View file @
645a13c
...
@@ -280,12 +280,14 @@ foodwavetemplate.waveName = Wave name
...
@@ -280,12 +280,14 @@ foodwavetemplate.waveName = Wave name
game.active
=
Active
game.active
=
Active
game.code
=
Code
game.code
=
Code
game.codecount
=
Opened
game.codecount
=
Opened
game.codes.available
=
Licensecodes
game.codes.opened
=
Opened licensecodes
game.create
=
Create
game.create
=
Create
game.description
=
Description
game.description
=
Description
game.edit
=
Edit
game.edit
=
Edit
game.gamepoints
=
Game points
game.gamepoints
=
Game points
game.name
=
Name
game.name
=
Name
game.noGameCodes
=
You have no
gamecodes
game.noGameCodes
=
You have no opened
gamecodes
game.open
=
Open code
game.open
=
Open code
game.out
=
Please contact out customer service
game.out
=
Please contact out customer service
game.product
=
Product
game.product
=
Product
...
...
code/MoyaWeb/src/fi/codecrew/moya/resources/i18n_fi.properties
View file @
645a13c
...
@@ -280,12 +280,14 @@ foodwavetemplate.waveName = Tilauksen nimi
...
@@ -280,12 +280,14 @@ foodwavetemplate.waveName = Tilauksen nimi
game.active
=
Aktiivinen
game.active
=
Aktiivinen
game.code
=
Koodi
game.code
=
Koodi
game.codecount
=
Avattuja
game.codecount
=
Avattuja
game.codes.available
=
Lisenssikoodit
game.codes.opened
=
Avatut lisenssikoodit
game.create
=
Luo
game.create
=
Luo
game.description
=
Kuvaus
game.description
=
Kuvaus
game.edit
=
Muokkaa
game.edit
=
Muokkaa
game.gamepoints
=
Insomnia Game pisteet:
game.gamepoints
=
Insomnia Game pisteet:
game.name
=
Nimi
game.name
=
Nimi
game.noGameCodes
=
Sinulla ei ole pelikoodeja
game.noGameCodes
=
Sinulla ei ole avattuja pelikoodeja.
game.open
=
Ota koodi k
\u
00E4ytt
\u
00F6
\u
00F6n
game.open
=
Ota koodi k
\u
00E4ytt
\u
00F6
\u
00F6n
game.out
=
Ei voitu avata pelikoodia, ota yhteytt
\u
00E4 asiakaspalveluun.
game.out
=
Ei voitu avata pelikoodia, ota yhteytt
\u
00E4 asiakaspalveluun.
game.product
=
Tuote
game.product
=
Tuote
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/license/LicenseView.java
View file @
645a13c
...
@@ -5,18 +5,18 @@ import java.util.List;
...
@@ -5,18 +5,18 @@ import java.util.List;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.faces.model.ListDataModel
;
import
javax.faces.model.ListDataModel
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.LicenseBeanLocal
;
import
fi.codecrew.moya.beans.LicenseBeanLocal
;
import
fi.codecrew.moya.beans.LicenseBeanLocal.GenerationException
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.ProductBeanLocal
;
import
fi.codecrew.moya.beans.ProductBeanLocal
;
import
fi.codecrew.moya.enums.apps.LicensePermission
;
import
fi.codecrew.moya.enums.apps.LicensePermission
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.LicenseCode
;
import
fi.codecrew.moya.model.LicenseCode
;
import
fi.codecrew.moya.model.LicenseTarget
;
import
fi.codecrew.moya.model.LicenseTarget
;
import
fi.codecrew.moya.model.Product
;
import
fi.codecrew.moya.model.Product
;
import
fi.codecrew.moya.web.annotations.SelectedUser
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
@Named
@Named
...
@@ -25,18 +25,19 @@ public class LicenseView extends GenericCDIView {
...
@@ -25,18 +25,19 @@ public class LicenseView extends GenericCDIView {
private
static
final
long
serialVersionUID
=
-
8346420143750551402L
;
private
static
final
long
serialVersionUID
=
-
8346420143750551402L
;
@Inject
private
EventUser
currentUser
;
@SelectedUser
private
EventUser
user
;
@EJB
@EJB
EventBeanLocal
event
Bean
;
private
PermissionBeanLocal
permission
Bean
;
@EJB
@EJB
LicenseBeanLocal
license
Bean
;
private
EventBeanLocal
event
Bean
;
@EJB
@EJB
ProductBeanLocal
productBean
;
private
LicenseBeanLocal
licenseBean
;
@EJB
private
ProductBeanLocal
productBean
;
private
ListDataModel
<
LicenseTarget
>
licenses
;
private
ListDataModel
<
LicenseTarget
>
licenses
;
private
ListDataModel
<
LicenseCode
>
licenseCodes
;
private
ListDataModel
<
LicenseCode
>
licenseCodes
;
...
@@ -57,8 +58,10 @@ public class LicenseView extends GenericCDIView {
...
@@ -57,8 +58,10 @@ public class LicenseView extends GenericCDIView {
public
void
initUserView
()
{
public
void
initUserView
()
{
if
(
super
.
requirePermissions
(
LicensePermission
.
VIEW_OWN_CODES
))
{
if
(
super
.
requirePermissions
(
LicensePermission
.
VIEW_OWN_CODES
))
{
if
(
licenses
==
null
)
{
if
(
licenseCodes
==
null
)
{
this
.
licenseCodes
=
new
ListDataModel
<
LicenseCode
>(
licenseBean
.
findUserCodes
(
user
));
currentUser
=
permissionBean
.
getCurrentUser
();
this
.
licenseCodes
=
new
ListDataModel
<
LicenseCode
>(
currentUser
.
getUser
().
getLicenseCodes
());
this
.
licenses
=
new
ListDataModel
<
LicenseTarget
>(
licenseBean
.
findUnopenedUserGames
(
currentUser
));
this
.
beginConversation
();
this
.
beginConversation
();
}
}
}
}
...
@@ -66,6 +69,7 @@ public class LicenseView extends GenericCDIView {
...
@@ -66,6 +69,7 @@ public class LicenseView extends GenericCDIView {
public
String
saveCurrentLicense
()
{
public
String
saveCurrentLicense
()
{
licenseBean
.
saveOrCreateLicense
(
currentLicense
);
licenseBean
.
saveOrCreateLicense
(
currentLicense
);
this
.
licenses
=
new
ListDataModel
<
LicenseTarget
>(
licenseBean
.
findAll
(
eventBean
.
getCurrentEvent
()));
return
null
;
return
null
;
}
}
...
@@ -75,20 +79,28 @@ public class LicenseView extends GenericCDIView {
...
@@ -75,20 +79,28 @@ public class LicenseView extends GenericCDIView {
}
}
public
String
openSelectedCode
()
{
public
String
openSelectedCode
()
{
/*if (gameCodesDataModel != null && gameCodesDataModel.isRowAvailable()) {
LicenseCode code = gameCodesDataModel.getRowData();
if (!licenseBean.accessCode(code, user)) {
if
(
this
.
licenses
!=
null
&&
this
.
licenses
.
isRowAvailable
())
{
LicenseTarget
license
=
this
.
licenses
.
getRowData
();
try
{
LicenseCode
code
=
licenseBean
.
createAndAccessCode
(
license
,
currentUser
.
getUser
());
}
catch
(
GenerationException
x
)
{
this
.
addFaceMessage
(
"game.out"
);
this
.
addFaceMessage
(
"game.out"
);
}
}
licenseCodes
=
null
;
initUserView
();
}
}
*/
return
null
;
return
"todo"
;
}
}
public
boolean
isNoGameCodes
()
{
public
boolean
isNoLicenseCodes
()
{
//return (getGameCodes().getRowCount() <= 0);
return
(
getLicenseCodes
().
getRowCount
()
<=
0
);
return
false
;
}
public
boolean
isNoLicenses
()
{
return
(
getLicenses
().
getRowCount
()
<=
0
);
}
}
public
ListDataModel
<
LicenseCode
>
getLicenseCodes
()
{
public
ListDataModel
<
LicenseCode
>
getLicenseCodes
()
{
...
...
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