Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Linnea Samila
/
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 1a4f03e3
authored
Apr 10, 2014
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added user export and initial accountevent moving
1 parent
fe44ba6d
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
97 additions
and
13 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/ProductPBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/UserBean.java
code/MoyaDatabase/src/fi/codecrew/moya/model/EventUser.java
code/MoyaWeb/WebContent/useradmin/list.xhtml
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/shop/ProductShopView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/UserCartView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/UserView.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/ProductPBean.java
View file @
1a4f03e
...
@@ -100,10 +100,8 @@ public class ProductPBean {
...
@@ -100,10 +100,8 @@ public class ProductPBean {
// discountinstancefacade.create(discInst);
// discountinstancefacade.create(discInst);
accEventdiscounts
.
add
(
new
DiscountInstance
(
ret
,
d
));
accEventdiscounts
.
add
(
new
DiscountInstance
(
ret
,
d
));
}
}
if
(
user
.
getAccountEvents
()
==
null
)
{
user
.
setAccountEvents
(
new
ArrayList
<
AccountEvent
>());
user
.
addAccountevent
(
ret
);
}
user
.
getAccountEvents
().
add
(
ret
);
accounteventfacade
.
create
(
ret
);
accounteventfacade
.
create
(
ret
);
logger
.
debug
(
"create ac {} for user {}"
,
ret
,
user
.
getUser
());
logger
.
debug
(
"create ac {} for user {}"
,
ret
,
user
.
getUser
());
// flush changes to db.
// flush changes to db.
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/UserBean.java
View file @
1a4f03e
...
@@ -7,6 +7,7 @@ import java.io.ByteArrayInputStream;
...
@@ -7,6 +7,7 @@ import java.io.ByteArrayInputStream;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
import
java.text.MessageFormat
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Calendar
;
...
@@ -31,6 +32,7 @@ import org.slf4j.LoggerFactory;
...
@@ -31,6 +32,7 @@ import org.slf4j.LoggerFactory;
import
fi.codecrew.moya.enums.apps.SpecialPermission
;
import
fi.codecrew.moya.enums.apps.SpecialPermission
;
import
fi.codecrew.moya.enums.apps.UserPermission
;
import
fi.codecrew.moya.enums.apps.UserPermission
;
import
fi.codecrew.moya.facade.AccountEventFacade
;
import
fi.codecrew.moya.facade.ApprovalFacade
;
import
fi.codecrew.moya.facade.ApprovalFacade
;
import
fi.codecrew.moya.facade.EventUserFacade
;
import
fi.codecrew.moya.facade.EventUserFacade
;
import
fi.codecrew.moya.facade.FeedbackFacade
;
import
fi.codecrew.moya.facade.FeedbackFacade
;
...
@@ -41,6 +43,7 @@ import fi.codecrew.moya.facade.RoleFacade;
...
@@ -41,6 +43,7 @@ import fi.codecrew.moya.facade.RoleFacade;
import
fi.codecrew.moya.facade.UserApprovalFacade
;
import
fi.codecrew.moya.facade.UserApprovalFacade
;
import
fi.codecrew.moya.facade.UserFacade
;
import
fi.codecrew.moya.facade.UserFacade
;
import
fi.codecrew.moya.facade.UserImageFacade
;
import
fi.codecrew.moya.facade.UserImageFacade
;
import
fi.codecrew.moya.model.AccountEvent
;
import
fi.codecrew.moya.model.Approval
;
import
fi.codecrew.moya.model.Approval
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.Feedback
;
import
fi.codecrew.moya.model.Feedback
;
...
@@ -51,6 +54,7 @@ import fi.codecrew.moya.model.LanEvent;
...
@@ -51,6 +54,7 @@ import fi.codecrew.moya.model.LanEvent;
import
fi.codecrew.moya.model.LanEventPropertyKey
;
import
fi.codecrew.moya.model.LanEventPropertyKey
;
import
fi.codecrew.moya.model.PlaceGroup
;
import
fi.codecrew.moya.model.PlaceGroup
;
import
fi.codecrew.moya.model.PrintedCard
;
import
fi.codecrew.moya.model.PrintedCard
;
import
fi.codecrew.moya.model.Product
;
import
fi.codecrew.moya.model.Role
;
import
fi.codecrew.moya.model.Role
;
import
fi.codecrew.moya.model.TournamentGame
;
import
fi.codecrew.moya.model.TournamentGame
;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.model.User
;
...
@@ -129,6 +133,10 @@ public class UserBean implements UserBeanLocal {
...
@@ -129,6 +133,10 @@ public class UserBean implements UserBeanLocal {
private
GameIDFacade
gameIDFacade
;
private
GameIDFacade
gameIDFacade
;
@EJB
@EJB
private
ProductBeanLocal
productbean
;
private
ProductBeanLocal
productbean
;
@EJB
private
ProductPBean
productPrivateBean
;
@EJB
private
AccountEventFacade
accountEventFacade
;
@Override
@Override
@RolesAllowed
(
UserPermission
.
S_VIEW_ALL
)
@RolesAllowed
(
UserPermission
.
S_VIEW_ALL
)
...
@@ -791,4 +799,57 @@ public class UserBean implements UserBeanLocal {
...
@@ -791,4 +799,57 @@ public class UserBean implements UserBeanLocal {
return
ret
;
return
ret
;
}
}
/**
* Transfers account saldo from previous event. Creates negative
* accountevent for source user and positive for dst user. There are few
* requirements.
* <ul>
* <li>User must be the same.
* <li>Organisation must be the same.
* </ul>
*
* @param source
* @param dst
* @return Saldo transferred. Zero if no transfer was made, Null if there
* was error..
*/
public
BigDecimal
transferAccountSaldoFromPreviousEvent
(
EventUser
source
,
EventUser
dst
)
{
if
(
source
==
null
||
dst
==
null
)
return
null
;
source
=
eventUserFacade
.
reload
(
source
);
dst
=
eventUserFacade
.
reload
(
dst
);
if
(!
source
.
getEvent
().
getOrganiser
().
equals
(
dst
.
getEvent
().
getOrganiser
()))
{
logger
.
warn
(
"Can not transfer funds between organisations!"
);
return
null
;
}
if
(!
source
.
getUser
().
equals
(
dst
.
getUser
()))
{
logger
.
warn
(
"Can not transfer accountenvets! Users should be the same!!! Source {}, dst {}"
,
source
.
getUser
(),
dst
.
getUser
());
return
null
;
}
Calendar
time
=
Calendar
.
getInstance
();
EventUser
seller
=
permbean
.
getCurrentUser
();
Product
credprod
=
productbean
.
findCreditProduct
();
BigDecimal
price
=
credprod
.
getPrice
().
negate
();
BigDecimal
srcBalance
=
source
.
getAccountBalance
();
// This should always
BigDecimal
count
=
srcBalance
.
divide
(
price
);
AccountEvent
srcacc
=
new
AccountEvent
(
source
,
credprod
,
price
,
count
.
negate
(),
time
);
srcacc
.
setDescription
(
"Credits transferred to: '"
+
dst
.
getEvent
().
getName
()
+
"'"
);
srcacc
.
setSeller
(
seller
);
source
.
addAccountevent
(
srcacc
);
accountEventFacade
.
create
(
srcacc
);
AccountEvent
dstacc
=
new
AccountEvent
(
source
,
credprod
,
price
,
count
,
time
);
dstacc
.
setDescription
(
"Credits transferred from: '"
+
source
.
getEvent
().
getName
()
+
"'"
);
dstacc
.
setSeller
(
seller
);
dst
.
addAccountevent
(
dstacc
);
accountEventFacade
.
create
(
dstacc
);
return
srcBalance
;
}
}
}
\ No newline at end of file
code/MoyaDatabase/src/fi/codecrew/moya/model/EventUser.java
View file @
1a4f03e
...
@@ -462,4 +462,10 @@ public class EventUser extends GenericEntity {
...
@@ -462,4 +462,10 @@ public class EventUser extends GenericEntity {
return
user
.
getShortUserDescriptor
();
return
user
.
getShortUserDescriptor
();
}
}
public
void
addAccountevent
(
AccountEvent
accountevent
)
{
if
(
accountEvents
==
null
)
{
accountEvents
=
new
ArrayList
<
AccountEvent
>();
}
accountEvents
.
add
(
accountevent
);
}
}
}
code/MoyaWeb/WebContent/useradmin/list.xhtml
View file @
1a4f03e
...
@@ -62,6 +62,9 @@
...
@@ -62,6 +62,9 @@
<h:commandButton
value=
"#{i18n['usercart.downloadCsv']}"
>
<h:commandButton
value=
"#{i18n['usercart.downloadCsv']}"
>
<p:fileDownload
value=
"#{userCartView.downloadCsv}"
/>
<p:fileDownload
value=
"#{userCartView.downloadCsv}"
/>
</h:commandButton>
</h:commandButton>
<h:commandButton
value=
"#{i18n['usercart.downloadExport']}"
>
<p:fileDownload
value=
"#{userCartView.userExport}"
/>
</h:commandButton>
<h:commandButton
action=
"#{userCartView.showOverview}"
value=
"#{i18n['usercart.showoverview']}"
/>
<h:commandButton
action=
"#{userCartView.showOverview}"
value=
"#{i18n['usercart.showoverview']}"
/>
</div>
</div>
</h:panelGroup>
</h:panelGroup>
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/shop/ProductShopView.java
View file @
1a4f03e
...
@@ -54,8 +54,6 @@ public class ProductShopView extends GenericCDIView {
...
@@ -54,8 +54,6 @@ public class ProductShopView extends GenericCDIView {
@EJB
@EJB
private
transient
EventBeanLocal
eventbean
;
private
transient
EventBeanLocal
eventbean
;
public
void
cashChanged
()
public
void
cashChanged
()
{
{
payInstant
=
false
;
payInstant
=
false
;
...
@@ -224,7 +222,7 @@ public class ProductShopView extends GenericCDIView {
...
@@ -224,7 +222,7 @@ public class ProductShopView extends GenericCDIView {
hasLimits
=
true
;
hasLimits
=
true
;
}
}
psiHelper
.
updateProductShopItemLimit
(
n
,
l
);
psiHelper
.
updateProductShopItemLimit
(
n
,
l
);
}
}
}
}
...
@@ -429,7 +427,7 @@ public class ProductShopView extends GenericCDIView {
...
@@ -429,7 +427,7 @@ public class ProductShopView extends GenericCDIView {
ReaderEvent
event
=
readerView
.
getReaderEvent
();
ReaderEvent
event
=
readerView
.
getReaderEvent
();
if
(
event
==
null
)
{
if
(
event
==
null
)
{
return
null
;
return
null
;
}
}
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/UserCartView.java
View file @
1a4f03e
...
@@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
...
@@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.GroupMembership
;
import
fi.codecrew.moya.model.GroupMembership
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
@Named
@Named
...
@@ -41,6 +42,23 @@ public class UserCartView extends GenericCDIView {
...
@@ -41,6 +42,23 @@ public class UserCartView extends GenericCDIView {
private
SimpleDateFormat
dateformat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
private
SimpleDateFormat
dateformat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
public
StreamedContent
getUserExport
()
{
StringBuilder
sb
=
new
StringBuilder
();
DefaultStreamedContent
ret
=
null
;
if
(
usercart
.
size
()
>
0
)
{
LanEvent
event
=
usercart
.
get
(
0
).
getEvent
();
for
(
EventUser
uc
:
usercart
)
{
sb
.
append
(
uc
.
getUser
().
getId
()).
append
(
";"
);
}
ret
=
new
DefaultStreamedContent
(
new
ByteArrayInputStream
(
sb
.
toString
().
getBytes
(
UTF8
)));
ret
.
setContentType
(
"text/csv"
);
ret
.
setName
(
event
.
getName
()
+
"userexport.dat"
);
}
return
ret
;
}
public
StreamedContent
getDownloadCsv
()
{
public
StreamedContent
getDownloadCsv
()
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/UserView.java
View file @
1a4f03e
...
@@ -39,7 +39,6 @@ import fi.codecrew.moya.model.Role;
...
@@ -39,7 +39,6 @@ import fi.codecrew.moya.model.Role;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.model.UserImage
;
import
fi.codecrew.moya.model.UserImage
;
import
fi.codecrew.moya.util.MassPrintResult
;
import
fi.codecrew.moya.util.MassPrintResult
;
import
fi.codecrew.moya.utilities.jsf.MessageHelper
;
import
fi.codecrew.moya.web.annotations.LoggedIn
;
import
fi.codecrew.moya.web.annotations.LoggedIn
;
import
fi.codecrew.moya.web.annotations.SelectedUser
;
import
fi.codecrew.moya.web.annotations.SelectedUser
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
...
@@ -277,6 +276,7 @@ public class UserView extends GenericCDIView {
...
@@ -277,6 +276,7 @@ public class UserView extends GenericCDIView {
canSave
=
getCurrentUser
().
equals
(
user
)
||
permbean
.
hasPermission
(
UserPermission
.
MODIFY
);
canSave
=
getCurrentUser
().
equals
(
user
)
||
permbean
.
hasPermission
(
UserPermission
.
MODIFY
);
this
.
beginConversation
();
this
.
beginConversation
();
if
(
user
.
getAccountEvents
()
!=
null
)
logger
.
debug
(
"Accountevents for user {}"
,
user
.
getAccountEvents
().
size
());
logger
.
debug
(
"Accountevents for user {}"
,
user
.
getAccountEvents
().
size
());
}
}
...
@@ -352,10 +352,9 @@ public class UserView extends GenericCDIView {
...
@@ -352,10 +352,9 @@ public class UserView extends GenericCDIView {
return
attachCodeToCard
(
readerView
.
getReaderEvent
());
return
attachCodeToCard
(
readerView
.
getReaderEvent
());
}
}
public
String
attachCodeToCard
(
ReaderEvent
event
)
{
public
String
attachCodeToCard
(
ReaderEvent
event
)
{
if
(
event
==
null
)
if
(
event
==
null
)
return
null
;
return
null
;
// already attached
// already attached
...
@@ -367,7 +366,7 @@ public class UserView extends GenericCDIView {
...
@@ -367,7 +366,7 @@ public class UserView extends GenericCDIView {
// still there, we can get real card and update it's barcodes
// still there, we can get real card and update it's barcodes
PrintedCard
card
=
cardBean
.
checkPrintedCard
(
user
);
PrintedCard
card
=
cardBean
.
checkPrintedCard
(
user
);
readerbean
.
assocCodeToCard
(
event
,
card
);
readerbean
.
assocCodeToCard
(
event
,
card
);
return
null
;
return
null
;
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment