Commit 4833901d by Tuukka Kivilahti

Merge branch 'streamfixes' into 'master'

Streamfixes

Mostly minor ui fixes.

kattonu: @tkfftk
2 parents b55e8ba0 696570ff
...@@ -122,16 +122,24 @@ public class CardTemplateBean implements CardTemplateBeanLocal { ...@@ -122,16 +122,24 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
List<PrintedCard> myCards = printedcardfacade.getCards(user); List<PrintedCard> myCards = printedcardfacade.getCards(user);
PrintedCard biggestCard = null; PrintedCard biggestCard = null;
PrintedCard smallestCard = null; // PrintedCard smallestCard = null;
for (PrintedCard card : myCards) { for (PrintedCard card : myCards) {
logger.info("Checking card {}", card); // logger.info("Checking card {}", card);
if (card.getEnabled()) { if (card.getEnabled()) {
if (biggestCard == null || biggestCard.getTemplate().getPower() < card.getTemplate().getPower()) { if (biggestCard == null || biggestCard.getTemplate().getPower() < card.getTemplate().getPower()) {
biggestCard = card; // The biggest card should be the only one enabled.
if (biggestCard != null) {
biggestCard.setEnabled(false);
} }
if (smallestCard == null || smallestCard.getTemplate().getPower() > card.getTemplate().getPower()) { biggestCard = card;
smallestCard = card; biggestCard.setEnabled(true);
} }
// if (smallestCard == null ||
// smallestCard.getTemplate().getPower() >
// card.getTemplate().getPower()) {
// smallestCard = card;
// }
} }
} }
......
...@@ -13,7 +13,6 @@ import javax.persistence.criteria.CriteriaBuilder; ...@@ -13,7 +13,6 @@ import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import javax.persistence.criteria.Subquery;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.enums.CardState; import fi.codecrew.moya.enums.CardState;
...@@ -37,7 +36,6 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> { ...@@ -37,7 +36,6 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
@EJB @EJB
private EventBeanLocal eventbean; private EventBeanLocal eventbean;
public PrintedCard findByCode(String code) { public PrintedCard findByCode(String code) {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
...@@ -49,7 +47,7 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> { ...@@ -49,7 +47,7 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
CardCode cardcode = getSingleNullableResult(getEm().createQuery(cq)); CardCode cardcode = getSingleNullableResult(getEm().createQuery(cq));
return (cardcode == null)?null : cardcode.getPrintedCard(); return (cardcode == null) ? null : cardcode.getPrintedCard();
} }
public List<PrintedCard> findAllEnabled(LanEvent currentEvent) { public List<PrintedCard> findAllEnabled(LanEvent currentEvent) {
...@@ -71,6 +69,7 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> { ...@@ -71,6 +69,7 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
cq.where(cb.equal(root.get(PrintedCard_.user), user), cq.where(cb.equal(root.get(PrintedCard_.user), user),
cb.equal(root.get(PrintedCard_.event), eventbean.getCurrentEvent())); cb.equal(root.get(PrintedCard_.event), eventbean.getCurrentEvent()));
cq.orderBy(cb.asc(root.get(PrintedCard_.template).get(CardTemplate_.power)));
return getEm().createQuery(cq).getResultList(); return getEm().createQuery(cq).getResultList();
} }
...@@ -113,7 +112,7 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> { ...@@ -113,7 +112,7 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
List<PrintedCard> pcl = getEm().createQuery(cq).getResultList(); List<PrintedCard> pcl = getEm().createQuery(cq).getResultList();
HashMap<Integer, PrintedCard> pch = new HashMap<>(); HashMap<Integer, PrintedCard> pch = new HashMap<>();
for(PrintedCard pc : pcl) { for (PrintedCard pc : pcl) {
pch.put(pc.getUser().getId(), pc); pch.put(pc.getUser().getId(), pc);
} }
......
...@@ -38,11 +38,10 @@ public class EventUserCardStateFilter implements FacadeCallback<EventUser> { ...@@ -38,11 +38,10 @@ public class EventUserCardStateFilter implements FacadeCallback<EventUser> {
logger.debug("Requiring states {}", states); logger.debug("Requiring states {}", states);
Path<Integer> rootId = root.get(EventUser_.id); Path<Integer> rootId = root.get(EventUser_.id);
Subquery<Integer> subq = cq.subquery(Integer.class); Subquery<Integer> subq = cq.subquery(Integer.class);
Root<PrintedCard> subroot = subq.from(PrintedCard.class); Root<PrintedCard> subroot = subq.from(PrintedCard.class);
subq.select(subroot.join(PrintedCard_.user).get(EventUser_.id)); subq.select(subroot.join(PrintedCard_.user).get(EventUser_.id));
subq.where(subroot.get(PrintedCard_.cardState).in(states)); subq.where(subroot.get(PrintedCard_.cardState).in(states), cb.isTrue(subroot.get(PrintedCard_.enabled)));
predicates.add(rootId.in(subq)); predicates.add(rootId.in(subq));
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<property name="eclipselink.ddl-generation" value="create-tables" /> <property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.cache.size.default" value="16384" /> <property name="eclipselink.cache.size.default" value="16384" />
<property name="eclipselink.ddl-generation.output-mode" <property name="eclipselink.ddl-generation.output-mode"
value="database" /> value="sql-script" />
<property name="eclipselink.logging.logger" value="ServerLogger" /> <property name="eclipselink.logging.logger" value="ServerLogger" />
<property name="eclipselink.jdbc.uppercase-columns" value="false" /> <property name="eclipselink.jdbc.uppercase-columns" value="false" />
<property name="eclipselink.target-database" <property name="eclipselink.target-database"
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
value="org.ancoron.postgresql.jpa.eclipselink.ConverterInitializer" /> value="org.ancoron.postgresql.jpa.eclipselink.ConverterInitializer" />
<property name="eclipselink.descriptor.customizer" <property name="eclipselink.descriptor.customizer"
value="fi.codecrew.moya.database.MoyaDescriptorCustomizer" /> value="fi.codecrew.moya.database.MoyaDescriptorCustomizer" />
<property name="eclipselink.create-ddl-jdbc-file-name" value="moyaCreateDDL.sql"/>
<property name="eclipselink.drop-ddl-jdbc-file-name" value="moyaDropDDL.sql"/>
</properties> </properties>
</persistence-unit> </persistence-unit>
......
...@@ -184,22 +184,6 @@ public class ReaderEvent extends GenericEntity { ...@@ -184,22 +184,6 @@ public class ReaderEvent extends GenericEntity {
@Transient @Transient
public String getSeenSince() { public String getSeenSince() {
return "" + ((getUpdatetime().getTime() / 1000) / 60) +" min." ; return "" + ((System.currentTimeMillis() - getUpdatetime().getTime()) / 1000 / 60) + " min.";
} }
} }
...@@ -33,13 +33,13 @@ ...@@ -33,13 +33,13 @@
</h:panelGroup> </h:panelGroup>
<h:panelGroup> <h:panelGroup >
<reader:codefield selectaction="#{productShopView.readCode}" selectvalue="#{i18n['shop.readBarcode']}" /> <reader:codefield selectaction="#{productShopView.readCode}" selectvalue="#{i18n['shop.readBarcode']}" />
<br /> <br />
<p:dataTable id="prods" value="#{productShopView.boughtItems}" var="prods"> <p:dataTable id="prods" value="#{productShopView.boughtItems}" var="prods" style="width:500px;">
<p:column headerText="#{i18n['shop.count']}"> <p:column headerText="#{i18n['shop.count']}">
<p:inputText value="#{prods.count}" size="2"> <p:inputText value="#{prods.count}" size="2">
<f:ajax render="@form" listener="#{productShopView.countBoughtChangeListener}" /> <f:ajax render="@form" listener="#{productShopView.countBoughtChangeListener}" />
......
<!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:tools="http://java.sun.com/jsf/composite/tools"
xmlns:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<f:viewParam name="reader" value="#{rfidListenerView.reader}" />
<f:viewParam name="tag" value="#{rfidListenerView.tag}" />
<f:event type="preRenderView" listener="#{rfidListenerView.cardRead()}" />
</f:metadata>
<ui:define name="title">
<h1>#{i18n['page.product.createBill.header']}</h1>
</ui:define>
<ui:define name="content">
Hi.
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
<h:body> <h:body>
<ui:composition template="#{sessionHandler.template}"> <ui:composition template="#{sessionHandler.template}">
<f:metadata> <f:metadata>
<f:event type="preRenderView" listener="#{userView.initView}" /> <f:event type="preRenderView" listener="#{voteListView.initView}" />
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<h1>My entries</h1> <h1>My entries</h1>
<h:form> <h:form>
<h:dataTable styleClass="bordertable" rowClasses="roweven,rowodd" id="compolisttable" value="#{userView.user.compoEntries}" var="entry"> <h:dataTable styleClass="bordertable" rowClasses="roweven,rowodd" id="compolisttable" value="#{voteListView.entries}" var="entry">
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="Title" /> <h:outputText value="Title" />
......
package fi.codecrew.moya.web.cdiview.reader;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import fi.codecrew.moya.beans.ReaderBeanLocal;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class RfidListenerView extends GenericCDIView {
@EJB
private ReaderBeanLocal readerbean;
private String reader;
private String tag;
public void cardRead()
{
readerbean.checkCode(reader, tag);
}
public String getReader() {
return reader;
}
public void setReader(String reader) {
this.reader = reader;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
}
package fi.codecrew.moya.web.cdiview.voting;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import fi.codecrew.moya.beans.VotingBeanLocal;
import fi.codecrew.moya.enums.apps.CompoPermission;
import fi.codecrew.moya.model.CompoEntry;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@RequestScoped
public class VoteListView extends GenericCDIView {
private static final long serialVersionUID = 4166316634472472472L;
@EJB
private VotingBeanLocal votebean;
private List<CompoEntry> entries;
public void initView()
{
if (super.requirePermissions(CompoPermission.SUBMIT_ENTRY))
setEntries(votebean.getEntriesForCurrentUser());
}
public List<CompoEntry> getEntries() {
return entries;
}
public void setEntries(List<CompoEntry> entries) {
this.entries = entries;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!