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 f7709320
authored
Jun 11, 2014
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin' into kioskifixi
2 parents
70890659
8a452fa5
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
391 additions
and
191 deletions
.gitignore
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/ActionLogBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/CardTemplateBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/ReaderBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/TournamentBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/UserBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/PlaceFacade.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/UserFacade.java
code/MoyaUtilities/pom.xml
code/MoyaUtilities/src/main/java/fi/codecrew/moya/utilities/GitRepositoryState.java
code/MoyaUtilities/src/main/java/fi/codecrew/moya/utilities/jpa/GenericFacade.java
code/MoyaWeb/WebContent/voting/details.xhtml
code/MoyaWeb/src/fi/codecrew/moya/web/flow/FlowUserContainer.java
code/MoyaWeb/src/fi/codecrew/moya/web/flow/IncomingView.java
code/MoyaWeb/src/fi/codecrew/moya/web/flow/flowShopView.java
code/MoyaWeb/src/fi/codecrew/moya/web/helper/fieldsetView.java → code/MoyaWeb/src/fi/codecrew/moya/web/helper/FieldsetView.java
.gitignore
View file @
f770932
...
@@ -8,3 +8,4 @@
...
@@ -8,3 +8,4 @@
.metadata
.metadata
/code/*/target/
/code/*/target/
/code/*/test-output/
/code/*/test-output/
moya-git.properties
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/ActionLogBean.java
View file @
f770932
...
@@ -2,7 +2,6 @@ package fi.codecrew.moya.beans;
...
@@ -2,7 +2,6 @@ package fi.codecrew.moya.beans;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
javax.annotation.security.DeclareRoles
;
import
javax.annotation.security.DeclareRoles
;
...
@@ -10,13 +9,10 @@ import javax.annotation.security.RolesAllowed;
...
@@ -10,13 +9,10 @@ import javax.annotation.security.RolesAllowed;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.ejb.Stateless
;
import
javax.ejb.Stateless
;
import
fi.codecrew.moya.facade.ActionLogFacade
;
import
fi.codecrew.moya.facade.ActionLogMessageTagFacade
;
import
fi.codecrew.moya.beans.ActionLogBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.RoleBeanLocal
;
import
fi.codecrew.moya.enums.ActionLogMessageState
;
import
fi.codecrew.moya.enums.ActionLogMessageState
;
import
fi.codecrew.moya.enums.apps.ContentPermission
;
import
fi.codecrew.moya.enums.apps.ContentPermission
;
import
fi.codecrew.moya.facade.ActionLogFacade
;
import
fi.codecrew.moya.facade.ActionLogMessageTagFacade
;
import
fi.codecrew.moya.model.ActionLogMessage
;
import
fi.codecrew.moya.model.ActionLogMessage
;
import
fi.codecrew.moya.model.ActionLogMessageResponse
;
import
fi.codecrew.moya.model.ActionLogMessageResponse
;
import
fi.codecrew.moya.model.ActionLogMessageTag
;
import
fi.codecrew.moya.model.ActionLogMessageTag
;
...
@@ -39,10 +35,10 @@ public class ActionLogBean implements ActionLogBeanLocal {
...
@@ -39,10 +35,10 @@ public class ActionLogBean implements ActionLogBeanLocal {
@EJB
@EJB
private
PermissionBeanLocal
permissionBean
;
private
PermissionBeanLocal
permissionBean
;
@EJB
@EJB
private
ActionLogMessageTagFacade
actionLogMessageTagFacade
;
private
ActionLogMessageTagFacade
actionLogMessageTagFacade
;
@EJB
@EJB
private
EventBean
eventBean
;
private
EventBean
eventBean
;
...
@@ -54,7 +50,7 @@ public class ActionLogBean implements ActionLogBeanLocal {
...
@@ -54,7 +50,7 @@ public class ActionLogBean implements ActionLogBeanLocal {
@RolesAllowed
(
ContentPermission
.
S_MANAGE_ACTIONLOG
)
@RolesAllowed
(
ContentPermission
.
S_MANAGE_ACTIONLOG
)
public
void
createActionLogEvent
(
String
message
,
boolean
isTask
)
{
public
void
createActionLogEvent
(
String
message
,
boolean
isTask
)
{
ArrayList
<
ActionLogMessageTag
>
almts
=
resolveTags
(
message
);
ArrayList
<
ActionLogMessageTag
>
almts
=
resolveTags
(
message
);
ActionLogMessage
alm
=
new
ActionLogMessage
();
ActionLogMessage
alm
=
new
ActionLogMessage
();
if
(
isTask
)
{
if
(
isTask
)
{
alm
.
setState
(
ActionLogMessageState
.
NEW
);
alm
.
setState
(
ActionLogMessageState
.
NEW
);
...
@@ -66,7 +62,7 @@ public class ActionLogBean implements ActionLogBeanLocal {
...
@@ -66,7 +62,7 @@ public class ActionLogBean implements ActionLogBeanLocal {
alm
.
setUser
(
permissionBean
.
getCurrentUser
());
alm
.
setUser
(
permissionBean
.
getCurrentUser
());
alm
.
setLanEvent
(
permissionBean
.
getCurrentUser
().
getEvent
());
alm
.
setLanEvent
(
permissionBean
.
getCurrentUser
().
getEvent
());
alm
.
setTags
(
almts
);
alm
.
setTags
(
almts
);
actionLogFacade
.
saveToActionLog
(
alm
);
actionLogFacade
.
saveToActionLog
(
alm
);
}
}
...
@@ -75,11 +71,11 @@ public class ActionLogBean implements ActionLogBeanLocal {
...
@@ -75,11 +71,11 @@ public class ActionLogBean implements ActionLogBeanLocal {
public
List
<
ActionLogMessage
>
getAllActionLogEvents
()
{
public
List
<
ActionLogMessage
>
getAllActionLogEvents
()
{
return
actionLogFacade
.
getAllSortedByTimestamp
(
permissionBean
.
getCurrentUser
().
getEvent
());
return
actionLogFacade
.
getAllSortedByTimestamp
(
permissionBean
.
getCurrentUser
().
getEvent
());
}
}
@Override
@Override
@RolesAllowed
(
ContentPermission
.
S_MANAGE_ACTIONLOG
)
@RolesAllowed
(
ContentPermission
.
S_MANAGE_ACTIONLOG
)
public
List
<
ActionLogMessage
>
getAllActionLogEventsByFilter
(
List
<
ActionLogMessageTag
>
filterTags
)
{
public
List
<
ActionLogMessage
>
getAllActionLogEventsByFilter
(
List
<
ActionLogMessageTag
>
filterTags
)
{
if
(
filterTags
.
size
()
==
0
)
if
(
filterTags
.
size
()
==
0
)
return
actionLogFacade
.
getAllSortedByTimestamp
(
permissionBean
.
getCurrentUser
().
getEvent
());
return
actionLogFacade
.
getAllSortedByTimestamp
(
permissionBean
.
getCurrentUser
().
getEvent
());
else
else
return
actionLogFacade
.
getAllSortedByTimestampFiltered
(
permissionBean
.
getCurrentUser
().
getEvent
(),
filterTags
);
return
actionLogFacade
.
getAllSortedByTimestampFiltered
(
permissionBean
.
getCurrentUser
().
getEvent
(),
filterTags
);
...
@@ -92,10 +88,11 @@ public class ActionLogBean implements ActionLogBeanLocal {
...
@@ -92,10 +88,11 @@ public class ActionLogBean implements ActionLogBeanLocal {
@RolesAllowed
(
ContentPermission
.
S_MANAGE_ACTIONLOG
)
@RolesAllowed
(
ContentPermission
.
S_MANAGE_ACTIONLOG
)
public
List
<
ActionLogMessageResponse
>
getActionLogMessageResponses
(
ActionLogMessage
alm
)
{
public
List
<
ActionLogMessageResponse
>
getActionLogMessageResponses
(
ActionLogMessage
alm
)
{
if
(!
alm
.
getLanEvent
().
equals
(
permissionBean
.
getCurrentUser
().
getEvent
()))
return
null
;
if
(!
alm
.
getLanEvent
().
equals
(
permissionBean
.
getCurrentUser
().
getEvent
()))
return
null
;
return
actionLogFacade
.
getActionLogMessageResponses
(
alm
);
return
actionLogFacade
.
getActionLogMessageResponses
(
alm
);
}
}
@Override
@Override
@RolesAllowed
(
ContentPermission
.
S_MANAGE_ACTIONLOG
)
@RolesAllowed
(
ContentPermission
.
S_MANAGE_ACTIONLOG
)
public
List
<
ActionLogMessageTag
>
getAllTags
()
{
public
List
<
ActionLogMessageTag
>
getAllTags
()
{
...
@@ -104,8 +101,9 @@ public class ActionLogBean implements ActionLogBeanLocal {
...
@@ -104,8 +101,9 @@ public class ActionLogBean implements ActionLogBeanLocal {
@RolesAllowed
(
ContentPermission
.
S_MANAGE_ACTIONLOG
)
@RolesAllowed
(
ContentPermission
.
S_MANAGE_ACTIONLOG
)
public
void
addActionLogMessageResponse
(
ActionLogMessage
alm
,
String
message
,
ActionLogMessageState
state
)
{
public
void
addActionLogMessageResponse
(
ActionLogMessage
alm
,
String
message
,
ActionLogMessageState
state
)
{
if
(!
alm
.
getLanEvent
().
equals
(
permissionBean
.
getCurrentUser
().
getEvent
()))
return
;
if
(!
alm
.
getLanEvent
().
equals
(
permissionBean
.
getCurrentUser
().
getEvent
()))
return
;
if
(
alm
.
getState
()
!=
state
&&
state
!=
null
)
{
if
(
alm
.
getState
()
!=
state
&&
state
!=
null
)
{
alm
=
actionLogFacade
.
merge
(
alm
);
alm
=
actionLogFacade
.
merge
(
alm
);
alm
.
setState
(
state
);
alm
.
setState
(
state
);
...
@@ -124,67 +122,68 @@ public class ActionLogBean implements ActionLogBeanLocal {
...
@@ -124,67 +122,68 @@ public class ActionLogBean implements ActionLogBeanLocal {
@RolesAllowed
(
ContentPermission
.
S_MANAGE_ACTIONLOG
)
@RolesAllowed
(
ContentPermission
.
S_MANAGE_ACTIONLOG
)
public
ActionLogMessage
find
(
Integer
id
)
{
public
ActionLogMessage
find
(
Integer
id
)
{
ActionLogMessage
alm
=
actionLogFacade
.
find
(
id
);
ActionLogMessage
alm
=
actionLogFacade
.
find
(
id
);
if
(!
alm
.
getLanEvent
().
equals
(
permissionBean
.
getCurrentUser
().
getEvent
()))
return
null
;
if
(!
alm
.
getLanEvent
().
equals
(
permissionBean
.
getCurrentUser
().
getEvent
()))
else
return
alm
;
return
null
;
else
return
alm
;
}
}
private
ArrayList
<
ActionLogMessageTag
>
resolveTags
(
String
message
)
{
private
ArrayList
<
ActionLogMessageTag
>
resolveTags
(
String
message
)
{
ArrayList
<
ActionLogMessageTag
>
almts
=
new
ArrayList
<>();
ArrayList
<
ActionLogMessageTag
>
almts
=
new
ArrayList
<>();
StringBuilder
sb
=
null
;
StringBuilder
sb
=
null
;
boolean
rflag
=
false
;
boolean
rflag
=
false
;
char
ch
;
char
ch
;
for
(
int
i
=
0
;
i
<
message
.
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
message
.
length
();
i
++)
{
if
(
rflag
)
{
if
(
rflag
)
{
if
((
ch
=
message
.
charAt
(
i
))
!=
' '
)
{
if
((
ch
=
message
.
charAt
(
i
))
!=
' '
)
{
sb
.
append
(
ch
);
sb
.
append
(
ch
);
}
else
{
}
else
{
if
(
sb
.
length
()
>
0
)
{
if
(
sb
.
length
()
>
0
)
{
ActionLogMessageTag
almt
=
getActionLogMessageTagByString
(
sb
.
toString
());
ActionLogMessageTag
almt
=
getActionLogMessageTagByString
(
sb
.
toString
());
if
(!
almts
.
contains
(
almt
))
{
if
(!
almts
.
contains
(
almt
))
{
almts
.
add
(
almt
);
almts
.
add
(
almt
);
}
}
}
}
rflag
=
false
;
rflag
=
false
;
sb
=
null
;
sb
=
null
;
}
}
}
else
if
(!
rflag
)
{
}
else
if
(!
rflag
)
{
if
(
message
.
charAt
(
i
)
==
'#'
)
{
if
(
message
.
charAt
(
i
)
==
'#'
)
{
rflag
=
true
;
rflag
=
true
;
sb
=
new
StringBuilder
();
sb
=
new
StringBuilder
();
}
}
}
}
}
}
if
(
sb
!=
null
&&
sb
.
length
()
>
0
)
{
if
(
sb
!=
null
&&
sb
.
length
()
>
0
)
{
ActionLogMessageTag
almt
=
getActionLogMessageTagByString
(
sb
.
toString
());
ActionLogMessageTag
almt
=
getActionLogMessageTagByString
(
sb
.
toString
());
if
(!
almts
.
contains
(
almt
))
{
if
(!
almts
.
contains
(
almt
))
{
almts
.
add
(
almt
);
almts
.
add
(
almt
);
}
}
}
}
return
almts
;
return
almts
;
}
}
@Override
@Override
@RolesAllowed
(
ContentPermission
.
S_MANAGE_ACTIONLOG
)
@RolesAllowed
(
ContentPermission
.
S_MANAGE_ACTIONLOG
)
public
ActionLogMessageTag
getActionLogMessageTagByString
(
String
s
)
{
public
ActionLogMessageTag
getActionLogMessageTagByString
(
String
s
)
{
s
=
s
.
toLowerCase
();
s
=
s
.
toLowerCase
();
ActionLogMessageTag
almt
=
null
;
ActionLogMessageTag
almt
=
null
;
if
((
almt
=
actionLogMessageTagFacade
.
findByTagStringInEvent
(
s
,
eventBean
.
getCurrentEvent
()))
==
null
)
{
if
((
almt
=
actionLogMessageTagFacade
.
findByTagStringInEvent
(
s
,
eventBean
.
getCurrentEvent
()))
==
null
)
{
almt
=
new
ActionLogMessageTag
();
almt
=
new
ActionLogMessageTag
();
almt
.
setEvent
(
eventBean
.
getCurrentEvent
());
almt
.
setEvent
(
eventBean
.
getCurrentEvent
());
almt
.
setTag
(
s
);
almt
.
setTag
(
s
);
a
lmt
=
a
ctionLogMessageTagFacade
.
create
(
almt
);
actionLogMessageTagFacade
.
create
(
almt
);
System
.
out
.
println
(
"creating tag: "
+
s
);
System
.
out
.
println
(
"creating tag: "
+
s
);
return
almt
;
return
almt
;
}
else
{
}
else
{
System
.
out
.
println
(
"re-using tag: "
+
s
);
System
.
out
.
println
(
"re-using tag: "
+
s
);
return
almt
;
return
almt
;
}
}
}
}
}
}
\ No newline at end of file
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/CardTemplateBean.java
View file @
f770932
...
@@ -87,7 +87,7 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
...
@@ -87,7 +87,7 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
@EJB
@EJB
private
CardObjectDataFacade
codFacade
;
private
CardObjectDataFacade
codFacade
;
@EJB
@EJB
private
CardCodeFacade
cardCodeFacade
;
private
CardCodeFacade
cardCodeFacade
;
...
@@ -274,18 +274,20 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
...
@@ -274,18 +274,20 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
@Override
@Override
public
CardTextData
save
(
CardTextData
textData
)
{
public
CardTextData
save
(
CardTextData
textData
)
{
if
(
textData
.
getId
()
!=
null
&&
textData
.
getId
()
!=
0
)
if
(
textData
.
getId
()
!=
null
&&
textData
.
getId
()
!=
0
)
return
ctdFacade
.
merge
(
textData
);
textData
=
ctdFacade
.
merge
(
textData
);
else
else
return
ctdFacade
.
create
(
textData
);
ctdFacade
.
create
(
textData
);
return
textData
;
}
}
@RolesAllowed
(
UserPermission
.
S_WRITE_ROLES
)
@RolesAllowed
(
UserPermission
.
S_WRITE_ROLES
)
@Override
@Override
public
CardObjectData
save
(
CardObjectData
objectData
)
{
public
CardObjectData
save
(
CardObjectData
objectData
)
{
if
(
objectData
.
getId
()
!=
null
&&
objectData
.
getId
()
!=
0
)
if
(
objectData
.
getId
()
!=
null
&&
objectData
.
getId
()
!=
0
)
return
codFacade
.
merge
(
objectData
);
objectData
=
codFacade
.
merge
(
objectData
);
else
else
return
codFacade
.
create
(
objectData
);
codFacade
.
create
(
objectData
);
return
objectData
;
}
}
@Override
@Override
...
@@ -375,12 +377,11 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
...
@@ -375,12 +377,11 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
card
.
setCardState
(
CardState
.
DELIVERED
);
card
.
setCardState
(
CardState
.
DELIVERED
);
}
else
{
}
else
{
logger
.
info
(
"Not marking card to delivered: "
+
card
.
getCardState
()
+
" : "
+
card
.
getId
());
logger
.
info
(
"Not marking card to delivered: "
+
card
.
getCardState
()
+
" : "
+
card
.
getId
());
}
}
if
(
markUserPlacesDelivered
)
{
if
(
markUserPlacesDelivered
)
{
for
(
GroupMembership
membership
:
gmFacade
.
findMemberships
(
user
))
{
for
(
GroupMembership
membership
:
gmFacade
.
findMemberships
(
user
))
{
membership
.
setEnteredEvent
(
Calendar
.
getInstance
());
membership
.
setEnteredEvent
(
Calendar
.
getInstance
());
gmFacade
.
merge
(
membership
);
}
}
}
}
...
@@ -389,12 +390,13 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
...
@@ -389,12 +390,13 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
@Override
@Override
public
void
removeCardCode
(
CardCode
code
)
{
public
void
removeCardCode
(
CardCode
code
)
{
code
=
cardCodeFacade
.
merge
(
code
);
code
=
cardCodeFacade
.
reload
(
code
);
if
(
code
.
getPrintedCard
().
getCardCodes
().
contains
(
code
))
{
if
(
code
.
getPrintedCard
().
getCardCodes
().
contains
(
code
))
{
code
.
getPrintedCard
().
getCardCodes
().
remove
(
code
);
code
.
getPrintedCard
().
getCardCodes
().
remove
(
code
);
cardCodeFacade
.
remove
(
code
);
}
}
cardCodeFacade
.
remove
(
code
);
}
}
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
View file @
f770932
...
@@ -35,6 +35,9 @@ import fi.codecrew.moya.model.MenuNavigation;
...
@@ -35,6 +35,9 @@ import fi.codecrew.moya.model.MenuNavigation;
/**
/**
*
*
* HUOM! JOS POISTAT SIVUN, PITÄÄ VIITTAUS POISTAA MYÖS KANNASTA! MUUTEN
* GALAKSIT RÄJÄHTÄÄ! (jsf ei löydä viittausta sivuun ja heittää poikkeuksen)
*
* Kaikki sivut pitää olla jossain menussa, muuten menu häviää näkyvistä ko.
* Kaikki sivut pitää olla jossain menussa, muuten menu häviää näkyvistä ko.
* sivulla kokonaan. Älä siis poista sivua vaaan aseta sivu näkymättömäksi:
* sivulla kokonaan. Älä siis poista sivua vaaan aseta sivu näkymättömäksi:
* .setVisible(false).
* .setVisible(false).
...
@@ -154,7 +157,6 @@ public class MenuBean implements MenuBeanLocal {
...
@@ -154,7 +157,6 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation
createuser
=
usermenu
.
addPage
(
null
,
null
);
MenuNavigation
createuser
=
usermenu
.
addPage
(
null
,
null
);
createuser
.
setKey
(
"topnavi.createuser"
);
createuser
.
setKey
(
"topnavi.createuser"
);
createuser
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/create"
),
UserPermission
.
CREATE_NEW
).
setVisible
(
false
);
createuser
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/create"
),
UserPermission
.
CREATE_NEW
).
setVisible
(
false
);
;
navifacade
.
create
(
usermenu
);
navifacade
.
create
(
usermenu
);
...
@@ -168,7 +170,8 @@ public class MenuBean implements MenuBeanLocal {
...
@@ -168,7 +170,8 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation
adminuser
=
adminmenu
.
addPage
(
null
,
null
);
MenuNavigation
adminuser
=
adminmenu
.
addPage
(
null
,
null
);
adminuser
.
setKey
(
"topnavi.usermgmt"
);
adminuser
.
setKey
(
"topnavi.usermgmt"
);
adminuser
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/useradmin/list"
),
UserPermission
.
VIEW_ALL
);
adminuser
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/useradmin/list"
),
UserPermission
.
VIEW_ALL
);
adminuser
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/useradmin/overview"
),
UserPermission
.
VIEW_ALL
).
setVisible
(
false
);;
adminuser
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/useradmin/overview"
),
UserPermission
.
VIEW_ALL
).
setVisible
(
false
);
adminuser
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/useradmin/create"
),
UserPermission
.
VIEW_ALL
);
adminuser
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/useradmin/create"
),
UserPermission
.
VIEW_ALL
);
adminuser
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/useradmin/sendPicture"
),
UserPermission
.
VIEW_ALL
).
setVisible
(
false
);
adminuser
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/useradmin/sendPicture"
),
UserPermission
.
VIEW_ALL
).
setVisible
(
false
);
adminuser
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/place/adminGroups"
),
UserPermission
.
VIEW_ALL
).
setVisible
(
false
);
adminuser
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/place/adminGroups"
),
UserPermission
.
VIEW_ALL
).
setVisible
(
false
);
...
@@ -202,7 +205,7 @@ public class MenuBean implements MenuBeanLocal {
...
@@ -202,7 +205,7 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation
adminAssociation
=
adminmenu
.
addPage
(
null
,
null
);
MenuNavigation
adminAssociation
=
adminmenu
.
addPage
(
null
,
null
);
adminAssociation
.
setKey
(
"topnavi.adminassoc"
);
adminAssociation
.
setKey
(
"topnavi.adminassoc"
);
adminAssociation
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/networkassociation/index"
),
NetworkAssociationPermission
.
CAN_ADMINISTER_ASSOCIATIONS
);
adminAssociation
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/networkassociation/index"
),
NetworkAssociationPermission
.
CAN_ADMINISTER_ASSOCIATIONS
);
// shop
// shop
MenuNavigation
adminshop
=
adminmenu
.
addPage
(
null
,
null
);
MenuNavigation
adminshop
=
adminmenu
.
addPage
(
null
,
null
);
adminshop
.
setKey
(
"topnavi.adminshop"
);
adminshop
.
setKey
(
"topnavi.adminshop"
);
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/ReaderBean.java
View file @
f770932
...
@@ -164,7 +164,7 @@ public class ReaderBean implements ReaderBeanLocal {
...
@@ -164,7 +164,7 @@ public class ReaderBean implements ReaderBeanLocal {
}
}
}
}
event
=
readerEventFacade
.
create
(
event
);
readerEventFacade
.
create
(
event
);
return
event
;
return
event
;
...
@@ -173,13 +173,9 @@ public class ReaderBean implements ReaderBeanLocal {
...
@@ -173,13 +173,9 @@ public class ReaderBean implements ReaderBeanLocal {
@Override
@Override
public
ReaderEvent
assocCodeToCard
(
ReaderEvent
readerEvent
,
PrintedCard
card
)
{
public
ReaderEvent
assocCodeToCard
(
ReaderEvent
readerEvent
,
PrintedCard
card
)
{
card
=
cardfacade
.
reload
(
card
);
CardCode
code
=
new
CardCode
(
card
,
readerEvent
.
getReader
().
getType
(),
readerEvent
.
getValue
());
CardCode
code
=
new
CardCode
(
card
,
readerEvent
.
getReader
().
getType
(),
readerEvent
.
getValue
(),
eventbean
.
getCurrentEvent
());
code
=
cardCodeFacade
.
create
(
code
);
cardCodeFacade
.
create
(
code
);
card
.
getCardCodes
().
add
(
code
);
card
=
cardfacade
.
merge
(
card
);
return
readerEvent
;
return
readerEvent
;
}
}
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/TournamentBean.java
View file @
f770932
...
@@ -70,13 +70,15 @@ public class TournamentBean implements TournamentBeanLocal {
...
@@ -70,13 +70,15 @@ public class TournamentBean implements TournamentBeanLocal {
@Override
@Override
@RolesAllowed
(
TournamentPermission
.
S_MANAGE_ALL
)
@RolesAllowed
(
TournamentPermission
.
S_MANAGE_ALL
)
public
TournamentGame
createGame
(
TournamentGame
tg
)
{
public
TournamentGame
createGame
(
TournamentGame
tg
)
{
return
tournamentGameFacade
.
create
(
tg
);
tournamentGameFacade
.
create
(
tg
);
return
tg
;
}
}
@Override
@Override
@RolesAllowed
(
TournamentPermission
.
S_MANAGE_ALL
)
@RolesAllowed
(
TournamentPermission
.
S_MANAGE_ALL
)
public
TournamentRule
createRule
(
TournamentRule
tr
)
{
public
TournamentRule
createRule
(
TournamentRule
tr
)
{
return
tournamentRuleFacade
.
create
(
tr
);
tournamentRuleFacade
.
create
(
tr
);
return
tr
;
}
}
@Override
@Override
...
@@ -100,12 +102,12 @@ public class TournamentBean implements TournamentBeanLocal {
...
@@ -100,12 +102,12 @@ public class TournamentBean implements TournamentBeanLocal {
else
else
throw
new
Exception
(
"tournament.invalid_event"
);
throw
new
Exception
(
"tournament.invalid_event"
);
}
}
@Override
@Override
@RolesAllowed
(
TournamentPermission
.
S_MANAGE_ALL
)
@RolesAllowed
(
TournamentPermission
.
S_MANAGE_ALL
)
public
void
updateTournamentRules
(
TournamentRule
tr
)
throws
Exception
{
public
void
updateTournamentRules
(
TournamentRule
tr
)
throws
Exception
{
// Assert correct event
// Assert correct event
if
(
eventBean
.
getCurrentEvent
().
equals
(
tr
.
getTournamentGame
().
getLanEvent
()))
{
if
(
eventBean
.
getCurrentEvent
().
equals
(
tr
.
getTournamentGame
().
getLanEvent
()))
{
tournamentRuleFacade
.
merge
(
tr
);
tournamentRuleFacade
.
merge
(
tr
);
}
else
{
}
else
{
throw
new
Exception
(
"tournament.invalid_event"
);
throw
new
Exception
(
"tournament.invalid_event"
);
...
@@ -115,8 +117,8 @@ public class TournamentBean implements TournamentBeanLocal {
...
@@ -115,8 +117,8 @@ public class TournamentBean implements TournamentBeanLocal {
@Override
@Override
@RolesAllowed
(
TournamentPermission
.
S_VIEW
)
@RolesAllowed
(
TournamentPermission
.
S_VIEW
)
public
List
<
Tournament
>
getTournamentsInStatus
(
TournamentStatus
status
,
boolean
useTimeConstraints
,
boolean
invertMatch
)
{
public
List
<
Tournament
>
getTournamentsInStatus
(
TournamentStatus
status
,
boolean
useTimeConstraints
,
boolean
invertMatch
)
{
if
(
useTimeConstraints
)
if
(
useTimeConstraints
)
if
(!
invertMatch
)
if
(!
invertMatch
)
return
tournamentFacade
.
getTournamentsInStatusWithParticipationTimeIn
(
status
,
eventBean
.
getCurrentEvent
());
return
tournamentFacade
.
getTournamentsInStatusWithParticipationTimeIn
(
status
,
eventBean
.
getCurrentEvent
());
else
else
return
tournamentFacade
.
getTournamentsInStatusWithParticipationTimeNotIn
(
status
,
eventBean
.
getCurrentEvent
());
return
tournamentFacade
.
getTournamentsInStatusWithParticipationTimeNotIn
(
status
,
eventBean
.
getCurrentEvent
());
...
@@ -170,7 +172,7 @@ public class TournamentBean implements TournamentBeanLocal {
...
@@ -170,7 +172,7 @@ public class TournamentBean implements TournamentBeanLocal {
// Assert team has the correct number of players for a match
// Assert team has the correct number of players for a match
if
(
tournamentParticipant
.
getTeamMembers
().
size
()
>=
tournamentParticipant
.
getTournament
().
getPlayersPerMatch
())
{
if
(
tournamentParticipant
.
getTeamMembers
().
size
()
>=
tournamentParticipant
.
getTournament
().
getPlayersPerMatch
())
{
tournamentParticipant
=
tournamentParticipant
Facade
.
create
(
tournamentParticipant
);
tournamentParticipantFacade
.
create
(
tournamentParticipant
);
t
.
getParticipants
().
add
(
tournamentParticipant
);
t
.
getParticipants
().
add
(
tournamentParticipant
);
}
else
{
}
else
{
throw
new
Exception
(
"tournament.not_enough_players"
);
throw
new
Exception
(
"tournament.not_enough_players"
);
...
@@ -206,10 +208,10 @@ public class TournamentBean implements TournamentBeanLocal {
...
@@ -206,10 +208,10 @@ public class TournamentBean implements TournamentBeanLocal {
@RolesAllowed
(
TournamentPermission
.
S_VIEW
)
@RolesAllowed
(
TournamentPermission
.
S_VIEW
)
public
List
<
TournamentParticipant
>
findOwnParticipations
()
{
public
List
<
TournamentParticipant
>
findOwnParticipations
()
{
EventUser
currentUser
=
permissionBean
.
getCurrentUser
();
EventUser
currentUser
=
permissionBean
.
getCurrentUser
();
return
tournamentParticipantFacade
.
findByParticipator
(
currentUser
);
return
tournamentParticipantFacade
.
findByParticipator
(
currentUser
);
}
}
@Override
@Override
@RolesAllowed
(
TournamentPermission
.
S_VIEW
)
@RolesAllowed
(
TournamentPermission
.
S_VIEW
)
public
EventUser
findAvailablePlayerForTournamentByLogin
(
Tournament
t
,
String
login
)
throws
Exception
{
public
EventUser
findAvailablePlayerForTournamentByLogin
(
Tournament
t
,
String
login
)
throws
Exception
{
...
@@ -230,27 +232,27 @@ public class TournamentBean implements TournamentBeanLocal {
...
@@ -230,27 +232,27 @@ public class TournamentBean implements TournamentBeanLocal {
public
void
deleteParticipationById
(
Integer
tpid
)
throws
Exception
{
public
void
deleteParticipationById
(
Integer
tpid
)
throws
Exception
{
TournamentParticipant
tp
=
tournamentParticipantFacade
.
find
(
tpid
);
TournamentParticipant
tp
=
tournamentParticipantFacade
.
find
(
tpid
);
EventUser
executor
=
permissionBean
.
getCurrentUser
();
EventUser
executor
=
permissionBean
.
getCurrentUser
();
// Assert we have permission to remove participant
// Assert we have permission to remove participant
// TODO: this will include check for remove any participation too!
// TODO: this will include check for remove any participation too!
if
(!
permissionBean
.
hasPermission
(
TournamentPermission
.
REMOVE_OWN_PARTICIPATION
)
||
!
tp
.
getParticipator
().
equals
(
executor
))
{
if
(!
permissionBean
.
hasPermission
(
TournamentPermission
.
REMOVE_OWN_PARTICIPATION
)
||
!
tp
.
getParticipator
().
equals
(
executor
))
{
throw
new
Exception
(
"tournaments.can_only_remove_own_participations"
);
throw
new
Exception
(
"tournaments.can_only_remove_own_participations"
);
}
}
// Assert that tournament has not closed participation
// Assert that tournament has not closed participation
// TODO: admin exception!
// TODO: admin exception!
if
(!
tp
.
getTournament
().
getRegistrationClosesAt
().
after
(
new
Date
()))
{
if
(!
tp
.
getTournament
().
getRegistrationClosesAt
().
after
(
new
Date
()))
{
throw
new
Exception
(
"tournaments.cannot_remove_participation_from_closed_tournament"
);
throw
new
Exception
(
"tournaments.cannot_remove_participation_from_closed_tournament"
);
}
}
// All ok, do nukage
// All ok, do nukage
for
(
TournamentTeamMember
ttm
:
tp
.
getTeamMembers
())
{
for
(
TournamentTeamMember
ttm
:
tp
.
getTeamMembers
())
{
tournamentTeamMemberFacade
.
remove
(
ttm
);
tournamentTeamMemberFacade
.
remove
(
ttm
);
}
}
// Let's not leave anything in cache :)
// Let's not leave anything in cache :)
tp
.
getTournament
().
getParticipants
().
remove
(
tp
);
tp
.
getTournament
().
getParticipants
().
remove
(
tp
);
tournamentParticipantFacade
.
remove
(
tp
);
tournamentParticipantFacade
.
remove
(
tp
);
}
}
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/UserBean.java
View file @
f770932
...
@@ -155,7 +155,7 @@ public class UserBean implements UserBeanLocal {
...
@@ -155,7 +155,7 @@ public class UserBean implements UserBeanLocal {
private
EventFacade
eventfacade
;
private
EventFacade
eventfacade
;
@EJB
@EJB
private
ProductFacade
productFacade
;
private
ProductFacade
productFacade
;
@Override
@Override
@RolesAllowed
(
UserPermission
.
S_VIEW_ALL
)
@RolesAllowed
(
UserPermission
.
S_VIEW_ALL
)
...
@@ -339,12 +339,12 @@ public class UserBean implements UserBeanLocal {
...
@@ -339,12 +339,12 @@ public class UserBean implements UserBeanLocal {
int
sourceCenterY
=
sourceHeight
/
2
;
int
sourceCenterY
=
sourceHeight
/
2
;
int
sourceTop
,
sourceLeft
,
sourceRight
,
sourceBottom
;
int
sourceTop
,
sourceLeft
,
sourceRight
,
sourceBottom
;
double
sourceRatio
=
(
double
)
sourceWidth
/
(
double
)
sourceHeight
;
double
sourceRatio
=
(
double
)
sourceWidth
/
(
double
)
sourceHeight
;
if
(
sourceRatio
>
targetRatio
)
{
if
(
sourceRatio
>
targetRatio
)
{
// the pic is too wide - reduce width
// the pic is too wide - reduce width
targetWidth
=
(
int
)
((
double
)
sourceHeight
*
targetRatio
);
targetWidth
=
(
int
)
((
double
)
sourceHeight
*
targetRatio
);
targetHeight
=
sourceHeight
;
targetHeight
=
sourceHeight
;
// crop box coords - calculate left and right
// crop box coords - calculate left and right
sourceLeft
=
sourceCenterX
-
(
targetWidth
/
2
);
sourceLeft
=
sourceCenterX
-
(
targetWidth
/
2
);
sourceTop
=
0
;
sourceTop
=
0
;
...
@@ -353,15 +353,15 @@ public class UserBean implements UserBeanLocal {
...
@@ -353,15 +353,15 @@ public class UserBean implements UserBeanLocal {
}
else
{
}
else
{
// the pic is too tall - reduce height
// the pic is too tall - reduce height
targetWidth
=
sourceWidth
;
targetWidth
=
sourceWidth
;
targetHeight
=
(
int
)
((
double
)
sourceWidth
/
targetRatio
);
targetHeight
=
(
int
)
((
double
)
sourceWidth
/
targetRatio
);
// crop box coords - calculate top and bottom
// crop box coords - calculate top and bottom
sourceLeft
=
0
;
sourceLeft
=
0
;
sourceTop
=
sourceCenterY
-
(
targetHeight
/
2
);
sourceTop
=
sourceCenterY
-
(
targetHeight
/
2
);
sourceRight
=
sourceWidth
;
sourceRight
=
sourceWidth
;
sourceBottom
=
sourceCenterY
+
(
targetHeight
/
2
);
sourceBottom
=
sourceCenterY
+
(
targetHeight
/
2
);
}
}
BufferedImage
cropped
=
new
BufferedImage
(
targetWidth
,
targetHeight
,
source
.
getType
());
BufferedImage
cropped
=
new
BufferedImage
(
targetWidth
,
targetHeight
,
source
.
getType
());
Graphics2D
g
=
cropped
.
createGraphics
();
Graphics2D
g
=
cropped
.
createGraphics
();
g
.
setRenderingHint
(
RenderingHints
.
KEY_INTERPOLATION
,
RenderingHints
.
VALUE_INTERPOLATION_BILINEAR
);
g
.
setRenderingHint
(
RenderingHints
.
KEY_INTERPOLATION
,
RenderingHints
.
VALUE_INTERPOLATION_BILINEAR
);
...
@@ -477,37 +477,37 @@ public class UserBean implements UserBeanLocal {
...
@@ -477,37 +477,37 @@ public class UserBean implements UserBeanLocal {
}
}
public
PrintedCard
rejectPrintedCard
(
PrintedCard
card
,
MailMessage
mail
)
{
public
PrintedCard
rejectPrintedCard
(
PrintedCard
card
,
MailMessage
mail
)
{
if
(
card
!=
null
)
{
if
(
card
!=
null
)
{
card
.
setCardState
(
CardState
.
REJECTED
);
card
.
setCardState
(
CardState
.
REJECTED
);
card
=
printedcardfacade
.
merge
(
card
);
card
=
printedcardfacade
.
merge
(
card
);
logger
.
info
(
"rejectPrintedCard(): Rejected card {}, state {}"
,
card
,
card
.
getCardState
()
);
logger
.
info
(
"rejectPrintedCard(): Rejected card {}, state {}"
,
card
,
card
.
getCardState
());
User
user
=
null
;
User
user
=
null
;
if
(
card
.
getUser
()
!=
null
&&
card
.
getUser
().
getUser
()
!=
null
)
if
(
card
.
getUser
()
!=
null
&&
card
.
getUser
().
getUser
()
!=
null
)
user
=
card
.
getUser
().
getUser
();
user
=
card
.
getUser
().
getUser
();
LanEvent
event
=
card
.
getEvent
();
LanEvent
event
=
card
.
getEvent
();
if
(
mail
!=
null
)
{
if
(
mail
!=
null
)
{
if
(!
utilbean
.
sendMail
(
mail
))
{
if
(!
utilbean
.
sendMail
(
mail
))
{
logger
.
info
(
"Sending mail failed"
);
logger
.
info
(
"Sending mail failed"
);
}
else
}
else
logger
.
info
(
"Sending mail succeeded"
);
logger
.
info
(
"Sending mail succeeded"
);
}
else
{
}
else
{
if
(
user
==
null
)
if
(
user
==
null
)
logger
.
info
(
"user is null"
);
logger
.
info
(
"user is null"
);
if
(
event
==
null
)
if
(
event
==
null
)
logger
.
info
(
"event is null"
);
logger
.
info
(
"event is null"
);
}
}
}
}
logger
.
info
(
"returning card"
);
logger
.
info
(
"returning card"
);
return
card
;
return
card
;
}
}
// @Override
// @Override
// @RolesAllowed(UserPermission.S_VIEW_ALL)
// @RolesAllowed(UserPermission.S_VIEW_ALL)
// public User findById(Integer id) {
// public User findById(Integer id) {
...
@@ -663,7 +663,7 @@ public class UserBean implements UserBeanLocal {
...
@@ -663,7 +663,7 @@ public class UserBean implements UserBeanLocal {
gid
.
setGame
(
game
);
gid
.
setGame
(
game
);
gid
.
setUser
(
u
);
gid
.
setUser
(
u
);
g
id
=
g
ameIDFacade
.
create
(
gid
);
gameIDFacade
.
create
(
gid
);
u
.
getGameIDs
().
add
(
gid
);
u
.
getGameIDs
().
add
(
gid
);
}
}
...
@@ -942,28 +942,29 @@ public class UserBean implements UserBeanLocal {
...
@@ -942,28 +942,29 @@ public class UserBean implements UserBeanLocal {
return
eventUserFacade
.
getOtherOrganisationsEventuser
(
user
,
event
);
return
eventUserFacade
.
getOtherOrganisationsEventuser
(
user
,
event
);
}
}
@Override
@Override
@RolesAllowed
(
EventPermission
.
S_MANAGE_EVENT
)
@RolesAllowed
(
EventPermission
.
S_MANAGE_EVENT
)
public
String
getAuthCode
(
EventUser
user
)
{
public
String
getAuthCode
(
EventUser
user
)
{
logger
.
info
(
"getAuthCode()"
);
logger
.
info
(
"getAuthCode()"
);
String
code
=
""
;
String
code
=
""
;
String
hex
=
Integer
.
toHexString
(
user
.
getId
());
String
hex
=
Integer
.
toHexString
(
user
.
getId
());
logger
.
info
(
"Hex code {} for id {}"
,
hex
,
user
.
getId
());
logger
.
info
(
"Hex code {} for id {}"
,
hex
,
user
.
getId
());
//padding hex string to 5 characters by adding Xs to the beginning
//
padding hex string to 5 characters by adding Xs to the beginning
if
(
hex
.
length
()
<
5
)
{
if
(
hex
.
length
()
<
5
)
{
logger
.
info
(
"Padding hex ({}) with X."
,
hex
.
length
());
logger
.
info
(
"Padding hex ({}) with X."
,
hex
.
length
());
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
if
(
hex
.
length
()
<
5
)
{
if
(
hex
.
length
()
<
5
)
{
hex
=
"X"
+
hex
;
hex
=
"X"
+
hex
;
}
}
else
break
;
else
break
;
}
}
}
else
}
else
logger
.
info
(
"Hex string too long ({}), no padding needed"
,
hex
.
length
());
logger
.
info
(
"Hex string too long ({}), no padding needed"
,
hex
.
length
());
String
hash
=
""
;
String
hash
=
""
;
logger
.
info
(
"Generating md5 hash from hex {}"
,
hex
);
logger
.
info
(
"Generating md5 hash from hex {}"
,
hex
);
try
{
try
{
...
@@ -971,63 +972,64 @@ public class UserBean implements UserBeanLocal {
...
@@ -971,63 +972,64 @@ public class UserBean implements UserBeanLocal {
byte
[]
array
=
md
.
digest
(
hex
.
getBytes
());
byte
[]
array
=
md
.
digest
(
hex
.
getBytes
());
hash
=
new
String
(
Hex
.
encodeHex
(
array
));
hash
=
new
String
(
Hex
.
encodeHex
(
array
));
logger
.
info
(
"Hash {}"
,
hash
);
logger
.
info
(
"Hash {}"
,
hash
);
}
catch
(
NoSuchAlgorithmException
ex
)
{
}
catch
(
NoSuchAlgorithmException
ex
)
{
logger
.
info
(
"Catched exeption {}"
,
ex
.
getMessage
());
logger
.
info
(
"Catched exeption {}"
,
ex
.
getMessage
());
}
}
if
(
hash
!=
""
&&
hash
.
length
()
>
2
)
{
if
(
hash
!=
""
&&
hash
.
length
()
>
2
)
{
//Generating code by concatenating hex string and first 3 characters from hash
// Generating code by concatenating hex string and first 3
// characters from hash
code
=
code
.
concat
(
hex
);
code
=
code
.
concat
(
hex
);
code
=
code
.
concat
(
hash
.
substring
(
0
,
3
));
code
=
code
.
concat
(
hash
.
substring
(
0
,
3
));
logger
.
info
(
"Code for user is {}"
,
code
);
logger
.
info
(
"Code for user is {}"
,
code
);
}
else
}
else
logger
.
info
(
"No code generated: hash.length() {}"
,
hash
.
length
());
logger
.
info
(
"No code generated: hash.length() {}"
,
hash
.
length
());
return
code
.
toUpperCase
();
return
code
.
toUpperCase
();
}
}
@Override
@Override
@RolesAllowed
(
EventPermission
.
S_MANAGE_EVENT
)
@RolesAllowed
(
EventPermission
.
S_MANAGE_EVENT
)
public
EventUser
getUser
(
String
authcode
)
{
public
EventUser
getUser
(
String
authcode
)
{
logger
.
info
(
"getUser({})"
,
authcode
);
logger
.
info
(
"getUser({})"
,
authcode
);
EventUser
user
=
null
;
EventUser
user
=
null
;
if
(
authcode
.
length
()
==
8
)
{
if
(
authcode
.
length
()
==
8
)
{
logger
.
info
(
"authcode length is 8"
);
logger
.
info
(
"authcode length is 8"
);
// First 5 characters are the hex
// First 5 characters are the hex
String
paddedHex
=
authcode
.
substring
(
0
,
5
);
String
paddedHex
=
authcode
.
substring
(
0
,
5
);
logger
.
info
(
"Padded hex {}"
,
paddedHex
);
logger
.
info
(
"Padded hex {}"
,
paddedHex
);
// Removing the padding characters
// Removing the padding characters
String
hex
=
paddedHex
.
replace
(
"X"
,
""
);
String
hex
=
paddedHex
.
replace
(
"X"
,
""
);
logger
.
info
(
"Hex {}"
,
hex
);
logger
.
info
(
"Hex {}"
,
hex
);
int
id
=
0
;
int
id
=
0
;
try
{
try
{
id
=
Integer
.
decode
(
"0x"
+
hex
.
toLowerCase
());
id
=
Integer
.
decode
(
"0x"
+
hex
.
toLowerCase
());
}
catch
(
NumberFormatException
ex
)
{
}
catch
(
NumberFormatException
ex
)
{
logger
.
info
(
"NumberFormatException was thrown"
);
logger
.
info
(
"NumberFormatException was thrown"
);
}
}
logger
.
info
(
"Id {}"
,
id
);
logger
.
info
(
"Id {}"
,
id
);
if
(
id
!=
0
)
{
if
(
id
!=
0
)
{
user
=
eventUserFacade
.
find
(
id
);
user
=
eventUserFacade
.
find
(
id
);
}
}
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
// Testing if the user is correct
// Testing if the user is correct
logger
.
info
(
"User {} found with id {}"
,
user
,
id
);
logger
.
info
(
"User {} found with id {}"
,
user
,
id
);
String
testCode
=
getAuthCode
(
user
);
String
testCode
=
getAuthCode
(
user
);
logger
.
info
(
"Testcode {}"
,
testCode
);
logger
.
info
(
"Testcode {}"
,
testCode
);
if
(
testCode
==
null
||
testCode
.
equals
(
""
)
||
!
authcode
.
equals
(
testCode
))
{
if
(
testCode
==
null
||
testCode
.
equals
(
""
)
||
!
authcode
.
equals
(
testCode
))
{
user
=
null
;
user
=
null
;
logger
.
info
(
"User set to null, test code not the same as user that was found."
);
logger
.
info
(
"User set to null, test code not the same as user that was found."
);
}
}
}
else
}
else
logger
.
info
(
"User not found with id {}"
,
id
);
logger
.
info
(
"User not found with id {}"
,
id
);
}
else
}
else
logger
.
info
(
"authcode length not 8!, length {}"
,
authcode
.
length
());
logger
.
info
(
"authcode length not 8!, length {}"
,
authcode
.
length
());
return
user
;
return
user
;
}
}
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/PlaceFacade.java
View file @
f770932
...
@@ -134,7 +134,7 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
...
@@ -134,7 +134,7 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
CriteriaQuery
<
Place
>
cq
=
cb
.
createQuery
(
Place
.
class
);
CriteriaQuery
<
Place
>
cq
=
cb
.
createQuery
(
Place
.
class
);
Root
<
Place
>
root
=
cq
.
from
(
Place
.
class
);
Root
<
Place
>
root
=
cq
.
from
(
Place
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
Place_
.
map
).
get
(
EventMap_
.
event
),
eventBean
.
getCurrentEvent
()));
cq
.
where
(
cb
.
equal
(
root
.
get
(
Place_
.
map
).
get
(
EventMap_
.
event
),
eventBean
.
getCurrentEvent
()));
//
cq.orderBy(cb.asc(root.get(Place_.name)));
cq
.
orderBy
(
cb
.
asc
(
root
.
get
(
Place_
.
name
)));
return
getEm
().
createQuery
(
cq
).
getResultList
();
return
getEm
().
createQuery
(
cq
).
getResultList
();
}
}
}
}
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/UserFacade.java
View file @
f770932
...
@@ -89,12 +89,6 @@ public class UserFacade extends IntegerPkGenericFacade<User> {
...
@@ -89,12 +89,6 @@ public class UserFacade extends IntegerPkGenericFacade<User> {
// }
// }
@Override
@Override
public
User
create
(
User
user
)
{
user
.
setLogin
(
user
.
getLogin
().
toLowerCase
().
trim
());
return
super
.
create
(
user
);
}
@Override
public
User
merge
(
User
user
)
{
public
User
merge
(
User
user
)
{
user
.
setLogin
(
user
.
getLogin
().
toLowerCase
().
trim
());
user
.
setLogin
(
user
.
getLogin
().
toLowerCase
().
trim
());
return
super
.
merge
(
user
);
return
super
.
merge
(
user
);
...
...
code/MoyaUtilities/pom.xml
View file @
f770932
...
@@ -5,9 +5,31 @@
...
@@ -5,9 +5,31 @@
<artifactId>
moya-utils
</artifactId>
<artifactId>
moya-utils
</artifactId>
<version>
0.2.0
</version>
<version>
0.2.0
</version>
<build>
<build>
<plugins>
<plugins>
<plugin>
<plugin>
<groupId>
pl.project13.maven
</groupId>
<artifactId>
git-commit-id-plugin
</artifactId>
<version>
2.1.10
</version>
<executions>
<execution>
<goals>
<goal>
revision
</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- this is false by default, forces the plugin to generate the git.properties
file -->
<generateGitPropertiesFile>
true
</generateGitPropertiesFile>
<!-- The path for the to be generated properties file, it's relative
to ${project.basedir} -->
<generateGitPropertiesFilename>
src/main/java/moya-git.properties
</generateGitPropertiesFilename>
<dotGitDirectory>
${project.basedir}/../../.git
</dotGitDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>
maven-compiler-plugin
</artifactId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.1
</version>
<version>
3.1
</version>
<configuration>
<configuration>
...
...
code/MoyaUtilities/src/main/java/fi/codecrew/moya/utilities/GitRepositoryState.java
0 → 100644
View file @
f770932
package
fi
.
codecrew
.
moya
.
utilities
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Properties
;
public
class
GitRepositoryState
{
private
static
GitRepositoryState
gitRepositoryState
;
public
static
GitRepositoryState
getGitRepositoryState
()
throws
IOException
{
if
(
gitRepositoryState
==
null
)
{
gitRepositoryState
=
new
GitRepositoryState
();
}
return
gitRepositoryState
;
}
private
final
String
branch
;
private
final
String
describe
;
private
final
String
describeShort
;
private
final
String
commitId
;
private
final
String
buildUserName
;
private
final
String
buildUserEmail
;
private
final
String
buildTime
;
private
final
String
commitUserName
;
private
final
String
commitUserEmail
;
private
final
String
commitMessageShort
;
private
final
String
commitMessageFull
;
private
final
String
commitTime
;
private
GitRepositoryState
()
throws
IOException
{
InputStream
resource
=
getClass
().
getClassLoader
().
getResourceAsStream
(
"moya-git.properties"
);
if
(
resource
==
null
)
{
throw
new
IOException
(
"ResourceFile not found"
);
}
Properties
properties
=
new
Properties
();
properties
.
load
(
resource
);
this
.
branch
=
properties
.
get
(
"git.branch"
).
toString
();
this
.
describe
=
properties
.
get
(
"git.commit.id.describe"
).
toString
();
this
.
describeShort
=
properties
.
get
(
"git.commit.id.describe-short"
).
toString
();
this
.
commitId
=
properties
.
get
(
"git.commit.id"
).
toString
();
this
.
buildUserName
=
properties
.
get
(
"git.build.user.name"
).
toString
();
this
.
buildUserEmail
=
properties
.
get
(
"git.build.user.email"
).
toString
();
this
.
buildTime
=
properties
.
get
(
"git.build.time"
).
toString
();
this
.
commitUserName
=
properties
.
get
(
"git.commit.user.name"
).
toString
();
this
.
commitUserEmail
=
properties
.
get
(
"git.commit.user.email"
).
toString
();
this
.
commitMessageShort
=
properties
.
get
(
"git.commit.message.short"
).
toString
();
this
.
commitMessageFull
=
properties
.
get
(
"git.commit.message.full"
).
toString
();
this
.
commitTime
=
properties
.
get
(
"git.commit.time"
).
toString
();
}
public
String
getBranch
()
{
return
branch
;
}
public
String
getDescribe
()
{
return
describe
;
}
public
String
getDescribeShort
()
{
return
describeShort
;
}
public
String
getCommitId
()
{
return
commitId
;
}
public
String
getBuildUserName
()
{
return
buildUserName
;
}
public
String
getBuildUserEmail
()
{
return
buildUserEmail
;
}
public
String
getBuildTime
()
{
return
buildTime
;
}
public
String
getCommitUserName
()
{
return
commitUserName
;
}
public
String
getCommitUserEmail
()
{
return
commitUserEmail
;
}
public
String
getCommitMessageShort
()
{
return
commitMessageShort
;
}
public
String
getCommitMessageFull
()
{
return
commitMessageFull
;
}
public
String
getCommitTime
()
{
return
commitTime
;
}
}
code/MoyaUtilities/src/main/java/fi/codecrew/moya/utilities/jpa/GenericFacade.java
View file @
f770932
...
@@ -38,10 +38,19 @@ public abstract class GenericFacade<C extends ModelInterface> {
...
@@ -38,10 +38,19 @@ public abstract class GenericFacade<C extends ModelInterface> {
protected
abstract
EntityManager
getEm
();
protected
abstract
EntityManager
getEm
();
public
C
create
(
C
entity
)
{
/*
* This function does not need to return the persisted entity. All changes are made to the parameter.
*
*/
/**
* Persists the entity into database. After calling this function the entity
* is attached and all changes are persisted to database
*
* @param entity
* Entity to be created and attached to database.
*/
public
void
create
(
C
entity
)
{
getEm
().
persist
(
entity
);
getEm
().
persist
(
entity
);
return
entity
;
}
}
public
void
remove
(
C
entity
)
{
public
void
remove
(
C
entity
)
{
...
@@ -49,11 +58,28 @@ public abstract class GenericFacade<C extends ModelInterface> {
...
@@ -49,11 +58,28 @@ public abstract class GenericFacade<C extends ModelInterface> {
getEm
().
remove
(
entity
);
getEm
().
remove
(
entity
);
}
}
/**
* Merge changes from a detached entity to the database.
*
* This function does nothing if entity is already attached.
*
* @param entity
* Detached entity to be merged into database
* @return Attached entity with changes merged
*/
public
C
merge
(
C
entity
)
{
public
C
merge
(
C
entity
)
{
return
getEm
().
merge
(
entity
);
return
getEm
().
merge
(
entity
);
}
}
/**
* Refresh the state of the instance from the database, overwriting changes
* made to the entity, if any.
*
* ENTITY MUST BE ATTACHED!
*
* @param entity
*/
public
void
refresh
(
C
entity
)
{
public
void
refresh
(
C
entity
)
{
getEm
().
refresh
(
entity
);
getEm
().
refresh
(
entity
);
}
}
...
@@ -282,14 +308,31 @@ public abstract class GenericFacade<C extends ModelInterface> {
...
@@ -282,14 +308,31 @@ public abstract class GenericFacade<C extends ModelInterface> {
// return q.getResultList();
// return q.getResultList();
// }
// }
/**
* Synchronize the persistence context to the underlying database.
*
* This gives to newly created entities ID, etc.
*/
public
void
flush
()
{
public
void
flush
()
{
getEm
().
flush
();
getEm
().
flush
();
}
}
/**
* Remove the given entity from cache.
*
* @param entity
*/
public
void
evict
(
C
entity
)
{
public
void
evict
(
C
entity
)
{
getEm
().
getEntityManagerFactory
().
getCache
().
evict
(
getEntityClass
(),
entity
.
getId
());
getEm
().
getEntityManagerFactory
().
getCache
().
evict
(
getEntityClass
(),
entity
.
getId
());
}
}
/**
* Tells wether the entity is attached to this transaction. ie. Changes to
* this object are automatically propagated to the database
*
* @param entity
* @return
*/
public
boolean
isAttached
(
ModelInterface
entity
)
{
public
boolean
isAttached
(
ModelInterface
entity
)
{
return
getEm
().
contains
(
entity
);
return
getEm
().
contains
(
entity
);
}
}
...
...
code/MoyaWeb/WebContent/voting/details.xhtml
View file @
f770932
...
@@ -18,68 +18,44 @@
...
@@ -18,68 +18,44 @@
<compo:editCompo
commitAction=
"#{compoMgmtView.saveCompo}"
commitValue=
"#{i18n['voting.create.saveCompo']}"
/>
<compo:editCompo
commitAction=
"#{compoMgmtView.saveCompo}"
commitValue=
"#{i18n['voting.create.saveCompo']}"
/>
<h2>
#{i18n['compoMgmtView.compo.entries']}
</h2>
<h2>
#{i18n['compoMgmtView.compo.entries']}
</h2>
<h:form>
<h:form>
<h:dataTable
styleClass=
"bordertable"
rowClasses=
"roweven,rowodd"
id=
"compolisttable"
value=
"#{compoMgmtView.entries}"
var=
"entry"
>
<p:dataTable
styleClass=
"bordertable"
rowClasses=
"roweven,rowodd"
id=
"compolisttable"
value=
"#{compoMgmtView.entries}"
var=
"entry"
>
<h:column>
<p:column
headerText=
"Title"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"Title"
/>
</f:facet>
<h:outputText
value=
"#{entry.title}"
/>
<h:outputText
value=
"#{entry.title}"
/>
</h:column>
</p:column>
<h:column>
<p:column
headerText=
"Author"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"Author"
/>
</f:facet>
<h:outputText
value=
"#{entry.author}"
/>
<h:outputText
value=
"#{entry.author}"
/>
</h:column>
</p:column>
<h:column>
<p:column
headerText=
"Notes"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"notes"
/>
</f:facet>
<h:outputText
value=
"#{entry.notes}"
/>
<h:outputText
value=
"#{entry.notes}"
/>
</h:column>
</p:column>
<h:column>
<p:column
headerText=
"Screenmessage"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"screenmessage"
/>
</f:facet>
<h:outputText
value=
"#{entry.screenMessage}"
/>
<h:outputText
value=
"#{entry.screenMessage}"
/>
</h:column>
</p:column>
<h:column>
<p:column
headerText=
"creator"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"creator"
/>
</f:facet>
<h:link
outcome=
"/useradmin/edit"
value=
"#{entry.creator.user.nick}"
>
<h:link
outcome=
"/useradmin/edit"
value=
"#{entry.creator.user.nick}"
>
<f:param
name=
"userid"
value=
"#{entry.creator.user.id}"
/>
<f:param
name=
"userid"
value=
"#{entry.creator.user.id}"
/>
</h:link>
</h:link>
</h:column>
</p:column>
<h:column>
<p:column
headerText=
"Sort"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"sort"
/>
</f:facet>
<h:inputText
value=
"#{entry.sort}"
size=
"4"
/>
<h:inputText
value=
"#{entry.sort}"
size=
"4"
/>
</h:column>
</p:column>
<h:column>
<p:column
headerText=
"Vote total"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"Vote total"
/>
</f:facet>
<h:outputText
value=
"#{entry.votetotal}"
/>
<h:outputText
value=
"#{entry.votetotal}"
/>
</h:column>
</p:column>
<h:column>
<p:column
headerText=
"Vote count"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"Vote count"
/>
</f:facet>
<h:outputText
value=
"#{entry.votes.size()}"
/>
<h:outputText
value=
"#{entry.votes.size()}"
/>
</
h
:column>
</
p
:column>
<
h
:column>
<
p
:column>
<h:link
outcome=
"/voting/submitEntry"
value=
"#{i18n['entry.edit']}"
>
<h:link
outcome=
"/voting/submitEntry"
value=
"#{i18n['entry.edit']}"
>
<f:param
name=
"entryId"
value=
"#{entry.id}"
/>
<f:param
name=
"entryId"
value=
"#{entry.id}"
/>
</h:link>
</h:link>
</
h
:column>
</
p
:column>
</
h
:dataTable>
</
p
:dataTable>
<h:commandButton
action=
"#{compoMgmtView.saveSort}"
value=
"#{i18n['compo.savesort']}"
/>
<h:commandButton
action=
"#{compoMgmtView.saveSort}"
value=
"#{i18n['compo.savesort']}"
/>
</h:form>
</h:form>
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/flow/FlowUserContainer.java
0 → 100644
View file @
f770932
package
fi
.
codecrew
.
moya
.
web
.
flow
;
import
javax.enterprise.context.SessionScoped
;
import
javax.inject.Named
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
/**
* Place to store userid between pageloads
* @author tuukka
*
*/
@Named
@SessionScoped
public
class
FlowUserContainer
extends
GenericCDIView
{
private
static
final
long
serialVersionUID
=
802344850073689859L
;
private
Integer
userId
;
/**
* Get current userid, remember to clear this, so there is no weird bugs
* @return
*/
public
Integer
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
}
}
code/MoyaWeb/src/fi/codecrew/moya/web/flow/IncomingView.java
View file @
f770932
...
@@ -56,6 +56,10 @@ public class IncomingView extends GenericCDIView {
...
@@ -56,6 +56,10 @@ public class IncomingView extends GenericCDIView {
@Inject
@Inject
private
ReaderNameContainer
namecontainer
;
private
ReaderNameContainer
namecontainer
;
@Inject
private
FlowUserContainer
flowUserContainer
;
@EJB
@EJB
private
BarcodeBeanLocal
barcodeBean
;
private
BarcodeBeanLocal
barcodeBean
;
...
@@ -127,6 +131,14 @@ public class IncomingView extends GenericCDIView {
...
@@ -127,6 +131,14 @@ public class IncomingView extends GenericCDIView {
if
(!
initialized
)
{
if
(!
initialized
)
{
logger
.
debug
(
"INITIALIZING!!!!"
);
logger
.
debug
(
"INITIALIZING!!!!"
);
if
(
flowUserContainer
.
getUserId
()
!=
null
&&
flowUserContainer
.
getUserId
()
>
0
)
{
userview
.
setUserid
(
flowUserContainer
.
getUserId
());
}
flowUserContainer
.
setUserId
(
null
);
// initializePoller();
// initializePoller();
initialized
=
true
;
initialized
=
true
;
super
.
beginConversation
();
super
.
beginConversation
();
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/flow/flowShopView.java
View file @
f770932
...
@@ -45,6 +45,9 @@ public class flowShopView extends GenericCDIView {
...
@@ -45,6 +45,9 @@ public class flowShopView extends GenericCDIView {
@Inject
@Inject
private
ReaderView
readerView
;
private
ReaderView
readerView
;
@Inject
private
FlowUserContainer
flowUserContainer
;
public
void
initView
()
{
public
void
initView
()
{
if
(
userId
==
null
||
userId
==
0
)
{
if
(
userId
==
null
||
userId
==
0
)
{
...
@@ -68,8 +71,10 @@ public class flowShopView extends GenericCDIView {
...
@@ -68,8 +71,10 @@ public class flowShopView extends GenericCDIView {
public
void
changeUser
(
SelectEvent
event
)
{
public
void
changeUser
(
SelectEvent
event
)
{
if
(
infoView
.
getMultiSearchUser
()
!=
null
)
{
if
(
infoView
.
getMultiSearchUser
()
!=
null
)
{
flowUserContainer
.
setUserId
(
infoView
.
getMultiSearchUser
().
getUser
().
getId
());
super
.
navihandler
.
redirectNavigation
(
"shop.jsf?userid="
+
infoView
.
getMultiSearchUser
().
getUser
().
getId
());
super
.
navihandler
.
redirectNavigation
(
"shop.jsf?userid="
+
infoView
.
getMultiSearchUser
().
getUser
().
getId
());
infoView
.
setMultiSearchUser
(
null
);
}
}
}
}
...
@@ -89,6 +94,7 @@ public class flowShopView extends GenericCDIView {
...
@@ -89,6 +94,7 @@ public class flowShopView extends GenericCDIView {
if
(!
user
.
equals
(
userView
.
getUser
()))
{
if
(!
user
.
equals
(
userView
.
getUser
()))
{
logger
.
info
(
"found user {}, redirecting"
,
user
.
getNick
());
logger
.
info
(
"found user {}, redirecting"
,
user
.
getNick
());
userView
.
setUser
(
user
);
userView
.
setUser
(
user
);
flowUserContainer
.
setUserId
(
user
.
getUser
().
getId
());
super
.
navihandler
.
redirectNavigation
(
"shop.jsf?userid="
+
user
.
getUser
().
getId
());
super
.
navihandler
.
redirectNavigation
(
"shop.jsf?userid="
+
user
.
getUser
().
getId
());
}
}
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/helper/
f
ieldsetView.java
→
code/MoyaWeb/src/fi/codecrew/moya/web/helper/
F
ieldsetView.java
View file @
f770932
...
@@ -14,10 +14,10 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
...
@@ -14,10 +14,10 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@Named
@SessionScoped
@SessionScoped
public
class
f
ieldsetView
extends
GenericCDIView
{
public
class
F
ieldsetView
extends
GenericCDIView
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
f
ieldsetView
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
F
ieldsetView
.
class
);
private
static
final
long
serialVersionUID
=
5L
;
private
static
final
long
serialVersionUID
=
5L
;
...
...
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