Commit a732e5d7 by Tuomas Riihimäki

foodwavea..

1 parent 86e51802
......@@ -7,7 +7,9 @@ import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
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;
......@@ -21,6 +23,8 @@ public class FoodWaveBean implements FoodWaveBeanLocal {
@EJB
private FoodWaveTemplateFacade fwtFacade;
@EJB
private FoodWaveFacade foodwaveFacade;
@Override
@RolesAllowed(ShopPermission.S_MANAGE_PRODUCTS)
......@@ -31,20 +35,28 @@ public class FoodWaveBean implements FoodWaveBeanLocal {
@Override
@RolesAllowed(ShopPermission.S_MANAGE_PRODUCTS)
public FoodWaveTemplate saveOrCreateTemplate(FoodWaveTemplate template) {
// TODO Auto-generated method stub
return null;
if (template.getId() == null)
{
fwtFacade.create(template);
} else {
template = fwtFacade.merge(template);
}
return template;
}
@Override
public List<FoodWave> findShoppableFoodwaves() {
// TODO Auto-generated method stub
return null;
throw new NotImplementedException();
}
@Override
public FoodWave findFoodwave(Integer foodwaveId) {
// TODO Auto-generated method stub
return null;
return foodwaveFacade.find(foodwaveId);
}
@Override
public FoodWaveTemplate findTemplate(Integer templateId) {
return fwtFacade.find(templateId);
}
}
......@@ -29,8 +29,21 @@ public class FoodWaveTemplateFacade extends IntegerPkGenericFacade<FoodWaveTempl
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());
cq.where(cb.equal(root.get(FoodWaveTemplate_.event), eventbean.getCurrentEvent()));
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 {
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 @@
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{foodWaveView.initEditTemplate()}" />
<f:viewParam name="id" value="#{userView.templateId}" />
</f:metadata>
<ui:define name="title">
......@@ -19,15 +21,18 @@
<h:outputLabel for="name" value="#{i18n['foodwavetemplate.name']}" />
<h:inputText id="name" value="#{foodWaveView.template.name}" />
<h:message for="name" />
</h:panelGrid>
<h:inputTextarea value="#{foodWaveView.template.description}" />
<h:commanButton action="#{foodWaveView.saveTemplate()}" value="#{i18n['foowavetemplate.save']}" />
<div>
<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:form>
<ui:fragment >
</h:form>
<ui:fragment>
</ui:fragment>
</ui:define>
......
......@@ -7,6 +7,7 @@
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{foodWaveView.initTemplateList()}" />
<f:viewParam name="id" value="#{foodWaveView.templateId}" />
</f:metadata>
<ui:define name="title">
......
......@@ -16,49 +16,45 @@
<ui:define name="content">
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
<h1>#{i18n['userlist.header']}</h1>
<h:form>
<h:panelGrid columns="2">
<h:panelGroup>
<a onclick="$('#advancedSearch').show(); $(this).hide();" ><h:outputText value="#{i18n['userlist.showAdvancedSearch']}" /></a>
<span id="advancedSearch" style="display:none;">
<h:selectBooleanCheckbox id="placeassoc" value="#{userSearchView.searchQuery.placeAssoc}" />
<h:outputLabel for="placeassoc" value="#{i18n['userlist.placeassoc']}" />
<h:panelGrid columns="2">
<h:panelGroup>
<a onclick="$('#advancedSearch').show(); $(this).hide();"><h:outputText value="#{i18n['userlist.showAdvancedSearch']}" /></a>
<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}">
<f:selectItems value="#{userSearchView.searchQuery.accountCompareValues}" />
</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 />
<h:outputLabel for="saldofilter" value="#{i18n['userlist.saldofilter']}" />
<h:selectOneMenu value="#{userSearchView.searchQuery.accountSaldoCompare}">
<f:selectItems value="#{userSearchView.searchQuery.accountCompareValues}" />
</h:selectOneMenu>
<h:inputText value="#{userSearchView.searchQuery.accountSaldo}">
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:inputText>
<h:selectBooleanCheckbox id="onlythisevent" value="#{userSearchView.searchQuery.onlyThisEvent}" />
<h:outputLabel for="onlythisevent" value="#{i18n['userlist.onlythisevent']}" />
<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 />
<h:selectBooleanCheckbox id="onlythisevent" value="#{userSearchView.searchQuery.onlyThisEvent}" />
<h:outputLabel for="onlythisevent" value="#{i18n['userlist.onlythisevent']}" />
<br />
<h:inputText value="#{userSearchView.search}" />
<h:commandButton value="#{i18n['userlist.search']}" action="#{userSearchView.newSearch()}" />
</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:inputText value="#{userSearchView.search}" />
<h:commandButton value="#{i18n['userlist.search']}" action="#{userSearchView.newSearch()}" />
</h:panelGroup>
<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')};">
<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']}" />
</div>
</h:panelGroup>
</h:panelGrid>
</h:form>
<p>
......
......@@ -5,6 +5,7 @@ import javax.enterprise.context.ConversationScoped;
import javax.faces.model.ListDataModel;
import javax.inject.Named;
import fi.insomnia.bortal.beans.EventBeanLocal;
import fi.insomnia.bortal.beans.FoodWaveBeanLocal;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.model.FoodWaveTemplate;
......@@ -19,6 +20,9 @@ public class FoodWaveView extends GenericCDIView {
private FoodWaveBeanLocal foodwaveBean;
private ListDataModel<FoodWaveTemplate> templates;
private FoodWaveTemplate template;
private Integer templateId;
@EJB
private EventBeanLocal eventbean;
public void initTemplateList()
{
......@@ -34,6 +38,7 @@ public class FoodWaveView extends GenericCDIView {
if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS) && template == null)
{
template = foodwaveBean.findTemplate(templateId);
super.beginConversation();
}
......@@ -43,7 +48,8 @@ public class FoodWaveView extends GenericCDIView {
{
if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS) && template == null)
{
setTemplate(new FoodWaveTemplate());
template = new FoodWaveTemplate();
template.setEvent(eventbean.getCurrentEvent());
super.beginConversation();
}
}
......@@ -57,7 +63,8 @@ public class FoodWaveView extends GenericCDIView {
public String saveTemplate()
{
setTemplate(foodwaveBean.saveOrCreateTemplate(getTemplate()));
return null;
return "/foodadmin/editTemplate";
}
public FoodWaveTemplate getTemplate() {
......
......@@ -28,6 +28,7 @@ public class UserCartView extends GenericCDIView {
public void initView()
{
}
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!