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 d0d41fdf
authored
Oct 12, 2013
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Random changes
1 parent
05a25dbb
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
133 additions
and
147 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BarcodeBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/CardPrintBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/LicenseBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/UserBean.java
code/MoyaWeb/WebContent/resources/templates/template1/template.xhtml
code/MoyaWeb/src/fi/codecrew/moya/rest/PrinterRestView.java
code/MoyaWeb/src/fi/codecrew/moya/servlet/PlaceMap.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/GenericCDIView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/menu/MenuView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/menu/PrimeMenuView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/shop/ProductShopView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentParticipateView.java
code/MoyaWeb/src/fi/codecrew/moya/web/helper/LayoutView.java
code/MoyaWeb/src/fi/codecrew/moya/web/helpers/ProductShopItem.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BarcodeBean.java
View file @
d0d41fd
...
@@ -24,19 +24,19 @@ import fi.codecrew.moya.utilities.BarcodeUtils;
...
@@ -24,19 +24,19 @@ import fi.codecrew.moya.utilities.BarcodeUtils;
@LocalBean
@LocalBean
public
class
BarcodeBean
implements
BarcodeBeanLocal
{
public
class
BarcodeBean
implements
BarcodeBeanLocal
{
private
static
final
String
PRINTED_CARD_PREFIX
=
"277"
;
//2M
private
static
final
String
PRINTED_CARD_PREFIX
=
"277"
;
//2M
private
static
final
String
EVENTUSER_PREFIX
=
"279"
;
//2O
private
static
final
String
EVENTUSER_PREFIX
=
"279"
;
//2O
private
static
final
String
PLACE_PREFIX
=
"289"
;
//2Y
private
static
final
String
PLACE_PREFIX
=
"289"
;
//2Y
//private static final String NEXT_PREFIX = "265"; //2A
//private static final String NEXT_PREFIX = "265"; //2A
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
BarcodeBean
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
BarcodeBean
.
class
);
@EJB
@EJB
PrintedCardFacade
printedCardFacade
;
PrintedCardFacade
printedCardFacade
;
@EJB
@EJB
PlaceFacade
placeFacade
;
PlaceFacade
placeFacade
;
@EJB
@EJB
UserBeanLocal
userBean
;
UserBeanLocal
userBean
;
...
@@ -46,7 +46,7 @@ public class BarcodeBean implements BarcodeBeanLocal {
...
@@ -46,7 +46,7 @@ public class BarcodeBean implements BarcodeBeanLocal {
public
BarcodeBean
()
{
public
BarcodeBean
()
{
// TODO Auto-generated constructor stub
// TODO Auto-generated constructor stub
}
}
public
InputStream
getUserBarcode
(
EventUser
user
)
throws
IOException
{
public
InputStream
getUserBarcode
(
EventUser
user
)
throws
IOException
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
EVENTUSER_PREFIX
);
sb
.
append
(
EVENTUSER_PREFIX
);
...
@@ -58,7 +58,7 @@ public class BarcodeBean implements BarcodeBeanLocal {
...
@@ -58,7 +58,7 @@ public class BarcodeBean implements BarcodeBeanLocal {
sb
.
append
(
idStr
);
sb
.
append
(
idStr
);
String
barcode
=
sb
.
toString
();
String
barcode
=
sb
.
toString
();
logger
.
debug
(
"Geneating barcode for user {} : {}"
,
user
,
barcode
);
logger
.
debug
(
"Geneating barcode for user {} : {}"
,
user
,
barcode
);
return
BarcodeUtils
.
getBarcodeEAN
(
barcode
);
return
BarcodeUtils
.
getBarcodeEAN
(
barcode
);
}
}
...
@@ -73,10 +73,10 @@ public class BarcodeBean implements BarcodeBeanLocal {
...
@@ -73,10 +73,10 @@ public class BarcodeBean implements BarcodeBeanLocal {
sb
.
append
(
idStr
);
sb
.
append
(
idStr
);
String
barcode
=
sb
.
toString
();
String
barcode
=
sb
.
toString
();
logger
.
debug
(
"Geneating barcode for card {} : {}"
,
printedCard
,
barcode
);
logger
.
debug
(
"Geneating barcode for card {} : {}"
,
printedCard
,
barcode
);
return
BarcodeUtils
.
getBarcodeEAN
(
barcode
);
return
BarcodeUtils
.
getBarcodeEAN
(
barcode
);
}
}
public
String
getPlaceHexcode
(
Place
place
)
{
public
String
getPlaceHexcode
(
Place
place
)
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
PLACE_PREFIX
);
sb
.
append
(
PLACE_PREFIX
);
...
@@ -85,58 +85,58 @@ public class BarcodeBean implements BarcodeBeanLocal {
...
@@ -85,58 +85,58 @@ public class BarcodeBean implements BarcodeBeanLocal {
for
(
int
i
=
8
-
idStr
.
length
()
-
sb
.
length
();
i
>
0
;
--
i
)
{
for
(
int
i
=
8
-
idStr
.
length
()
-
sb
.
length
();
i
>
0
;
--
i
)
{
sb
.
append
(
"0"
);
sb
.
append
(
"0"
);
}
}
sb
.
append
(
idStr
);
sb
.
append
(
idStr
);
String
barcode
=
sb
.
toString
();
String
barcode
=
sb
.
toString
();
String
hexcode
=
Long
.
toHexString
(
Long
.
parseLong
(
barcode
));
String
hexcode
=
Long
.
toHexString
(
Long
.
parseLong
(
barcode
));
String
checksum
=
Integer
.
toHexString
(
hexcode
.
hashCode
());
String
checksum
=
Integer
.
toHexString
(
hexcode
.
hashCode
());
checksum
=
checksum
.
substring
(
checksum
.
length
()
-
3
);
checksum
=
checksum
.
substring
(
checksum
.
length
()
-
3
);
hexcode
+=
checksum
;
hexcode
+=
checksum
;
logger
.
debug
(
"Geneating hexcode for place {} : {}"
,
place
.
getId
(),
hexcode
);
logger
.
debug
(
"Geneating hexcode for place {} : {}"
,
place
.
getId
(),
hexcode
);
return
hexcode
;
return
hexcode
;
}
}
public
String
getVrAuthCodeForCard
(
PrintedCard
printedCard
)
{
public
String
getVrAuthCodeForCard
(
PrintedCard
printedCard
)
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
PRINTED_CARD_PREFIX
);
sb
.
append
(
PRINTED_CARD_PREFIX
);
if
(
printedCard
==
null
)
if
(
printedCard
==
null
)
return
""
;
return
""
;
String
idStr
=
printedCard
.
getId
().
toString
();
String
idStr
=
printedCard
.
getId
().
toString
();
for
(
int
i
=
8
-
idStr
.
length
()
-
sb
.
length
();
i
>
0
;
--
i
)
{
for
(
int
i
=
8
-
idStr
.
length
()
-
sb
.
length
();
i
>
0
;
--
i
)
{
sb
.
append
(
"0"
);
sb
.
append
(
"0"
);
}
}
sb
.
append
(
idStr
);
sb
.
append
(
idStr
);
String
code
=
sb
.
toString
();
String
code
=
sb
.
toString
();
String
hexcode
=
Integer
.
toHexString
(
Integer
.
parseInt
(
code
));
String
hexcode
=
Integer
.
toHexString
(
Integer
.
parseInt
(
code
));
String
checksum
=
Integer
.
toHexString
(
hexcode
.
hashCode
());
String
checksum
=
Integer
.
toHexString
(
hexcode
.
hashCode
());
checksum
=
checksum
.
substring
(
checksum
.
length
()
-
3
);
checksum
=
checksum
.
substring
(
checksum
.
length
()
-
3
);
hexcode
+=
checksum
;
hexcode
+=
checksum
;
//hexcode = Integer.toString(hexcode.hashCode());
//hexcode = Integer.toString(hexcode.hashCode());
logger
.
debug
(
"Geneating VrAuthcode for card {} : {}"
,
printedCard
.
getId
(),
hexcode
);
logger
.
debug
(
"Geneating VrAuthcode for card {} : {}"
,
printedCard
.
getId
(),
hexcode
);
return
hexcode
;
return
hexcode
;
}
}
public
String
checkVrAuthCode
(
String
code
)
{
public
String
checkVrAuthCode
(
String
code
)
{
String
checksumNew
=
code
.
substring
(
code
.
length
()
-
3
);
String
checksumNew
=
code
.
substring
(
code
.
length
()
-
3
);
code
=
code
.
substring
(
0
,
(
code
.
length
()
-
3
));
code
=
code
.
substring
(
0
,
(
code
.
length
()
-
3
));
String
checksumOld
=
Integer
.
toHexString
(
code
.
hashCode
());
String
checksumOld
=
Integer
.
toHexString
(
code
.
hashCode
());
checksumOld
=
checksumOld
.
substring
(
checksumOld
.
length
()
-
3
);
checksumOld
=
checksumOld
.
substring
(
checksumOld
.
length
()
-
3
);
if
(
checksumNew
==
checksumOld
)
{
if
(
checksumNew
.
equals
(
checksumOld
)
)
{
int
decimal
=
Integer
.
decode
(
code
);
int
decimal
=
Integer
.
decode
(
code
);
code
=
Integer
.
toString
(
decimal
);
code
=
Integer
.
toString
(
decimal
);
String
prefix
=
code
.
substring
(
0
,
2
);
String
prefix
=
code
.
substring
(
0
,
2
);
int
id
=
Integer
.
parseInt
(
code
.
substring
(
3
,
code
.
length
()
-
1
));
int
id
=
Integer
.
parseInt
(
code
.
substring
(
3
,
code
.
length
()
-
1
));
if
(
prefix
==
PRINTED_CARD_PREFIX
&&
id
!=
0
)
{
if
(
prefix
.
equals
(
PRINTED_CARD_PREFIX
)
&&
id
!=
0
)
{
PrintedCard
printedCard
=
printedCardFacade
.
find
(
id
);
PrintedCard
printedCard
=
printedCardFacade
.
find
(
id
);
if
(
printedCard
!=
null
)
if
(
printedCard
!=
null
)
return
printedCard
.
getUser
().
getNick
();
return
printedCard
.
getUser
().
getNick
();
else
else
return
"Invalid"
;
return
"Invalid"
;
...
@@ -146,73 +146,70 @@ public class BarcodeBean implements BarcodeBeanLocal {
...
@@ -146,73 +146,70 @@ public class BarcodeBean implements BarcodeBeanLocal {
}
}
return
"Invalid"
;
return
"Invalid"
;
}
}
@Override
@Override
public
Place
getPlaceFromHexcode
(
String
hexcode
)
{
public
Place
getPlaceFromHexcode
(
String
hexcode
)
{
String
barcode
=
""
+
Integer
.
parseInt
(
hexcode
,
16
);
String
barcode
=
""
+
Integer
.
parseInt
(
hexcode
,
16
);
try
{
try
{
if
(
barcode
.
startsWith
(
PLACE_PREFIX
))
{
if
(
barcode
.
startsWith
(
PLACE_PREFIX
))
{
int
id
=
Integer
.
parseInt
(
barcode
.
substring
(
3
,
barcode
.
length
()
-
1
));
int
id
=
Integer
.
parseInt
(
barcode
.
substring
(
3
,
barcode
.
length
()
-
1
));
Place
place
=
placeFacade
.
find
(
id
);
Place
place
=
placeFacade
.
find
(
id
);
return
place
;
return
place
;
}
}
}
catch
(
NumberFormatException
x
)
{
}
catch
(
NumberFormatException
x
)
{
}
}
return
null
;
return
null
;
}
}
public
PrintedCard
getPrintedCard
(
String
barcode
)
{
public
PrintedCard
getPrintedCard
(
String
barcode
)
{
if
(
barcode
==
null
||
barcode
.
isEmpty
())
if
(
barcode
==
null
||
barcode
.
isEmpty
())
return
null
;
return
null
;
// it's our special front barcode
// it's our special front barcode
try
{
try
{
if
(
barcode
.
startsWith
(
PRINTED_CARD_PREFIX
))
{
if
(
barcode
.
startsWith
(
PRINTED_CARD_PREFIX
))
{
int
id
=
Integer
.
parseInt
(
barcode
.
substring
(
3
,
barcode
.
length
()
-
1
));
int
id
=
Integer
.
parseInt
(
barcode
.
substring
(
3
,
barcode
.
length
()
-
1
));
PrintedCard
card
=
printedCardFacade
.
find
(
id
);
PrintedCard
card
=
printedCardFacade
.
find
(
id
);
if
(
card
!=
null
)
if
(
card
!=
null
)
return
card
;
return
card
;
}
}
}
catch
(
NumberFormatException
x
)
{
}
catch
(
NumberFormatException
x
)
{
}
}
return
printedCardFacade
.
findByBarcode
(
barcode
);
return
printedCardFacade
.
findByBarcode
(
barcode
);
}
}
public
EventUser
getUser
(
String
barcode
)
{
public
EventUser
getUser
(
String
barcode
)
{
if
(
barcode
==
null
||
barcode
.
isEmpty
())
if
(
barcode
==
null
||
barcode
.
isEmpty
())
return
null
;
return
null
;
// trim zeros off from barcode
// trim zeros off from barcode
String
stripped
=
barcode
;
String
stripped
=
barcode
;
while
(
stripped
.
length
()
>
0
&&
stripped
.
charAt
(
0
)
==
'0'
)
{
while
(
stripped
.
length
()
>
0
&&
stripped
.
charAt
(
0
)
==
'0'
)
{
stripped
=
stripped
.
substring
(
1
);
stripped
=
stripped
.
substring
(
1
);
}
}
if
(
stripped
.
length
()
>
0
)
barcode
=
stripped
;
if
(
stripped
.
length
()
>
0
)
barcode
=
stripped
;
try
{
try
{
// it's our special front barcode
// it's our special front barcode
if
(
barcode
.
startsWith
(
EVENTUSER_PREFIX
))
{
if
(
barcode
.
startsWith
(
EVENTUSER_PREFIX
))
{
int
id
=
Integer
.
parseInt
(
barcode
.
substring
(
3
,
barcode
.
length
()
-
1
));
int
id
=
Integer
.
parseInt
(
barcode
.
substring
(
3
,
barcode
.
length
()
-
1
));
logger
.
debug
(
"finding user with barcode {} and id {}"
,
barcode
,
id
);
logger
.
debug
(
"finding user with barcode {} and id {}"
,
barcode
,
id
);
EventUser
user
=
userBean
.
findByEventUserId
(
id
);
EventUser
user
=
userBean
.
findByEventUserId
(
id
);
return
user
;
return
user
;
}
}
}
catch
(
NumberFormatException
x
)
{
}
catch
(
NumberFormatException
x
)
{
}
}
return
null
;
return
null
;
}
}
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/CardPrintBean.java
View file @
d0d41fd
...
@@ -291,18 +291,17 @@ public class CardPrintBean implements CardPrintBeanLocal {
...
@@ -291,18 +291,17 @@ public class CardPrintBean implements CardPrintBeanLocal {
g
.
setFont
(
new
Font
(
"Century gothic"
,
Font
.
PLAIN
,
30
));
g
.
setFont
(
new
Font
(
"Century gothic"
,
Font
.
PLAIN
,
30
));
g
.
setColor
(
Color
.
white
);
g
.
setColor
(
Color
.
white
);
if
(
printedCard
!=
null
)
g
.
drawString
(
barcodeBean
.
getVrAuthCodeForCard
(
printedCard
),
445
,
905
);
BufferedImage
barCodeBufferedImage
=
ImageIO
.
read
(
barcodeBean
.
getCardBarcode
(
printedCard
))
;
BufferedImage
barCodeBufferedImage
=
null
;
//int barcodeX = (base.getWidth()/2) - (image.getWidth()/2);
if
(
printedCard
!=
null
)
{
int
barcodeX
=
(
base
.
getWidth
()
-
400
)
/
2
;
int
barcodeX
=
(
base
.
getWidth
()
-
400
)
/
2
;
int
barcodeY
=
base
.
getHeight
()
-
50
;
int
barcodeY
=
base
.
getHeight
()
-
50
;
if
(
printedCard
!=
null
)
g
.
drawString
(
barcodeBean
.
getVrAuthCodeForCard
(
printedCard
),
445
,
905
);
barCodeBufferedImage
=
ImageIO
.
read
(
barcodeBean
.
getCardBarcode
(
printedCard
));
g
.
drawImage
(
barCodeBufferedImage
,
barcodeX
,
barcodeY
,
400
,
barCodeBufferedImage
.
getHeight
(),
null
);
g
.
drawImage
(
barCodeBufferedImage
,
barcodeX
,
barcodeY
,
400
,
barCodeBufferedImage
.
getHeight
(),
null
);
g
.
setColor
(
Color
.
white
);
g
.
setColor
(
Color
.
white
);
}
g
.
fillRect
(
0
,
base
.
getHeight
()
-
20
,
base
.
getWidth
(),
base
.
getHeight
());
g
.
fillRect
(
0
,
base
.
getHeight
()
-
20
,
base
.
getWidth
(),
base
.
getHeight
());
g
.
dispose
();
g
.
dispose
();
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/LicenseBean.java
View file @
d0d41fd
...
@@ -30,25 +30,24 @@ import fi.codecrew.moya.model.User;
...
@@ -30,25 +30,24 @@ import fi.codecrew.moya.model.User;
*/
*/
@Stateless
@Stateless
public
class
LicenseBean
implements
LicenseBeanLocal
{
public
class
LicenseBean
implements
LicenseBeanLocal
{
@EJB
@EJB
LicenseCodeFacade
licenseCodeFacade
;
LicenseCodeFacade
licenseCodeFacade
;
@EJB
@EJB
UserFacade
userFacade
;
UserFacade
userFacade
;
@EJB
@EJB
LicenseTargetFacade
licenseTargetFacade
;
LicenseTargetFacade
licenseTargetFacade
;
@EJB
@EJB
EventBeanLocal
eventBean
;
EventBeanLocal
eventBean
;
@EJB
@EJB
PlaceBeanLocal
placeBean
;
PlaceBeanLocal
placeBean
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
LicenseBean
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
LicenseBean
.
class
);
/**
/**
* Check, and if needed generate code for gamecode.
* Check, and if needed generate code for gamecode.
*
*
...
@@ -78,15 +77,15 @@ public class LicenseBean implements LicenseBeanLocal {
...
@@ -78,15 +77,15 @@ public class LicenseBean implements LicenseBeanLocal {
}
}
codeString
+=
tmpLine
;
codeString
+=
tmpLine
;
}
}
if
(
codeString
.
trim
().
equals
(
"0"
)
||
codeString
.
trim
().
equals
(
""
))
{
if
(
codeString
.
trim
().
equals
(
"0"
)
||
codeString
.
trim
().
equals
(
""
))
{
throw
new
GenerationException
(
"Code generate failed"
);
throw
new
GenerationException
(
"Code generate failed"
);
}
}
code
.
setCode
(
codeString
);
code
.
setCode
(
codeString
);
code
=
licenseCodeFacade
.
merge
(
code
);
code
=
licenseCodeFacade
.
merge
(
code
);
return
code
;
return
code
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
@@ -98,16 +97,15 @@ public class LicenseBean implements LicenseBeanLocal {
...
@@ -98,16 +97,15 @@ public class LicenseBean implements LicenseBeanLocal {
}
}
public
LicenseCode
accessCode
(
LicenseCode
code
)
throws
GenerationException
{
public
LicenseCode
accessCode
(
LicenseCode
code
)
throws
GenerationException
{
code
=
generateCode
(
code
);
code
=
generateCode
(
code
);
if
(!
code
.
isAccessed
())
{
if
(!
code
.
isAccessed
())
{
code
.
setAccessed
(
Calendar
.
getInstance
());
code
.
setAccessed
(
Calendar
.
getInstance
());
code
=
licenseCodeFacade
.
merge
(
code
);
code
=
licenseCodeFacade
.
merge
(
code
);
}
}
return
code
;
return
code
;
}
}
...
@@ -120,7 +118,7 @@ public class LicenseBean implements LicenseBeanLocal {
...
@@ -120,7 +118,7 @@ public class LicenseBean implements LicenseBeanLocal {
target
.
setEvent
(
eventBean
.
getCurrentEvent
());
target
.
setEvent
(
eventBean
.
getCurrentEvent
());
eventBean
.
getCurrentEvent
().
getGames
().
add
(
target
);
eventBean
.
getCurrentEvent
().
getGames
().
add
(
target
);
licenseTargetFacade
.
create
(
target
);
licenseTargetFacade
.
create
(
target
);
target
=
licenseTargetFacade
.
merge
(
target
);
//
target = licenseTargetFacade.merge(target);
}
}
else
{
else
{
target
=
licenseTargetFacade
.
merge
(
target
);
target
=
licenseTargetFacade
.
merge
(
target
);
...
@@ -136,36 +134,35 @@ public class LicenseBean implements LicenseBeanLocal {
...
@@ -136,36 +134,35 @@ public class LicenseBean implements LicenseBeanLocal {
@Override
@Override
public
List
<
LicenseTarget
>
findUserGames
(
EventUser
user
)
{
public
List
<
LicenseTarget
>
findUserGames
(
EventUser
user
)
{
ArrayList
<
LicenseTarget
>
returnLicenses
=
new
ArrayList
<
LicenseTarget
>();
if
(
user
.
getGroupMemberships
()
!=
null
)
{
for
(
GroupMembership
memberShip
:
user
.
getGroupMemberships
())
{
if
(
memberShip
.
getPlaceReservation
()
==
null
)
ArrayList
<
LicenseTarget
>
returnLicenses
=
new
ArrayList
<
LicenseTarget
>();
if
(
user
.
getGroupMemberships
()
!=
null
)
{
for
(
GroupMembership
memberShip
:
user
.
getGroupMemberships
())
{
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
;
}
}
@Override
@Override
public
List
<
LicenseTarget
>
findUnopenedUserGames
(
EventUser
user
)
{
public
List
<
LicenseTarget
>
findUnopenedUserGames
(
EventUser
user
)
{
List
<
LicenseTarget
>
returnLicenses
=
findUserGames
(
user
);
List
<
LicenseTarget
>
returnLicenses
=
findUserGames
(
user
);
for
(
LicenseCode
code
:
user
.
getUser
().
getLicenseCodes
())
{
for
(
LicenseCode
code
:
user
.
getUser
().
getLicenseCodes
())
{
returnLicenses
.
remove
(
code
.
getLicenseTarget
());
returnLicenses
.
remove
(
code
.
getLicenseTarget
());
}
}
return
returnLicenses
;
return
returnLicenses
;
}
}
...
@@ -176,28 +173,10 @@ public class LicenseBean implements LicenseBeanLocal {
...
@@ -176,28 +173,10 @@ public class LicenseBean implements LicenseBeanLocal {
user
.
getLicenseCodes
().
add
(
code
);
user
.
getLicenseCodes
().
add
(
code
);
code
.
setUser
(
user
);
code
.
setUser
(
user
);
licenseCodeFacade
.
create
(
code
);
licenseCodeFacade
.
create
(
code
);
code
=
accessCode
(
code
);
code
=
accessCode
(
code
);
return
code
;
return
code
;
}
}
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/UserBean.java
View file @
d0d41fd
...
@@ -189,10 +189,10 @@ public class UserBean implements UserBeanLocal {
...
@@ -189,10 +189,10 @@ public class UserBean implements UserBeanLocal {
if
(
member
!=
null
&&
member
.
getPlaceReservation
()
!=
null
)
if
(
member
!=
null
&&
member
.
getPlaceReservation
()
!=
null
)
{
{
addRecursive
(
checkedRoles
,
member
.
getPlaceReservation
().
getProvidesRole
());
addRecursive
(
checkedRoles
,
member
.
getPlaceReservation
().
getProvidesRole
());
}
if
(
member
.
getPlaceReservation
().
getProduct
()
!=
null
)
if
(
member
.
getPlaceReservation
().
getProduct
()
!=
null
)
{
{
addRecursive
(
checkedRoles
,
member
.
getPlaceReservation
().
getProduct
().
getProvides
());
addRecursive
(
checkedRoles
,
member
.
getPlaceReservation
().
getProduct
().
getProvides
());
}
}
}
}
}
}
}
...
...
code/MoyaWeb/WebContent/resources/templates/template1/template.xhtml
View file @
d0d41fd
...
@@ -58,7 +58,9 @@
...
@@ -58,7 +58,9 @@
</div>
</div>
<div
id=
"header_center"
class=
"flex1"
></div>
<div
id=
"header_center"
class=
"flex1"
></div>
<div
id=
"header_right"
>
<div
id=
"header_right"
>
<img
src=
"#{request.contextPath}/resources/templates/template1/img/moya_logo.png"
/>
<a
href=
"http://www.codecrew.fi"
><img
src=
"#{request.contextPath}/resources/templates/template1/img/moya_logo.png"
/>
</a>
</div>
</div>
</header>
</header>
...
...
code/MoyaWeb/src/fi/codecrew/moya/rest/PrinterRestView.java
View file @
d0d41fd
...
@@ -86,8 +86,10 @@ public class PrinterRestView {
...
@@ -86,8 +86,10 @@ public class PrinterRestView {
card
=
cardbean
.
findCard
(
cardId
);
card
=
cardbean
.
findCard
(
cardId
);
ret
=
Response
.
ok
(
printbean
.
constructPNG
(
card
),
"image/png"
);
ret
=
Response
.
ok
(
printbean
.
constructPNG
(
card
),
"image/png"
);
}
catch
(
Throwable
t
)
{
}
catch
(
Throwable
t
)
{
card
.
setCardState
(
CardState
.
DATA_MISSING
);
if
(
card
!=
null
)
{
cardbean
.
saveCard
(
card
);
card
.
setCardState
(
CardState
.
DATA_MISSING
);
cardbean
.
saveCard
(
card
);
}
logger
.
warn
(
"Error creating card for user cardId "
+
cardId
,
t
);
logger
.
warn
(
"Error creating card for user cardId "
+
cardId
,
t
);
ret
=
Response
.
status
(
Response
.
Status
.
NOT_ACCEPTABLE
);
ret
=
Response
.
status
(
Response
.
Status
.
NOT_ACCEPTABLE
);
...
...
code/MoyaWeb/src/fi/codecrew/moya/servlet/PlaceMap.java
View file @
d0d41fd
...
@@ -250,7 +250,7 @@ public class PlaceMap extends HttpServlet {
...
@@ -250,7 +250,7 @@ public class PlaceMap extends HttpServlet {
}
}
if
(
p
.
isReservedFor
(
user
))
{
if
(
p
.
isReservedFor
(
user
))
{
logger
.
info
(
"Setting place selected {}"
,
p
);
logger
.
debug
(
"Setting place selected {}"
,
p
);
color
=
SELECTED_COLOR
;
color
=
SELECTED_COLOR
;
}
else
if
(
user
.
equals
(
p
.
getCurrentUser
())
}
else
if
(
user
.
equals
(
p
.
getCurrentUser
())
||
(
p
.
getGroup
()
!=
null
&&
user
.
equals
(
p
.
getGroup
()
||
(
p
.
getGroup
()
!=
null
&&
user
.
equals
(
p
.
getGroup
()
...
@@ -258,11 +258,11 @@ public class PlaceMap extends HttpServlet {
...
@@ -258,11 +258,11 @@ public class PlaceMap extends HttpServlet {
||
(
p
.
getPlaceReserver
()
!=
null
&&
user
.
equals
(
p
||
(
p
.
getPlaceReserver
()
!=
null
&&
user
.
equals
(
p
.
getPlaceReserver
().
getUser
())))
{
.
getPlaceReserver
().
getUser
())))
{
color
=
OWNED_COLOR
;
color
=
OWNED_COLOR
;
logger
.
info
(
"Setting place owned {}"
,
p
);
logger
.
debug
(
"Setting place owned {}"
,
p
);
}
else
if
(
p
.
isTaken
())
{
}
else
if
(
p
.
isTaken
())
{
color
=
RESERVED_COLOR
;
color
=
RESERVED_COLOR
;
logger
.
info
(
"Setting place Reserved {}"
,
p
);
logger
.
debug
(
"Setting place Reserved {}"
,
p
);
}
else
if
(
p
.
getProduct
().
getColor
()
!=
null
&&
!
p
.
getProduct
().
getColor
().
isEmpty
())
{
}
else
if
(
p
.
getProduct
().
getColor
()
!=
null
&&
!
p
.
getProduct
().
getColor
().
isEmpty
())
{
...
@@ -278,7 +278,7 @@ public class PlaceMap extends HttpServlet {
...
@@ -278,7 +278,7 @@ public class PlaceMap extends HttpServlet {
.
getHeight
()));
.
getHeight
()));
if
(
color
!=
null
)
{
if
(
color
!=
null
)
{
logger
.
info
(
"Setting fill color: {} for p"
,
color
,
p
);
logger
.
debug
(
"Setting fill color: {} for p"
,
color
,
p
);
g
.
setColor
(
color
);
g
.
setColor
(
color
);
g
.
fill
(
new
Rectangle
(
p
.
getMapX
()
+
BORDER_WIDTH
,
p
.
getMapY
()
g
.
fill
(
new
Rectangle
(
p
.
getMapX
()
+
BORDER_WIDTH
,
p
.
getMapY
()
+
BORDER_WIDTH
,
p
.
getWidth
()
-
BORDER_WIDTH
,
p
.
getHeight
()
+
BORDER_WIDTH
,
p
.
getWidth
()
-
BORDER_WIDTH
,
p
.
getHeight
()
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/GenericCDIView.java
View file @
d0d41fd
...
@@ -42,9 +42,10 @@ public abstract class GenericCDIView implements Serializable {
...
@@ -42,9 +42,10 @@ public abstract class GenericCDIView implements Serializable {
}
}
public
void
endConversation
()
{
public
void
endConversation
()
{
if
(!
conversation
.
isTransient
())
conversation
.
end
();
if
(!
conversation
.
isTransient
())
conversation
.
end
();
}
}
public
boolean
hasPermission
(
IAppPermission
perm
)
{
public
boolean
hasPermission
(
IAppPermission
perm
)
{
// boolean ret =
// boolean ret =
// FacesContext.getCurrentInstance().getExternalContext().isUserInRole(perm.getFullName());
// FacesContext.getCurrentInstance().getExternalContext().isUserInRole(perm.getFullName());
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/menu/MenuView.java
View file @
d0d41fd
...
@@ -17,19 +17,22 @@ import org.slf4j.Logger;
...
@@ -17,19 +17,22 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.MenuBeanLocal
;
import
fi.codecrew.moya.beans.MenuBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.SitePageBeanLocal
;
import
fi.codecrew.moya.beans.SitePageBeanLocal
;
import
fi.codecrew.moya.handler.NavigationHandler
;
import
fi.codecrew.moya.model.MenuNavigation
;
import
fi.codecrew.moya.model.MenuNavigation
;
import
fi.codecrew.moya.model.PageContent
;
import
fi.codecrew.moya.model.PageContent
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
fi.codecrew.moya.web.helper.LayoutView
;
import
fi.codecrew.moya.web.helper.LayoutView
;
@Named
@Named
@RequestScoped
@RequestScoped
public
class
MenuView
extends
GenericCDIView
{
public
class
MenuView
{
private
static
final
long
serialVersionUID
=
-
5720164797157054213L
;
private
static
final
long
serialVersionUID
=
-
5720164797157054213L
;
private
String
pagename
;
private
String
pagename
;
@Inject
protected
NavigationHandler
navihandler
;
@Inject
@Inject
private
transient
LayoutView
layoutview
;
private
transient
LayoutView
layoutview
;
...
@@ -40,7 +43,7 @@ public class MenuView extends GenericCDIView {
...
@@ -40,7 +43,7 @@ public class MenuView extends GenericCDIView {
@EJB
@EJB
private
transient
MenuBeanLocal
menubean
;
private
transient
MenuBeanLocal
menubean
;
private
LinkedList
<
List
<
JsfMenuitem
>>
menus
;
private
transient
LinkedList
<
List
<
JsfMenuitem
>>
menus
;
private
HashSet
<
MenuNavigation
>
navis
;
private
HashSet
<
MenuNavigation
>
navis
;
...
@@ -94,7 +97,10 @@ public class MenuView extends GenericCDIView {
...
@@ -94,7 +97,10 @@ public class MenuView extends GenericCDIView {
return
getViewChangeTopmenu
().
size
()
>
1
;
return
getViewChangeTopmenu
().
size
()
>
1
;
}
}
private
List
<
JsfMenuitem
>
viewchangeTopmenu
;
private
transient
List
<
JsfMenuitem
>
viewchangeTopmenu
;
@EJB
private
PermissionBeanLocal
permbean
;
public
List
<
JsfMenuitem
>
getViewChangeTopmenu
()
public
List
<
JsfMenuitem
>
getViewChangeTopmenu
()
{
{
...
@@ -151,7 +157,7 @@ public class MenuView extends GenericCDIView {
...
@@ -151,7 +157,7 @@ public class MenuView extends GenericCDIView {
// Iterate through children
// Iterate through children
for
(
MenuNavigation
child
:
children
)
{
for
(
MenuNavigation
child
:
children
)
{
// if is visible, permission is null or has permission, continue
// if is visible, permission is null or has permission, continue
if
(!
child
.
isVisible
()
||
(
child
.
getPermission
()
!=
null
&&
!
super
.
hasPermission
(
child
.
getPermission
())))
{
if
(!
child
.
isVisible
()
||
(
child
.
getPermission
()
!=
null
&&
!
permbean
.
hasPermission
(
child
.
getPermission
())))
{
continue
;
continue
;
}
}
...
@@ -194,7 +200,7 @@ public class MenuView extends GenericCDIView {
...
@@ -194,7 +200,7 @@ public class MenuView extends GenericCDIView {
// try to get the outcome from the first child we have permission to.
// try to get the outcome from the first child we have permission to.
for
(
MenuNavigation
child
:
navi
.
getChildren
())
for
(
MenuNavigation
child
:
navi
.
getChildren
())
{
{
if
(!
child
.
isVisible
()
||
(
child
.
getPermission
()
!=
null
&&
!
super
.
hasPermission
(
child
.
getPermission
())))
{
if
(!
child
.
isVisible
()
||
(
child
.
getPermission
()
!=
null
&&
!
permbean
.
hasPermission
(
child
.
getPermission
())))
{
continue
;
continue
;
}
}
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/menu/PrimeMenuView.java
View file @
d0d41fd
...
@@ -17,7 +17,6 @@ import org.slf4j.Logger;
...
@@ -17,7 +17,6 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.MenuBeanLocal
;
import
fi.codecrew.moya.beans.MenuBeanLocal
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.MenuNavigation
;
import
fi.codecrew.moya.model.MenuNavigation
;
import
fi.codecrew.moya.utilities.I18n
;
import
fi.codecrew.moya.utilities.I18n
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
...
@@ -54,7 +53,7 @@ public class PrimeMenuView extends GenericCDIView {
...
@@ -54,7 +53,7 @@ public class PrimeMenuView extends GenericCDIView {
private
MenuModel
nameMenu
;
private
MenuModel
nameMenu
;
private
EventUser
user
;
//
private EventUser user;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PrimeMenuView
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PrimeMenuView
.
class
);
...
@@ -81,7 +80,6 @@ public class PrimeMenuView extends GenericCDIView {
...
@@ -81,7 +80,6 @@ public class PrimeMenuView extends GenericCDIView {
if
(
m
.
getItem
()
!=
null
&&
m
.
getChildren
().
isEmpty
())
{
if
(
m
.
getItem
()
!=
null
&&
m
.
getChildren
().
isEmpty
())
{
DefaultMenuItem
menuitem
=
mkMenuitem
(
m
);
DefaultMenuItem
menuitem
=
mkMenuitem
(
m
);
if
(
menuitem
!=
null
)
{
if
(
menuitem
!=
null
)
{
menuModel
.
addElement
(
menuitem
);
menuModel
.
addElement
(
menuitem
);
}
}
}
else
{
}
else
{
...
@@ -92,7 +90,10 @@ public class PrimeMenuView extends GenericCDIView {
...
@@ -92,7 +90,10 @@ public class PrimeMenuView extends GenericCDIView {
}
}
}
}
}
}
// logger.info("Initialized menumodel for user {} with {} entries" )
}
else
{
logger
.
info
(
"Not initializing menumodel with {} entries for user {}"
,
menuModel
.
getElements
().
size
());
}
}
return
menuModel
;
return
menuModel
;
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/shop/ProductShopView.java
View file @
d0d41fd
...
@@ -407,7 +407,7 @@ public class ProductShopView extends GenericCDIView {
...
@@ -407,7 +407,7 @@ public class ProductShopView extends GenericCDIView {
PrintedCard
card
=
readerView
.
getPrintedCard
();
PrintedCard
card
=
readerView
.
getPrintedCard
();
if
(
readerView
.
getBarcode
()
==
null
||
readerView
.
getBarcode
().
trim
()
==
""
)
{
if
(
readerView
.
getBarcode
()
==
null
||
readerView
.
getBarcode
().
trim
()
.
isEmpty
()
)
{
return
null
;
return
null
;
}
}
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentParticipateView.java
View file @
d0d41fd
...
@@ -51,7 +51,7 @@ public class TournamentParticipateView extends GenericCDIView {
...
@@ -51,7 +51,7 @@ public class TournamentParticipateView extends GenericCDIView {
public
void
removePlayerFromTeam
(
Integer
euid
)
{
public
void
removePlayerFromTeam
(
Integer
euid
)
{
TournamentTeamMember
ttcand
=
null
;
TournamentTeamMember
ttcand
=
null
;
for
(
TournamentTeamMember
ttm
:
tournamentParticipant
.
getTeamMembers
())
{
for
(
TournamentTeamMember
ttm
:
tournamentParticipant
.
getTeamMembers
())
{
if
(
ttm
.
getEventUser
().
getId
()
==
euid
)
{
if
(
ttm
.
getEventUser
().
getId
()
.
equals
(
euid
)
)
{
ttcand
=
ttm
;
ttcand
=
ttm
;
}
}
}
}
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/helper/LayoutView.java
View file @
d0d41fd
...
@@ -37,9 +37,9 @@ public class LayoutView {
...
@@ -37,9 +37,9 @@ public class LayoutView {
private
ResourceBundle
rb
;
private
ResourceBundle
rb
;
private
String
pagename
;
private
String
pagename
;
@EJB
@EJB
private
EventBeanLocal
eventbean
;
private
transient
EventBeanLocal
eventbean
;
@EJB
@EJB
private
PermissionBeanLocal
permbean
;
private
transient
PermissionBeanLocal
permbean
;
private
StreamedContent
headerimage
;
private
StreamedContent
headerimage
;
private
String
headertext
;
private
String
headertext
;
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/helpers/ProductShopItem.java
View file @
d0d41fd
...
@@ -138,20 +138,19 @@ public class ProductShopItem {
...
@@ -138,20 +138,19 @@ public class ProductShopItem {
return
limit
;
return
limit
;
}
}
public
boolean
updateLimit
(
BigDecimal
limit
)
{
public
boolean
updateLimit
(
BigDecimal
limit
Value
)
{
if
(
limit
!=
null
&&
limit
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
if
(
limit
Value
!=
null
&&
limitValue
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
{
logger
.
info
(
"product limit {}, count {}"
,
limit
,
count
);
logger
.
info
(
"product limit {}, count {}"
,
limitValue
,
count
);
setCount
(
getCount
().
add
(
limit
));
setCount
(
getCount
().
add
(
limitValue
));
if
(
count
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
if
(
count
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
{
setCount
(
BigDecimal
.
ZERO
);
setCount
(
BigDecimal
.
ZERO
);
}
}
limit
=
BigDecimal
.
ZERO
;
limit
=
BigDecimal
.
ZERO
;
return
true
;
return
true
;
}
}
setLimit
(
limit
)
;
limit
=
limitValue
;
return
false
;
return
false
;
}
}
}
}
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