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 28e56178
authored
Oct 23, 2012
by
Tuukka Kivilahti, TKffTK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
can I haz foodwaves???
1 parent
888c50fb
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
754 additions
and
33 deletions
.gitignore
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/FoodWaveBean.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/FoodWaveTemplateFacade.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/FoodWaveBeanLocal.java
code/LanBortalWeb/WebContent/foodwave/ThanksForOrderingFromCounter.xhtml
code/LanBortalWeb/WebContent/foodwave/list.xhtml
code/LanBortalWeb/WebContent/foodwave/listProducts.xhtml
code/LanBortalWeb/WebContent/foodwave/listTemplates.xhtml
code/LanBortalWeb/WebContent/resources/cditools/foodwave/list.xhtml
code/LanBortalWeb/WebContent/resources/cditools/foodwave/listFoods.xhtml
code/LanBortalWeb/WebContent/resources/cditools/foodwave/listTemplates.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/FoodWaveFoodView.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/FoodWaveView.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/FoodWaveView.java.old
.gitignore
View file @
28e5617
...
...
@@ -5,3 +5,5 @@
/code/LanBortalDatabase/src/fi/insomnia/bortal/model/*_.java
/code/LanBortalDatabase/src/fi/insomnia/bortal/model/*/*_.java
*~
.metadata
code/LanBortal/.settings/org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/FoodWaveBean.java
View file @
28e5617
...
...
@@ -52,14 +52,18 @@ public class FoodWaveBean implements FoodWaveBeanLocal {
}
public
FoodWave
findFoodwave
(
Integer
foodwaveId
)
{
// TODO Auto-generated method stub
return
null
;
return
foodWaveFacade
.
find
(
foodwaveId
);
}
@Override
public
FoodWaveTemplate
saveTemplate
(
FoodWaveTemplate
waveTemplate
)
{
// TODO Auto-generated method stub
return
null
;
throw
new
UnsupportedOperationException
(
"would you mind to implement this method?"
);
}
@Override
public
FoodWave
merge
(
FoodWave
foodWave
)
{
return
foodWaveFacade
.
merge
(
foodWave
);
}
}
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/FoodWaveTemplateFacade.java
View file @
28e5617
...
...
@@ -25,12 +25,13 @@ public class FoodWaveTemplateFacade extends IntegerPkGenericFacade<FoodWaveTempl
super
(
FoodWaveTemplate
.
class
);
}
public
List
<
FoodWaveTemplate
>
findAllTemplates
()
{
public
List
<
FoodWaveTemplate
>
findAllTemplates
()
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
FoodWaveTemplate
>
cq
=
cb
.
createQuery
(
FoodWaveTemplate
.
class
);
Root
<
FoodWaveTemplate
>
root
=
cq
.
from
(
FoodWaveTemplate
.
class
);
cb
.
equal
(
root
.
get
(
FoodWaveTemplate_
.
event
),
eventbean
.
getCurrentEvent
());
return
getEm
().
createQuery
(
cq
).
getResultList
();
List
<
FoodWaveTemplate
>
ret
=
getEm
().
createQuery
(
cq
).
getResultList
();
return
ret
;
}
}
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/FoodWaveBeanLocal.java
View file @
28e5617
...
...
@@ -21,4 +21,6 @@ public interface FoodWaveBeanLocal {
List
<
FoodWave
>
getOpenFoodWaves
();
public
FoodWave
findFoodwave
(
Integer
foodwaveId
);
public
FoodWave
merge
(
FoodWave
foodWave
);
}
code/LanBortalWeb/WebContent/foodwave/ThanksForOrderingFromCounter.xhtml
0 → 100644
View file @
28e5617
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:foodwave=
"http://java.sun.com/jsf/composite/cditools/foodwave"
xmlns:users=
"http://java.sun.com/jsf/composite/cditools/user"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<f:metadata>
<f:viewParam
name=
"userid"
value=
"#{userView.userid}"
/>
<f:event
type=
"preRenderView"
listener=
"#{foodWaveView.initTemplateList}"
/>
</f:metadata>
<ui:define
name=
"title"
>
<h1>
#{i18n['user.shop.title']}
</h1>
<users:usertabs
tabId=
"foodwave"
/>
</ui:define>
<ui:define
name=
"content"
>
Kiitoksia tilauksesta, muista käydä maksamassa tilaukset tiskillä.
Maksamattomia tilauksia ei pistetä etiäpäin.
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/LanBortalWeb/WebContent/foodwave/list.xhtml
0 → 100644
View file @
28e5617
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:foodwave=
"http://java.sun.com/jsf/composite/cditools/foodwave"
xmlns:users=
"http://java.sun.com/jsf/composite/cditools/user"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<f:metadata>
<f:viewParam
name=
"userid"
value=
"#{userView.userid}"
/>
<f:event
type=
"preRenderView"
listener=
"#{foodWaveView.initTemplateList}"
/>
</f:metadata>
<ui:define
name=
"title"
>
<h1>
#{i18n['user.shop.title']}
</h1>
<users:usertabs
tabId=
"foodwave"
/>
</ui:define>
<ui:define
name=
"content"
>
<h:dataTable
columnClasses=
"nowrap,numalign,numalign,nowrap,numalign"
styleClass=
"bordertable"
value=
"#{foodWaveView.foodWaves}"
var=
"foodwave"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputLabel
id=
"name"
value=
"${i18n['foodWave.name']}"
/>
</f:facet>
<h:link
outcome=
"/foodwave/listProducts"
value=
"#{foodwave.name}"
>
<f:param
name=
"foodwaveid"
value=
"#{foodwave.id}"
/>
</h:link>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['foodWave.template.name']}"
/>
</f:facet>
<h:link
outcome=
"/foodwave/listProducts"
value=
"#{foodwave.template.name}"
>
<f:param
name=
"foodwaveid"
value=
"#{foodwave.id}"
/>
</h:link>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['foodWave.description']}"
/>
</f:facet>
<h:outputText
id=
"description"
value=
"#{foodwave.template.description}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['foodWave.time']}"
/>
</f:facet>
<h:link
outcome=
"/foodwave/listProducts"
value=
"#{foodwave.time.time}"
>
<f:param
name=
"foodwaveid"
value=
"#{foodwave.id}"
/>
</h:link>
</h:column>
</h:dataTable>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/LanBortalWeb/WebContent/foodwave/listProducts.xhtml
0 → 100644
View file @
28e5617
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:foodwave=
"http://java.sun.com/jsf/composite/cditools/foodwave"
xmlns:products=
"http://java.sun.com/jsf/composite/cditools/products"
xmlns:users=
"http://java.sun.com/jsf/composite/cditools/user"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<f:metadata>
<f:viewParam
name=
"userid"
value=
"#{userView.userid}"
/>
<f:viewParam
name=
"foodwaveid"
value=
"#{foodWaveFoodView.foodwaveid}"
/>
<f:event
type=
"preRenderView"
listener=
"#{foodWaveFoodView.initFoodWaveFoods}"
/>
</f:metadata>
<ui:define
name=
"title"
>
<h1>
#{i18n['user.foodwave.products.title']}
</h1>
<users:usertabs
tabId=
"foodwave"
/>
</ui:define>
<ui:define
name=
"content"
>
<!-- products:shop commitaction="#{foodWaveFoodView.commitShoppingCart()}" items="#{foodWaveFoodView.shoppingcart}" commitValue="#{i18n['productshop.commit']}" /-->
<foodwave:listFoods
selectaction=
"#{foodWaveFoodView.commitShoppingCart()}"
items=
"#{foodWaveFoodView.shoppingcart}"
commitValue=
"#{i18n['productshop.commit']}"
/>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/LanBortalWeb/WebContent/foodwave/listTemplates.xhtml
0 → 100644
View file @
28e5617
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:foodwave=
"http://java.sun.com/jsf/composite/cditools/foodwave"
xmlns:users=
"http://java.sun.com/jsf/composite/cditools/user"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<f:metadata>
<f:viewParam
name=
"userid"
value=
"#{userView.userid}"
/>
<f:event
type=
"preRenderView"
listener=
"#{foodWaveView.initTemplateList}"
/>
</f:metadata>
<ui:define
name=
"title"
>
<h1>
#{i18n['user.shop.title']}
</h1>
<users:usertabs
tabId=
"foodwave"
/>
</ui:define>
<ui:define
name=
"content"
>
<foodwave:listTemplates
selectaction=
"#{foodWaveView.selectTemplate}"
items=
"#{foodWaveView.templates}"
commitValue=
"#{i18n['food']}"
/>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/LanBortalWeb/WebContent/resources/cditools/foodwave/list.xhtml
View file @
28e5617
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:tools=
"http://java.sun.com/jsf/composite/tools"
>
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:tools=
"http://java.sun.com/jsf/composite/tools"
>
<composite:interface>
<composite:attribute
name=
"items"
required=
"true"
/>
<!-- <composite:attribute name="selectValue" required="true" /> -->
<composite:attribute
name=
"selectaction"
method-signature=
"java.lang.String action()"
required=
"true"
/>
<!-- <composite:attribute name="selectValue" required="true" /> -->
<composite:attribute
name=
"selectaction"
method-signature=
"java.lang.String action()"
required=
"true"
/>
</composite:interface>
<composite:implementation>
<!-- <h:outputScript target="head" library="script" name="jquery.min.js" /> -->
<!-- <h:outputScript target="head" library="script" name="shopscript.js" /> -->
<h:outputScript
library=
"primefaces"
name=
"jquery/jquery.js"
/>
<div
style=
"margin-top: 5px;"
>
<h:commandButton
action=
"#{cc.attrs.selectaction}"
id=
"selectbutton-top"
value=
"#{cc.attrs.selectValue}"
/>
</div>
<h:dataTable
columnClasses=
"nowrap,numalign,numalign,nowrap,numalign"
styleClass=
"bordertable"
id=
"billcart"
value=
"#{cc.attrs.items}"
var=
"foodwave"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
id=
"name"
value=
"${i18n['foodWave.name']}"
/>
</f:facet>
<h:outputText
value=
"#{foodwave.template.name}"
/>
</h:column>
<h:column
>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['foodWave.description']}"
/>
</f:facet>
<h:outputText
id=
"description"
value=
"#{foodwave.template.description}"
/>
</h:column>
<h:commandButton
action=
"#{cc.attrs.selectaction}"
id=
"selectbutton-botton"
value=
"#{cc.attrs.selectValue}"
/>
</h:dataTable>
<h:form>
<h:dataTable
columnClasses=
"nowrap,numalign,numalign,nowrap,numalign"
styleClass=
"bordertable"
value=
"#{cc.attrs.items}"
var=
"foodwave"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputLabel
id=
"name"
value=
"${i18n['foodWave.name']}"
/>
</f:facet>
<h:commandLink
action=
"#{cc.attrs.selectaction}"
value=
"#{foodwave.name}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['foodWave.template.name']}"
/>
</f:facet>
<h:commandLink
action=
"#{cc.attrs.selectaction}"
id=
"template_name"
value=
"#{foodwave.template.name}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['foodWave.description']}"
/>
</f:facet>
<h:outputText
id=
"description"
value=
"#{foodwave.template.description}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['foodWave.time']}"
/>
</f:facet>
<h:commandLink
action=
"#{cc.attrs.selectaction}"
id=
"time"
value=
"#{foodwave.time.time}"
/>
</h:column>
<h:commandButton
action=
"#{cc.attrs.selectaction}"
id=
"selectbutton-botton"
value=
"Valitte"
/>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
...
...
code/LanBortalWeb/WebContent/resources/cditools/foodwave/listFoods.xhtml
0 → 100644
View file @
28e5617
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:tools=
"http://java.sun.com/jsf/composite/tools"
>
<composite:interface>
<composite:attribute
name=
"items"
required=
"true"
/>
<!-- <composite:attribute name="selectValue" required="true" /> -->
<composite:attribute
name=
"selectaction"
method-signature=
"java.lang.String action()"
required=
"true"
/>
</composite:interface>
<composite:implementation>
<!-- <h:outputScript target="head" library="script" name="jquery.min.js" /> -->
<!-- <h:outputScript target="head" library="script" name="shopscript.js" /> -->
<h:outputScript
library=
"primefaces"
name=
"jquery/jquery.js"
/>
<h:form>
<h:dataTable
columnClasses=
"nowrap,numalign,numalign,nowrap,numalign"
styleClass=
"bordertable"
value=
"#{cc.attrs.items}"
var=
"cart"
>
<!-- h:column>
<f:facet name="header">
<h:outputLabel id="name" value="${i18n['product.name']}" />
</f:facet>
<h:commandLink action="#{cc.attrs.selectaction}" value="#{cart.product.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['product.price']}" />
</f:facet>
<h:commandLink action="#{cc.attrs.selectaction}" id="template_name" value="#{cart.product.price}" />
</h:column>
<h:commandButton action="#{cc.attrs.selectaction}"
id="selectbutton-botton" value="Valitte" /-->
<h:column>
<f:facet
name=
"header"
>
<h:outputText
id=
"name"
value=
"${i18n['product.name']}"
/>
</f:facet>
<h:outputText
value=
"#{cart.product.name}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['product.price']}"
/>
</f:facet>
<h:outputText
id=
"price"
value=
"#{cart.product.price.abs()}"
>
<f:convertNumber
maxFractionDigits=
"2"
minFractionDigits=
"2"
/>
</h:outputText>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['product.totalPrice']}"
/>
</f:facet>
<h:outputText
id=
"total"
value=
"#{cart.price}"
>
<f:convertNumber
maxFractionDigits=
"2"
minFractionDigits=
"2"
/>
</h:outputText>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
id=
"count"
value=
"${i18n['product.cart.count']}"
/>
</f:facet>
<h:commandButton
action=
"#{foodWaveFoodView.addMinusOne}"
value=
"#{i18n['productshop.minusOne']}"
>
<f:ajax
render=
"@form"
/>
</h:commandButton>
<h:inputText
size=
"4"
id=
"cartcount"
value=
"#{cart.count}"
>
<f:convertNumber
maxIntegerDigits=
"2"
minFractionDigits=
"0"
/>
</h:inputText>
<h:commandButton
action=
"#{foodWaveFoodView.addOne}"
value=
"#{i18n['productshop.plusOne']}"
>
<f:ajax
render=
"@form"
/>
</h:commandButton>
</h:column>
</h:dataTable>
<h:commandButton
action=
"#{foodWaveFoodView.buyFromCounter}"
value=
"#{i18n['foodshop.buyFromCounter']}"
/>
</h:form>
</composite:implementation>
</html>
code/LanBortalWeb/WebContent/resources/cditools/foodwave/listTemplates.xhtml
0 → 100644
View file @
28e5617
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:tools=
"http://java.sun.com/jsf/composite/tools"
>
<composite:interface>
<composite:attribute
name=
"items"
required=
"true"
/>
<composite:attribute
name=
"selectaction"
method-signature=
"java.lang.String action()"
required=
"true"
/>
</composite:interface>
<composite:implementation>
<!-- <h:outputScript target="head" library="script" name="jquery.min.js" /> -->
<!-- <h:outputScript target="head" library="script" name="shopscript.js" /> -->
<h:outputScript
library=
"primefaces"
name=
"jquery/jquery.js"
/>
<h:form>
<h:dataTable
columnClasses=
"nowrap,numalign,numalign,nowrap,numalign"
styleClass=
"bordertable"
id=
"billcart"
value=
"#{cc.attrs.items}"
var=
"template"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
id=
"name"
value=
"${i18n['foodWave.name']}"
/>
</f:facet>
<h:commandLink
action=
"#{cc.attrs.selectaction}"
value=
"#{template.name}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['foodWave.description']}"
/>
</f:facet>
<h:outputText
id=
"description"
value=
"#{template.description}"
/>
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/FoodWaveFoodView.java
0 → 100644
View file @
28e5617
package
fi
.
insomnia
.
bortal
.
web
.
cdiview
.
shop
;
import
java.math.BigDecimal
;
import
java.util.Iterator
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.faces.model.ListDataModel
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
fi.insomnia.bortal.beans.AccountEventBeanLocal
;
import
fi.insomnia.bortal.beans.FoodWaveBeanLocal
;
import
fi.insomnia.bortal.beans.ProductBeanLocal
;
import
fi.insomnia.bortal.enums.apps.ShopPermission
;
import
fi.insomnia.bortal.model.AccountEvent
;
import
fi.insomnia.bortal.model.EventUser
;
import
fi.insomnia.bortal.model.FoodWave
;
import
fi.insomnia.bortal.model.Product
;
import
fi.insomnia.bortal.web.annotations.SelectedUser
;
import
fi.insomnia.bortal.web.cdiview.GenericCDIView
;
import
fi.insomnia.bortal.web.helpers.ProductShopItem
;
@Named
@ConversationScoped
public
class
FoodWaveFoodView
extends
GenericCDIView
{
/**
*
*/
private
static
final
long
serialVersionUID
=
5723448087928988814L
;
@EJB
private
FoodWaveBeanLocal
foodWaveBean
;
@EJB
private
AccountEventBeanLocal
accountEventBean
;
private
FoodWave
foodWave
=
null
;
@EJB
private
transient
ProductBeanLocal
productBean
;
@Inject
@SelectedUser
private
EventUser
user
;
private
Integer
foodwaveid
=
0
;
private
ListDataModel
<
Product
>
products
;
private
transient
ListDataModel
<
ProductShopItem
>
shoppingcart
;
public
void
initFoodWaveFoods
()
{
if
(
requirePermissions
(
ShopPermission
.
LIST_USERPRODUCTS
)
&&
getFoodwaveid
()
>
0
&&
getShoppingcart
()
==
null
)
{
setFoodWave
(
foodWaveBean
.
findFoodwave
(
getFoodwaveid
()));
setShoppingcart
(
new
ListDataModel
<
ProductShopItem
>(
ProductShopItem
.
productGTList
(
getFoodWave
().
getTemplate
().
getProducts
()
)));
System
.
out
.
println
(
"beginconversation"
);
this
.
beginConversation
();
//products = new ListDataModel<Product>(getFoodWave().getTemplate().getProducts());
}
}
public
ListDataModel
<
Product
>
getProducts
()
{
return
products
;
}
public
void
setProducts
(
ListDataModel
<
Product
>
products
)
{
this
.
products
=
products
;
}
public
Integer
getFoodwaveid
()
{
return
foodwaveid
;
}
public
void
setFoodwaveid
(
Integer
foodwaveid
)
{
this
.
foodwaveid
=
foodwaveid
;
}
public
FoodWave
getFoodWave
()
{
return
foodWave
;
}
public
void
setFoodWave
(
FoodWave
foodWave
)
{
this
.
foodWave
=
foodWave
;
}
////////////////////////////////////////////
/*
public void initBillView() {
if (requirePermissions(ShopPermission.LIST_USERPRODUCTS)
&& getShoppingcart() == null) {
setShoppingcart(new ListDataModel<ProductShopItem>(
ProductShopItem.productList(productBean
.listUserShoppableProducts())));
updateCartLimits(null);
logger.debug("Initialized billing shoppingcart to {}", getShoppingcart());
this.beginConversation();
}
}*/
/*
public void initShopView() {
setShoppingcart(new ListDataModel<ProductShopItem>(
ProductShopItem.productGTList( getFoodWave().getTemplate().getProducts() )));
this.beginConversation();
}
*/
public
String
add
(
Integer
count
)
{
ProductShopItem
item
=
getShoppingcart
().
getRowData
();
item
.
setCount
(
item
.
getCount
().
add
(
BigDecimal
.
valueOf
(
count
)));
System
.
out
.
println
(
"foobar"
+
item
.
getCount
());
return
null
;
}
public
String
addOne
()
{
return
add
(
1
);
}
public
String
addMinusOne
()
{
return
add
(-
1
);
}
/*
public BigDecimal getAccountBalance() {
BigDecimal ret = user.getAccountBalance();
ret = ret.add(getCash());
ret = ret.subtract(getTotalPrice());
return ret;
}*/
public
BigDecimal
getTotalPrice
()
{
BigDecimal
ret
=
BigDecimal
.
ZERO
;
for
(
ProductShopItem
cart
:
getShoppingcart
())
{
ret
=
ret
.
add
(
cart
.
getPrice
());
}
return
ret
;
}
/*
public String commitBillCart() {
if (!productsInCart()) {
super.addFaceMessage("productshop.noItemsInCart");
return null;
}
Bill bill = new Bill(eventbean.getCurrentEvent(), user);
bill.setOurReference(eventbean.getCurrentEvent().getName());
for (ProductShopItem shopitem : getShoppingcart()) {
if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) {
bill.addProduct(shopitem.getProduct(), shopitem.getCount());
}
}
billbean.createBill(bill);
addFaceMessage("productshop.billCreated");
cash = BigDecimal.ZERO;
setShoppingcart(null);
billEditView.setBill(bill);
return "showCreatedBill";
}*/
/**
* When we buy stuff from counter, we actually just create accountevents with zero price,
* and add them to foodWave.
*
* @return
*/
public
String
buyFromCounter
()
{
for
(
ProductShopItem
shopitem
:
getShoppingcart
())
{
if
(
shopitem
.
getCount
().
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
AccountEvent
ae
=
productBean
.
createAccountEvent
(
shopitem
.
getProduct
(),
shopitem
.
getCount
(),
user
);
ae
.
setUnitPrice
(
new
BigDecimal
(
0
));
ae
.
setFoodWave
(
foodWave
);
accountEventBean
.
merge
(
ae
);
}
}
return
"/foodWave/ThanksForOrderingFromCounter."
;
}
public
String
commitShoppingCart
()
{
/* EventUser retuser = null;
for (ProductShopItem shopitem : getShoppingcart()) {
if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) {
retuser = productBean.createAccountEvent(shopitem.getProduct(), shopitem.getCount(), user).getUser();
}
}
if (cash != null && cash.compareTo(BigDecimal.ZERO) != 0) {
Product credProd = productBean.findCreditProduct();
retuser = productBean.createAccountEvent(credProd, cash, user).getUser();
}
if (user != null) {
user = retuser;
}
setShoppingcart(null);
cash = BigDecimal.ZERO;*/
return
null
;
}
public
void
setUser
(
EventUser
user
)
{
this
.
user
=
user
;
}
public
EventUser
getUser
()
{
return
user
;
}
public
void
setShoppingcart
(
ListDataModel
<
ProductShopItem
>
shoppingcart
)
{
this
.
shoppingcart
=
shoppingcart
;
}
public
ListDataModel
<
ProductShopItem
>
getShoppingcart
()
{
return
shoppingcart
;
}
private
boolean
productsInCart
()
{
Iterator
<
ProductShopItem
>
nullcheckIter
=
getShoppingcart
().
iterator
();
while
(
nullcheckIter
.
hasNext
())
{
if
(
nullcheckIter
.
next
().
getCount
().
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
return
true
;
}
}
return
false
;
}
/*
public BillListView getBillListView() {
return billListView;
}
public void setBillListView(BillListView billListView) {
this.billListView = billListView;
}
public BigDecimal getCash() {
if (payInstant) {
cash = getTotalPrice();
logger.info("Getting instantcash as {}", cash);
}
if (cash == null) {
cash = BigDecimal.ZERO;
}
return cash;
}
public void setCash(BigDecimal cash) {
this.cash = cash;
}
public boolean isHasLimits() {
return hasLimits;
}
public void setHasLimits(boolean hasLimits) {
this.hasLimits = hasLimits;
}
*/
}
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/FoodWaveView.java
View file @
28e5617
...
...
@@ -4,6 +4,7 @@ import javax.ejb.EJB;
import
javax.enterprise.context.ConversationScoped
;
import
javax.faces.model.ListDataModel
;
import
javax.inject.Named
;
import
javax.inject.Inject
;
import
fi.insomnia.bortal.beans.FoodWaveBeanLocal
;
import
fi.insomnia.bortal.enums.apps.ShopPermission
;
...
...
@@ -18,6 +19,11 @@ public class FoodWaveView extends GenericCDIView {
private
static
final
long
serialVersionUID
=
7281708393927365603L
;
@EJB
private
FoodWaveBeanLocal
foodWaveBean
;
@Inject
private
FoodWaveFoodView
foodWaveFoodView
;
private
ListDataModel
<
FoodWaveTemplate
>
templates
;
private
FoodWaveTemplate
template
;
...
...
@@ -26,11 +32,13 @@ public class FoodWaveView extends GenericCDIView {
private
FoodWave
selectedFoodWave
=
null
;
public
void
initTemplateList
()
{
if
(
super
.
requirePermissions
(
ShopPermission
.
MANAGE_PRODUCTS
))
{
if
(
super
.
requirePermissions
(
ShopPermission
.
LIST_USERPRODUCTS
))
{
setTemplates
(
new
ListDataModel
<
FoodWaveTemplate
>(
foodWaveBean
.
getTemplates
()));
super
.
beginConversation
();
}
}
public
void
initEditTemplate
()
{
...
...
@@ -87,10 +95,20 @@ public class FoodWaveView extends GenericCDIView {
public
String
selectFoodWave
()
{
if
(
foodWaves
.
isRowAvailable
())
{
setSelectedFoodWave
(
foodWaves
.
getRowData
());
//setSelectedFoodWave(foodWaves.getRowData());
}
return
"foorwave/listProducts"
;
return
"/foodwave/listProducts"
;
}
public
String
selectTemplate
()
{
if
(
templates
.
isRowAvailable
())
{
foodWaves
=
new
ListDataModel
<
FoodWave
>(
templates
.
getRowData
()
.
getFoodwaves
());
}
return
"/foodwave/list"
;
}
public
FoodWave
getSelectedFoodWave
()
{
...
...
@@ -101,4 +119,12 @@ public class FoodWaveView extends GenericCDIView {
this
.
selectedFoodWave
=
selectedFoodWave
;
}
private
FoodWaveFoodView
getFoodWaveFoodView
()
{
return
foodWaveFoodView
;
}
private
void
setFoodWaveFoodView
(
FoodWaveFoodView
foodWaveFoodView
)
{
this
.
foodWaveFoodView
=
foodWaveFoodView
;
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/FoodWaveView.java.old
0 → 100644
View file @
28e5617
package fi.insomnia.bortal.web.cdiview.shop;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.faces.model.ListDataModel;
import javax.inject.Inject;
import javax.inject.Named;
import fi.insomnia.bortal.beans.FoodWaveBeanLocal;
import fi.insomnia.bortal.model.EventUser;
import fi.insomnia.bortal.model.FoodWave;
import fi.insomnia.bortal.web.annotations.SelectedUser;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class FoodWaveView extends GenericCDIView {
/**
*
*/
private static final long serialVersionUID = -4668803787903428164L;
@Inject
@SelectedUser
private transient EventUser eventUser;
@EJB
private transient FoodWaveBeanLocal foodWaveBean;
private ListDataModel<FoodWave> foodWaves;
public EventUser getEventUser() {
return eventUser;
}
public void setEventUser(EventUser eventUser) {
this.eventUser = eventUser;
}
public ListDataModel<FoodWave> getFoodWaves() {
if(this.foodWaves == null) {
this.foodWaves = new ListDataModel<FoodWave>(foodWaveBean.getOpenFoodWaves());
}
return foodWaves;
}
public String selectFoodWave() {
}
}
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