Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
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 0335b31b
authored
Oct 26, 2012
by
Riku Silvola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit templates in beans
1 parent
9c27721e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
166 additions
and
25 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/FoodWaveBean.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/FoodWaveBeanLocal.java
code/LanBortalWeb/WebContent/foodadmin/editTemplate.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/FoodWaveView.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/FoodWaveBean.java
View file @
0335b31
package
fi
.
insomnia
.
bortal
.
beans
;
package
fi
.
insomnia
.
bortal
.
beans
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
javax.annotation.security.DeclareRoles
;
import
javax.annotation.security.DeclareRoles
;
...
@@ -11,8 +12,11 @@ import sun.reflect.generics.reflectiveObjects.NotImplementedException;
...
@@ -11,8 +12,11 @@ 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.FoodWaveFacade
;
import
fi.insomnia.bortal.facade.FoodWaveTemplateFacade
;
import
fi.insomnia.bortal.facade.FoodWaveTemplateFacade
;
import
fi.insomnia.bortal.facade.GenericFacade
;
import
fi.insomnia.bortal.facade.ProductFacade
;
import
fi.insomnia.bortal.model.FoodWave
;
import
fi.insomnia.bortal.model.FoodWave
;
import
fi.insomnia.bortal.model.FoodWaveTemplate
;
import
fi.insomnia.bortal.model.FoodWaveTemplate
;
import
fi.insomnia.bortal.model.Product
;
/**
/**
* Session Bean implementation class FoodWaveBean
* Session Bean implementation class FoodWaveBean
...
@@ -26,6 +30,8 @@ public class FoodWaveBean implements FoodWaveBeanLocal {
...
@@ -26,6 +30,8 @@ public class FoodWaveBean implements FoodWaveBeanLocal {
@EJB
@EJB
private
FoodWaveFacade
foodWaveFacade
;
private
FoodWaveFacade
foodWaveFacade
;
@EJB
private
ProductFacade
productfacade
;
@Override
@Override
@RolesAllowed
(
ShopPermission
.
S_MANAGE_PRODUCTS
)
@RolesAllowed
(
ShopPermission
.
S_MANAGE_PRODUCTS
)
...
@@ -38,7 +44,7 @@ public class FoodWaveBean implements FoodWaveBeanLocal {
...
@@ -38,7 +44,7 @@ public class FoodWaveBean implements FoodWaveBeanLocal {
public
void
createFoodWave
(
FoodWave
fw
)
{
public
void
createFoodWave
(
FoodWave
fw
)
{
foodWaveFacade
.
create
(
fw
);
foodWaveFacade
.
create
(
fw
);
}
}
@Override
@Override
@RolesAllowed
(
ShopPermission
.
S_MANAGE_PRODUCTS
)
@RolesAllowed
(
ShopPermission
.
S_MANAGE_PRODUCTS
)
public
FoodWaveTemplate
saveOrCreateTemplate
(
FoodWaveTemplate
template
)
{
public
FoodWaveTemplate
saveOrCreateTemplate
(
FoodWaveTemplate
template
)
{
...
@@ -81,10 +87,34 @@ public class FoodWaveBean implements FoodWaveBeanLocal {
...
@@ -81,10 +87,34 @@ public class FoodWaveBean implements FoodWaveBeanLocal {
public
FoodWaveTemplate
findTemplate
(
Integer
templateId
)
{
public
FoodWaveTemplate
findTemplate
(
Integer
templateId
)
{
return
fwtFacade
.
find
(
templateId
);
return
fwtFacade
.
find
(
templateId
);
}
}
@Override
@Override
public
List
<
FoodWave
>
getEventFoodWaves
()
{
public
List
<
FoodWave
>
getEventFoodWaves
()
{
return
foodWaveFacade
.
getEventFoodWaves
();
return
foodWaveFacade
.
getEventFoodWaves
();
}
}
@Override
public
FoodWaveTemplate
addProductToTemplate
(
FoodWaveTemplate
template
,
Product
product
)
{
template
=
fwtFacade
.
reload
(
template
);
if
(
product
.
getId
()
==
null
)
{
productfacade
.
create
(
product
);
}
else
{
product
=
productfacade
.
reload
(
product
);
}
if
(
product
.
getFoodWaveTemplates
()
==
null
)
{
product
.
setFoodWaveTemplates
(
new
ArrayList
<
FoodWaveTemplate
>());
}
if
(
template
.
getProducts
()
==
null
)
{
template
.
setProducts
(
new
ArrayList
<
Product
>());
}
template
.
getProducts
().
add
(
product
);
product
.
getFoodWaveTemplates
().
add
(
template
);
return
template
;
}
}
}
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/FoodWaveBeanLocal.java
View file @
0335b31
...
@@ -6,6 +6,7 @@ import javax.ejb.Local;
...
@@ -6,6 +6,7 @@ import javax.ejb.Local;
import
fi.insomnia.bortal.model.FoodWave
;
import
fi.insomnia.bortal.model.FoodWave
;
import
fi.insomnia.bortal.model.FoodWaveTemplate
;
import
fi.insomnia.bortal.model.FoodWaveTemplate
;
import
fi.insomnia.bortal.model.Product
;
@Local
@Local
public
interface
FoodWaveBeanLocal
{
public
interface
FoodWaveBeanLocal
{
...
@@ -29,4 +30,6 @@ public interface FoodWaveBeanLocal {
...
@@ -29,4 +30,6 @@ public interface FoodWaveBeanLocal {
public
List
<
FoodWave
>
getEventFoodWaves
();
public
List
<
FoodWave
>
getEventFoodWaves
();
public
void
createFoodWave
(
FoodWave
fw
);
public
void
createFoodWave
(
FoodWave
fw
);
FoodWaveTemplate
addProductToTemplate
(
FoodWaveTemplate
template
,
Product
currentProduct
);
}
}
code/LanBortalWeb/WebContent/foodadmin/editTemplate.xhtml
View file @
0335b31
<!DOCTYPE html
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
"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"
<html
xmlns=
"http://www.w3.org/1999/xhtml"
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"
xmlns:p=
"http://primefaces.org/ui"
>
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"
xmlns:p=
"http://primefaces.org/ui"
>
<h:body>
<h:body>
<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=
"#{foodWaveView.templateId}"
/>
<f:viewParam
name=
"id"
value=
"#{foodWaveView.templateId}"
/>
</f:metadata>
</f:metadata>
...
@@ -18,34 +26,123 @@
...
@@ -18,34 +26,123 @@
<h:form>
<h:form>
<p:panel
header=
"#{i18n['foodwavetemplate.edit']}"
>
<p:panel
header=
"#{i18n['foodwavetemplate.edit']}"
>
<h:panelGrid
columns=
"3"
>
<h:panelGrid
columns=
"3"
>
<h:outputLabel
for=
"name"
value=
"#{i18n['foodwavetemplate.name']}"
/>
<h:outputLabel
for=
"name"
value=
"#{i18n['foodwave.template.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:outputLabel
for=
"desc"
value=
"#{i18n['foodwavetemplate.description']}"
/>
<h:outputLabel
for=
"desc"
<h:inputText
id=
"desc"
value=
"#{foodWaveView.template.description}"
/>
value=
"#{i18n['foodwave.template.description']}"
/>
<h:inputText
id=
"desc"
value=
"#{foodWaveView.template.description}"
/>
<h:message
for=
"desc"
/>
<h:message
for=
"desc"
/>
<h:outputText
value=
" "
/>
<h:outputText
value=
" "
/>
<h:commandButton
action=
"#{foodWaveView.saveTemplate()}"
value=
"#{i18n['foodwavetemplate.save']}"
/>
<h:commandButton
action=
"#{foodWaveView.saveTemplate()}"
value=
"#{i18n['foodwavetemplate.save']}"
/>
</h:panelGrid>
</h:panelGrid>
<h:selectOneMenu
value=
"#{foodWaveView.currentProduct}"
converter=
"#{productConverter}"
>
<f:selectItems
value=
"#{foodWaveView.products}"
var=
"product"
itemLabel=
"#{product.name}"
></f:selectItems>
</h:selectOneMenu>
<p:commandButton
value=
"#{i18n['foodwavetemplate.addproduct']}"
actionListener=
"#{foodWaveView.addProductToTemplate}"
update=
"productTable"
/>
<!-- <h:panelGrid columns="4">
<h:outputText value="#{i18n['foodwavetemplate.productname']}" />
<h:outputText
value="#{i18n['foodwavetemplate.productdescription']}" />
<h:outputText value="#{i18n['foodwavetemplate.price']}" />
<h:outputText value=" " />
<h:inputText id="productname"
value="#{foodWaveView.currentProduct.name}" />
<h:inputText id="productdescription"
value="#{foodWaveView.currentProduct.description}" />
<h:inputText id="price"
value="#{foodWaveView.currentProduct.price}" />
<p:commandButton value="#{i18n['foodwavetemplate.addproduct']}"
actionListener="#{foodWaveView.addProductToTemplate}"
update="productTable" />
</h:panelGrid>
-->
<p:dataTable
name=
"productTable"
id=
"productTable"
value=
"#{foodWaveView.template.products}"
var=
"product"
editable=
"true"
>
<p:column
headerText=
"#{i18n['foodwavetemplate.productname']}"
>
<p:cellEditor>
<f:facet
name=
"output"
>
<h:outputText
value=
"#{product.name}"
/>
</f:facet>
<f:facet
name=
"input"
>
<p:inputText
value=
"#{product.name}"
style=
"width:100%"
required=
"true"
requiredMessage=
"Name required"
/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column
headerText=
"#{i18n['foodwavetemplate.productdescription']}"
>
<p:cellEditor>
<f:facet
name=
"output"
>
<h:outputText
value=
"#{product.description}"
/>
</f:facet>
<f:facet
name=
"input"
>
<p:inputText
value=
"#{product.description}"
style=
"width:100%"
required=
"true"
requiredMessage=
"Description required"
/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column
headerText=
"#{i18n['foodwavetemplate.price']}"
>
<p:cellEditor>
<f:facet
name=
"output"
>
<h:outputText
value=
"#{product.price}"
/>
</f:facet>
<f:facet
name=
"input"
>
<p:inputText
value=
"#{product.price}"
style=
"width:100%"
required=
"true"
requiredMessage=
"Price required"
/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column
headerText=
"#{i18n['foodwavetemplate.editRow']}"
style=
"width:20px"
>
<p:rowEditor
/>
</p:column>
<p:column
headerText=
"#{i18n['foodwavetemplate.actions']}"
style=
"width:20px;"
>
<p:commandButton
value=
"#{i18n['foodwavetemplate.removeFromList']}"
action=
"#{foodWaveView.removeProductFromList(product)}"
update=
"productTable"
/>
</p:column>
</p:dataTable>
<h:commandButton
action=
"#{foodWaveView.saveTemplate()}"
value=
"#{i18n['foodwavetemplate.savetemplate']}"
/>
<!-- -->
</p:panel>
</p:panel>
<p:panel
header=
"#{i18n['foodwavetemplate.createwave']}"
>
<p:panel
header=
"#{i18n['foodwavetemplate.createwave']}"
>
<h:panelGrid
columns=
"3"
>
<h:panelGrid
columns=
"3"
>
<h:outputLabel
for=
"waveName"
value=
"#{i18n['foodwavetemplate.waveName']}"
/>
<h:outputLabel
for=
"waveName"
<h:inputText
id=
"waveName"
value=
"#{foodWaveView.selectedFoodWave.name}"
/>
value=
"#{i18n['foodwavetemplate.waveName']}"
/>
<h:inputText
id=
"waveName"
value=
"#{foodWaveView.selectedFoodWave.name}"
/>
<h:message
for=
"waveName"
/>
<h:message
for=
"waveName"
/>
<h:outputLabel
for=
"waveMaxFoods"
value=
"#{i18n['foodwavetemplate.maxfoods']}"
/>
<h:outputLabel
for=
"waveMaxFoods"
<h:inputText
id=
"waveMaxFoods"
value=
"#{foodWaveView.selectedFoodWave.maximumFoods}"
/>
value=
"#{i18n['foodwavetemplate.maxfoods']}"
/>
<h:inputText
id=
"waveMaxFoods"
value=
"#{foodWaveView.selectedFoodWave.maximumFoods}"
/>
<h:message
for=
"waveMaxFoods"
/>
<h:message
for=
"waveMaxFoods"
/>
<h:outputLabel
for=
"startTime"
value=
"#{i18n['foodwavetemplate.startTime']}"
/>
<h:outputLabel
for=
"startTime"
<p:calendar
id=
"startTime"
value=
"#{foodWaveView.startDate}"
pattern=
"dd.MM.yyyy HH:mm"
/>
value=
"#{i18n['foodwavetemplate.startTime']}"
/>
<p:calendar
id=
"startTime"
value=
"#{foodWaveView.startDate}"
pattern=
"dd.MM.yyyy HH:mm"
/>
<h:message
for=
"startTime"
/>
<h:message
for=
"startTime"
/>
</h:panelGrid>
</h:panelGrid>
<h:commandButton
action=
"#{foodWaveView.createFoodwave()}"
value=
"#{i18n['foodwavetemplate.createFoodwave']}"
/>
<h:commandButton
action=
"#{foodWaveView.createFoodwave()}"
value=
"#{i18n['foodwavetemplate.createFoodwave']}"
/>
</p:panel>
</p:panel>
</h:form>
</h:form>
<ui:fragment>
<ui:fragment>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/FoodWaveView.java
View file @
0335b31
...
@@ -3,6 +3,7 @@ package fi.insomnia.bortal.web.cdiview.shop;
...
@@ -3,6 +3,7 @@ package fi.insomnia.bortal.web.cdiview.shop;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.TreeSet
;
import
java.util.TreeSet
;
import
java.util.Vector
;
import
java.util.Vector
;
...
@@ -14,6 +15,7 @@ import javax.inject.Named;
...
@@ -14,6 +15,7 @@ import javax.inject.Named;
import
fi.insomnia.bortal.beans.EventBeanLocal
;
import
fi.insomnia.bortal.beans.EventBeanLocal
;
import
fi.insomnia.bortal.beans.FoodWaveBeanLocal
;
import
fi.insomnia.bortal.beans.FoodWaveBeanLocal
;
import
fi.insomnia.bortal.beans.ProductBeanLocal
;
import
fi.insomnia.bortal.enums.apps.ShopPermission
;
import
fi.insomnia.bortal.enums.apps.ShopPermission
;
import
fi.insomnia.bortal.model.FoodWave
;
import
fi.insomnia.bortal.model.FoodWave
;
import
fi.insomnia.bortal.model.FoodWaveTemplate
;
import
fi.insomnia.bortal.model.FoodWaveTemplate
;
...
@@ -37,7 +39,10 @@ public class FoodWaveView extends GenericCDIView {
...
@@ -37,7 +39,10 @@ public class FoodWaveView extends GenericCDIView {
private
Integer
templateId
;
private
Integer
templateId
;
@EJB
@EJB
private
EventBeanLocal
eventbean
;
private
EventBeanLocal
eventbean
;
@EJB
private
ProductBeanLocal
productbeanlocal
;
private
ListDataModel
<
FoodWave
>
foodWaves
;
private
ListDataModel
<
FoodWave
>
foodWaves
;
private
FoodWave
selectedFoodWave
=
null
;
private
FoodWave
selectedFoodWave
=
null
;
...
@@ -47,6 +52,10 @@ public class FoodWaveView extends GenericCDIView {
...
@@ -47,6 +52,10 @@ public class FoodWaveView extends GenericCDIView {
private
Product
currentProduct
;
private
Product
currentProduct
;
public
List
<
Product
>
getProducts
()
{
return
productbeanlocal
.
getProducts
();
}
public
void
initTemplateList
()
{
public
void
initTemplateList
()
{
if
(
super
.
requirePermissions
(
ShopPermission
.
LIST_USERPRODUCTS
))
{
if
(
super
.
requirePermissions
(
ShopPermission
.
LIST_USERPRODUCTS
))
{
...
@@ -63,8 +72,8 @@ public class FoodWaveView extends GenericCDIView {
...
@@ -63,8 +72,8 @@ public class FoodWaveView extends GenericCDIView {
foodWaveBean
.
createFoodWave
(
selectedFoodWave
);
foodWaveBean
.
createFoodWave
(
selectedFoodWave
);
initFoodwaveManagerList
();
return
"/food
admin/listTemplat
es"
;
return
"/food
manager/listFoodwav
es"
;
}
}
public
void
initEditTemplate
()
{
public
void
initEditTemplate
()
{
...
@@ -72,6 +81,8 @@ public class FoodWaveView extends GenericCDIView {
...
@@ -72,6 +81,8 @@ 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
);
template
=
foodWaveBean
.
findTemplate
(
templateId
);
// prepare to make new foodwaves
selectedFoodWave
=
new
FoodWave
();
selectedFoodWave
=
new
FoodWave
();
selectedFoodWave
.
setTemplate
(
template
);
selectedFoodWave
.
setTemplate
(
template
);
super
.
beginConversation
();
super
.
beginConversation
();
...
@@ -102,7 +113,7 @@ public class FoodWaveView extends GenericCDIView {
...
@@ -102,7 +113,7 @@ public class FoodWaveView extends GenericCDIView {
}
}
public
void
addProductToTemplate
()
{
public
void
addProductToTemplate
()
{
template
.
getProducts
().
add
(
currentProduct
);
template
=
foodWaveBean
.
addProductToTemplate
(
template
,
currentProduct
);
createNewProductSkeleton
();
createNewProductSkeleton
();
}
}
...
...
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