Commit a732e5d7 by Tuomas Riihimäki

foodwavea..

1 parent 86e51802
...@@ -7,7 +7,9 @@ import javax.annotation.security.RolesAllowed; ...@@ -7,7 +7,9 @@ import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import fi.insomnia.bortal.enums.apps.ShopPermission; import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.facade.FoodWaveFacade;
import fi.insomnia.bortal.facade.FoodWaveTemplateFacade; import fi.insomnia.bortal.facade.FoodWaveTemplateFacade;
import fi.insomnia.bortal.model.FoodWave; import fi.insomnia.bortal.model.FoodWave;
import fi.insomnia.bortal.model.FoodWaveTemplate; import fi.insomnia.bortal.model.FoodWaveTemplate;
...@@ -21,6 +23,8 @@ public class FoodWaveBean implements FoodWaveBeanLocal { ...@@ -21,6 +23,8 @@ public class FoodWaveBean implements FoodWaveBeanLocal {
@EJB @EJB
private FoodWaveTemplateFacade fwtFacade; private FoodWaveTemplateFacade fwtFacade;
@EJB
private FoodWaveFacade foodwaveFacade;
@Override @Override
@RolesAllowed(ShopPermission.S_MANAGE_PRODUCTS) @RolesAllowed(ShopPermission.S_MANAGE_PRODUCTS)
...@@ -31,20 +35,28 @@ public class FoodWaveBean implements FoodWaveBeanLocal { ...@@ -31,20 +35,28 @@ public class FoodWaveBean implements FoodWaveBeanLocal {
@Override @Override
@RolesAllowed(ShopPermission.S_MANAGE_PRODUCTS) @RolesAllowed(ShopPermission.S_MANAGE_PRODUCTS)
public FoodWaveTemplate saveOrCreateTemplate(FoodWaveTemplate template) { public FoodWaveTemplate saveOrCreateTemplate(FoodWaveTemplate template) {
// TODO Auto-generated method stub if (template.getId() == null)
return null; {
fwtFacade.create(template);
} else {
template = fwtFacade.merge(template);
}
return template;
} }
@Override @Override
public List<FoodWave> findShoppableFoodwaves() { public List<FoodWave> findShoppableFoodwaves() {
// TODO Auto-generated method stub throw new NotImplementedException();
return null;
} }
@Override @Override
public FoodWave findFoodwave(Integer foodwaveId) { public FoodWave findFoodwave(Integer foodwaveId) {
// TODO Auto-generated method stub return foodwaveFacade.find(foodwaveId);
return null; }
@Override
public FoodWaveTemplate findTemplate(Integer templateId) {
return fwtFacade.find(templateId);
} }
} }
...@@ -29,8 +29,21 @@ public class FoodWaveTemplateFacade extends IntegerPkGenericFacade<FoodWaveTempl ...@@ -29,8 +29,21 @@ public class FoodWaveTemplateFacade extends IntegerPkGenericFacade<FoodWaveTempl
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<FoodWaveTemplate> cq = cb.createQuery(FoodWaveTemplate.class); CriteriaQuery<FoodWaveTemplate> cq = cb.createQuery(FoodWaveTemplate.class);
Root<FoodWaveTemplate> root = cq.from(FoodWaveTemplate.class); Root<FoodWaveTemplate> root = cq.from(FoodWaveTemplate.class);
cb.equal(root.get(FoodWaveTemplate_.event), eventbean.getCurrentEvent()); cq.where(cb.equal(root.get(FoodWaveTemplate_.event), eventbean.getCurrentEvent()));
return getEm().createQuery(cq).getResultList(); return getEm().createQuery(cq).getResultList();
} }
@Override
public FoodWaveTemplate find(Integer id)
{
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<FoodWaveTemplate> cq = cb.createQuery(FoodWaveTemplate.class);
Root<FoodWaveTemplate> root = cq.from(FoodWaveTemplate.class);
cq.where(cb.equal(root.get(FoodWaveTemplate_.event), eventbean.getCurrentEvent()),
cb.equal(root.get(FoodWaveTemplate_.id), id)
);
return super.getSingleNullableResult(getEm().createQuery(cq));
}
} }
...@@ -18,4 +18,6 @@ public interface FoodWaveBeanLocal { ...@@ -18,4 +18,6 @@ public interface FoodWaveBeanLocal {
FoodWave findFoodwave(Integer foodwaveId); FoodWave findFoodwave(Integer foodwaveId);
FoodWaveTemplate findTemplate(Integer templateId);
} }
<!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: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:event type="preRenderView" listener="#{foodWaveView.initCreateTemplate()}" />
</f:metadata>
<ui:define name="title">
<h1>#{i18n['foodwave.template.edit.title']}</h1>
</ui:define>
<ui:define name="content">
<h:form>
<h:panelGrid columns="3">
<h:outputLabel for="name" value="#{i18n['foodwavetemplate.name']}" />
<h:inputText id="name" value="#{foodWaveView.template.name}" />
<h:message for="name" />
</h:panelGrid>
<h:commandButton action="#{foodWaveView.saveTemplate()}" value="#{i18n['foowavetemplate.create']}" />
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata> <f:metadata>
<f:event type="preRenderView" listener="#{foodWaveView.initEditTemplate()}" /> <f:event type="preRenderView" listener="#{foodWaveView.initEditTemplate()}" />
<f:viewParam name="id" value="#{userView.templateId}" />
</f:metadata> </f:metadata>
<ui:define name="title"> <ui:define name="title">
...@@ -19,15 +21,18 @@ ...@@ -19,15 +21,18 @@
<h:outputLabel for="name" value="#{i18n['foodwavetemplate.name']}" /> <h:outputLabel for="name" value="#{i18n['foodwavetemplate.name']}" />
<h:inputText id="name" value="#{foodWaveView.template.name}" /> <h:inputText id="name" value="#{foodWaveView.template.name}" />
<h:message for="name" /> <h:message for="name" />
</h:panelGrid> </h:panelGrid>
<h:inputTextarea value="#{foodWaveView.template.description}" /> <div>
<h:commanButton action="#{foodWaveView.saveTemplate()}" value="#{i18n['foowavetemplate.save']}" /> <h:inputTextarea value="#{foodWaveView.template.description}" />
</div>
<h:commandButton action="#{foodWaveView.saveTemplate()}" value="#{i18n['foowavetemplate.save']}" />
<h:commandButton action="#{foodWaveView.createFoodwave()}" value="#{i18n['foodwavetemplate.createFoodwave']}" /> <h:commandButton action="#{foodWaveView.createFoodwave()}" value="#{i18n['foodwavetemplate.createFoodwave']}" />
</h:form>
<ui:fragment >
</h:form>
<ui:fragment>
</ui:fragment> </ui:fragment>
</ui:define> </ui:define>
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata> <f:metadata>
<f:event type="preRenderView" listener="#{foodWaveView.initTemplateList()}" /> <f:event type="preRenderView" listener="#{foodWaveView.initTemplateList()}" />
<f:viewParam name="id" value="#{foodWaveView.templateId}" />
</f:metadata> </f:metadata>
<ui:define name="title"> <ui:define name="title">
......
...@@ -16,49 +16,45 @@ ...@@ -16,49 +16,45 @@
<ui:define name="content"> <ui:define name="content">
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" /> <h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
<h1>#{i18n['userlist.header']}</h1> <h1>#{i18n['userlist.header']}</h1>
<h:form> <h:form>
<h:panelGrid columns="2"> <h:panelGrid columns="2">
<h:panelGroup> <h:panelGroup>
<a onclick="$('#advancedSearch').show(); $(this).hide();" ><h:outputText value="#{i18n['userlist.showAdvancedSearch']}" /></a> <a onclick="$('#advancedSearch').show(); $(this).hide();"><h:outputText value="#{i18n['userlist.showAdvancedSearch']}" /></a>
<span id="advancedSearch" style="display:none;"> <span id="advancedSearch" style="display: none;"> <h:selectBooleanCheckbox id="placeassoc" value="#{userSearchView.searchQuery.placeAssoc}" /> <h:outputLabel for="placeassoc"
value="#{i18n['userlist.placeassoc']}" /> <br /> <h:outputLabel for="saldofilter" value="#{i18n['userlist.saldofilter']}" /> <h:selectOneMenu
value="#{userSearchView.searchQuery.accountSaldoCompare}">
<h:selectBooleanCheckbox id="placeassoc" value="#{userSearchView.searchQuery.placeAssoc}" /> <f:selectItems value="#{userSearchView.searchQuery.accountCompareValues}" />
<h:outputLabel for="placeassoc" value="#{i18n['userlist.placeassoc']}" /> </h:selectOneMenu> <h:inputText value="#{userSearchView.searchQuery.accountSaldo}">
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:inputText> <br /> <h:outputLabel for="rolefilter" value="#{i18n['userlist.rolefilter']}" /> <h:selectManyCheckbox layout="pageDirection" styleClass="nowrap" id="rolefilter"
value="#{userSearchView.searchQuery.filterRoles}" converter="#{roleConverter}">
<f:selectItems value="#{roleDataView.roles}" var="r" itemLabel="#{r.name}" />
</h:selectManyCheckbox>
</span>
<br /> <br />
<h:outputLabel for="saldofilter" value="#{i18n['userlist.saldofilter']}" />
<h:selectOneMenu value="#{userSearchView.searchQuery.accountSaldoCompare}"> <h:selectBooleanCheckbox id="onlythisevent" value="#{userSearchView.searchQuery.onlyThisEvent}" />
<f:selectItems value="#{userSearchView.searchQuery.accountCompareValues}" /> <h:outputLabel for="onlythisevent" value="#{i18n['userlist.onlythisevent']}" />
</h:selectOneMenu>
<h:inputText value="#{userSearchView.searchQuery.accountSaldo}">
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:inputText>
<br /> <br />
<h:outputLabel for="rolefilter" value="#{i18n['userlist.rolefilter']}" /> <h:inputText value="#{userSearchView.search}" />
<h:selectManyCheckbox layout="pageDirection" styleClass="nowrap" id="rolefilter" value="#{userSearchView.searchQuery.filterRoles}" converter="#{roleConverter}"> <h:commandButton value="#{i18n['userlist.search']}" action="#{userSearchView.newSearch()}" />
<f:selectItems value="#{roleDataView.roles}" var="r" itemLabel="#{r.name}" /> </h:panelGroup>
</h:selectManyCheckbox> <h:panelGroup>
<a style="display: #{((userCartView.isEmpty())?'block':'none')};" onclick="$('#usercart').show(); $(this).hide();"><h:outputText value="#{i18n['userlist.showAdvancedSearch']}" /></a>
<div id="usercart" style="display: #{((userCartView.isEmpty())?'none':'block')};">
</span> <h:outputText value="#{i18n['usercart.cartsize']}" />
<br /> <h:outputText value=" #{userCartView.userCartSize}" />
<br />
<h:selectBooleanCheckbox id="onlythisevent" value="#{userSearchView.searchQuery.onlyThisEvent}" /> <h:commandButton actionListener="#{userSearchView.addToCart}" value="#{i18n['usercart.addSearcherUsers']}" />
<h:outputLabel for="onlythisevent" value="#{i18n['userlist.onlythisevent']}" /> <h:commandButton action="#{userCartView.traverse}" value="#{i18n['usercart.traverse']}" />
<br /> </div>
<h:inputText value="#{userSearchView.search}" /> </h:panelGroup>
<h:commandButton value="#{i18n['userlist.search']}" action="#{userSearchView.newSearch()}" /> </h:panelGrid>
</h:panelGroup>
<h:panelGroup>
<h:outputText value="i18n['usercart.cartsize']" /> <h:outputText value="#{userCartView.userCartSize}" />
<br/>
<h:commandButton actionListener="#{userSearchView.addToCart}" value="#{i18n['usercart.addSearcherUsers']}" />
<h:commandButton action="#{userCartView.traverse}" value="#{i18n['usercart.traverse']}"/>
</h:panelGroup>
</h:panelGrid>
</h:form> </h:form>
<p> <p>
......
...@@ -5,6 +5,7 @@ import javax.enterprise.context.ConversationScoped; ...@@ -5,6 +5,7 @@ import javax.enterprise.context.ConversationScoped;
import javax.faces.model.ListDataModel; import javax.faces.model.ListDataModel;
import javax.inject.Named; import javax.inject.Named;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.FoodWaveBeanLocal; import fi.insomnia.bortal.beans.FoodWaveBeanLocal;
import fi.insomnia.bortal.enums.apps.ShopPermission; import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.model.FoodWaveTemplate; import fi.insomnia.bortal.model.FoodWaveTemplate;
...@@ -19,6 +20,9 @@ public class FoodWaveView extends GenericCDIView { ...@@ -19,6 +20,9 @@ public class FoodWaveView extends GenericCDIView {
private FoodWaveBeanLocal foodwaveBean; private FoodWaveBeanLocal foodwaveBean;
private ListDataModel<FoodWaveTemplate> templates; private ListDataModel<FoodWaveTemplate> templates;
private FoodWaveTemplate template; private FoodWaveTemplate template;
private Integer templateId;
@EJB
private EventBeanLocal eventbean;
public void initTemplateList() public void initTemplateList()
{ {
...@@ -34,6 +38,7 @@ public class FoodWaveView extends GenericCDIView { ...@@ -34,6 +38,7 @@ public class FoodWaveView extends GenericCDIView {
if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS) && template == null) if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS) && template == null)
{ {
template = foodwaveBean.findTemplate(templateId);
super.beginConversation(); super.beginConversation();
} }
...@@ -43,7 +48,8 @@ public class FoodWaveView extends GenericCDIView { ...@@ -43,7 +48,8 @@ public class FoodWaveView extends GenericCDIView {
{ {
if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS) && template == null) if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS) && template == null)
{ {
setTemplate(new FoodWaveTemplate()); template = new FoodWaveTemplate();
template.setEvent(eventbean.getCurrentEvent());
super.beginConversation(); super.beginConversation();
} }
} }
...@@ -57,7 +63,8 @@ public class FoodWaveView extends GenericCDIView { ...@@ -57,7 +63,8 @@ public class FoodWaveView extends GenericCDIView {
public String saveTemplate() public String saveTemplate()
{ {
setTemplate(foodwaveBean.saveOrCreateTemplate(getTemplate())); setTemplate(foodwaveBean.saveOrCreateTemplate(getTemplate()));
return null;
return "/foodadmin/editTemplate";
} }
public FoodWaveTemplate getTemplate() { public FoodWaveTemplate getTemplate() {
......
...@@ -28,6 +28,7 @@ public class UserCartView extends GenericCDIView { ...@@ -28,6 +28,7 @@ public class UserCartView extends GenericCDIView {
public void initView() public void initView()
{ {
} }
private static final Logger logger = LoggerFactory.getLogger(UserCartView.class); private static final Logger logger = LoggerFactory.getLogger(UserCartView.class);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!