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 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
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
502 additions
and
418 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
...
...
@@ -30,7 +30,7 @@ public class ProductPBean {
@EJB
private
PermissionBean
permbean
;
@EJB
private
DiscountBean
discountBean
;
@EJB
...
...
@@ -100,10 +100,8 @@ public class ProductPBean {
// discountinstancefacade.create(discInst);
accEventdiscounts
.
add
(
new
DiscountInstance
(
ret
,
d
));
}
if
(
user
.
getAccountEvents
()
==
null
)
{
user
.
setAccountEvents
(
new
ArrayList
<
AccountEvent
>());
}
user
.
getAccountEvents
().
add
(
ret
);
user
.
addAccountevent
(
ret
);
accounteventfacade
.
create
(
ret
);
logger
.
debug
(
"create ac {} for user {}"
,
ret
,
user
.
getUser
());
// flush changes to db.
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/UserBean.java
View file @
1a4f03e
...
...
@@ -7,6 +7,7 @@ import java.io.ByteArrayInputStream;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
...
...
@@ -31,6 +32,7 @@ import org.slf4j.LoggerFactory;
import
fi.codecrew.moya.enums.apps.SpecialPermission
;
import
fi.codecrew.moya.enums.apps.UserPermission
;
import
fi.codecrew.moya.facade.AccountEventFacade
;
import
fi.codecrew.moya.facade.ApprovalFacade
;
import
fi.codecrew.moya.facade.EventUserFacade
;
import
fi.codecrew.moya.facade.FeedbackFacade
;
...
...
@@ -41,6 +43,7 @@ import fi.codecrew.moya.facade.RoleFacade;
import
fi.codecrew.moya.facade.UserApprovalFacade
;
import
fi.codecrew.moya.facade.UserFacade
;
import
fi.codecrew.moya.facade.UserImageFacade
;
import
fi.codecrew.moya.model.AccountEvent
;
import
fi.codecrew.moya.model.Approval
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.Feedback
;
...
...
@@ -51,6 +54,7 @@ import fi.codecrew.moya.model.LanEvent;
import
fi.codecrew.moya.model.LanEventPropertyKey
;
import
fi.codecrew.moya.model.PlaceGroup
;
import
fi.codecrew.moya.model.PrintedCard
;
import
fi.codecrew.moya.model.Product
;
import
fi.codecrew.moya.model.Role
;
import
fi.codecrew.moya.model.TournamentGame
;
import
fi.codecrew.moya.model.User
;
...
...
@@ -129,6 +133,10 @@ public class UserBean implements UserBeanLocal {
private
GameIDFacade
gameIDFacade
;
@EJB
private
ProductBeanLocal
productbean
;
@EJB
private
ProductPBean
productPrivateBean
;
@EJB
private
AccountEventFacade
accountEventFacade
;
@Override
@RolesAllowed
(
UserPermission
.
S_VIEW_ALL
)
...
...
@@ -791,4 +799,57 @@ public class UserBean implements UserBeanLocal {
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
...
...
@@ -36,430 +36,436 @@ import fi.codecrew.moya.enums.Gender;
@OptimisticLocking
(
type
=
OptimisticLockingType
.
CHANGED_COLUMNS
)
public
class
EventUser
extends
GenericEntity
{
protected
static
final
String
USER_ID_COLUMN
=
"user_id"
;
protected
static
final
String
EVENT_ID_COLUMN
=
"event_id"
;
protected
static
final
String
USER_ID_COLUMN
=
"user_id"
;
protected
static
final
String
EVENT_ID_COLUMN
=
"event_id"
;
@ManyToOne
(
cascade
=
{
PERSIST
,
MERGE
,
REFRESH
,
DETACH
})
@JoinColumn
(
nullable
=
false
,
name
=
USER_ID_COLUMN
)
private
User
user
;
@ManyToOne
(
cascade
=
{
PERSIST
,
MERGE
,
REFRESH
,
DETACH
})
@JoinColumn
(
nullable
=
false
,
name
=
USER_ID_COLUMN
)
private
User
user
;
@ManyToOne
@JoinColumn
(
nullable
=
false
,
name
=
EVENT_ID_COLUMN
)
private
LanEvent
event
;
@ManyToOne
@JoinColumn
(
nullable
=
false
,
name
=
EVENT_ID_COLUMN
)
private
LanEvent
event
;
private
static
final
long
serialVersionUID
=
6042691271548196815L
;
private
static
final
long
serialVersionUID
=
6042691271548196815L
;
@OneToMany
(
mappedBy
=
"voter"
)
private
List
<
Vote
>
votes
;
@OneToMany
(
mappedBy
=
"voter"
)
private
List
<
Vote
>
votes
;
@OneToMany
(
mappedBy
=
"user"
,
cascade
=
CascadeType
.
ALL
)
private
List
<
UserNote
>
notes
;
@OneToMany
(
mappedBy
=
"user"
,
cascade
=
CascadeType
.
ALL
)
private
List
<
UserNote
>
notes
;
@ManyToMany
(
mappedBy
=
"users"
)
private
List
<
Role
>
roles
=
new
ArrayList
<
Role
>();
@ManyToMany
(
mappedBy
=
"users"
)
private
List
<
Role
>
roles
=
new
ArrayList
<
Role
>();
@OneToMany
(
mappedBy
=
"user"
)
private
List
<
CompoEntryParticipant
>
compoEntryParticipants
;
@OneToMany
(
mappedBy
=
"user"
)
private
List
<
CompoEntryParticipant
>
compoEntryParticipants
;
@OneToMany
(
mappedBy
=
"creator"
)
@OrderBy
()
private
List
<
CompoEntry
>
compoEntries
;
@OneToMany
(
mappedBy
=
"creator"
)
@OrderBy
()
private
List
<
CompoEntry
>
compoEntries
;
@OneToMany
(
mappedBy
=
"creator"
,
cascade
=
CascadeType
.
ALL
)
private
List
<
PlaceGroup
>
placeGroups
=
new
ArrayList
<
PlaceGroup
>();
@OneToMany
(
mappedBy
=
"creator"
,
cascade
=
CascadeType
.
ALL
)
private
List
<
PlaceGroup
>
placeGroups
=
new
ArrayList
<
PlaceGroup
>();
@OneToMany
(
mappedBy
=
"user"
)
@OrderBy
private
List
<
GroupMembership
>
groupMemberships
;
@OneToMany
(
mappedBy
=
"user"
)
@OrderBy
private
List
<
GroupMembership
>
groupMemberships
;
/**
* The places this user has registered into.
*/
@OneToMany
(
mappedBy
=
"currentUser"
,
fetch
=
FetchType
.
LAZY
)
@OrderBy
()
private
List
<
Place
>
currentPlaces
;
/**
* The places this user has registered into.
*/
@OneToMany
(
mappedBy
=
"currentUser"
,
fetch
=
FetchType
.
LAZY
)
@OrderBy
()
private
List
<
Place
>
currentPlaces
;
@OneToMany
(
cascade
=
CascadeType
.
ALL
,
mappedBy
=
"user"
)
private
List
<
PrintedCard
>
printedCards
;
@OneToMany
(
cascade
=
CascadeType
.
ALL
,
mappedBy
=
"user"
)
private
List
<
PrintedCard
>
printedCards
;
@OneToMany
(
mappedBy
=
"user"
)
@OrderBy
()
private
List
<
AccountEvent
>
accountEvents
;
@OneToMany
(
mappedBy
=
"user"
)
@OrderBy
()
private
List
<
Bill
>
bills
;
@OneToMany
(
mappedBy
=
"seller"
)
@OrderBy
(
AccountEvent
.
ID_COLUMN
)
private
List
<
AccountEvent
>
soldItems
;
@OneToMany
(
mappedBy
=
"user"
)
private
List
<
PollAnswer
>
pollAnswers
;
@ManyToOne
()
@JoinColumn
(
name
=
"creator"
)
private
EventUser
creator
;
@Temporal
(
TemporalType
.
TIMESTAMP
)
@Column
(
name
=
"createtime"
,
nullable
=
false
,
updatable
=
false
)
private
Date
eventuserCreated
;
@OneToMany
(
mappedBy
=
"eventUser"
)
private
List
<
GameID
>
gameIDs
;
public
List
<
GameID
>
getGameIDs
()
{
return
gameIDs
;
}
public
void
setGameIDs
(
List
<
GameID
>
gameIDs
)
{
this
.
gameIDs
=
gameIDs
;
}
public
EventUser
getCreator
()
{
return
creator
;
}
public
void
setCreator
(
EventUser
creator
)
{
this
.
creator
=
creator
;
}
public
Date
getEventuserCreated
()
{
return
eventuserCreated
;
}
public
void
setEventuserCreated
(
Date
eventuserCreated
)
{
this
.
eventuserCreated
=
eventuserCreated
;
}
public
EventUser
()
{
super
();
}
public
EventUser
(
User
usr
,
LanEvent
evnt
,
EventUser
usercreator
)
{
super
();
this
.
eventuserCreated
=
new
Date
();
this
.
creator
=
usercreator
;
this
.
user
=
usr
;
this
.
event
=
evnt
;
}
public
User
getUser
()
{
return
user
;
}
public
void
setUser
(
User
user
)
{
this
.
user
=
user
;
}
public
LanEvent
getEvent
()
{
return
event
;
}
public
void
setEvent
(
LanEvent
event
)
{
this
.
event
=
event
;
}
public
List
<
Vote
>
getVotes
()
{
return
votes
;
}
public
void
setVotes
(
List
<
Vote
>
votes
)
{
this
.
votes
=
votes
;
}
public
List
<
UserNote
>
getNotes
()
{
return
notes
;
}
public
void
setNotes
(
List
<
UserNote
>
notes
)
{
this
.
notes
=
notes
;
}
/**
* NOTICE: This returns only manually added roles. If you want to get all
* roles from products, places, etc, use
* {@link fi.codecrew.moya.beans.UserBeanLocal#findUsersRoles(EventUser)
* UserBeanLocal#findUsersRoles(EventUser) }
*
* @return
*/
public
List
<
Role
>
getRoles
()
{
return
roles
;
}
public
void
setRoles
(
List
<
Role
>
roles
)
{
this
.
roles
=
roles
;
}
public
List
<
CompoEntryParticipant
>
getCompoEntryParticipants
()
{
return
compoEntryParticipants
;
}
public
void
setCompoEntryParticipants
(
List
<
CompoEntryParticipant
>
compoEntryParticipants
)
{
this
.
compoEntryParticipants
=
compoEntryParticipants
;
}
public
List
<
CompoEntry
>
getCompoEntries
()
{
return
compoEntries
;
}
public
void
setCompoEntries
(
List
<
CompoEntry
>
compoEntries
)
{
this
.
compoEntries
=
compoEntries
;
}
public
List
<
PlaceGroup
>
getPlaceGroups
()
{
return
placeGroups
;
}
public
void
setPlaceGroups
(
List
<
PlaceGroup
>
placeGroups
)
{
this
.
placeGroups
=
placeGroups
;
}
public
List
<
GroupMembership
>
getGroupMemberships
()
{
return
groupMemberships
;
}
public
void
setGroupMemberships
(
List
<
GroupMembership
>
groupMemberships
)
{
this
.
groupMemberships
=
groupMemberships
;
}
public
List
<
Place
>
getCurrentPlaces
()
{
return
currentPlaces
;
}
public
void
setCurrentPlaces
(
List
<
Place
>
currentPlaces
)
{
this
.
currentPlaces
=
currentPlaces
;
}
public
List
<
PrintedCard
>
getPrintedCards
()
{
return
printedCards
;
}
public
void
setPrintedCards
(
List
<
PrintedCard
>
printedCards
)
{
this
.
printedCards
=
printedCards
;
}
public
List
<
AccountEvent
>
getAccountEvents
()
{
return
accountEvents
;
}
public
void
setAccountEvents
(
List
<
AccountEvent
>
accountEvents
)
{
this
.
accountEvents
=
accountEvents
;
}
public
List
<
Bill
>
getBills
()
{
return
bills
;
}
public
void
setBills
(
List
<
Bill
>
bills
)
{
this
.
bills
=
bills
;
}
public
List
<
AccountEvent
>
getSoldItems
()
{
return
soldItems
;
}
public
void
setSoldItems
(
List
<
AccountEvent
>
soldItems
)
{
this
.
soldItems
=
soldItems
;
}
public
List
<
PollAnswer
>
getPollAnswers
()
{
return
pollAnswers
;
}
public
void
setPollAnswers
(
List
<
PollAnswer
>
pollAnswers
)
{
this
.
pollAnswers
=
pollAnswers
;
}
public
void
setCreated
(
Calendar
created
)
{
user
.
setCreated
(
created
);
}
public
boolean
getActive
()
{
return
user
.
getActive
();
}
public
void
setActive
(
boolean
active
)
{
user
.
setActive
(
active
);
}
@OneToMany
(
mappedBy
=
"user"
)
@OrderBy
()
private
List
<
AccountEvent
>
accountEvents
;
@OneToMany
(
mappedBy
=
"user"
)
@OrderBy
()
private
List
<
Bill
>
bills
;
@OneToMany
(
mappedBy
=
"seller"
)
@OrderBy
(
AccountEvent
.
ID_COLUMN
)
private
List
<
AccountEvent
>
soldItems
;
@OneToMany
(
mappedBy
=
"user"
)
private
List
<
PollAnswer
>
pollAnswers
;
@ManyToOne
()
@JoinColumn
(
name
=
"creator"
)
private
EventUser
creator
;
@Temporal
(
TemporalType
.
TIMESTAMP
)
@Column
(
name
=
"createtime"
,
nullable
=
false
,
updatable
=
false
)
private
Date
eventuserCreated
;
@OneToMany
(
mappedBy
=
"eventUser"
)
private
List
<
GameID
>
gameIDs
;
public
List
<
GameID
>
getGameIDs
()
{
return
gameIDs
;
}
public
void
setGameIDs
(
List
<
GameID
>
gameIDs
)
{
this
.
gameIDs
=
gameIDs
;
}
public
EventUser
getCreator
()
{
return
creator
;
}
public
void
setCreator
(
EventUser
creator
)
{
this
.
creator
=
creator
;
}
public
Date
getEventuserCreated
()
{
return
eventuserCreated
;
}
public
void
setEventuserCreated
(
Date
eventuserCreated
)
{
this
.
eventuserCreated
=
eventuserCreated
;
}
public
EventUser
()
{
super
();
}
public
EventUser
(
User
usr
,
LanEvent
evnt
,
EventUser
usercreator
)
{
super
();
this
.
eventuserCreated
=
new
Date
();
this
.
creator
=
usercreator
;
this
.
user
=
usr
;
this
.
event
=
evnt
;
}
public
User
getUser
()
{
return
user
;
}
public
void
setUser
(
User
user
)
{
this
.
user
=
user
;
}
public
LanEvent
getEvent
()
{
return
event
;
}
public
void
setEvent
(
LanEvent
event
)
{
this
.
event
=
event
;
}
public
List
<
Vote
>
getVotes
()
{
return
votes
;
}
public
void
setVotes
(
List
<
Vote
>
votes
)
{
this
.
votes
=
votes
;
}
public
List
<
UserNote
>
getNotes
()
{
return
notes
;
}
public
void
setNotes
(
List
<
UserNote
>
notes
)
{
this
.
notes
=
notes
;
}
/**
* NOTICE: This returns only manually added roles. If you want to get all
* roles from products, places, etc, use
* {@link fi.codecrew.moya.beans.UserBeanLocal#findUsersRoles(EventUser)
* UserBeanLocal#findUsersRoles(EventUser) }
*
* @return
*/
public
List
<
Role
>
getRoles
()
{
return
roles
;
}
public
void
setRoles
(
List
<
Role
>
roles
)
{
this
.
roles
=
roles
;
}
public
List
<
CompoEntryParticipant
>
getCompoEntryParticipants
()
{
return
compoEntryParticipants
;
}
public
void
setCompoEntryParticipants
(
List
<
CompoEntryParticipant
>
compoEntryParticipants
)
{
this
.
compoEntryParticipants
=
compoEntryParticipants
;
}
public
List
<
CompoEntry
>
getCompoEntries
()
{
return
compoEntries
;
}
public
void
setCompoEntries
(
List
<
CompoEntry
>
compoEntries
)
{
this
.
compoEntries
=
compoEntries
;
}
public
List
<
PlaceGroup
>
getPlaceGroups
()
{
return
placeGroups
;
}
public
void
setPlaceGroups
(
List
<
PlaceGroup
>
placeGroups
)
{
this
.
placeGroups
=
placeGroups
;
}
public
List
<
GroupMembership
>
getGroupMemberships
()
{
return
groupMemberships
;
}
public
void
setGroupMemberships
(
List
<
GroupMembership
>
groupMemberships
)
{
this
.
groupMemberships
=
groupMemberships
;
}
public
List
<
Place
>
getCurrentPlaces
()
{
return
currentPlaces
;
}
public
void
setCurrentPlaces
(
List
<
Place
>
currentPlaces
)
{
this
.
currentPlaces
=
currentPlaces
;
}
public
List
<
PrintedCard
>
getPrintedCards
()
{
return
printedCards
;
}
public
void
setPrintedCards
(
List
<
PrintedCard
>
printedCards
)
{
this
.
printedCards
=
printedCards
;
}
public
List
<
AccountEvent
>
getAccountEvents
()
{
return
accountEvents
;
}
public
void
setAccountEvents
(
List
<
AccountEvent
>
accountEvents
)
{
this
.
accountEvents
=
accountEvents
;
}
public
List
<
Bill
>
getBills
()
{
return
bills
;
}
public
void
setBills
(
List
<
Bill
>
bills
)
{
this
.
bills
=
bills
;
}
public
List
<
AccountEvent
>
getSoldItems
()
{
return
soldItems
;
}
public
void
setSoldItems
(
List
<
AccountEvent
>
soldItems
)
{
this
.
soldItems
=
soldItems
;
}
public
List
<
PollAnswer
>
getPollAnswers
()
{
return
pollAnswers
;
}
public
void
setPollAnswers
(
List
<
PollAnswer
>
pollAnswers
)
{
this
.
pollAnswers
=
pollAnswers
;
}
public
void
setCreated
(
Calendar
created
)
{
user
.
setCreated
(
created
);
}
public
boolean
getActive
()
{
return
user
.
getActive
();
}
public
void
setActive
(
boolean
active
)
{
user
.
setActive
(
active
);
}
public
String
getPassword
()
{
return
user
.
getPassword
();
}
public
String
getPassword
()
{
return
user
.
getPassword
();
}
public
void
setPassword
(
String
password
)
{
user
.
setPassword
(
password
);
}
public
void
setPassword
(
String
password
)
{
user
.
setPassword
(
password
);
}
public
String
getWholeName
()
{
return
user
.
getWholeName
();
}
public
String
getWholeName
()
{
return
user
.
getWholeName
();
}
public
String
getLastname
()
{
return
user
.
getLastname
();
}
public
String
getLastname
()
{
return
user
.
getLastname
();
}
public
void
setLastname
(
String
lastname
)
{
user
.
setLastname
(
lastname
);
}
public
void
setLastname
(
String
lastname
)
{
user
.
setLastname
(
lastname
);
}
public
String
getFirstnames
()
{
return
user
.
getFirstnames
();
}
public
String
getFirstnames
()
{
return
user
.
getFirstnames
();
}
public
void
setFirstnames
(
String
firstnames
)
{
user
.
setFirstnames
(
firstnames
);
}
public
void
setFirstnames
(
String
firstnames
)
{
user
.
setFirstnames
(
firstnames
);
}
public
Date
getBirthday
()
{
return
user
.
getBirthday
();
}
public
Date
getBirthday
()
{
return
user
.
getBirthday
();
}
public
void
setBirthday
(
Date
birthday
)
{
user
.
setBirthday
(
birthday
);
}
public
void
setBirthday
(
Date
birthday
)
{
user
.
setBirthday
(
birthday
);
}
public
String
getNick
()
{
return
user
.
getNick
();
}
public
String
getNick
()
{
return
user
.
getNick
();
}
public
void
setNick
(
String
nick
)
{
user
.
setNick
(
nick
);
}
public
void
setNick
(
String
nick
)
{
user
.
setNick
(
nick
);
}
public
String
getEmail
()
{
return
user
.
getEmail
();
}
public
String
getEmail
()
{
return
user
.
getEmail
();
}
public
void
setEmail
(
String
email
)
{
user
.
setEmail
(
email
);
}
public
void
setEmail
(
String
email
)
{
user
.
setEmail
(
email
);
}
public
String
getAddress
()
{
return
user
.
getAddress
();
}
public
String
getAddress
()
{
return
user
.
getAddress
();
}
public
void
setAddress
(
String
address
)
{
user
.
setAddress
(
address
);
}
public
void
setAddress
(
String
address
)
{
user
.
setAddress
(
address
);
}
public
String
getZip
()
{
return
user
.
getZip
();
}
public
String
getZip
()
{
return
user
.
getZip
();
}
public
void
setZip
(
String
zip
)
{
user
.
setZip
(
zip
);
}
public
void
setZip
(
String
zip
)
{
user
.
setZip
(
zip
);
}
public
String
getTown
()
{
return
user
.
getTown
();
}
public
String
getTown
()
{
return
user
.
getTown
();
}
public
void
setTown
(
String
town
)
{
user
.
setTown
(
town
);
}
public
void
setTown
(
String
town
)
{
user
.
setTown
(
town
);
}
public
String
getPhone
()
{
return
user
.
getPhone
();
}
public
void
setPhone
(
String
phone
)
{
user
.
setPhone
(
phone
);
}
public
String
getLogin
()
{
return
user
.
getLogin
();
}
public
void
setLogin
(
String
login
)
{
user
.
setLogin
(
login
);
}
public
List
<
UserImage
>
getUserImageList
()
{
return
user
.
getUserImageList
();
}
public
void
setUserImageList
(
List
<
UserImage
>
userImageList
)
{
user
.
setUserImageList
(
userImageList
);
}
public
String
getConfirmHash
()
{
return
user
.
getConfirmHash
();
}
public
void
setConfirmHash
(
String
confirmHash
)
{
user
.
setConfirmHash
(
confirmHash
);
}
public
Calendar
getConfirmTime
()
{
return
user
.
getConfirmTime
();
}
public
void
setConfirmTime
(
Calendar
confirmTime
)
{
user
.
setConfirmTime
(
confirmTime
);
}
public
void
resetPassword
(
String
password
)
{
user
.
resetPassword
(
password
);
}
public
boolean
checkPassword
(
String
plainPassword
)
{
return
user
.
checkPassword
(
plainPassword
);
}
public
boolean
isSuperadmin
()
{
return
user
.
isSuperadmin
();
}
public
void
setPostalTown
(
String
postalTown
)
{
user
.
setPostalTown
(
postalTown
);
}
public
String
getPostalTown
()
{
return
user
.
getPostalTown
();
}
public
void
setGender
(
Gender
gender
)
{
user
.
setGender
(
gender
);
}
public
Gender
getGender
()
{
return
user
.
getGender
();
}
public
void
setCurrentImage
(
UserImage
currentImage
)
{
user
.
setCurrentImage
(
currentImage
);
}
public
UserImage
getCurrentImage
()
{
return
user
.
getCurrentImage
();
}
public
boolean
isAnonymous
()
{
return
user
.
isAnonymous
();
}
public
Calendar
getCreated
()
{
return
user
.
getCreated
();
}
public
BigDecimal
getAccountBalance
()
{
BigDecimal
ret
=
BigDecimal
.
ZERO
;
if
(
accountEvents
!=
null
)
{
for
(
AccountEvent
ac
:
accountEvents
)
{
ret
=
ret
.
add
(
ac
.
getTotal
()).
setScale
(
2
,
RoundingMode
.
HALF_UP
);
}
}
return
ret
;
}
public
String
getShortUserDescriptor
()
{
return
user
.
getShortUserDescriptor
();
}
public
String
getPhone
()
{
return
user
.
getPhone
();
}
public
void
setPhone
(
String
phone
)
{
user
.
setPhone
(
phone
);
}
public
String
getLogin
()
{
return
user
.
getLogin
();
}
public
void
setLogin
(
String
login
)
{
user
.
setLogin
(
login
);
}
public
List
<
UserImage
>
getUserImageList
()
{
return
user
.
getUserImageList
();
}
public
void
setUserImageList
(
List
<
UserImage
>
userImageList
)
{
user
.
setUserImageList
(
userImageList
);
}
public
String
getConfirmHash
()
{
return
user
.
getConfirmHash
();
}
public
void
setConfirmHash
(
String
confirmHash
)
{
user
.
setConfirmHash
(
confirmHash
);
}
public
Calendar
getConfirmTime
()
{
return
user
.
getConfirmTime
();
}
public
void
setConfirmTime
(
Calendar
confirmTime
)
{
user
.
setConfirmTime
(
confirmTime
);
}
public
void
resetPassword
(
String
password
)
{
user
.
resetPassword
(
password
);
}
public
boolean
checkPassword
(
String
plainPassword
)
{
return
user
.
checkPassword
(
plainPassword
);
}
public
boolean
isSuperadmin
()
{
return
user
.
isSuperadmin
();
}
public
void
setPostalTown
(
String
postalTown
)
{
user
.
setPostalTown
(
postalTown
);
}
public
String
getPostalTown
()
{
return
user
.
getPostalTown
();
}
public
void
setGender
(
Gender
gender
)
{
user
.
setGender
(
gender
);
}
public
Gender
getGender
()
{
return
user
.
getGender
();
}
public
void
setCurrentImage
(
UserImage
currentImage
)
{
user
.
setCurrentImage
(
currentImage
);
}
public
UserImage
getCurrentImage
()
{
return
user
.
getCurrentImage
();
}
public
boolean
isAnonymous
()
{
return
user
.
isAnonymous
();
}
public
Calendar
getCreated
()
{
return
user
.
getCreated
();
}
public
BigDecimal
getAccountBalance
()
{
BigDecimal
ret
=
BigDecimal
.
ZERO
;
if
(
accountEvents
!=
null
)
{
for
(
AccountEvent
ac
:
accountEvents
)
{
ret
=
ret
.
add
(
ac
.
getTotal
()).
setScale
(
2
,
RoundingMode
.
HALF_UP
);
}
}
return
ret
;
}
public
String
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 @@
<h:commandButton
value=
"#{i18n['usercart.downloadCsv']}"
>
<p:fileDownload
value=
"#{userCartView.downloadCsv}"
/>
</h:commandButton>
<h:commandButton
value=
"#{i18n['usercart.downloadExport']}"
>
<p:fileDownload
value=
"#{userCartView.userExport}"
/>
</h:commandButton>
<h:commandButton
action=
"#{userCartView.showOverview}"
value=
"#{i18n['usercart.showoverview']}"
/>
</div>
</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 {
@EJB
private
transient
EventBeanLocal
eventbean
;
public
void
cashChanged
()
{
payInstant
=
false
;
...
...
@@ -81,10 +79,10 @@ public class ProductShopView extends GenericCDIView {
@Inject
private
BillEditView
billEditView
;
@Inject
private
ProductShopItemHelper
psiHelper
;
public
ProductShopItemHelper
getPsiHelper
()
{
return
psiHelper
;
}
...
...
@@ -166,7 +164,7 @@ public class ProductShopView extends GenericCDIView {
public
String
add
(
Integer
count
)
{
ProductShopItem
item
=
shoppingcart
.
getRowData
();
psiHelper
.
setProductShopItemCount
(
item
,
item
.
getCount
().
add
(
BigDecimal
.
valueOf
(
count
)));
updateCartLimits
(
item
);
...
...
@@ -223,15 +221,15 @@ public class ProductShopView extends GenericCDIView {
if
(
l
!=
null
)
{
hasLimits
=
true
;
}
psiHelper
.
updateProductShopItemLimit
(
n
,
l
);
psiHelper
.
updateProductShopItemLimit
(
n
,
l
);
}
}
public
String
removeBought
()
{
ProductShopItem
row
=
boughtItems
.
getRowData
();
psiHelper
.
setProductShopItemCount
(
row
,
row
.
getCount
().
subtract
(
BigDecimal
.
ONE
));
updateCartLimits
(
row
);
return
null
;
...
...
@@ -428,8 +426,8 @@ public class ProductShopView extends GenericCDIView {
public
String
readCode
()
{
ReaderEvent
event
=
readerView
.
getReaderEvent
();
if
(
event
==
null
)
{
if
(
event
==
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;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.GroupMembership
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
@Named
...
...
@@ -41,6 +42,23 @@ public class UserCartView extends GenericCDIView {
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
()
{
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -56,7 +74,7 @@ public class UserCartView extends GenericCDIView {
sb
.
append
(
"Zip"
).
append
(
CSV_SEPARATOR
);
sb
.
append
(
"City"
).
append
(
CSV_SEPARATOR
);
sb
.
append
(
"Places"
).
append
(
CSV_SEPARATOR
);
sb
.
append
(
"\n"
);
for
(
EventUser
uc
:
usercart
)
{
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/UserView.java
View file @
1a4f03e
...
...
@@ -39,7 +39,6 @@ import fi.codecrew.moya.model.Role;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.model.UserImage
;
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.SelectedUser
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
...
...
@@ -277,7 +276,8 @@ public class UserView extends GenericCDIView {
canSave
=
getCurrentUser
().
equals
(
user
)
||
permbean
.
hasPermission
(
UserPermission
.
MODIFY
);
this
.
beginConversation
();
logger
.
debug
(
"Accountevents for user {}"
,
user
.
getAccountEvents
().
size
());
if
(
user
.
getAccountEvents
()
!=
null
)
logger
.
debug
(
"Accountevents for user {}"
,
user
.
getAccountEvents
().
size
());
}
...
...
@@ -351,23 +351,22 @@ public class UserView extends GenericCDIView {
public
String
attachCodeToCard
()
{
return
attachCodeToCard
(
readerView
.
getReaderEvent
());
}
public
String
attachCodeToCard
(
ReaderEvent
event
)
{
if
(
event
==
null
)
public
String
attachCodeToCard
(
ReaderEvent
event
)
{
if
(
event
==
null
)
return
null
;
// already attached
if
(
event
.
getPrintedCard
()
!=
null
)
{
super
.
addFaceMessage
(
"usercard.alreadyassociated"
);
return
null
;
}
// still there, we can get real card and update it's barcodes
PrintedCard
card
=
cardBean
.
checkPrintedCard
(
user
);
readerbean
.
assocCodeToCard
(
event
,
card
);
readerbean
.
assocCodeToCard
(
event
,
card
);
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