Commit a0f8e4bf by Petri Jarvisalo

Merge branch 'devel' of codecrew.fi:bortal

2 parents b7c3026e 8df2b0e6
......@@ -25,11 +25,13 @@ import fi.insomnia.bortal.facade.AccountEventFacade;
import fi.insomnia.bortal.facade.BillLineFacade;
import fi.insomnia.bortal.facade.DiscountFacade;
import fi.insomnia.bortal.facade.EventUserFacade;
import fi.insomnia.bortal.facade.InventoryEventFacade;
import fi.insomnia.bortal.facade.ProductFacade;
import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.EventUser;
import fi.insomnia.bortal.model.InventoryEvent;
import fi.insomnia.bortal.model.LanEvent;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.ProductFlag;
......@@ -56,6 +58,9 @@ public class ProductBean implements ProductBeanLocal {
private ProductFacade productFacade;
@EJB
private InventoryEventFacade ieFacade;
@EJB
private EventBeanLocal eventBean;
@EJB
......@@ -343,4 +348,16 @@ public class ProductBean implements ProductBeanLocal {
return productFacade.findProductByBarcode(barcode);
}
@Override
@RolesAllowed(ShopPermission.S_MANAGE_PRODUCTS)
public void saveInventoryEvent(InventoryEvent ie) {
logger.debug("Creating new Inventoryevent {}", ie);
ieFacade.create(ie);
}
@Override
@RolesAllowed(ShopPermission.S_MANAGE_PRODUCTS)
public List<Product> findProductsForEvent() {
return productFacade.findAll();
}
}
package fi.insomnia.bortal.facade;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.insomnia.bortal.model.InventoryEvent;
@Stateless
@LocalBean
public class InventoryEventFacade extends IntegerPkGenericFacade<InventoryEvent> {
public InventoryEventFacade() {
super(InventoryEvent.class);
// TODO Auto-generated constructor stub
}
}
......@@ -11,6 +11,7 @@ import javax.ejb.Local;
import fi.insomnia.bortal.model.AccountEvent;
import fi.insomnia.bortal.model.Discount;
import fi.insomnia.bortal.model.EventUser;
import fi.insomnia.bortal.model.InventoryEvent;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.ProductFlag;
......@@ -51,4 +52,8 @@ public interface ProductBeanLocal {
BigDecimal getProductLimit(Product product, EventUser user, Map<Integer, BigDecimal> prodCounts);
void saveInventoryEvent(InventoryEvent ie);
List<Product> findProductsForEvent();
}
......@@ -25,7 +25,16 @@ public class InventoryEvent extends GenericEntity {
@JoinColumn(name = "user_id")
private User user;
@JoinColumn(name = "product_id")
private Product product;
@Column(name = "info", nullable = true)
private String info;
@Column(name = "quantity", nullable = false, precision = 24, scale = 4)
private BigDecimal quantity;
public Product getProduct() {
return product;
}
......@@ -42,17 +51,6 @@ public class InventoryEvent extends GenericEntity {
this.info = info;
}
@JoinColumn(name = "product_id")
private Product product;
@Column(name = "info", nullable = true)
private String info;
@Column(name = "quantity", nullable = false, precision = 24, scale = 4)
private BigDecimal quantity;
public User getUser() {
return user;
}
......@@ -77,5 +75,4 @@ public class InventoryEvent extends GenericEntity {
this.quantity = quantity;
}
}
......@@ -5,7 +5,7 @@
xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<f:view locale="#{sessionHandler.locale}">
<f:view locale="#{sessionHandler.locale}" >
<ui:insert name="metadata" />
<h:head>
......@@ -17,7 +17,7 @@
<link rel="stylesheet" type="text/css" href="#{request.contextPath}/resources/style/insomnia1/style.css" />
<ui:insert name="headerdata" />
</h:head>
<h:body>
<h:body >
<div id="wrapper">
......
......@@ -5,16 +5,19 @@
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:orgrole="http://java.sun.com/jsf/composite/cditools/orgrole"
xmlns:c="http://java.sun.com/jsp/jstl/core">
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui"
>
<h:body>
<ui:composition
template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.orgrole.list" />
<f:metadata>
<f:event type="preRenderView"
listener="#{orgRoleView.permissionList()}" />
<f:event type="preRenderView" listener="#{orgRoleView.permissionList()}" />
</f:metadata>
<ui:define name="title">
<h1>#{i18n['foodwave.template.edit.title']}</h1>
</ui:define>
<ui:define name="content">
<orgrole:list />
</ui:define>
......
<!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:products="http://java.sun.com/jsf/composite/cditools/products"
xmlns:f="http://java.sun.com/jsf/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{addInventoryView.initCreateInventory}" />
</f:metadata>
<ui:define name="content">
<products:addInventory />
</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" xmlns:p="http://primefaces.org/ui">
<composite:interface>
</composite:interface>
<composite:implementation>
<h1>${i18n['inventory.product.title']}</h1>
<h:form id="inventoryform">
<h:panelGrid columns="2">
<h:outputText value="${i18n['inventory.product.name']}" />
<p:selectOneMenu required="true" id="product" value="#{addInventoryView.inventoryEvent.product}" converter="#{productConverter}">
<f:selectItem itemLabel="----" />
<f:selectItems value="#{addInventoryView.products}" var="product" itemLabel="#{product.name}" />
</p:selectOneMenu>
<h:outputText value="${i18n['inventory.product.quantity']}" />
<p:inputText value="#{addInventoryView.inventoryEvent.quantity}" required="true">
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</p:inputText>
<h:outputText value="${i18n['inventory.product.info']}" />
<p:inputTextarea value="#{addInventoryView.inventoryEvent.info}" />
</h:panelGrid>
<p:commandButton ajax="false" value="${i18n['inventory.product.submitButton']}" action="#{addInventoryView.save}" />
</h:form>
</composite:implementation>
</html>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<!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:users="http://java.sun.com/jsf/composite/tools/user" xmlns:c="http://java.sun.com/jsp/jstl/core">
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.eventorg.edit" />
<ui:define name="content">
<ui:composition template="/resources/#{sessionHandler.layout}/template.xhtml">
<ui:define name="page">
#{sessionHandler.flushCache()}
<h:form>
<h:commandButton action="#{testView.resetMenu()}" value="Reset to newui menu" onclick="return confirm('THIS WILL RESET ALL MODIFICATIONS TO DEFAULT MENU!!\n Are you really sure?!');" />
<h:commandButton action="#{testView.resetOldMenu()}" value="Reset to old menu" onclick="return confirm('THIS WILL RESET ALL MODIFICATIONS TO DEFAULT MENU!!\n Are you really sure?!');" />
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
</html>
......@@ -10,7 +10,6 @@ import java.util.TimeZone;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import javax.servlet.http.HttpServletRequest;
......@@ -34,10 +33,10 @@ import fi.insomnia.bortal.model.LanEventPropertyKey;
public class SessionHandler {
private static final Logger logger = LoggerFactory.getLogger(SessionHandler.class);
@Inject
private HttpServletRequest httprequest;
//
// @Inject
// private HttpServletRequest httprequest;
//
@EJB
private RoleBeanLocal rolebean;
@EJB
......
......@@ -294,6 +294,13 @@ infoview.back = Back
infoview.computerplace = Computer places
infoview.shop = Shop
inventory.product.info = Info
inventory.product.name = Product
inventory.product.pickProduct = Pick product
inventory.product.quantity = Quantatity
inventory.product.submitButton = Add
inventory.product.title = Add items to storage
invite.emailexists = User with that email address already exists in the system.
invite.notFound = Invite invalid or already used
invite.successfull = Invite sent successfully
......
......@@ -301,6 +301,13 @@ infoview.back = Takaisin
infoview.computerplace = Tietokonepaikat
infoview.shop = Kauppa
inventory.product.info = Info
inventory.product.name = Tuote
inventory.product.pickProduct = Valitse tuote
inventory.product.quantity = M\u00E4\u00E4r\u00E4
inventory.product.submitButton = Lis\u00E4\u00E4
inventory.product.title = Lis\u00E4\u00E4 tuottetta varastoon
invite.emailexists = J\u00E4rjestelm\u00E4ss\u00E4 on jo k\u00E4ytt\u00E4j\u00E4tunnus samalla s\u00E4hk\u00F6postiosoitteella.
invite.notFound = Kutsu virheellinen tai jo k\u00E4ytetty.
invite.successfull = Kutsu l\u00E4hetetty
......
......@@ -54,7 +54,7 @@ public abstract class GenericCDIView implements Serializable {
ret = requirePermissions(externalChecks);
}
if (!ret) {
logger.info("Permission required failed for {}", perm.getFullName());
logger.info("Permission required failed for {} Permission: {} (or extrachecks)", perm.getFullName(), perm);
}
......
......@@ -77,15 +77,15 @@ public class PollView extends GenericCDIView {
if (super.requirePermissions(PollPermission.ANSWER) && poll == null) {
thisPage = 1;
poll = pollBean.find(pollId);
if (super.requirePermissions(poll != null && poll.getQuestions() != null && !poll.getQuestions().isEmpty()))
logger.debug("Initializing poll with id {} , poll {}", pollId, poll);
if (!super.requirePermissions(poll != null && poll.getQuestions() != null && !poll.getQuestions().isEmpty()))
{
return;
}
logger.debug("initializing poll questions {}", poll.getQuestions());
pages = new HashMap<Integer, List<QuestionWrapper>>();
logger.info("initializing poll {}", poll);
for (PollQuestion q : getPoll().getQuestions()) {
for (PollQuestion q : poll.getQuestions()) {
if (!getPages().containsKey(q.getPage())) {
......
package fi.insomnia.bortal.web.cdiview.shop;
import java.math.BigDecimal;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.PermissionBeanLocal;
import fi.insomnia.bortal.beans.ProductBeanLocal;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.model.InventoryEvent;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class AddInventoryView extends GenericCDIView {
private static final long serialVersionUID = 1L;
@EJB
private ProductBeanLocal pblocal;
@EJB
private PermissionBeanLocal permBeanLocal;
private InventoryEvent inventoryEvent;
private List<Product> products;
private static final Logger logger = LoggerFactory.getLogger(AddInventoryView.class);
public void initCreateInventory()
{
if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS) && inventoryEvent == null)
{
inventoryEvent = new InventoryEvent();
super.beginConversation();
setProducts(pblocal.findProductsForEvent());
logger.debug("Initialized {} products for inventoryview", products.size());
}
}
public String save() {
pblocal.saveInventoryEvent(inventoryEvent);
return null;
}
public List<Product> getProducts() {
return products;
}
public void setProducts(List<Product> products) {
this.products = products;
}
public InventoryEvent getInventoryEvent() {
return inventoryEvent;
}
public void setInventoryEvent(InventoryEvent inventoryEvent) {
this.inventoryEvent = inventoryEvent;
}
}
......@@ -26,5 +26,6 @@ public class ProductListView extends PaginationView<Product> {
super.setResults(pizzabean.getProducts());
}
}
}
......@@ -39,11 +39,9 @@ public class AuthView extends GenericCDIView {
private HttpServletRequest getRequest() {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.
getExternalContext();
ExternalContext externalContext = facesContext.getExternalContext();
Object request = externalContext.getRequest();
return request instanceof HttpServletRequest ?
(HttpServletRequest) request : null;
return request instanceof HttpServletRequest ? (HttpServletRequest) request : null;
}
public void executeLogout() {
......@@ -57,6 +55,7 @@ public class AuthView extends GenericCDIView {
}
req.getSession().invalidate();
navihandler.forward("logoutDone");
}
public void executeLogin() {
......
......@@ -4,6 +4,9 @@ import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.ProductBeanLocal;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.utilities.jsf.GenericIntegerEntityConverter;
......@@ -14,10 +17,13 @@ public class ProductConverter extends GenericIntegerEntityConverter<Product> {
@EJB
private ProductBeanLocal productbean;
private static final Logger logger = LoggerFactory.getLogger(ProductConverter.class);
@Override
protected Product find(Integer id) {
return productbean.findById(id);
}
Product ret = productbean.findById(id);
logger.info("Converting product id {} to result {}", id, ret);
return ret;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!