Commit 9ab32952 by Tuomas Riihimäki

Merge branch 'master' of codecrew.fi:bortal

Conflicts:
	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/src/fi/insomnia/bortal/web/cdiview/shop/FoodWaveView.java
2 parents a732e5d7 03f90098
......@@ -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
......@@ -9,7 +9,6 @@ import javax.ejb.Stateless;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.facade.FoodWaveFacade;
import fi.insomnia.bortal.facade.FoodWaveTemplateFacade;
import fi.insomnia.bortal.model.FoodWave;
import fi.insomnia.bortal.model.FoodWaveTemplate;
......@@ -23,8 +22,9 @@ public class FoodWaveBean implements FoodWaveBeanLocal {
@EJB
private FoodWaveTemplateFacade fwtFacade;
@EJB
private FoodWaveFacade foodwaveFacade;
private FoodWaveFacade foodWaveFacade;
@Override
@RolesAllowed(ShopPermission.S_MANAGE_PRODUCTS)
......@@ -50,13 +50,24 @@ public class FoodWaveBean implements FoodWaveBeanLocal {
}
@Override
@RolesAllowed("SHOP/READ")
public List<FoodWave> getOpenFoodWaves() {
return foodWaveFacade.getOpenFoodWaves();
}
public FoodWave findFoodwave(Integer foodwaveId) {
return foodwaveFacade.find(foodwaveId);
return foodWaveFacade.find(foodwaveId);
}
@Override
public FoodWaveTemplate findTemplate(Integer templateId) {
return fwtFacade.find(templateId);
public FoodWaveTemplate saveTemplate(FoodWaveTemplate waveTemplate) {
throw new UnsupportedOperationException("would you mind to implement this method?");
}
@Override
public FoodWave merge(FoodWave foodWave) {
return foodWaveFacade.merge(foodWave);
}
}
......@@ -109,6 +109,10 @@ public class MenuBean implements MenuBeanLocal {
shopTopmenu.addPage(menuitemfacade.findOrCreate("/checkout/delayed"), null).setVisible(false);
shopTopmenu.addPage(menuitemfacade.findOrCreate("/checkout/reject"), null).setVisible(false);
shopTopmenu.addPage(menuitemfacade.findOrCreate("/checkout/return"), null).setVisible(false);
MenuNavigation foodwaveTopmenu = usernavi.addPage(null, null);
foodwaveTopmenu.setKey("topnavi.foodwave");
foodwaveTopmenu.addPage(menuitemfacade.findOrCreate("/foodwave/list"), BillPermission.VIEW_OWN);
MenuNavigation pollTopmenu = usernavi.addPage(null, null);
pollTopmenu.setKey("topnavi.poll");
......
package fi.insomnia.bortal.facade;
import java.util.Calendar;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.model.FoodWave;
import fi.insomnia.bortal.model.FoodWaveTemplate_;
import fi.insomnia.bortal.model.FoodWave_;
import fi.insomnia.bortal.model.OrgRole_;
@Stateless
@LocalBean
public class FoodWaveFacade extends IntegerPkGenericFacade<FoodWave> {
@EJB
EventBeanLocal eventBean;
public FoodWaveFacade() {
super(FoodWave.class);
}
public List<FoodWave> getOpenFoodWaves() {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<FoodWave> cq = cb.createQuery(FoodWave.class);
Root<FoodWave> root = cq.from(FoodWave.class);
cq.where(cb.greaterThan(root.get(FoodWave_.time), Calendar.getInstance()),
cb.isFalse(root.get(FoodWave_.closed)),
cb.equal(root.get(FoodWave_.template).get(FoodWaveTemplate_.event), eventBean.getCurrentEvent())
);
return getEm().createQuery(cq).getResultList();
}
}
......@@ -25,7 +25,7 @@ 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);
......
......@@ -16,8 +16,13 @@ public interface FoodWaveBeanLocal {
List<FoodWave> findShoppableFoodwaves();
FoodWave findFoodwave(Integer foodwaveId);
FoodWaveTemplate saveTemplate(FoodWaveTemplate waveTemplate);
List<FoodWave> getOpenFoodWaves();
FoodWaveTemplate findTemplate(Integer templateId);
public FoodWave findFoodwave(Integer foodwaveId);
public FoodWave merge(FoodWave foodWave);
}
......@@ -60,6 +60,9 @@ public class AccountEvent extends GenericEntity {
@Temporal(TemporalType.TIMESTAMP)
private Calendar delivered;
@Column(name = "delivered_count", nullable = false, precision = 24, scale = 4)
private BigDecimal deliveredCount;
/**
* If this AccountEvent is a product in foodwace, this field is a reference
* to that foodwave.
......@@ -219,4 +222,12 @@ public class AccountEvent extends GenericEntity {
this.description = description;
}
public BigDecimal getDeliveredCount() {
return deliveredCount;
}
public void setDeliveredCount(BigDecimal deliveredCount) {
this.deliveredCount = deliveredCount;
}
}
......@@ -13,7 +13,6 @@ import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import org.eclipse.persistence.annotations.OptimisticLocking;
......@@ -70,9 +69,12 @@ public class BillLine extends GenericEntity {
@JoinColumn(name = "lineProduct_id", referencedColumnName = "id", nullable = true, updatable = false)
@OneToOne
@OrderBy("id")
private Product lineProduct;
@OneToOne
@JoinColumn(name = "foodwave_id", referencedColumnName = "id", nullable = true, updatable = false)
private FoodWave foodwave;
/**
* Calculate the total price for the items on this line
*
......@@ -179,4 +181,12 @@ public class BillLine extends GenericEntity {
return lineProduct;
}
public FoodWave getFoodwave() {
return foodwave;
}
public void setFoodwave(FoodWave foodwave) {
this.foodwave = foodwave;
}
}
<!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
<!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
<!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
<!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
<?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>
......
<?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>
<?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>
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;
}
*/
}
......@@ -4,10 +4,12 @@ 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.EventBeanLocal;
import fi.insomnia.bortal.beans.FoodWaveBeanLocal;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.model.FoodWave;
import fi.insomnia.bortal.model.FoodWaveTemplate;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
......@@ -17,24 +19,33 @@ public class FoodWaveView extends GenericCDIView {
private static final long serialVersionUID = 7281708393927365603L;
@EJB
private FoodWaveBeanLocal foodwaveBean;
private FoodWaveBeanLocal foodWaveBean;
@Inject
private FoodWaveFoodView foodWaveFoodView;
private ListDataModel<FoodWaveTemplate> templates;
private FoodWaveTemplate template;
private Integer templateId;
@EJB
private EventBeanLocal eventbean;
public void initTemplateList()
{
if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS))
{
setTemplates(new ListDataModel<FoodWaveTemplate>(foodwaveBean.getTemplates()));
private ListDataModel<FoodWave> foodWaves;
private FoodWave selectedFoodWave = null;
public void initTemplateList() {
if (super.requirePermissions(ShopPermission.LIST_USERPRODUCTS)) {
setTemplates(new ListDataModel<FoodWaveTemplate>(
foodWaveBean.getTemplates()));
super.beginConversation();
}
}
public void initEditTemplate()
{
public void initEditTemplate() {
if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS) && template == null)
{
......@@ -54,8 +65,12 @@ public class FoodWaveView extends GenericCDIView {
}
}
public String editTemplate()
{
public void initUserFoodWaveList() {
this.foodWaves = new ListDataModel<FoodWave>(
foodWaveBean.getOpenFoodWaves());
}
public String editTemplate() {
setTemplate(getTemplates().getRowData());
return "/foodadmin/editTemplate";
}
......@@ -83,4 +98,42 @@ public class FoodWaveView extends GenericCDIView {
this.templates = templates;
}
public ListDataModel<FoodWave> getFoodWaves() {
return foodWaves;
}
public String selectFoodWave() {
if (foodWaves.isRowAvailable()) {
//setSelectedFoodWave(foodWaves.getRowData());
}
return "/foodwave/listProducts";
}
public String selectTemplate() {
if (templates.isRowAvailable()) {
foodWaves = new ListDataModel<FoodWave>(templates.getRowData()
.getFoodwaves());
}
return "/foodwave/list";
}
public FoodWave getSelectedFoodWave() {
return selectedFoodWave;
}
public void setSelectedFoodWave(FoodWave selectedFoodWave) {
this.selectedFoodWave = selectedFoodWave;
}
private FoodWaveFoodView getFoodWaveFoodView() {
return foodWaveFoodView;
}
private void setFoodWaveFoodView(FoodWaveFoodView foodWaveFoodView) {
this.foodWaveFoodView = foodWaveFoodView;
}
}
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() {
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!