Commit 8b83db6c by Tuukka Kivilahti

and last to barcodefuckup

1 parent c3428b5b
......@@ -224,7 +224,8 @@ public class BarcodeBean implements BarcodeBeanLocal {
@Override
public Place getPlaceFromBarcode(String barcode) {
throw new UnsupportedOperationException();
//throw new UnsupportedOperationException();
return null;
// TODO: tarttee hakea se paikkakoodi, ja sen avulla paikka. Toivon että se on ny tämä eikä placecodehäsmäkkä, mikä se oikeasti on. Vittu lisää refactorointia
}
......
......@@ -42,14 +42,15 @@ public class BootstrapBean implements BootstrapBeanLocal {
});
// barcodefuckup
dbUpdates.add(new String[] {
"DELETE TABLE card_barcode",
"DROP TABLE card_barcode",
"ALTER TABLE printed_cards DROP COLUMN barcode;",
"ALTER TABLE printed_cards DROP COLUMN rfid_uid;",
"ALTER TABLE reader_events ADD COLUMN event_users_id integer REFERENCES event_users(id) DEFAULT null;",
"ALTER TABLE reader_events ADD COLUMN places_id integer REFERENCES places(id) DEFAULT null;",
"ALTER TABLE reader_events ADD COLUMN products_id integer REFERENCES products(id) DEFAULT null;",
"ALTER TABLE reader_events ADD COLUMN type text NOT NULL;",
"ALTER TABLE reader_events DROP COLUMN gamepoint;"
"ALTER TABLE reader_events ADD COLUMN type text NOT NULL DEFAULT 'UNKNOWN';",
"ALTER TABLE reader_events DROP COLUMN gamepoint;",
"ALTER TABLE reader_events ALTER COLUMN type DROP DEFAULT;",
});
}
......
......@@ -38,6 +38,8 @@ public class ReaderBean implements ReaderBeanLocal {
@EJB
private ReaderFacade readerfacade;
@EJB
private PrintedCardFacade cardfacade;
......@@ -72,7 +74,12 @@ public class ReaderBean implements ReaderBeanLocal {
}
@Override
/**
* check reader code, and add it to the database
*/
public ReaderEvent checkCode(Reader reader, String code) {
logger.info("got code from reader {}", code);
code = code.replace("\"\b", "");
......@@ -102,6 +109,10 @@ public class ReaderBean implements ReaderBeanLocal {
ReaderEvent lastevent = lastevents.get(0);
if(lastevent.getValue() == event.getValue() && (lastevent.getUpdatetime().getTime() + 60000l) > event.getTime().getTime()) {
lastevent = readerEventFacade.reload(lastevent);
lastevent = readerEventFacade.merge(lastevent);
return lastevent; // todo: update lastevent bfore return
}
}
......@@ -155,6 +166,8 @@ public class ReaderBean implements ReaderBeanLocal {
event.setNotes("Created automatic account event from reader. " + createAc);
}
event = readerEventFacade.create(event);
return event;
......@@ -184,6 +197,8 @@ public class ReaderBean implements ReaderBeanLocal {
@Override
public List<ReaderEvent> getReaderEvents(Integer readerId, Integer count) {
logger.info("Getting events for reader {}", readerId);
Reader reader = readerfacade.find(readerId);
return readerEventFacade.findLastEvents(reader, count);
}
......
package fi.codecrew.moya.model;
import java.beans.Transient;
import java.util.Calendar;
import java.util.Date;
......@@ -178,5 +179,25 @@ public class ReaderEvent extends GenericEntity {
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
@Transient
public String getSeenSince() {
return "" + ((getUpdatetime().getTime() / 1000) / 60) +" min." ;
}
}
......@@ -30,19 +30,13 @@
<br />
<br />
<reader:barcode_and_rfid selectvalue="#{i18n['barcodeReader.readBarcode']}" selectaction="#{incomingView.selectUser}" />
<reader:codefield selectvalue="#{i18n['barcodeReader.readBarcode']}" selectaction="#{incomingView.selectUser}" />
<reader:backendReader selectvalue="#{i18n['barcodeReader.readBarcode']}" selectaction="#{incomingView.selectUser}" />
</ui:define>
<ui:define name="sidebar">
<reader:readerlisttiles />
<br />
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -12,12 +12,7 @@
</f:metadata>
<ui:define name="content">
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
<h:form>
<p:poll interval="1" listener="#{incomingView.polledRead}" onerror="location.reload();" />
</h:form>
<h:form>
<h1>#{i18n['incomingflow.userdetails']} (RFID-lukija: #{incomingView.readerId})</h1><h:commandButton action="#{incomingView.changeReader}" value="#{i18n['incomingflow.changereader']}" />
</h:form>
<h1>#{i18n['incomingflow.userdetails']} </h1>
<h:panelGrid id="cropper" columns="3">
<h:panelGroup>
<user:edit id="usereditor" commitaction="#{incomingView.saveUser()}" commitvalue="#{i18n['user.save']}" camAlwaysOn="true" />
......
......@@ -15,6 +15,10 @@ xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
<composite:attribute name="linkoutcome" required="false" />
<composite:attribute name="showAssociateToUser" required="false" />
<composite:attribute name="showEditReader" required="false" />
</composite:interface>
......@@ -30,17 +34,22 @@ xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
<f:facet name="header">
<h:outputText value="#{i18n['reader.name']}" />
</f:facet>
<p:outputText value="#{rr.identification}" />
<h:outputText value="#{rr.identification}" />
</p:column>
<p:column>
<p:commandButton action="#{readerListDataView.selectReader}" value="#{i18n['reader.select']}" />
<p:commandButton actionListener="#{readerListDataView.selectReader}" value="#{i18n['reader.select']}" update="@all" />
</p:column>
<p:column rendered="#{cc.attrs.showEditReader}" >
<h:link outcome="/shop/editReader" value="#{i18n['reader.edit']}">
<f:param value="#{rr.id}" name="readerId" />
</h:link>
</p:column>
</p:dataTable>
</h:form>
<h:form>
<p:outputLabel value="#{i18n['reader.autopoll']}" /><p:selectBooleanButton offLabel="#{i18n['off']}" onLabel="#{i18n['on']}" value="#{readerView.pollingMode}" immediate="true" update="reader_autopoll">
<p:outputLabel value="#{i18n['reader.autopoll']}" /><p:selectBooleanButton offLabel="#{i18n['off']}" onLabel="#{i18n['on']}" value="#{readerView.pollingMode}" immediate="true" update="reader_autopoll" />
</h:form>
<reader:readerevents rendered="#{!empty readerNameContainer.readerId}" showAssociateToUser="#{cc.attrs.showAssociateToUser}" selectvalue="#{cc.attrs.selectvalue}" selectaction="#{cc.attrs.selectaction}" linkvalue="#{cc.attrs.linkvalue}" linkoutcome="#{cc.attrs.linkoutcome}" />
......
......@@ -17,33 +17,36 @@
<h:form>
<p:poll interval="3" onerror="location.reload();" update="eventlist" />
<p:commandLink actionListener="#{readerView.changeReader}" value="#{i18n['incomingflow.changereader']}" update="@all" />
<p:dataTable border="1" id="eventlist" value="#{readerView.readerEvents}" var="event">
<f:facet name="header">
<p:outputLabel value="#{readerView.currentReader.identification}" />
</f:facet>
<p:column>
<f:facet name="header">
<h:outputText value="${i18n['readerevent.tagname']}" />
</f:facet>
<p:outputText rendered="#{!empty event.printedCard}" id="cardtag" value="#{event.printedCard.rfidUid}" />
<p:outputText rendered="#{empty event.printedCard}" id="newtag" value="#{event.value}" />
<h:outputText rendered="#{empty event.printedCard}" id="newtag" value="#{event.value}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="${i18n['reader.user']}" />
</f:facet>
<p:outputText rendered="#{!empty event.printedCard}" value="#{event.printedCard.user.wholeName} (#{event.printedCard.user.nick})" />
<h:outputText rendered="#{!empty event.user}" value="#{event.user.wholeName} (#{event.user.nick})" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="${i18n['readerevent.seenSince']}" />
</f:facet>
<p:outputText value="#{event.seenSince}" />
<h:outputText value="#{event.seenSince}" />
</p:column>
<p:column>
<h:link rendered="#{!empty event.printedCard and !empty cc.attrs.linkoutcome}" outcome="#{cc.attrs.linkoutcome}" value="#{cc.attrs.linkvalue}">
<f:param name="userid" value="#{event.printedCard.user.user.id}" />
<h:link rendered="#{!empty event.user and !empty cc.attrs.linkoutcome}" outcome="#{cc.attrs.linkoutcome}" value="#{cc.attrs.linkvalue}">
<f:param name="userid" value="#{event.user.user.id}" />
</h:link>
<p:commandLink rendered="#{!empty cc.attrs.selectaction}" actionListener="#{cc.attrs.selectaction}" value="#{cc.attrs.selectvalue}" update="@all" />
......
......@@ -36,7 +36,7 @@
<h:panelGroup>
<reader:codeField selectaction="#{productShopView.readCode}" selectvalue="#{i18n['shop.readBarcode']}" />
<reader:codefield selectaction="#{productShopView.readCode}" selectvalue="#{i18n['shop.readBarcode']}" />
<br />
<p:dataTable id="prods" value="#{productShopView.boughtItems}" var="prods">
......
......@@ -15,24 +15,24 @@
<h:form id="editform">
<h:panelGrid columns="3">
<h:outputLabel for="type" value="#{i18n['reader.type']}:" />
<h:selectOneMenu id="type" value="#{readerView.reader.type}">
<h:selectOneMenu id="type" value="#{readerView.editReader.type}">
<f:selectItems value="#{readerView.readertypes}"/>
</h:selectOneMenu>
<h:message for="type"/>
<h:outputLabel for="identification" value="#{i18n['reader.identification']}:" />
<h:outputText id="identification" value="#{readerView.reader.identification}" />
<h:outputText id="identification" value="#{readerView.editReader.identification}" />
<h:message for="identification" />
<h:outputLabel for="automaticProduct" value="#{i18n['reader.automaticProduct']}:" />
<h:selectOneMenu converter="#{productConverter}" id="automaticProduct" value="#{readerView.reader.automaticProduct}" >
<h:selectOneMenu converter="#{productConverter}" id="automaticProduct" value="#{readerView.editReader.automaticProduct}" >
<f:selectItems value="#{readerView.autoProducts}" var="prod" itemLabel="#{prod.name}"/>
</h:selectOneMenu>
<h:message for="automaticProduct" />
<h:outputLabel for="automaticProductCount" value="#{i18n['reader.automaticProductCount']}:" />
<h:inputText id="automaticProductCount" value="#{readerView.reader.automaticProductCount}" >
<h:inputText id="automaticProductCount" value="#{readerView.editReader.automaticProductCount}" >
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:inputText>
<h:message for="automaticProductCount" />
......
......@@ -8,14 +8,9 @@
>
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<f:viewParam name="readerId" value="#{readerNameContainer.readerId}" />
<f:event type="preRenderView" listener="#{readerView.initReaderList}" />
</f:metadata>
<ui:define name="content">
<reader:backendReader rendered="#{!empty readerNameContainer.readerId}" />
<reader:readerlist rendered="#{empty readerNameContainer.readerId}" />
<reader:backendReader showEditReader="true" />
</ui:define>
</ui:composition>
</h:body>
......
......@@ -63,6 +63,14 @@ public class ReaderRestView {
return new ReaderEventRestRoot(ReaderEventRestPojo.parse(events));
}
@GET
@Path("/createevent/{reader}/{code}/{hash}")
public Response createReaderEvent(@PathParam("reader") String readerName, @PathParam("code") String readerCode, @PathParam("hash") String hash ) {
readerbean.checkCode(readerName, readerCode);
return Response.ok().build();
}
@GET
@Path("/LastEventusers")
......
......@@ -53,5 +53,6 @@ public class ReaderListDataView extends GenericCDIView {
return null;
}
}
......@@ -298,8 +298,24 @@ public class ReaderView extends GenericCDIView {
}
public void readerPoll() {
public void changeReader() {
namecontainer.setReaderId(null);
}
public Reader getCurrentReader() {
return readerbean.getReader(namecontainer.getReaderId());
}
public Reader getEditReader() {
return editReader;
}
public void setEditReader(Reader editReader) {
this.editReader = editReader;
}
}
......@@ -349,8 +349,10 @@ public class UserView extends GenericCDIView {
* @return
*/
public String attachCodeToCard() {
ReaderEvent event = readerView.getReaderEvent();
return attachCodeToCard(readerView.getReaderEvent());
}
public String attachCodeToCard(ReaderEvent event ) {
if(event == null)
......
......@@ -177,8 +177,7 @@ public class IncomingView extends GenericCDIView {
// still there, it must be "clean" barcode
if (userview.getUser() != null) {
userview.attachBarcodeToCard();
userview.attachCodeToCard(event);
}
}
......@@ -252,10 +251,6 @@ public class IncomingView extends GenericCDIView {
}
public void changeReader() {
namecontainer.setReaderId(null);
super.navihandler.redirectNavigation("index.jsf");
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!