Commit da6108d3 by Tuomas Riihimäki

Merge branch 'master' of dev.intra.insomnia.fi:/data/bortal

2 parents 925fef77 60612ba4
package fi.insomnia.bortal.beans;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import fi.insomnia.bortal.facade.ProductFacade;
import fi.insomnia.bortal.model.Product;
/**
* Session Bean implementation class ProductBean
*/
@Stateless
public class ProductBean implements ProductBeanLocal {
@EJB
ProductFacade productFacade;
/**
* Default constructor.
*/
public ProductBean() {
// TODO Auto-generated constructor stub
}
@Override
public List<Product> listUserShoppableProducts() {
// XXX: Only user shoppable products
return productFacade.findAll();
}
}
package fi.insomnia.bortal.beans;
import java.util.List;
import javax.ejb.Local;
import fi.insomnia.bortal.model.Product;
@Local
public interface ProductBeanLocal {
List<Product> listUserShoppableProducts();
}
......@@ -29,7 +29,7 @@ import javax.persistence.Version;
@NamedQuery(name = "CompoEntryParticipant.findAll", query = "SELECT c FROM CompoEntryParticipant c"),
@NamedQuery(name = "CompoEntryParticipant.findByRole", query = "SELECT c FROM CompoEntryParticipant c WHERE c.role = :role") })
public class CompoEntryParticipant implements EventChildInterface{
public class CompoEntryParticipant implements EventChildInterface {
private static final long serialVersionUID = 1L;
@EmbeddedId
......@@ -41,24 +41,19 @@ public class CompoEntryParticipant implements EventChildInterface{
@Column(name = "nick")
private String nick;
@Column(name = "confirmed")
@Temporal(TemporalType.TIMESTAMP)
private Calendar confirmed;
@JoinColumns({
@JoinColumn(name = "entries_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="entries_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
@JoinColumns( {
@JoinColumn(name = "entries_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name = "entries_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false)
private CompoEntry entry;
@JoinColumns({
@JoinColumn(name = "users_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="users_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@JoinColumn(name = "users_id", referencedColumnName = "users_id", nullable = false, updatable = false, insertable = false)
@ManyToOne(optional = false)
private User users;
......@@ -169,7 +164,8 @@ public class CompoEntryParticipant implements EventChildInterface{
}
/**
* @param nick the nick to set
* @param nick
* the nick to set
*/
public void setNick(String nick) {
this.nick = nick;
......@@ -183,7 +179,8 @@ public class CompoEntryParticipant implements EventChildInterface{
}
/**
* @param confirmed the confirmed to set
* @param confirmed
* the confirmed to set
*/
public void setConfirmed(Calendar confirmed) {
this.confirmed = confirmed;
......
......@@ -33,7 +33,7 @@ import javax.persistence.Version;
@NamedQuery(name = "GroupMembership.findByInviteAccepted", query = "SELECT g FROM GroupMembership g WHERE g.inviteAccepted = :inviteAccepted"),
@NamedQuery(name = "GroupMembership.findByInviteEmail", query = "SELECT g FROM GroupMembership g WHERE g.inviteEmail = :inviteEmail"),
@NamedQuery(name = "GroupMembership.findByInviteName", query = "SELECT g FROM GroupMembership g WHERE g.inviteName = :inviteName") })
public class GroupMembership implements EventChildInterface{
public class GroupMembership implements EventChildInterface {
private static final long serialVersionUID = 1L;
@EmbeddedId
......@@ -49,35 +49,29 @@ public class GroupMembership implements EventChildInterface{
@Column(name = "invite_name")
private String inviteName;
@JoinColumns({
@JoinColumn(name = "groups_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="groups_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
@JoinColumns( {
@JoinColumn(name = "groups_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name = "groups_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false)
private PlaceGroup placeGroup;
@JoinColumns({
@JoinColumn(name = "place_reservation_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="place_reservation_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
@JoinColumns( {
@JoinColumn(name = "place_reservation_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name = "place_reservation_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@OneToOne(optional = false)
private Place placeReservation;
@JoinColumns({
@JoinColumn(name = "users_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="users_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@JoinColumn(name = "users_id", referencedColumnName = "users_id", nullable = false, updatable = false, insertable = false)
@ManyToOne
private User user;
@Column(name = "entered_event")
@Temporal(TemporalType.TIMESTAMP)
private Calendar enteredEvent;
@Version
@Column(nullable = false)
......@@ -207,7 +201,8 @@ public class GroupMembership implements EventChildInterface{
}
/**
* @param enteredEvent the enteredEvent to set
* @param enteredEvent
* the enteredEvent to set
*/
public void setEnteredEvent(Calendar enteredEvent) {
this.enteredEvent = enteredEvent;
......
......@@ -9,11 +9,8 @@
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsf</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
......
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GlassFish JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/default-template.xhtml">
<ui:define name="title">Omnia</ui:define>
<ui:define name="header">Header</ui:define>
<ui:define name="content">
Plop
</ui:define>
<ui:define name="footer">Footer</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">
<composite:interface>
</composite:interface>
<composite:implementation>
<h:form>
<h:dataTable border="1" id="productListTable"
value="#{productView.userShoppableProducts}"
var="product">
<h:column>
<f:facet name="header">
<h:outputText value="#" />
</f:facet>
<h:outputText value="#{product.id}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['product.name']}" />
</f:facet>
<h:outputText value="#{product.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['product.price']}" />
</f:facet>
<h:outputText value="#{product.price}" />
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:shop="http://java.sun.com/jsf/composite/tools/shop"
>
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/default-template.xhtml">
<ui:define name="title">Omnia</ui:define>
<ui:define name="header">Lippukauppa</ui:define>
<ui:define name="content">
</ui:define>
<shop:productlist />
<ui:define name="footer">Osta liput</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
package fi.insomnia.bortal;
import java.util.ResourceBundle;
import javax.faces.application.Application;
import javax.faces.context.FacesContext;
/***
* Access i18n localisations from Java code. Feel free to make up a better way.
* @author jkj
*
*/
public class I18n {
public static ResourceBundle GetResourceBundle()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
Application app = facesContext.getApplication();
ResourceBundle bundle = app.getResourceBundle(facesContext, "i18n");
return bundle;
}
public static String Get(String key)
{
String value = GetResourceBundle().getString(key);
if(key==null) {
return "########";
}
return value;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.view;
import fi.insomnia.bortal.beans.ProductBeanLocal;
import fi.insomnia.bortal.beans.RoleBeanLocal;
import fi.insomnia.bortal.beans.SecurityBeanLocal;
import fi.insomnia.bortal.exceptions.PermissionDeniedException;
import fi.insomnia.bortal.handler.SessionHandler;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.Role;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author jkj
*/
@ManagedBean(name = "productView")
@SessionScoped
public class ProductView {
@ManagedProperty("#{sessionHandler}")
private SessionHandler sessionhandler;
@EJB
private ProductBeanLocal productBean;
private static final Logger logger = LoggerFactory.getLogger(ProductView.class);
@EJB
private SecurityBeanLocal securitybean;
public DataModel<Product> getUserShoppableProducts() {
ListDataModel<Product> items = new ListDataModel<Product>(productBean.listUserShoppableProducts());
logger.info("Fetching products. Found {}", items.getRowCount());
return items;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!