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 8ee9667b
authored
Oct 26, 2012
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hurr.. Kaupan optimointia...
1 parent
698607d0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
8 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/ProductBean.java
code/LanBortalWeb/WebContent/foodmanager/listOrders.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/ProductShopView.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/ProductBean.java
View file @
8ee9667
...
...
@@ -4,9 +4,11 @@ import java.math.BigDecimal;
import
java.math.RoundingMode
;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
javax.annotation.security.DeclareRoles
;
import
javax.annotation.security.RolesAllowed
;
...
...
@@ -141,11 +143,12 @@ public class ProductBean implements ProductBeanLocal {
@Override
public
HashMap
<
Integer
,
BigDecimal
>
getProductLimit
(
Map
<
Integer
,
BigDecimal
>
prodCounts
,
EventUser
user
)
{
Set
<
Role
>
userroles
=
new
HashSet
<
Role
>(
userbean
.
findUsersRoles
(
user
));
HashMap
<
Integer
,
BigDecimal
>
ret
=
new
HashMap
<
Integer
,
BigDecimal
>();
for
(
Entry
<
Integer
,
BigDecimal
>
pc
:
prodCounts
.
entrySet
())
{
Product
prod
=
productFacade
.
find
(
pc
.
getKey
());
BigDecimal
lim
=
getPr
oductLimit
(
prod
,
user
,
prodCount
s
);
BigDecimal
lim
=
getPr
ivateProductLimit
(
prod
,
user
,
prodCounts
,
userrole
s
);
ret
.
put
(
prod
.
getId
(),
lim
);
// logger.info("Added product limit {} to {}", lim, prod);
}
...
...
@@ -157,9 +160,13 @@ public class ProductBean implements ProductBeanLocal {
public
BigDecimal
getProductLimit
(
Product
product
,
EventUser
user
,
Map
<
Integer
,
BigDecimal
>
prodCounts
)
{
product
=
productFacade
.
reload
(
product
);
List
<
Role
>
userroles
=
userbean
.
findUsersRoles
(
user
);
BigDecimal
ret
=
null
;
HashSet
<
Role
>
userroles
=
new
HashSet
<
Role
>(
userbean
.
findUsersRoles
(
user
));
return
getPrivateProductLimit
(
product
,
user
,
prodCounts
,
userroles
);
}
private
BigDecimal
getPrivateProductLimit
(
Product
product
,
EventUser
user
,
Map
<
Integer
,
BigDecimal
>
prodCounts
,
Set
<
Role
>
userroles
)
{
BigDecimal
ret
=
null
;
if
(
product
!=
null
&&
product
.
getProductLimits
()
!=
null
)
{
...
...
code/LanBortalWeb/WebContent/foodmanager/listOrders.xhtml
View file @
8ee9667
...
...
@@ -131,7 +131,7 @@
<f:facet
name=
"header"
>
<h:outputLabel
value=
"#{i18n['accountEvent.delivered']}"
/>
</f:facet>
<h:outputText
rendered=
"#{acc_line.
d
elivered}"
value=
"#{i18n['accountEvent.delivered']}"
/>
<h:outputText
rendered=
"#{acc_line.
eventD
elivered}"
value=
"#{i18n['accountEvent.delivered']}"
/>
<h:commandButton
rendered=
"#{not acc_line.eventDelivered}"
value=
"#{i18n['accountEvent.deliver']}"
action=
"#{foodWaveView.deliverAccountEvent}"
/>
</p:column>
</p:dataTable>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/ProductShopView.java
View file @
8ee9667
...
...
@@ -2,6 +2,7 @@ package fi.insomnia.bortal.web.cdiview.shop;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
...
...
@@ -33,8 +34,7 @@ import fi.insomnia.bortal.web.helpers.ProductShopItem;
@ConversationScoped
public
class
ProductShopView
extends
GenericCDIView
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ProductShopView
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ProductShopView
.
class
);
/**
*
*/
...
...
@@ -102,11 +102,16 @@ public class ProductShopView extends GenericCDIView {
}
}
long
logtime
;
public
String
add
(
Integer
count
)
{
logtime
=
Calendar
.
getInstance
().
getTimeInMillis
();
ProductShopItem
item
=
shoppingcart
.
getRowData
();
item
.
setCount
(
item
.
getCount
().
add
(
BigDecimal
.
valueOf
(
count
)));
logger
.
debug
(
"product add count {}"
,
Calendar
.
getInstance
().
getTimeInMillis
()
-
logtime
);
updateCartLimits
(
item
);
logger
.
debug
(
"Updated cartLimits count {}"
,
Calendar
.
getInstance
().
getTimeInMillis
()
-
logtime
);
return
null
;
}
...
...
@@ -139,14 +144,16 @@ public class ProductShopView extends GenericCDIView {
if
(
item
!=
null
&&
!
listdata
.
contains
(
item
))
{
listdata
.
add
(
item
);
}
logger
.
debug
(
"update 1 {}"
,
Calendar
.
getInstance
().
getTimeInMillis
()
-
logtime
);
Map
<
Integer
,
BigDecimal
>
prodCounts
=
new
HashMap
<
Integer
,
BigDecimal
>();
for
(
ProductShopItem
sc
:
shoppingcart
)
{
prodCounts
.
put
(
sc
.
getProduct
().
getId
(),
sc
.
getCount
());
}
logger
.
debug
(
"update 2 {}"
,
Calendar
.
getInstance
().
getTimeInMillis
()
-
logtime
);
HashMap
<
Integer
,
BigDecimal
>
limits
=
productBean
.
getProductLimit
(
prodCounts
,
user
);
HashMap
<
Integer
,
BigDecimal
>
limits
=
productBean
.
getProductLimit
(
prodCounts
,
user
);
logger
.
debug
(
"update 4 {}"
,
Calendar
.
getInstance
().
getTimeInMillis
()
-
logtime
);
// Update the updated cart first
if
(
item
!=
null
)
...
...
@@ -158,6 +165,7 @@ public class ProductShopView extends GenericCDIView {
return
;
}
}
logger
.
debug
(
"update 5 {}"
,
Calendar
.
getInstance
().
getTimeInMillis
()
-
logtime
);
for
(
ProductShopItem
n
:
shoppingcart
)
{
BigDecimal
l
=
limits
.
get
(
n
.
getProduct
().
getId
());
...
...
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