Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Max Mecklin
/
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;
...
@@ -4,9 +4,11 @@ import java.math.BigDecimal;
import
java.math.RoundingMode
;
import
java.math.RoundingMode
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
javax.annotation.security.DeclareRoles
;
import
javax.annotation.security.DeclareRoles
;
import
javax.annotation.security.RolesAllowed
;
import
javax.annotation.security.RolesAllowed
;
...
@@ -141,11 +143,12 @@ public class ProductBean implements ProductBeanLocal {
...
@@ -141,11 +143,12 @@ public class ProductBean implements ProductBeanLocal {
@Override
@Override
public
HashMap
<
Integer
,
BigDecimal
>
getProductLimit
(
Map
<
Integer
,
BigDecimal
>
prodCounts
,
EventUser
user
)
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
>();
HashMap
<
Integer
,
BigDecimal
>
ret
=
new
HashMap
<
Integer
,
BigDecimal
>();
for
(
Entry
<
Integer
,
BigDecimal
>
pc
:
prodCounts
.
entrySet
())
for
(
Entry
<
Integer
,
BigDecimal
>
pc
:
prodCounts
.
entrySet
())
{
{
Product
prod
=
productFacade
.
find
(
pc
.
getKey
());
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
);
ret
.
put
(
prod
.
getId
(),
lim
);
// logger.info("Added product limit {} to {}", lim, prod);
// logger.info("Added product limit {} to {}", lim, prod);
}
}
...
@@ -157,9 +160,13 @@ public class ProductBean implements ProductBeanLocal {
...
@@ -157,9 +160,13 @@ public class ProductBean implements ProductBeanLocal {
public
BigDecimal
getProductLimit
(
Product
product
,
EventUser
user
,
Map
<
Integer
,
BigDecimal
>
prodCounts
)
public
BigDecimal
getProductLimit
(
Product
product
,
EventUser
user
,
Map
<
Integer
,
BigDecimal
>
prodCounts
)
{
{
product
=
productFacade
.
reload
(
product
);
product
=
productFacade
.
reload
(
product
);
List
<
Role
>
userroles
=
userbean
.
findUsersRoles
(
user
);
HashSet
<
Role
>
userroles
=
new
HashSet
<
Role
>(
userbean
.
findUsersRoles
(
user
));
BigDecimal
ret
=
null
;
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
)
if
(
product
!=
null
&&
product
.
getProductLimits
()
!=
null
)
{
{
...
...
code/LanBortalWeb/WebContent/foodmanager/listOrders.xhtml
View file @
8ee9667
...
@@ -131,7 +131,7 @@
...
@@ -131,7 +131,7 @@
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
<h:outputLabel
value=
"#{i18n['accountEvent.delivered']}"
/>
<h:outputLabel
value=
"#{i18n['accountEvent.delivered']}"
/>
</f:facet>
</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}"
/>
<h:commandButton
rendered=
"#{not acc_line.eventDelivered}"
value=
"#{i18n['accountEvent.deliver']}"
action=
"#{foodWaveView.deliverAccountEvent}"
/>
</p:column>
</p:column>
</p:dataTable>
</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;
...
@@ -2,6 +2,7 @@ package fi.insomnia.bortal.web.cdiview.shop;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
...
@@ -33,8 +34,7 @@ import fi.insomnia.bortal.web.helpers.ProductShopItem;
...
@@ -33,8 +34,7 @@ import fi.insomnia.bortal.web.helpers.ProductShopItem;
@ConversationScoped
@ConversationScoped
public
class
ProductShopView
extends
GenericCDIView
{
public
class
ProductShopView
extends
GenericCDIView
{
private
static
final
Logger
logger
=
LoggerFactory
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ProductShopView
.
class
);
.
getLogger
(
ProductShopView
.
class
);
/**
/**
*
*
*/
*/
...
@@ -102,11 +102,16 @@ public class ProductShopView extends GenericCDIView {
...
@@ -102,11 +102,16 @@ public class ProductShopView extends GenericCDIView {
}
}
}
}
long
logtime
;
public
String
add
(
Integer
count
)
{
public
String
add
(
Integer
count
)
{
logtime
=
Calendar
.
getInstance
().
getTimeInMillis
();
ProductShopItem
item
=
shoppingcart
.
getRowData
();
ProductShopItem
item
=
shoppingcart
.
getRowData
();
item
.
setCount
(
item
.
getCount
().
add
(
BigDecimal
.
valueOf
(
count
)));
item
.
setCount
(
item
.
getCount
().
add
(
BigDecimal
.
valueOf
(
count
)));
logger
.
debug
(
"product add count {}"
,
Calendar
.
getInstance
().
getTimeInMillis
()
-
logtime
);
updateCartLimits
(
item
);
updateCartLimits
(
item
);
logger
.
debug
(
"Updated cartLimits count {}"
,
Calendar
.
getInstance
().
getTimeInMillis
()
-
logtime
);
return
null
;
return
null
;
}
}
...
@@ -139,14 +144,16 @@ public class ProductShopView extends GenericCDIView {
...
@@ -139,14 +144,16 @@ public class ProductShopView extends GenericCDIView {
if
(
item
!=
null
&&
!
listdata
.
contains
(
item
))
{
if
(
item
!=
null
&&
!
listdata
.
contains
(
item
))
{
listdata
.
add
(
item
);
listdata
.
add
(
item
);
}
}
logger
.
debug
(
"update 1 {}"
,
Calendar
.
getInstance
().
getTimeInMillis
()
-
logtime
);
Map
<
Integer
,
BigDecimal
>
prodCounts
=
new
HashMap
<
Integer
,
BigDecimal
>();
Map
<
Integer
,
BigDecimal
>
prodCounts
=
new
HashMap
<
Integer
,
BigDecimal
>();
for
(
ProductShopItem
sc
:
shoppingcart
)
{
for
(
ProductShopItem
sc
:
shoppingcart
)
{
prodCounts
.
put
(
sc
.
getProduct
().
getId
(),
sc
.
getCount
());
prodCounts
.
put
(
sc
.
getProduct
().
getId
(),
sc
.
getCount
());
}
}
logger
.
debug
(
"update 2 {}"
,
Calendar
.
getInstance
().
getTimeInMillis
()
-
logtime
);
HashMap
<
Integer
,
BigDecimal
>
limits
=
productBean
.
getProductLimit
(
HashMap
<
Integer
,
BigDecimal
>
limits
=
productBean
.
getProductLimit
(
prodCounts
,
user
);
prodCounts
,
user
);
logger
.
debug
(
"update 4 {}"
,
Calendar
.
getInstance
().
getTimeInMillis
()
-
logtime
);
// Update the updated cart first
// Update the updated cart first
if
(
item
!=
null
)
if
(
item
!=
null
)
...
@@ -158,6 +165,7 @@ public class ProductShopView extends GenericCDIView {
...
@@ -158,6 +165,7 @@ public class ProductShopView extends GenericCDIView {
return
;
return
;
}
}
}
}
logger
.
debug
(
"update 5 {}"
,
Calendar
.
getInstance
().
getTimeInMillis
()
-
logtime
);
for
(
ProductShopItem
n
:
shoppingcart
)
{
for
(
ProductShopItem
n
:
shoppingcart
)
{
BigDecimal
l
=
limits
.
get
(
n
.
getProduct
().
getId
());
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