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 62938a4e
authored
Feb 11, 2012
by
Tuukka Kivilahti, TKffTK
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of dev.intra.insomnia.fi:/data/bortal
2 parents
2eb42892
3d9986b2
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
317 additions
and
172 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/ReaderBean.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/TestDataBean.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/UserUtilBean.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/CardTemplateFacade.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/EventOrganiserFacade.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/GenericFacade.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/ProductFacade.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/SitePageFacade.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/UserFacade.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/RoleBeanLocal.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/TestDataBeanLocal.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/NewsGroup.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Role.java
code/LanBortalWeb/WebContent/product/createDiscount.xhtml
code/LanBortalWeb/WebContent/product/edit.xhtml
code/LanBortalWeb/WebContent/product/editDiscount.xhtml
code/LanBortalWeb/WebContent/resources/cditools/products/edit.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/resources/i18n.properties
code/LanBortalWeb/src/fi/insomnia/bortal/web/TestDataView.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/ProductView.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/user/RoleDataView.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/converter/PollAnswerConverter.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/converter/RoleConverter.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/ReaderBean.java
View file @
62938a4
...
...
@@ -45,7 +45,6 @@ public class ReaderBean implements ReaderBeanLocal {
@Override
public
ReaderEvent
checkTag
(
String
ident
,
String
tag
,
String
hash
)
{
LanEvent
ev
=
eventbean
.
getCurrentEvent
();
PrintedCard
card
=
cardfacade
.
findByRfid
(
tag
);
ReaderEvent
ret
=
null
;
logger
.
debug
(
"Found card by rfid: {}"
,
card
);
...
...
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/TestDataBean.java
View file @
62938a4
...
...
@@ -5,7 +5,6 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.net.URISyntaxException
;
import
java.util.Calendar
;
import
java.util.List
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
...
...
@@ -272,16 +271,17 @@ public class TestDataBean implements TestDataBeanLocal {
}
}
@Override
public
void
printPlacesInfo
()
{
logger
.
debug
(
"Fetching places"
);
List
<
Place
>
places
=
placeFacade
.
findAll
();
logger
.
debug
(
"Got places: {}"
,
places
);
logger
.
info
(
"Printing info from places"
);
for
(
Place
place
:
places
)
{
logger
.
info
(
"Place id: {}. Event Map id: {}."
,
place
.
getId
(),
place
.
getMap
().
getId
());
}
}
// @Override
// public void printPlacesInfo() {
// logger.debug("Fetching places");
// List<Place> places = placeFacade.findAll();
// logger.debug("Got places: {}", places);
// logger.info("Printing info from places");
// for (Place place : places) {
// logger.info("Place id: {}. Event Map id: {}.", place.getId(),
// place.getMap().getId());
// }
// }
@Override
public
void
generateTestCompos
()
{
...
...
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/UserUtilBean.java
View file @
62938a4
...
...
@@ -39,7 +39,6 @@ public class UserUtilBean implements UserUtilBeanLocal {
logger
.
warn
(
"User {} has empty login..."
);
continue
;
}
User
testU
=
userfacade
.
findByLogin
(
u
.
getLogin
().
toLowerCase
());
if
(
testU
==
null
||
testU
.
equals
(
u
))
{
u
.
setLogin
(
u
.
getLogin
().
toLowerCase
());
...
...
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/CardTemplateFacade.java
View file @
62938a4
package
fi
.
insomnia
.
bortal
.
facade
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
javax.persistence.EntityManager
;
import
javax.persistence.PersistenceContext
;
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.CardTemplate
;
import
fi.insomnia.bortal.model.CardTemplate_
;
@Stateless
@LocalBean
...
...
@@ -13,6 +21,8 @@ public class CardTemplateFacade extends GenericFacade<Integer, CardTemplate> {
@PersistenceContext
private
EntityManager
em
;
@EJB
private
EventBeanLocal
eventbean
;
public
CardTemplateFacade
()
{
super
(
CardTemplate
.
class
);
...
...
@@ -23,4 +33,14 @@ public class CardTemplateFacade extends GenericFacade<Integer, CardTemplate> {
return
em
;
}
public
List
<
CardTemplate
>
findAll
()
{
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
CardTemplate
>
cq
=
cb
.
createQuery
(
CardTemplate
.
class
);
Root
<
CardTemplate
>
root
=
cq
.
from
(
CardTemplate
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
CardTemplate_
.
event
),
eventbean
.
getCurrentEvent
()));
return
em
.
createQuery
(
cq
).
getResultList
();
}
}
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/EventOrganiserFacade.java
View file @
62938a4
package
fi
.
insomnia
.
bortal
.
facade
;
import
java.util.List
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
javax.persistence.EntityManager
;
...
...
@@ -37,4 +39,11 @@ public class EventOrganiserFacade extends GenericFacade<Integer, EventOrganiser>
return
getSingleNullableResult
(
em
.
createQuery
(
cq
));
}
public
List
<
EventOrganiser
>
findAll
()
{
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
EventOrganiser
>
cq
=
cb
.
createQuery
(
EventOrganiser
.
class
);
return
em
.
createQuery
(
cq
).
getResultList
();
}
}
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/GenericFacade.java
View file @
62938a4
...
...
@@ -74,34 +74,40 @@ public abstract class GenericFacade<I extends Serializable, C extends ModelInter
return
ret
;
}
@Deprecated
public
List
<
C
>
findAll
()
{
return
findAll
(
null
);
}
@Deprecated
public
List
<
C
>
findAll
(
String
sort
)
{
return
findAll
(
0
,
0
,
sort
);
}
@Deprecated
public
List
<
C
>
findRange
(
int
[]
range
)
{
CriteriaQuery
<
C
>
cq
=
getEm
().
getCriteriaBuilder
().
createQuery
(
getEntityClass
());
cq
.
select
(
cq
.
from
(
getEntityClass
()));
TypedQuery
<
C
>
q
=
getEm
().
createQuery
(
cq
);
q
.
setMaxResults
(
range
[
1
]
-
range
[
0
]);
q
.
setFirstResult
(
range
[
0
]);
return
q
.
getResultList
();
}
@Deprecated
public
long
count
()
{
CriteriaQuery
<
Long
>
cq
=
getEm
().
getCriteriaBuilder
().
createQuery
(
Long
.
class
);
Root
<
C
>
rt
=
cq
.
from
(
getEntityClass
());
cq
.
select
(
getEm
().
getCriteriaBuilder
().
count
(
rt
));
TypedQuery
<
Long
>
q
=
getEm
().
createQuery
(
cq
);
return
q
.
getSingleResult
();
}
/**
* Deprekoitu! Yleensä ei haluta palauttaa kaikkia entryjä kannasta, vaan
* vain ko. tapahtumaan / käyttäjään / muuhun olioon liittyvät Jos oikeasti
* tarpeellinen luo funktio facadeen!
*/
// @Deprecated
// public List<C> findAll() {
// return findAll(null);
// }
//
// @Deprecated
// public List<C> findAll(String sort) {
// return findAll(0, 0, sort);
// }
//
// @Deprecated
// public List<C> findRange(int[] range) {
// CriteriaQuery<C> cq =
// getEm().getCriteriaBuilder().createQuery(getEntityClass());
// cq.select(cq.from(getEntityClass()));
// TypedQuery<C> q = getEm().createQuery(cq);
// q.setMaxResults(range[1] - range[0]);
// q.setFirstResult(range[0]);
// return q.getResultList();
// }
// @Deprecated
// public long count() {
// CriteriaQuery<Long> cq =
// getEm().getCriteriaBuilder().createQuery(Long.class);
// Root<C> rt = cq.from(getEntityClass());
// cq.select(getEm().getCriteriaBuilder().count(rt));
// TypedQuery<Long> q = getEm().createQuery(cq);
// return q.getSingleResult();
// }
protected
static
<
K
>
K
getSingleNullableResult
(
TypedQuery
<
K
>
q
)
{
K
ret
=
null
;
...
...
@@ -247,26 +253,26 @@ public abstract class GenericFacade<I extends Serializable, C extends ModelInter
return
q
.
getSingleResult
();
}
@Deprecated
public
List
<
C
>
findAll
(
int
page
,
int
pagesize
,
String
sort
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
C
>
cq
=
cb
.
createQuery
(
getEntityClass
());
Root
<
C
>
root
=
cq
.
from
(
getEntityClass
());
if
(
sort
!=
null
)
{
cq
.
orderBy
(
cb
.
asc
(
root
.
get
(
sort
)));
}
cq
.
select
(
cq
.
from
(
getEntityClass
()));
TypedQuery
<
C
>
q
=
getEm
().
createQuery
(
cq
);
if
(
pagesize
>
0
)
{
q
.
setFirstResult
(
page
*
pagesize
);
q
.
setMaxResults
(
pagesize
);
}
return
q
.
getResultList
();
}
//
@Deprecated
//
public List<C> findAll(int page, int pagesize, String sort) {
//
CriteriaBuilder cb = getEm().getCriteriaBuilder();
//
CriteriaQuery<C> cq = cb.createQuery(getEntityClass());
//
Root<C> root = cq.from(getEntityClass());
//
//
if (sort != null) {
//
cq.orderBy(cb.asc(root.get(sort)));
//
}
//
//
cq.select(cq.from(getEntityClass()));
//
TypedQuery<C> q = getEm().createQuery(cq);
//
//
if (pagesize > 0) {
//
q.setFirstResult(page * pagesize);
//
q.setMaxResults(pagesize);
//
}
//
//
return q.getResultList();
//
}
public
void
flush
()
{
getEm
().
flush
();
...
...
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/ProductFacade.java
View file @
62938a4
...
...
@@ -31,6 +31,16 @@ public class ProductFacade extends IntegerPkGenericFacade<Product> {
super
(
Product
.
class
);
}
public
List
<
Product
>
findAll
()
{
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Product
>
cq
=
cb
.
createQuery
(
Product
.
class
);
Root
<
Product
>
root
=
cq
.
from
(
Product
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
Product_
.
event
),
eventbean
.
getCurrentEvent
()));
return
em
.
createQuery
(
cq
).
getResultList
();
}
@Override
protected
EntityManager
getEm
()
{
return
em
;
...
...
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/SitePageFacade.java
View file @
62938a4
...
...
@@ -79,7 +79,6 @@ public class SitePageFacade extends GenericFacade<Integer, SitePage> {
}
@Override
public
List
<
SitePage
>
findAll
()
{
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
...
...
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/UserFacade.java
View file @
62938a4
...
...
@@ -166,4 +166,12 @@ public class UserFacade extends GenericFacade<Integer, User> {
em
.
getEntityManagerFactory
().
getCache
().
evictAll
();
}
public
List
<
User
>
findAll
()
{
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
User
>
cq
=
cb
.
createQuery
(
User
.
class
);
return
em
.
createQuery
(
cq
).
getResultList
();
}
}
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/RoleBeanLocal.java
View file @
62938a4
...
...
@@ -31,4 +31,6 @@ public interface RoleBeanLocal {
public
Role
setPermissions
(
Role
role
,
List
<
IAppPermission
>
newPerms
);
public
Object
getEmptyRole
();
}
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/TestDataBeanLocal.java
View file @
62938a4
...
...
@@ -17,7 +17,7 @@ public interface TestDataBeanLocal {
User
createUser
();
public
void
printPlacesInfo
();
//
public void printPlacesInfo();
void
generateTestCompos
();
...
...
code/LanBortalDatabase/src/fi/insomnia/bortal/model/NewsGroup.java
View file @
62938a4
...
...
@@ -54,6 +54,7 @@ public class NewsGroup extends GenericEntity {
@OrderBy
(
"priority"
)
@OneToMany
(
cascade
=
CascadeType
.
ALL
,
mappedBy
=
"group"
)
@PrivateOwned
private
List
<
News
>
news
;
@ManyToMany
()
...
...
@@ -92,9 +93,6 @@ public class NewsGroup extends GenericEntity {
this
.
priority
=
priority
;
}
@OrderBy
(
"priority"
)
@OneToMany
(
mappedBy
=
"group"
,
cascade
=
CascadeType
.
ALL
)
@PrivateOwned
public
List
<
News
>
getNews
()
{
return
news
;
}
...
...
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Role.java
View file @
62938a4
...
...
@@ -32,6 +32,8 @@ public class Role extends GenericEntity {
protected
static
final
String
EVENT_ID_COLUMN
=
"event_id"
;
public
static
final
Role
EMPTY_ROLE
=
new
Role
(
"----"
);
@Column
(
name
=
NAME_COLUMN
,
nullable
=
false
)
private
String
name
;
...
...
@@ -83,6 +85,11 @@ public class Role extends GenericEntity {
this
.
name
=
roleName
;
}
private
Role
(
String
rolename
)
{
setId
(
0
);
name
=
rolename
;
}
public
String
getName
()
{
return
name
;
}
...
...
code/LanBortalWeb/WebContent/product/createDiscount.xhtml
View file @
62938a4
...
...
@@ -11,8 +11,11 @@
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<ui:param
name=
"thispage"
value=
"page.product.edit"
/>
<ui:define
name=
"content"
>
<h:link
id=
"back"
outcome=
"/product/edit"
value=
"#{i18n['product.returnProductEdit']} #{productView.product.name}"
>
<f:param
name=
"productid"
value=
"#{productView.product.id}"
/>
</h:link>
<products:manageDiscount
commitaction=
"#{productView.createDiscount()}"
commitvalue=
"#{i18n['discount.create']}"
/>
...
...
code/LanBortalWeb/WebContent/product/edit.xhtml
View file @
62938a4
<!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"
<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:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:products=
"http://java.sun.com/jsf/composite/cditools/products"
>
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:products=
"http://java.sun.com/jsf/composite/cditools/products"
>
<h:head>
<title></title>
...
...
@@ -18,9 +17,72 @@
</f:metadata>
<ui:param
name=
"thispage"
value=
"page.product.edit"
/>
<ui:define
name=
"content"
>
<products:edit
commitaction=
"#{productView.saveProduct()}"
commitvalue=
"#{i18n['products.save']}"
/>
<products:edit
commitaction=
"#{productView.saveProduct()}"
commitvalue=
"#{i18n['products.save']}"
/>
<h:form
id=
"discounts"
>
<h:commandButton
rendered=
"#{!empty productView.product.id}"
action=
"#{productView.initCreateDiscount()}"
value=
"#{i18n['product.createDiscount']}"
>
</h:commandButton>
<h:dataTable
border=
"1"
id=
"discount"
value=
"#{productView.productDiscounts}"
var=
"discount"
rendered=
"#{!empty productView.product.id and !empty productView.product.discounts}"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.percentage']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.percentage}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.code']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.code}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.details']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.details}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.shortdesc']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.shortdesc}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.amountMin']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.amountMin}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.amountMax']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.amountMax}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.maxNum']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.maxNum}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.perUser']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.perUser}"
/>
</h:column>
<h:column>
<h:commandButton
action=
"#{productView.editDiscount()}"
value=
"#{i18n['discount.edit']}"
/>
</h:column>
</h:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
...
...
code/LanBortalWeb/WebContent/product/editDiscount.xhtml
View file @
62938a4
...
...
@@ -3,7 +3,7 @@
"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:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:
tools=
"http://java.sun.com/jsf/composite/tool
s"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:
products=
"http://java.sun.com/jsf/composite/cditools/product
s"
>
<h:head>
<title></title>
...
...
@@ -11,11 +11,8 @@
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<ui:param
name=
"thispage"
value=
"page.product.edit"
/>
<ui:define
name=
"content"
>
<products:manageDiscount
commitaction=
"#{productView.save()}"
commitvalue=
"#{i18n['discount.save']}"
/>
</ui:define>
</ui:composition>
</h:body>
...
...
code/LanBortalWeb/WebContent/resources/cditools/products/edit.xhtml
View file @
62938a4
...
...
@@ -3,7 +3,7 @@
"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"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
...
...
@@ -15,105 +15,60 @@
<composite:implementation>
<h:form
id=
"productform"
>
<h:inputHidden
value=
"#{productView.product.id}"
/>
<h:panelGrid
columns=
"2"
>
<h:outputLabel
value=
"#{i18n['product.name']}:"
/>
<h:inputText
value=
"#{productView.product.name}"
/>
<h:outputLabel
value=
"#{i18n['product.price']}:"
/>
<h:inputText
value=
"#{productView.product.price}"
/>
<h:outputLabel
value=
"#{i18n['product.unitName']}:"
/>
<h:inputText
value=
"#{productView.product.unitName}"
/>
<h:panelGrid
columns=
"3"
>
<h:outputLabel
for=
"name"
value=
"#{i18n['product.name']}:"
/>
<h:inputText
id=
"name"
value=
"#{productView.product.name}"
/>
<h:message
for=
"name"
/>
<h:outputLabel
for=
"price"
value=
"#{i18n['product.price']}:"
/>
<h:inputText
id=
"price"
value=
"#{productView.product.price}"
/>
<h:message
for=
"price"
/>
<h:outputLabel
for=
"unitName"
value=
"#{i18n['product.unitName']}:"
/>
<h:inputText
id=
"unitName"
value=
"#{productView.product.unitName}"
/>
<h:message
for=
"unitName"
/>
<h:outputLabel
for=
"vat"
value=
"#{i18n['product.vat']}:"
/>
<h:inputText
id=
"vat"
value=
"#{productView.product.vat}"
/>
<h:message
for=
"vat"
/>
<h:outputLabel
for=
"sort"
value=
"#{i18n['product.sort']}:"
/>
<h:inputText
id=
"sort"
value=
"#{productView.product.sort}"
/>
<h:message
for=
"sort"
/>
<h:outputLabel
for=
"barcode"
value=
"#{i18n['product.barcode']}:"
/>
<h:inputText
id=
"barcode"
value=
"#{productView.product.barcode}"
/>
<h:message
for=
"barcode"
/>
<h:outputLabel
for=
"prepaid"
value=
"#{i18n['product.prepaid']}"
/>
<h:selectBooleanCheckbox
id=
"prepaid"
value=
"#{productView.product.prepaid}"
/>
<h:message
for=
"prepaid"
/>
<h:outputLabel
for=
"instant"
value=
"#{i18n['product.prepaidInstant']}"
/>
<h:selectBooleanCheckbox
id=
"instant"
value=
"#{productView.product.prepaidInstant}"
/>
<h:message
for=
"instant"
/>
<h:outputLabel
for=
"provides"
value=
"#{i18n['product.providedRole']}"
/>
<h:selectOneMenu
id=
"provides"
layout=
"pageDirection"
value=
"#{productView.product.provides}"
converter=
"#{roleConverter}"
>
<f:selectItems
var=
"role"
itemLabel=
"#{role.name}"
value=
"#{roleDataView.rolesWithEmpty}"
noSelectionValue=
"#{roleDataView.noSelection}"
/>
</h:selectOneMenu>
<h:message
for=
"provides"
/>
<h:outputLabel
value=
"#{i18n['product.vat']}:"
/>
<h:inputText
value=
"#{productView.product.vat}"
/>
<h:
outputLabel
value=
"#{i18n['product.sort']}:
"
/>
<h:inputText
value=
"#{productView.product.sort}"
/
>
<h:
commandButton
id=
"commitbtn"
action=
"#{cc.attrs.commitaction}"
value=
"#{cc.attrs.commitvalue}
"
/>
</h:panelGrid
>
<h:outputLabel
value=
"#{i18n['product.barcode']}:"
/>
<h:inputText
value=
"#{productView.product.barcode}"
/>
<h:outputLabel
value=
"#{i18n['product.prepaid']}"
/>
<h:selectBooleanCheckbox
value=
"#{productView.product.prepaid}"
/>
<h:outputLabel
value=
"#{i18n['product.prepaidInstant']}"
/>
<h:selectBooleanCheckbox
value=
"#{productView.product.prepaidInstant}"
/>
<h:outputLabel
value=
"#{i18n['product.providedRole']}"
/>
<h:selectOneMenu
layout=
"pageDirection"
value=
"#{productView.product.role}"
converter=
"#{roleConverter}"
id=
"roles"
>
<f:selectItems
var=
"role"
itemLabel=
"#{role.name}"
value=
"#{roleDataView.roles}"
/>
</h:selectOneMenu>
<h:commandButton
id=
"commitbtn"
action=
"#{cc.attrs.commitaction}"
value=
"#{cc.attrs.commitvalue}"
/>
</h:panelGrid>
</h:form>
<h:commandButton
rendered=
"#{!empty productView.product.id}"
action=
"#{productView.createDiscount}"
value=
"#{i18n['product.createDiscount']}"
/>
<h:form
id=
"discounts"
rendered=
"#{!empty productView.product.id and !empty productView.product.discounts}"
>
<h:dataTable
border=
"1"
id=
"discount"
value=
"#{productView.product.discounts}"
var=
"discount"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.percentage']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.percentage}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.code']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.code}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.details']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.details}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.shortdesc']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.shortdesc}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.amountMin']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.amountMin}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.amountMax']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.amountMax}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.maxNum']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.maxNum}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"${i18n['discount.perUser']}"
/>
</f:facet>
<h:outputText
value=
"#{discount.perUser}"
/>
</h:column>
<h:column>
<h:link
outcome=
"/product/editDiscount"
value=
"#{i18n['discount.edit']}"
>
<f:param
name=
"discountid"
value=
"#{discount.id.id}"
/>
</h:link>
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/resources/i18n.properties
View file @
62938a4
...
...
@@ -40,6 +40,11 @@ page.product.createBill.pagegroup=shop
page.product.edit.pagegroup
=
admin
page.product.list.pagegroup
=
admin
product.providedRole
=
Tuote tarjoaa roolin
product.createDiscount
=
Lis mralennus
product.saved
=
Tuote tallennettu
product.returnProductEdit
=
Palaa tuotteeseen:
page.role.create.pagegroup
=
admin
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/TestDataView.java
View file @
62938a4
...
...
@@ -51,6 +51,7 @@ public class TestDataView {
private
PollBeanLocal
pollbean
;
public
void
convertUsernames
()
{
utilbean
.
convertUsernames
();
}
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/shop/ProductView.java
View file @
62938a4
...
...
@@ -2,8 +2,12 @@ package fi.insomnia.bortal.web.cdiview.shop;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.faces.model.ListDataModel
;
import
javax.inject.Named
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.insomnia.bortal.beans.EventBeanLocal
;
import
fi.insomnia.bortal.beans.ProductBeanLocal
;
import
fi.insomnia.bortal.enums.apps.ShopPermission
;
...
...
@@ -27,6 +31,10 @@ public class ProductView extends GenericCDIView {
private
Integer
productId
;
private
ListDataModel
<
Discount
>
productDiscounts
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ProductView
.
class
);
public
void
initEditView
()
{
if
(
super
.
requirePermissions
(
ShopPermission
.
MANAGE_PRODUCTS
)
&&
product
==
null
)
{
product
=
prodbean
.
findById
(
getProductId
());
...
...
@@ -76,4 +84,30 @@ public class ProductView extends GenericCDIView {
public
Discount
getDiscount
()
{
return
discount
;
}
public
String
createDiscount
()
{
product
=
prodbean
.
mergeChanges
(
product
);
return
"/product/edit"
;
}
public
String
initCreateDiscount
()
{
discount
=
new
Discount
(
product
);
product
.
getDiscounts
().
add
(
discount
);
return
"/product/createDiscount"
;
}
public
String
editDiscount
()
{
discount
=
productDiscounts
.
getRowData
();
return
"/product/editDiscount"
;
}
public
ListDataModel
<
Discount
>
getProductDiscounts
()
{
productDiscounts
=
new
ListDataModel
<
Discount
>(
product
.
getDiscounts
());
return
productDiscounts
;
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/user/RoleDataView.java
View file @
62938a4
package
fi
.
insomnia
.
bortal
.
web
.
cdiview
.
user
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.model.ListDataModel
;
import
javax.inject.Named
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.insomnia.bortal.beans.RoleBeanLocal
;
import
fi.insomnia.bortal.model.Role
;
import
fi.insomnia.bortal.web.cdiview.GenericCDIView
;
...
...
@@ -20,10 +25,27 @@ public class RoleDataView extends GenericCDIView {
private
transient
ListDataModel
<
Role
>
roles
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RoleDataView
.
class
);
public
ListDataModel
<
Role
>
getRoles
()
{
if
(
roles
==
null
)
{
roles
=
new
ListDataModel
<
Role
>(
rolebean
.
listRoles
());
}
return
roles
;
}
public
Role
getNoSelection
()
{
return
Role
.
EMPTY_ROLE
;
}
public
ListDataModel
<
Role
>
getRolesWithEmpty
()
{
if
(
roles
==
null
)
{
List
<
Role
>
list
=
rolebean
.
listRoles
();
list
.
add
(
0
,
Role
.
EMPTY_ROLE
);
roles
=
new
ListDataModel
<
Role
>(
list
);
logger
.
info
(
"rolecount {}"
,
roles
.
getRowCount
());
}
return
roles
;
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/web/converter/PollAnswerConverter.java
View file @
62938a4
...
...
@@ -23,6 +23,7 @@ public class PollAnswerConverter implements Converter {
@Override
public
Object
getAsObject
(
FacesContext
context
,
UIComponent
component
,
String
value
)
{
PossibleAnswer
possibleAnswer
=
pollbean
.
findPossibleAnwerById
(
Integer
.
parseInt
(
value
));
PollAnswer
ret
=
new
PollAnswer
();
ret
.
setChoice
(
possibleAnswer
);
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/converter/RoleConverter.java
View file @
62938a4
...
...
@@ -13,7 +13,7 @@ import org.slf4j.LoggerFactory;
import
fi.insomnia.bortal.beans.RoleBeanLocal
;
import
fi.insomnia.bortal.model.Role
;
@Named
@Named
(
"roleConverter"
)
@RequestScoped
public
class
RoleConverter
implements
Converter
{
...
...
@@ -25,6 +25,10 @@ public class RoleConverter implements Converter {
@Override
public
Object
getAsObject
(
FacesContext
context
,
UIComponent
component
,
String
value
)
{
logger
.
debug
(
"converting string {} to Object"
,
value
);
if
(
value
==
null
||
value
.
isEmpty
()
||
value
.
equals
(
"0"
))
{
return
null
;
}
Role
ret
=
rolebean
.
find
(
Integer
.
parseInt
(
value
));
return
ret
;
}
...
...
@@ -32,11 +36,15 @@ public class RoleConverter implements Converter {
@Override
public
String
getAsString
(
FacesContext
context
,
UIComponent
component
,
Object
value
)
{
String
ret
=
""
;
if
(
value
instanceof
Role
)
{
ret
=
((
Role
)
value
).
getId
().
toString
();
Role
r
=
((
Role
)
value
);
if
(
r
.
getId
()
!=
null
)
{
ret
=
r
.
getId
().
toString
();
}
}
logger
.
debug
(
"converting role {} to string"
,
ret
);
return
ret
;
}
}
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