Commit 24f2ee08 by Tuomas Riihimäki

Merge branch 'barcodefuckup' into 'master'

Barcodefuckup

Viivakoodipuolen refaktorointi, ny kaikki menee kannan kautta, ja ReaderEventteihin mapataan kaikki mahollinen -> ei tartte käsin vieweissä tehä mappauslogiikkaa 👍  Closes #43
2 parents 033e23cc 8170e8b0
Showing with 680 additions and 762 deletions
...@@ -15,6 +15,7 @@ import fi.codecrew.moya.facade.PrintedCardFacade; ...@@ -15,6 +15,7 @@ import fi.codecrew.moya.facade.PrintedCardFacade;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Place; import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PrintedCard; import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.utilities.BarcodeUtils; import fi.codecrew.moya.utilities.BarcodeUtils;
/** /**
...@@ -39,6 +40,10 @@ public class BarcodeBean implements BarcodeBeanLocal { ...@@ -39,6 +40,10 @@ public class BarcodeBean implements BarcodeBeanLocal {
@EJB @EJB
UserBeanLocal userBean; UserBeanLocal userBean;
@EJB
ProductBeanLocal productBean;
/** /**
* Default constructor. * Default constructor.
...@@ -181,7 +186,7 @@ public class BarcodeBean implements BarcodeBeanLocal { ...@@ -181,7 +186,7 @@ public class BarcodeBean implements BarcodeBeanLocal {
} catch (NumberFormatException x) { } catch (NumberFormatException x) {
} }
return printedCardFacade.findByBarcode(barcode); return printedCardFacade.findByCode(barcode);
} }
public EventUser getUser(String barcode) { public EventUser getUser(String barcode) {
...@@ -212,4 +217,17 @@ public class BarcodeBean implements BarcodeBeanLocal { ...@@ -212,4 +217,17 @@ public class BarcodeBean implements BarcodeBeanLocal {
return null; return null;
} }
@Override
public Product getProduct(String barcode) {
return productBean.findByBarcode(barcode);
}
@Override
public Place getPlaceFromBarcode(String barcode) {
//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
}
} }
...@@ -40,6 +40,19 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -40,6 +40,19 @@ public class BootstrapBean implements BootstrapBeanLocal {
"ALTER TABLE org_roles ADD ldap_role boolean not null default false", "ALTER TABLE org_roles ADD ldap_role boolean not null default false",
"ALTER TABLE org_roles ADD ldap_weight integer NOT NULL default 100" "ALTER TABLE org_roles ADD ldap_weight integer NOT NULL default 100"
}); });
// barcodefuckup
dbUpdates.add(new String[] {
"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 DEFAULT 'UNKNOWN';",
"ALTER TABLE reader_events DROP COLUMN gamepoint;",
"ALTER TABLE reader_events ALTER COLUMN type DROP DEFAULT;",
});
} }
@EJB @EJB
......
...@@ -13,15 +13,20 @@ import javax.ejb.Stateless; ...@@ -13,15 +13,20 @@ import javax.ejb.Stateless;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.facade.CardCodeFacade;
import fi.codecrew.moya.facade.PrintedCardFacade; import fi.codecrew.moya.facade.PrintedCardFacade;
import fi.codecrew.moya.facade.ReaderEventFacade; import fi.codecrew.moya.facade.ReaderEventFacade;
import fi.codecrew.moya.facade.ReaderFacade; import fi.codecrew.moya.facade.ReaderFacade;
import fi.codecrew.moya.model.AccountEvent; import fi.codecrew.moya.model.AccountEvent;
import fi.codecrew.moya.model.CardCode;
import fi.codecrew.moya.model.CardTemplate; import fi.codecrew.moya.model.CardTemplate;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PrintedCard; import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.Reader; import fi.codecrew.moya.model.Reader;
import fi.codecrew.moya.model.ReaderEvent; import fi.codecrew.moya.model.ReaderEvent;
import fi.codecrew.moya.model.ReaderEventType;
import fi.codecrew.moya.model.ReaderType; import fi.codecrew.moya.model.ReaderType;
import fi.codecrew.moya.model.User; import fi.codecrew.moya.model.User;
...@@ -33,8 +38,12 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -33,8 +38,12 @@ public class ReaderBean implements ReaderBeanLocal {
@EJB @EJB
private ReaderFacade readerfacade; private ReaderFacade readerfacade;
@EJB @EJB
private PrintedCardFacade cardfacade; private PrintedCardFacade cardfacade;
@EJB @EJB
private CardTemplateBeanLocal cardtemplatebean; private CardTemplateBeanLocal cardtemplatebean;
@EJB @EJB
...@@ -47,152 +56,133 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -47,152 +56,133 @@ public class ReaderBean implements ReaderBeanLocal {
private CardTemplateBean cardTemplateBean; private CardTemplateBean cardTemplateBean;
@EJB @EJB
private ProductPBean productPBean; private ProductPBean productPBean;
@EJB
private CardCodeFacade cardCodeFacade;
@EJB
private BarcodeBeanLocal barcodeBean;
private static final Logger logger = LoggerFactory.getLogger(ReaderBean.class); private static final Logger logger = LoggerFactory.getLogger(ReaderBean.class);
@Override @Override
public ReaderEvent checkTag(String readerIdent, String tag) { public ReaderEvent checkCode(String readerIdent, String code) {
Reader reader = readerfacade.findOrCreateByIdent(readerIdent); Reader reader = readerfacade.findOrCreateByIdent(readerIdent);
return checkCode(reader, code);
}
@Override
/**
* check reader code, and add it to the database
*/
public ReaderEvent checkCode(Reader reader, String code) {
logger.info("got code from reader {}", code);
tag = tag.replace("\"\b", ""); code = code.replace("\"\b", "");
if (reader.getType() == ReaderType.RFID) { if (reader.getType() == ReaderType.RFID) {
if (Pattern.matches("^.*000000$", tag)) if (Pattern.matches("^.*000000$", code))
{ {
tag = tag.replace("000000", ""); code = code.replace("000000", "");
} }
StringBuilder sb = new StringBuilder(tag); StringBuilder sb = new StringBuilder(code);
while (sb.length() < 16) while (sb.length() < 16)
{ {
sb.insert(0, "0"); sb.insert(0, "0");
} }
tag = sb.toString(); code = sb.toString();
} }
PrintedCard card = cardfacade.findByRfid(tag);
ReaderEvent event = new ReaderEvent(new Date(), reader, code);
logger.info("reader {}, card {}", reader, card);
// RfidEvent revent = reventcontainer.foundTag(reader, tag); // first, check if dublicate, there is 30s timeout for dublicates, afther that it's ok to create dublicate
// that's bcause accident dublicates are bad, but otherwise it's probably bcause user want's to read it again
List<ReaderEvent> lastevents = readerEventFacade.findLastEvents(reader, 1); List<ReaderEvent> lastevents = readerEventFacade.findLastEvents(reader, 1);
ReaderEvent ret = null;
if (!lastevents.isEmpty() && !reader.isAutoproduct()) if (!lastevents.isEmpty() && !reader.isAutoproduct())
{ {
ReaderEvent lastevent = lastevents.get(0); ReaderEvent lastevent = lastevents.get(0);
if (card == null)
{ if(lastevent.getValue() == event.getValue() && (lastevent.getUpdatetime().getTime() + 60000l) > event.getTime().getTime()) {
if (lastevent.getPrintedCard() == null && tag.equals(lastevent.getValue()))
{ lastevent = readerEventFacade.reload(lastevent);
ret = lastevent; lastevent = readerEventFacade.merge(lastevent);
}
return lastevent; // todo: update lastevent bfore return
} else if (card.equals(lastevent.getPrintedCard())) {
ret = lastevent;
} }
} }
if (ret == null)
{
ret = createReaderEvent(reader, card); // find stuff with barcode and set type
logger.debug("Got reader autoproduct {} with count {}", reader.getAutomaticProduct(), reader.getAutomaticProductCount()); // IF we find 2 stuff with same barcode, it's just bad luck and things may be little random.
logger.debug("ret {}, card, {} autoproduct {}", new Object[] { ret, card, reader.isAutoproduct() }); EventUser user = barcodeBean.getUser(code);
if (ret != null && card != null && reader.isAutoproduct()) {
EventUser eu = userbean.getEventUser(card.getUser().getUser()); if(user != null) {
AccountEvent createAc = productPBean.createAccountEvent(reader.getAutomaticProduct(), reader.getAutomaticProductCount(), eu, Calendar.getInstance()); event.setType(ReaderEventType.USER);
readerfacade.flush(); event.setUser(user);
logger.info("Creating new accountevent from autoproduct {}", createAc); }
ret.setNotes("Created automatic account event from reader. " + createAc);
PrintedCard card = barcodeBean.getPrintedCard(code);
if(card != null) {
event.setType(ReaderEventType.CARD);
event.setPrintedCard(card);
if(card.getUser() != null) {
event.setUser(card.getUser());
} }
} else {
ret.setUpdatetime(new Date());
} }
if (card == null)
{ Product product = barcodeBean.getProduct(code);
ret.setValue(tag);
if(product != null) {
event.setType(ReaderEventType.PRODUCT);
event.setProduct(product);
} }
return ret;
Place place = barcodeBean.getPlaceFromBarcode(code);
}
if(place != null) {
// event.setType(ReaderEventType.PLACE);
// @Override event.setPlace(place);
// public ReaderEvent assocTagToPlacecode(String tag, String readerIdent,
// String placecode) throws BortalCatchableException,
// PermissionDeniedException {
//
// GroupMembership gm = gmfacade.findByToken(placecode);
// if (gm == null) {
// throw new BortalCatchableException("Token" + placecode + " not found!",
// "readerbean.tokenNotFound");
// }
// if (gm.getUser() == null) {
// throw new BortalCatchableException("Token " + placecode +
// "found but not assoc to user!",
// "readerbean.userNotAssociateToMembership");
// }
//
// PrintedCard card = cardtemplatebean.setRfidUid(tag, gm.getUser());
//
// Reader reader = readerfacade.findOrCreateByIdent(readerIdent);
//
// return createReaderEvent(reader, card);
//
// }
private ReaderEvent createReaderEvent(Reader reader, PrintedCard card) {
ReaderEvent ret = new ReaderEvent(Calendar.getInstance(), card, reader);
Integer gamepoints = reader.getGamepoints();
if (gamepoints > 0 && card != null) {
int awardedCount = 0;
for (ReaderEvent oldRe : reader.getEvents()) {
if (oldRe.getGamePoint() > 0)
{
++awardedCount;
// User has been already awarded points from this reader.
// Not awarding again...
if (oldRe.getPrintedCard().equals(card)) {
gamepoints = 0;
break;
}
}
}
// if points can be awarded only limited times...
if (reader.getMaxEvents() > 0 && reader.getMaxEvents() > awardedCount) {
gamepoints = 0;
}
} }
event.setUpdatetime(new Date());
// reader is in autoproduct-mode, create dat product
if (reader.isAutoproduct()) {
EventUser eu = userbean.getEventUser(card.getUser().getUser());
AccountEvent createAc = productPBean.createAccountEvent(reader.getAutomaticProduct(), reader.getAutomaticProductCount(), eu, Calendar.getInstance());
readerfacade.flush();
logger.info("Creating new accountevent from autoproduct {}", createAc);
event.setNotes("Created automatic account event from reader. " + createAc);
ret.setGamePoint(gamepoints);
reader.getEvents().add(ret);
if (card != null)
{
card.getReaderEvents().add(ret);
} }
event = readerEventFacade.create(event);
return event;
return ret;
} }
@Override @Override
public ReaderEvent assocTagToCard(String tag, String readerIdent, PrintedCard card) { public ReaderEvent assocCodeToCard(ReaderEvent readerEvent, PrintedCard card) {
Reader reader = readerfacade.findOrCreateByIdent(readerIdent); CardCode code = new CardCode(card, readerEvent.getReader().getType(), readerEvent.getValue());
code = cardCodeFacade.create(code);
card = cardfacade.reload(card); card = cardfacade.reload(card);
card.setRfidUid(tag);
// card = cardtemplatebean.setRfidUid(tag, card);
return createReaderEvent(reader, card); return readerEvent;
} }
@Override @Override
...@@ -207,6 +197,8 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -207,6 +197,8 @@ public class ReaderBean implements ReaderBeanLocal {
@Override @Override
public List<ReaderEvent> getReaderEvents(Integer readerId, Integer count) { public List<ReaderEvent> getReaderEvents(Integer readerId, Integer count) {
logger.info("Getting events for reader {}", readerId);
Reader reader = readerfacade.find(readerId); Reader reader = readerfacade.find(readerId);
return readerEventFacade.findLastEvents(reader, count); return readerEventFacade.findLastEvents(reader, count);
} }
...@@ -235,7 +227,7 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -235,7 +227,7 @@ public class ReaderBean implements ReaderBeanLocal {
@Override @Override
public User findTagFromAnyEvent(String value) { public User findTagFromAnyEvent(String value) {
PrintedCard card = cardfacade.findLatestByRfidFromAny(value); PrintedCard card = cardfacade.findLatestByCodeFromAny(value);
User ret = null; User ret = null;
if (card != null && card.getUser() != null) { if (card != null && card.getUser() != null) {
ret = card.getUser().getUser(); ret = card.getUser().getUser();
...@@ -244,6 +236,9 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -244,6 +236,9 @@ public class ReaderBean implements ReaderBeanLocal {
return ret; return ret;
} }
// ok, let's comment this out, so I can see where this is used
/*
@Override @Override
public ReaderEvent createCard(ReaderEvent event, EventUser user) { public ReaderEvent createCard(ReaderEvent event, EventUser user) {
ReaderEvent ret = null; ReaderEvent ret = null;
...@@ -268,6 +263,7 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -268,6 +263,7 @@ public class ReaderBean implements ReaderBeanLocal {
} }
return ret; return ret;
} }
*/
@Override @Override
public Reader getReader(Integer readerid) { public Reader getReader(Integer readerid) {
......
...@@ -3,14 +3,14 @@ package fi.codecrew.moya.facade; ...@@ -3,14 +3,14 @@ package fi.codecrew.moya.facade;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import fi.codecrew.moya.model.CardBarcode; import fi.codecrew.moya.model.CardCode;
@Stateless @Stateless
@LocalBean @LocalBean
public class CardBarcodeFacade extends IntegerPkGenericFacade<CardBarcode> { public class CardCodeFacade extends IntegerPkGenericFacade<CardCode> {
public CardBarcodeFacade() { public CardCodeFacade() {
super(CardBarcode.class); super(CardCode.class);
} }
} }
...@@ -3,7 +3,6 @@ package fi.codecrew.moya.facade; ...@@ -3,7 +3,6 @@ package fi.codecrew.moya.facade;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
...@@ -14,9 +13,12 @@ import javax.persistence.criteria.CriteriaBuilder; ...@@ -14,9 +13,12 @@ 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;
import fi.codecrew.moya.model.CardCode;
import fi.codecrew.moya.model.CardCode_;
import fi.codecrew.moya.model.CardTemplate_; import fi.codecrew.moya.model.CardTemplate_;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.LanEvent; import fi.codecrew.moya.model.LanEvent;
...@@ -35,31 +37,19 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> { ...@@ -35,31 +37,19 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
@EJB @EJB
private EventBeanLocal eventbean; private EventBeanLocal eventbean;
public PrintedCard findByRfid(String uid) {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); public PrintedCard findByCode(String code) {
CriteriaQuery<PrintedCard> cq = cb.createQuery(PrintedCard.class);
Root<PrintedCard> root = cq.from(PrintedCard.class);
cq.where(
cb.or(
cb.equal(root.get(PrintedCard_.barcode), uid),
cb.equal(root.get(PrintedCard_.rfidUid), uid)),
cb.equal(root.get(PrintedCard_.event), eventbean.getCurrentEvent()));
return getSingleNullableResult(getEm().createQuery(cq));
}
public PrintedCard findByBarcode(String barcode) {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<PrintedCard> cq = cb.createQuery(PrintedCard.class); CriteriaQuery<CardCode> cq = cb.createQuery(CardCode.class);
Root<PrintedCard> root = cq.from(PrintedCard.class); Root<CardCode> root = cq.from(CardCode.class);
cq.where(cb.equal(root.get(PrintedCard_.barcode), barcode), cq.where(cb.equal(root.get(CardCode_.code), code),
cb.equal(root.get(PrintedCard_.event), eventbean.getCurrentEvent())); cb.equal(root.get(CardCode_.event), eventbean.getCurrentEvent()));
return getSingleNullableResult(getEm().createQuery(cq)); CardCode cardcode = getSingleNullableResult(getEm().createQuery(cq));
return (cardcode == null)?null : cardcode.getPrintedCard();
} }
public List<PrintedCard> findAllEnabled(LanEvent currentEvent) { public List<PrintedCard> findAllEnabled(LanEvent currentEvent) {
...@@ -85,14 +75,16 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> { ...@@ -85,14 +75,16 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
} }
public PrintedCard findLatestByRfidFromAny(String uid) { public PrintedCard findLatestByCodeFromAny(String code) {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<PrintedCard> cq = cb.createQuery(PrintedCard.class); CriteriaQuery<PrintedCard> cq = cb.createQuery(PrintedCard.class);
Root<PrintedCard> root = cq.from(PrintedCard.class); Root<CardCode> root = cq.from(CardCode.class);
cq.select(root.get(CardCode_.printedCard));
cq.where(cb.equal(root.get(PrintedCard_.rfidUid), uid));
cq.orderBy(cb.desc(root.get(PrintedCard_.printTime))); cq.where(cb.equal(root.get(CardCode_.code), code));
cq.orderBy(cb.desc(root.get(CardCode_.printedCard).get(PrintedCard_.printTime)));
TypedQuery<PrintedCard> q = getEm().createQuery(cq); TypedQuery<PrintedCard> q = getEm().createQuery(cq);
q.setMaxResults(1); q.setMaxResults(1);
......
...@@ -8,6 +8,7 @@ import javax.ejb.Local; ...@@ -8,6 +8,7 @@ import javax.ejb.Local;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Place; import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PrintedCard; import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.Product;
@Local @Local
public interface BarcodeBeanLocal { public interface BarcodeBeanLocal {
...@@ -20,5 +21,8 @@ public interface BarcodeBeanLocal { ...@@ -20,5 +21,8 @@ public interface BarcodeBeanLocal {
public String getPlaceHexcode(Place place); public String getPlaceHexcode(Place place);
public Place getPlaceFromHexcode(String hexcode); public Place getPlaceFromHexcode(String hexcode);
public String checkVrAuthCode(String code); public String checkVrAuthCode(String code);
public Product getProduct(String barcode);
public Place getPlaceFromBarcode(String barcode);
} }
...@@ -9,6 +9,7 @@ import fi.codecrew.moya.enums.CardState; ...@@ -9,6 +9,7 @@ import fi.codecrew.moya.enums.CardState;
import fi.codecrew.moya.model.CardTemplate; import fi.codecrew.moya.model.CardTemplate;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.PrintedCard; import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.ReaderEvent;
import fi.codecrew.moya.utilities.jsf.EntityFinderBean; import fi.codecrew.moya.utilities.jsf.EntityFinderBean;
@Local @Local
......
...@@ -17,7 +17,7 @@ public interface ReaderBeanLocal { ...@@ -17,7 +17,7 @@ public interface ReaderBeanLocal {
// ReaderEvent assocTagToPlacecode(String tag, String readerIdent, String // ReaderEvent assocTagToPlacecode(String tag, String readerIdent, String
// placecode) throws BortalCatchableException, PermissionDeniedException; // placecode) throws BortalCatchableException, PermissionDeniedException;
ReaderEvent assocTagToCard(String tag, String readerIdent, PrintedCard card); ReaderEvent assocCodeToCard(ReaderEvent readerEvent, PrintedCard card);
List<Reader> getReaders(); List<Reader> getReaders();
...@@ -27,7 +27,8 @@ public interface ReaderBeanLocal { ...@@ -27,7 +27,8 @@ public interface ReaderBeanLocal {
User findTagFromAnyEvent(String value); User findTagFromAnyEvent(String value);
ReaderEvent createCard(ReaderEvent event, EventUser user); // lets comment this out, so I can see where this is going
// ReaderEvent createCard(ReaderEvent event, EventUser user);
Reader getReader(Integer readerid); Reader getReader(Integer readerid);
...@@ -39,7 +40,9 @@ public interface ReaderBeanLocal { ...@@ -39,7 +40,9 @@ public interface ReaderBeanLocal {
List<ReaderEvent> getLastReaderEvents(); List<ReaderEvent> getLastReaderEvents();
ReaderEvent checkTag(String readerIdent, String tag); ReaderEvent checkCode(String readerIdent, String code);
ReaderEvent checkCode(Reader reader, String code);
List<ReaderEvent> getReaderEvents(Integer readerId, Integer count); List<ReaderEvent> getReaderEvents(Integer readerId, Integer count);
......
...@@ -15,7 +15,7 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression= ...@@ -15,7 +15,7 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=1 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assignment=0 org.eclipse.jdt.core.formatter.alignment_for_assignment=0
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
...@@ -90,7 +90,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true ...@@ -90,7 +90,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=8 org.eclipse.jdt.core.formatter.indentation.size=4
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
...@@ -283,7 +283,7 @@ org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false ...@@ -283,7 +283,7 @@ org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space org.eclipse.jdt.core.formatter.tabulation.char=tab
org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.tabulation.size=4
org.eclipse.jdt.core.formatter.use_on_off_tags=false org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
......
cleanup_settings_version=2 cleanup_settings_version=2
eclipse.preferences.version=1 eclipse.preferences.version=1
formatter_profile=_InsomniaConventions formatter_profile=_Insomnia
formatter_settings_version=12 formatter_settings_version=12
...@@ -9,14 +9,59 @@ import org.eclipse.persistence.annotations.OptimisticLocking; ...@@ -9,14 +9,59 @@ import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType; import org.eclipse.persistence.annotations.OptimisticLockingType;
@Entity @Entity
@Table(name = "card_barcode") @Table(name = "card_code")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS) @OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class CardBarcode extends GenericEntity { public class CardCode extends GenericEntity {
private static final long serialVersionUID = 4771609802672223277L;
private static final long serialVersionUID = 307145499023412008L;
private ReaderType type;
private String code;
public static final String EVENT_ID_COLUMN = "event_id";
@ManyToOne @ManyToOne
@JoinColumn(name = EVENT_ID_COLUMN, nullable = false)
private LanEvent event;
@ManyToOne()
@JoinColumn(name = "printed_cards_id") @JoinColumn(name = "printed_cards_id")
private PrintedCard printedCard; private PrintedCard printedCard;
public CardCode(PrintedCard card, ReaderType type, String code) {
this.printedCard = card;
this.type = type;
this.code = code;
}
public CardCode() {
}
public ReaderType getType() {
return type;
}
public void setType(ReaderType type) {
this.type = type;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public LanEvent getEvent() {
return event;
}
public void setEvent(LanEvent event) {
this.event = event;
}
public PrintedCard getPrintedCard() { public PrintedCard getPrintedCard() {
return printedCard; return printedCard;
...@@ -25,4 +70,7 @@ public class CardBarcode extends GenericEntity { ...@@ -25,4 +70,7 @@ public class CardBarcode extends GenericEntity {
public void setPrintedCard(PrintedCard printedCard) { public void setPrintedCard(PrintedCard printedCard) {
this.printedCard = printedCard; this.printedCard = printedCard;
} }
} }
...@@ -51,19 +51,19 @@ public class PrintedCard extends GenericEntity { ...@@ -51,19 +51,19 @@ public class PrintedCard extends GenericEntity {
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar printTime; private Calendar printTime;
@Column(name = "barcode")
private String barcode;
@Column(name = "card_enabled", nullable = false) @Column(name = "card_enabled", nullable = false)
private boolean enabled = true; private boolean enabled = true;
@Column(name = "rfid_uid")
private String rfidUid;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "printedCard") @OneToMany(cascade = CascadeType.ALL, mappedBy = "printedCard")
private List<ReaderEvent> readerEvents = new ArrayList<ReaderEvent>(); private List<ReaderEvent> readerEvents = new ArrayList<ReaderEvent>();
@OneToMany(cascade = CascadeType.ALL, mappedBy = "printedCard")
private List<CardCode> cardCodes = new ArrayList<CardCode>();
@Column(name = "print_count", nullable = false)
@Column(name = "print_count", nullable = false)
private int printCount = 0; private int printCount = 0;
@JoinColumn(name = "current_location_id", referencedColumnName = "id") @JoinColumn(name = "current_location_id", referencedColumnName = "id")
...@@ -112,13 +112,6 @@ public class PrintedCard extends GenericEntity { ...@@ -112,13 +112,6 @@ public class PrintedCard extends GenericEntity {
this.printTime = printTime; this.printTime = printTime;
} }
public String getBarcode() {
return barcode;
}
public void setBarcode(String barcode) {
this.barcode = barcode;
}
public boolean getEnabled() { public boolean getEnabled() {
return enabled; return enabled;
...@@ -128,14 +121,6 @@ public class PrintedCard extends GenericEntity { ...@@ -128,14 +121,6 @@ public class PrintedCard extends GenericEntity {
this.enabled = cardEnabled; this.enabled = cardEnabled;
} }
public String getRfidUid() {
return rfidUid;
}
public void setRfidUid(String rfidUid) {
this.rfidUid = rfidUid;
}
public List<ReaderEvent> getReaderEvents() { public List<ReaderEvent> getReaderEvents() {
return readerEvents; return readerEvents;
} }
...@@ -152,6 +137,17 @@ public class PrintedCard extends GenericEntity { ...@@ -152,6 +137,17 @@ public class PrintedCard extends GenericEntity {
this.currentLocation = currentLocation; this.currentLocation = currentLocation;
} }
public List<CardCode> getCardCodes() {
return cardCodes;
}
public void setCardCodes(List<CardCode> cardCodes) {
this.cardCodes = cardCodes;
}
public EventUser getUser() { public EventUser getUser() {
return user; return user;
} }
...@@ -175,34 +171,7 @@ public class PrintedCard extends GenericEntity { ...@@ -175,34 +171,7 @@ public class PrintedCard extends GenericEntity {
public int getPrintCount() { public int getPrintCount() {
return printCount; return printCount;
} }
public static final Comparator<PrintedCard> GAMEPOINT_COMPARATOR = new Comparator<PrintedCard>() {
@Override
public int compare(PrintedCard o1, PrintedCard o2) {
int ret = o2.getGamepoints().compareTo(o1.getGamepoints());
if (ret == 0 && o1.getUser().getUser().getNick() != null && o2.getUser().getUser().getNick() != null)
{
ret = o1.getUser().getUser().getNick().compareTo(o2.getUser().getUser().getNick());
}
return ret;
}
};
@Transient
private Integer gamepoints = null;
public Integer getGamepoints() {
if (gamepoints == null) {
Integer ret = 0;
for (ReaderEvent re : this.getReaderEvents()) {
ret += re.getGamePoint();
}
gamepoints = ret;
}
return gamepoints;
}
public CardState getCardState() { public CardState getCardState() {
return cardState; return cardState;
...@@ -212,21 +181,4 @@ public class PrintedCard extends GenericEntity { ...@@ -212,21 +181,4 @@ public class PrintedCard extends GenericEntity {
this.cardState = cardState; this.cardState = cardState;
} }
@Transient
private transient ListDataModel<ReaderEvent> revents;
public ListDataModel<ReaderEvent> getGameCards() {
if (revents == null) {
List<ReaderEvent> ev = this.getReaderEvents();
ArrayList<ReaderEvent> ret = new ArrayList<ReaderEvent>();
for (ReaderEvent e : ev) {
if (e.getGamePoint() > 0) {
ret.add(e);
}
}
revents = new ListDataModel<ReaderEvent>(ret);
}
return revents;
}
} }
package fi.codecrew.moya.model; package fi.codecrew.moya.model;
import java.beans.Transient;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
...@@ -23,121 +24,180 @@ import org.eclipse.persistence.annotations.OptimisticLockingType; ...@@ -23,121 +24,180 @@ import org.eclipse.persistence.annotations.OptimisticLockingType;
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS) @OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class ReaderEvent extends GenericEntity { public class ReaderEvent extends GenericEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "event_time", nullable = false) @Column(name = "event_time", nullable = false)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date time; private Date time;
@Column(name = "event_updated") @Column(name = "event_updated")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date updatetime; private Date updatetime;
@Column(name = "value") @Column(name = "value")
private String value; private String value;
@Lob @Lob
@Column(name = "notes") @Column(name = "notes")
private String notes; private String notes;
@Column(nullable = false) @JoinColumn(name = "printed_cards_id", referencedColumnName = "id", nullable = true, updatable = false)
private Integer gamePoint = 0; @ManyToOne(optional = false)
private PrintedCard printedCard;
@JoinColumn(name = "printed_cards_id", referencedColumnName = "id", nullable = true, updatable = false)
@ManyToOne(optional = false) @JoinColumn(name = "readers_id", referencedColumnName = "id", nullable = false, updatable = false)
private PrintedCard printedCard; @ManyToOne(optional = false)
private Reader reader;
@JoinColumn(name = "readers_id", referencedColumnName = "id", nullable = false, updatable = false)
@ManyToOne(optional = false) @JoinColumn(name = "event_users_id", referencedColumnName = "id", nullable = true, updatable = false)
private Reader reader; @ManyToOne(optional = false)
private EventUser user;
public ReaderEvent(Calendar eventTime, PrintedCard card, Reader reader) {
this.time = eventTime.getTime(); @JoinColumn(name = "places_id", referencedColumnName = "id", nullable = true, updatable = false)
this.printedCard = card; @ManyToOne(optional = false)
this.reader = reader; private Place place;
}
@JoinColumn(name = "products_id", referencedColumnName = "id", nullable = true, updatable = false)
public ReaderEvent() { @ManyToOne(optional = false)
super(); private Product product;
}
private ReaderEventType type;
public String getNotes() {
return notes; public ReaderEvent(Date eventTime, Reader reader, String value) {
}
this(eventTime, reader, value, null, null, null, null, ReaderEventType.UNKNOWN);
public void setNotes(String notes) {
this.notes = notes; }
}
public ReaderEvent(Date eventTime, Reader reader, String value, ReaderEventType type) {
public Date getTime() {
return time; this(eventTime, reader, value, null, null, null, null, type);
}
}
public void setTime(Date eventTime) {
this.time = eventTime; public ReaderEvent(Date eventTime, Reader reader, String value, PrintedCard card, EventUser user, Place place, Product product, ReaderEventType type) {
}
this.time = eventTime;
public String getValue() { this.reader = reader;
return value; this.value = value;
} this.user = user;
this.printedCard = card;
public void setValue(String value) { this.user = user;
this.value = value; this.place = place;
} this.product = product;
public PrintedCard getPrintedCard() { if (type == null)
return printedCard; type = ReaderEventType.UNKNOWN;
}
this.type = type;
public void setPrintedCard(PrintedCard printedCardsId) {
this.printedCard = printedCardsId; }
}
public ReaderEvent() {
public Reader getReader() { super();
return reader; }
}
public EventUser getUser() {
public void setReader(Reader readersId) { return user;
this.reader = readersId; }
}
public void setUser(EventUser user) {
public void setGamePoint(Integer gamePoint) { this.user = user;
this.gamePoint = gamePoint; }
}
public Place getPlace() {
public Integer getGamePoint() { return place;
return gamePoint; }
}
public void setPlace(Place place) {
public Date getUpdatetime() { this.place = place;
return updatetime; }
}
public Product getProduct() {
public void setUpdatetime(Date updatetime) { return product;
this.updatetime = updatetime; }
}
public void setProduct(Product product) {
public String getSeenSince() { this.product = product;
Date comptime = updatetime; }
if (comptime == null)
{ public ReaderEventType getType() {
comptime = time; return type;
} }
long diffSec = (new Date().getTime() - comptime.getTime()) / 1000;
long secs = diffSec % 60; public void setType(ReaderEventType type) {
long diffMin = diffSec / 60; this.type = type;
long mins = diffMin % 60; }
long hours = diffMin / 60;
public String getNotes() {
StringBuilder ret = new StringBuilder(); return notes;
if (hours > 0) { }
ret.append(hours).append(" h ");
} public void setNotes(String notes) {
if (hours > 0 || mins > 0) { this.notes = notes;
ret.append(mins).append(" min "); }
}
ret.append(secs).append(" sec"); public Date getTime() {
return ret.toString(); return time;
} }
public void setTime(Date eventTime) {
this.time = eventTime;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public PrintedCard getPrintedCard() {
return printedCard;
}
public void setPrintedCard(PrintedCard printedCardsId) {
this.printedCard = printedCardsId;
}
public Reader getReader() {
return reader;
}
public void setReader(Reader readersId) {
this.reader = readersId;
}
public Date getUpdatetime() {
if (updatetime == null)
return time;
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
@Transient
public String getSeenSince() {
return "" + ((getUpdatetime().getTime() / 1000) / 60) +" min." ;
}
} }
package fi.codecrew.moya.model;
public enum ReaderEventType {
USER,
PLACE,
CARD,
PRODUCT,
UNKNOWN
}
...@@ -66,6 +66,7 @@ public class JpegReader { ...@@ -66,6 +66,7 @@ public class JpegReader {
return null; return null;
} }
public void checkAdobeMarker(File file) throws IOException, ImageReadException { public void checkAdobeMarker(File file) throws IOException, ImageReadException {
JpegImageParser parser = new JpegImageParser(); JpegImageParser parser = new JpegImageParser();
ByteSource byteSource = new ByteSourceFile(file); ByteSource byteSource = new ByteSourceFile(file);
......
...@@ -30,19 +30,13 @@ ...@@ -30,19 +30,13 @@
<br /> <br />
<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>
<ui:define name="sidebar">
<reader:readerlisttiles />
<br />
</ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
</html> </html>
\ No newline at end of file
...@@ -12,12 +12,7 @@ ...@@ -12,12 +12,7 @@
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" /> <h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
<h:form> <h1>#{i18n['incomingflow.userdetails']} </h1>
<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>
<h:panelGrid id="cropper" columns="3"> <h:panelGrid id="cropper" columns="3">
<h:panelGroup> <h:panelGroup>
<user:edit id="usereditor" commitaction="#{incomingView.saveUser()}" commitvalue="#{i18n['user.save']}" camAlwaysOn="true" /> <user:edit id="usereditor" commitaction="#{incomingView.saveUser()}" commitvalue="#{i18n['user.save']}" camAlwaysOn="true" />
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "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:login="http://java.sun.com/jsf/composite/cditools/login" xmlns:tools="http://java.sun.com/jsf/composite/cditools" <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:login="http://java.sun.com/jsf/composite/cditools/login" xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:p="http://primefaces.org/ui"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader" xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
> >
...@@ -14,27 +15,45 @@ xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader" ...@@ -14,27 +15,45 @@ xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
<composite:attribute name="linkoutcome" required="false" /> <composite:attribute name="linkoutcome" required="false" />
<composite:attribute name="showAssociateToUser" required="false" /> <composite:attribute name="showAssociateToUser" required="false" />
<composite:attribute name="showEditReader" required="false" />
</composite:interface> </composite:interface>
<composite:implementation> <composite:implementation>
<h:form id="reader_autopoll" rendered="#{readerView.pollingMode}">
<p:poll interval="1" listener="#{cc.attrs.selectaction}" onerror="location.reload();" />
</h:form>
<h:form rendered="#{empty readerNameContainer.readerId}"> <h:form rendered="#{empty readerNameContainer.readerId}">
<h:dataTable border="1" id="reader" value="#{readerListDataView.readers}" var="rr"> <p:dataTable border="1" id="reader" value="#{readerListDataView.readers}" var="rr">
<h:column> <p:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="#{i18n['reader.name']}" /> <h:outputText value="#{i18n['reader.name']}" />
</f:facet> </f:facet>
<h:outputText value="#{rr.identification}" /> <h:outputText value="#{rr.identification}" />
</h:column> </p:column>
<h:column> <p:column>
<h:commandButton action="#{readerListDataView.selectReader}" value="#{i18n['reader.select']}" /> <p:commandButton actionListener="#{readerListDataView.selectReader}" value="#{i18n['reader.select']}" update="@all" />
</h:column> </p:column>
<p:column rendered="#{cc.attrs.showEditReader}" >
</h:dataTable> <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" />
</h:form> </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}" /> <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}" />
</composite:implementation> </composite:implementation>
......
<?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:login="http://java.sun.com/jsf/composite/cditools/login"
xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
>
<composite:interface>
<composite:attribute name="selectvalue" required="false" />
<composite:attribute name="selectaction" method-signature="java.lang.String action()" required="false" />
<composite:attribute name="linkvalue" required="false" />
<composite:attribute name="linkoutcome" required="false" />
</composite:interface>
<composite:implementation>
<reader:barcode selectvalue="#{cc.attrs.selectvalue}" selectaction="#{cc.attrs.selectaction}" /> <br />
<reader:rfid selectvalue="#{cc.attrs.selectvalue}" selectaction="#{cc.attrs.selectaction}" linkvalue="#{cc.attrs.linkvalue}" linkoutcome="#{cc.attrs.linkoutcome}" /> <br />
</composite:implementation>
</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:login="http://java.sun.com/jsf/composite/cditools/login"
xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
>
<composite:interface>
<composite:attribute name="selectvalue" required="false" />
<composite:attribute name="selectaction" method-signature="java.lang.String action()" required="false" />
<composite:attribute name="linkvalue" required="false" />
<composite:attribute name="linkoutcome" required="false" />
</composite:interface>
<composite:implementation>
todo: kato tapahtuman conffeista kumpi käytössä: <br />
<reader:barcode selectvalue="#{cc.attrs.selectvalue}" selectaction="#{cc.attrs.selectaction}" /> <br />
<reader:rfid selectvalue="#{cc.attrs.selectvalue}" selectaction="#{cc.attrs.selectaction}" linkvalue="#{cc.attrs.linkvalue}" linkoutcome="#{cc.attrs.linkoutcome}" /> <br />
</composite:implementation>
</html>
\ No newline at end of file
<?xml version='1.0' encoding='UTF-8' ?> <?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "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:login="http://java.sun.com/jsf/composite/cditools/login" xmlns:tools="http://java.sun.com/jsf/composite/cditools"> <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:login="http://java.sun.com/jsf/composite/cditools/login" xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:p="http://primefaces.org/ui">
<composite:interface> <composite:interface>
<composite:attribute name="selectvalue" required="false" /> <composite:attribute name="selectvalue" required="false" />
...@@ -10,11 +12,9 @@ ...@@ -10,11 +12,9 @@
<composite:implementation> <composite:implementation>
<h:form> <h:form>
<p:outputLabel value="#{i18n['code.inputfield']}" />
<h:outputLabel value="#{i18n['shop.barcode']}" /> <p:inputText id="code" value="#{readerView.userInsertCode}" />
<h:inputText id="barcode" value="#{readerView.barcode}" /> <p:commandButton action="#{cc.attrs.selectaction}" value="#{cc.attrs.selectvalue}" update="@all" />
<h:commandButton action="#{cc.attrs.selectaction}" value="#{cc.attrs.selectvalue}" />
</h:form> </h:form>
</composite:implementation> </composite:implementation>
......
...@@ -16,44 +16,42 @@ ...@@ -16,44 +16,42 @@
<composite:implementation> <composite:implementation>
<h:form> <h:form>
<p:poll interval="3" onerror="location.reload();" /> <p:poll interval="3" onerror="location.reload();" update="eventlist" />
<h:dataTable border="1" id="event" value="#{readerView.readerEvents}" var="event"> <p:commandLink actionListener="#{readerView.changeReader}" value="#{i18n['incomingflow.changereader']}" update="@all" />
<h:column> <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"> <f:facet name="header">
<h:outputText value="${i18n['readerevent.tagname']}" /> <h:outputText value="${i18n['readerevent.tagname']}" />
</f:facet> </f:facet>
<h:outputText rendered="#{!empty event.printedCard}" id="cardtag" value="#{event.printedCard.rfidUid}" />
<h:outputText rendered="#{empty event.printedCard}" id="newtag" value="#{event.value}" /> <h:outputText rendered="#{empty event.printedCard}" id="newtag" value="#{event.value}" />
</h:column> </p:column>
<h:column> <p:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['reader.user']}" /> <h:outputText value="${i18n['reader.user']}" />
</f:facet> </f:facet>
<h: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})" />
</h:column> </p:column>
<h:column> <p:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['readerevent.seenSince']}" /> <h:outputText value="${i18n['readerevent.seenSince']}" />
</f:facet> </f:facet>
<h:outputText value="#{event.seenSince}" /> <h:outputText value="#{event.seenSince}" />
</h:column> </p:column>
<h:column> <p:column>
<f:facet name="header"> <h:link rendered="#{!empty event.user and !empty cc.attrs.linkoutcome}" outcome="#{cc.attrs.linkoutcome}" value="#{cc.attrs.linkvalue}">
<h:outputText value="${i18n['gamepoints']}" /> <f:param name="userid" value="#{event.user.user.id}" />
</f:facet>
<h:outputText value="#{event.gamePoint}" />
</h:column>
<h: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> </h:link>
<h:commandLink rendered="#{!empty cc.attrs.selectaction}" action="#{cc.attrs.selectaction}" value="#{cc.attrs.selectvalue}" /> <p:commandLink rendered="#{!empty cc.attrs.selectaction}" actionListener="#{cc.attrs.selectaction}" value="#{cc.attrs.selectvalue}" update="@all" />
<!--
<h:link rendered="#{empty event.printedCard and !empty cc.attrs.showAssociateToUser}" outcome="/shop/assocToUser" value="#{i18n['readerevent.associateToUser']}"> <h:link rendered="#{empty event.printedCard and !empty cc.attrs.showAssociateToUser}" outcome="/shop/assocToUser" value="#{i18n['readerevent.associateToUser']}">
<f:param name="eventid" value="#{event.id}" /> <f:param name="eventid" value="#{event.id}" />
</h:link> </h:link>
...@@ -66,10 +64,10 @@ ...@@ -66,10 +64,10 @@
<h:link rendered="#{empty event.printedCard}" outcome="/shop/assocToUser" value="#{i18n['readerevent.associateToUser']}"> <h:link rendered="#{empty event.printedCard}" outcome="/shop/assocToUser" value="#{i18n['readerevent.associateToUser']}">
<f:param name="eventid" value="#{event.id}" /> <f:param name="eventid" value="#{event.id}" />
</h:link> </h:link> -->
</h:column> </p:column>
</h:dataTable> </p:dataTable>
</h:form> </h:form>
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<h:panelGroup> <h:panelGroup>
<reader:barcode selectaction="#{productShopView.readBarcode}" 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">
......
...@@ -15,24 +15,24 @@ ...@@ -15,24 +15,24 @@
<h:form id="editform"> <h:form id="editform">
<h:panelGrid columns="3"> <h:panelGrid columns="3">
<h:outputLabel for="type" value="#{i18n['reader.type']}:" /> <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}"/> <f:selectItems value="#{readerView.readertypes}"/>
</h:selectOneMenu> </h:selectOneMenu>
<h:message for="type"/> <h:message for="type"/>
<h:outputLabel for="identification" value="#{i18n['reader.identification']}:" /> <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:message for="identification" />
<h:outputLabel for="automaticProduct" value="#{i18n['reader.automaticProduct']}:" /> <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}"/> <f:selectItems value="#{readerView.autoProducts}" var="prod" itemLabel="#{prod.name}"/>
</h:selectOneMenu> </h:selectOneMenu>
<h:message for="automaticProduct" /> <h:message for="automaticProduct" />
<h:outputLabel for="automaticProductCount" value="#{i18n['reader.automaticProductCount']}:" /> <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" /> <f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</h:inputText> </h:inputText>
<h:message for="automaticProductCount" /> <h:message for="automaticProductCount" />
......
<!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:tools="http://java.sun.com/jsf/composite/tools"
xmlns:f="http://java.sun.com/jsf/core"
>
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="#{sessionHandler.template}">
<ui:define name="metadata">
<f:metadata>
<f:viewParam name="reader" value="#{rfidView.reader}" />
<f:viewParam name="tag" value="#{rfidView.tag}" />
<f:viewParam name="hash" value="#{rfidView.hash}" />
<f:event type="preRenderView" listener="#{rfidView.readTag}" />
</f:metadata>
</ui:define>
<ui:define name="content">
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
...@@ -8,14 +8,9 @@ ...@@ -8,14 +8,9 @@
> >
<h:body> <h:body>
<ui:composition template="#{sessionHandler.template}"> <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"> <ui:define name="content">
<reader:readerevents rendered="#{!empty readerNameContainer.readerId}" /> <reader:backendReader showEditReader="true" />
<reader:readerlist rendered="#{empty readerNameContainer.readerId}" />
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
</h:form> </h:form>
<h3>RFID</h3> <h3>RFID</h3>
<reader:barcode_rfid selectvalue="#{i18n['readerevent.associateToUser']}" selectaction="#{userView.attachBarcodeToCard()}" /> <reader:backendReader selectvalue="#{i18n['readerevent.associateToUser']}" selectaction="#{userView.attachCodeToCard}" />
</ui:fragment> </ui:fragment>
......
...@@ -109,6 +109,8 @@ card.massprint.title = Print all ...@@ -109,6 +109,8 @@ card.massprint.title = Print all
cardTemplate.emptyCardTemplate = ---- cardTemplate.emptyCardTemplate = ----
code.inputfield = Sy\u00F6t\u00E4 viivakoodi
error.contact = If this happens again, contact Info with the following code: error.contact = If this happens again, contact Info with the following code:
error.error = You have encountered an error. error.error = You have encountered an error.
......
...@@ -215,6 +215,8 @@ checkout.return.errorMessage = Error confirming the successfull return message ...@@ -215,6 +215,8 @@ checkout.return.errorMessage = Error confirming the successfull return message
checkout.return.successDelayed = Delayed payment successfull. Payment will be confirmed at a later time, usually within a hour. checkout.return.successDelayed = Delayed payment successfull. Payment will be confirmed at a later time, usually within a hour.
checkout.return.successMessage = Payment confirmed. Your products have been paid. checkout.return.successMessage = Payment confirmed. Your products have been paid.
code.inputfield = Give readercode
compo.edit = Edit compo compo.edit = Edit compo
compo.saveVotes = Save votes compo.saveVotes = Save votes
compo.savesort = Save order compo.savesort = Save order
...@@ -1153,7 +1155,7 @@ user.accountBalance = Account balance ...@@ -1153,7 +1155,7 @@ user.accountBalance = Account balance
user.accountEventHeader = Account events user.accountEventHeader = Account events
user.accountevents = Account events user.accountevents = Account events
user.address = Address user.address = Address
user.age = Age user.age = Age
user.bank = Bank user.bank = Bank
user.bankaccount = Bank number user.bankaccount = Bank number
user.birthday = Birthday user.birthday = Birthday
......
...@@ -217,6 +217,8 @@ checkout.return.errorMessage = Virhe maksun onnistuneen maksun vahvistuksessa. ...@@ -217,6 +217,8 @@ checkout.return.errorMessage = Virhe maksun onnistuneen maksun vahvistuksessa.
checkout.return.successDelayed = Viiv\u00E4stetty maksu onnistunut. Maksu vahvistet\u00E4\u00E4n my\u00F6hemp\u00E4n\u00E4 ajankohtana, yleens\u00E4 noin tunnin sis\u00E4ll\u00E4. checkout.return.successDelayed = Viiv\u00E4stetty maksu onnistunut. Maksu vahvistet\u00E4\u00E4n my\u00F6hemp\u00E4n\u00E4 ajankohtana, yleens\u00E4 noin tunnin sis\u00E4ll\u00E4.
checkout.return.successMessage = Maksu vahvistettu. Tuotteet on maksettu. Voit siirty\u00E4 eteenp\u00E4in tilauksessasi. checkout.return.successMessage = Maksu vahvistettu. Tuotteet on maksettu. Voit siirty\u00E4 eteenp\u00E4in tilauksessasi.
code.inputfield = Sy\u00F6t\u00E4 viivakoodi
compo.edit = Muokkaa compoa compo.edit = Muokkaa compoa
compo.saveVotes = Tallenna \u00E4\u00E4net compo.saveVotes = Tallenna \u00E4\u00E4net
compo.savesort = Tallenna j\u00E4rjestys compo.savesort = Tallenna j\u00E4rjestys
...@@ -1138,7 +1140,7 @@ user.accountBalance = Tilin saldo ...@@ -1138,7 +1140,7 @@ user.accountBalance = Tilin saldo
user.accountEventHeader = Tilitapahtumat user.accountEventHeader = Tilitapahtumat
user.accountevents = Tilitapahtumat user.accountevents = Tilitapahtumat
user.address = Osoite user.address = Osoite
user.age = Ik user.age = Ik\u00E4
user.bank = Pankki user.bank = Pankki
user.bankaccount = Pankkitili user.bankaccount = Pankkitili
user.birthday = Syntym\u00E4aika user.birthday = Syntym\u00E4aika
......
...@@ -63,6 +63,14 @@ public class ReaderRestView { ...@@ -63,6 +63,14 @@ public class ReaderRestView {
return new ReaderEventRestRoot(ReaderEventRestPojo.parse(events)); 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 @GET
@Path("/LastEventusers") @Path("/LastEventusers")
...@@ -76,46 +84,46 @@ public class ReaderRestView { ...@@ -76,46 +84,46 @@ public class ReaderRestView {
// public void createRfidEvent(@PathParam("reader") String reader, @PathParam("tagId") String tagId) { // public void createRfidEvent(@PathParam("reader") String reader, @PathParam("tagId") String tagId) {
// //
// } // }
//
// TBD: WTF! - Tarttis varmaan käydä ajatuksella läpi.. - Tuomari 2014-02-28 // // TBD: WTF! - Tarttis varmaan käydä ajatuksella läpi.. - Tuomari 2014-02-28
@GET // @GET
@Path("/EventRole/{reader}/{tagId}/{roleid}") // @Path("/EventRole/{reader}/{tagId}/{roleid}")
public Response eventRole(@PathParam("reader") String reader, @PathParam("tagId") String tag, @PathParam("roleid") Integer roleId) { // public Response eventRole(@PathParam("reader") String reader, @PathParam("tagId") String tag, @PathParam("roleid") Integer roleId) {
ReaderEvent ret = readerbean.checkTag(reader, tag); // ReaderEvent ret = readerbean.checkTag(reader, tag);
ResponseBuilder builder = null; // ResponseBuilder builder = null;
if (roleId == null || roleId.equals(0)) // if (roleId == null || roleId.equals(0))
{ // {
builder = Response.status(Status.BAD_REQUEST); // builder = Response.status(Status.BAD_REQUEST);
builder.entity("role ID is required!"); // builder.entity("role ID is required!");
builder.type(MediaType.TEXT_PLAIN); // builder.type(MediaType.TEXT_PLAIN);
//
} // }
if (builder == null) // if (builder == null)
{ // {
if (ret == null || ret.getPrintedCard() == null) { // if (ret == null || ret.getPrintedCard() == null) {
builder = Response.status(Status.NOT_ACCEPTABLE); // builder = Response.status(Status.NOT_ACCEPTABLE);
builder.entity("No card found for uid."); // builder.entity("No card found for uid.");
builder.type(MediaType.TEXT_PLAIN); // builder.type(MediaType.TEXT_PLAIN);
} else { // } else {
EventUser user = ret.getPrintedCard().getUser(); // EventUser user = ret.getPrintedCard().getUser();
boolean found = userbean.isUserInRole(user, roleId); // boolean found = userbean.isUserInRole(user, roleId);
if (found) { // if (found) {
builder = Response.status(Status.OK); // builder = Response.status(Status.OK);
} else { // } else {
builder = Response.status(Status.FORBIDDEN); // builder = Response.status(Status.FORBIDDEN);
} // }
builder.entity(new UserPermissionRestPojo(new EventUserRestPojo(user), found)); // builder.entity(new UserPermissionRestPojo(new EventUserRestPojo(user), found));
//
} // }
} // }
//
return builder.build(); // return builder.build();
} // }
//
@GET // @GET
@Path("/EventCard/{reader}/{cardid}") // @Path("/EventCard/{reader}/{cardid}")
public void eventCard(@PathParam("reader") String reader, @PathParam("cardid") String cardId) { // public void eventCard(@PathParam("reader") String reader, @PathParam("cardid") String cardId) {
//
} // }
} }
...@@ -53,5 +53,6 @@ public class ReaderListDataView extends GenericCDIView { ...@@ -53,5 +53,6 @@ public class ReaderListDataView extends GenericCDIView {
return null; return null;
} }
} }
...@@ -38,18 +38,13 @@ public class ReaderView extends GenericCDIView { ...@@ -38,18 +38,13 @@ public class ReaderView extends GenericCDIView {
private static final long serialVersionUID = 802344850073689859L; private static final long serialVersionUID = 802344850073689859L;
private Integer eventid;
private String placecode;
private String usersearch;
private String barcode;
private Reader reader;
private boolean pollingMode = false; private boolean pollingMode = false;
private ReaderEvent lastReadEvent = null; private ReaderEvent lastReadEvent = null;
private transient ListDataModel<UserCardWrapper> userlist; private transient ListDataModel<UserCardWrapper> userlist;
private ListDataModel<ReaderEvent> readerEventList; private ListDataModel<ReaderEvent> readerEventList;
private Reader editReader = null;
@Inject @Inject
private ReaderNameContainer namecontainer; private ReaderNameContainer namecontainer;
...@@ -57,15 +52,13 @@ public class ReaderView extends GenericCDIView { ...@@ -57,15 +52,13 @@ public class ReaderView extends GenericCDIView {
@EJB @EJB
private transient ReaderBeanLocal readerbean; private transient ReaderBeanLocal readerbean;
private ReaderEvent event;
@EJB @EJB
private transient UserBeanLocal userbean; private transient UserBeanLocal userbean;
@EJB @EJB
private transient BarcodeBeanLocal barcodebean; private transient BarcodeBeanLocal barcodebean;
private UserCardWrapper neighborUser; // private UserCardWrapper neighborUser;
private static final Logger logger = LoggerFactory.getLogger(ReaderView.class); private static final Logger logger = LoggerFactory.getLogger(ReaderView.class);
...@@ -76,21 +69,14 @@ public class ReaderView extends GenericCDIView { ...@@ -76,21 +69,14 @@ public class ReaderView extends GenericCDIView {
@Inject @Inject
private UserView userview; private UserView userview;
public void initEditReader() { public void initEditReader() {
if (super.requirePermissions(ShopPermission.SHOP_TO_OTHERS) && reader == null) { if (super.requirePermissions(ShopPermission.SHOP_TO_OTHERS) && editReader == null) {
reader = readerbean.getReader(readerid); editReader = readerbean.getReader(readerid);
super.beginConversation(); super.beginConversation();
} }
} }
public String createCardForUser() {
UserCardWrapper usr = userlist.getRowData();
logger.info("Creating card for user {} from event {}", usr, event);
ReaderEvent card = readerbean.createCard(event, usr.getUser());
// super.addFaceMessage("Created card for user with id: " +
// card.getPrintedCard());
return null;
}
public List<Role> getUserRoles(EventUser user) { public List<Role> getUserRoles(EventUser user) {
return userbean.findUsersRoles(user); return userbean.findUsersRoles(user);
...@@ -103,20 +89,20 @@ public class ReaderView extends GenericCDIView { ...@@ -103,20 +89,20 @@ public class ReaderView extends GenericCDIView {
public void initCreateReader() public void initCreateReader()
{ {
if (super.requirePermissions(ShopPermission.SHOP_TO_OTHERS) && reader == null) if (super.requirePermissions(ShopPermission.SHOP_TO_OTHERS) && editReader == null)
{ {
reader = new Reader(); editReader = new Reader();
super.beginConversation(); super.beginConversation();
} }
} }
public String createReader() public String createReader()
{ {
readerbean.createReader(reader); readerbean.createReader(editReader);
namecontainer.setReaderId(reader.getId()); namecontainer.setReaderId(editReader.getId());
return "/shop/showReaderEvents"; return "/shop/showReaderEvents";
} }
/*
public void initUserassocView() { public void initUserassocView() {
if (super.requirePermissions(UserPermission.CREATE_NEW) && event == null) { if (super.requirePermissions(UserPermission.CREATE_NEW) && event == null) {
event = readerbean.getEvent(eventid); event = readerbean.getEvent(eventid);
...@@ -126,25 +112,28 @@ public class ReaderView extends GenericCDIView { ...@@ -126,25 +112,28 @@ public class ReaderView extends GenericCDIView {
} }
super.beginConversation(); super.beginConversation();
} }
} }*/
public boolean isReaderSelected() { public boolean isReaderSelected() {
return this.readerid != null; return this.readerid != null;
} }
/*
public String assocToCard() public String assocToCard()
{ {
UserCardWrapper user = userlist.getRowData(); UserCardWrapper user = userlist.getRowData();
PrintedCard card = user.getPrintedCards().getRowData(); PrintedCard card = user.getPrintedCards().getRowData();
ReaderEvent re = readerbean.assocTagToCard(event.getValue(), event.getReader().getIdentification(), card); ReaderEvent re = readerbean.assocTagToCard(event, card);
super.addFaceMessage("usercard.associated"); super.addFaceMessage("usercard.associated");
logger.info("re {}", re.getPrintedCard()); logger.info("re {}", re.getPrintedCard());
userview.setUser(re.getPrintedCard().getUser()); userview.setUser(re.getPrintedCard().getUser());
return "/useradmin/edit"; return "/useradmin/edit";
}
public String searchforuser() }
public String searchforuser()
{ {
if (usersearch == null || usersearch.length() < 2) { if (usersearch == null || usersearch.length() < 2) {
super.addFaceMessage("user.tooShortSearch"); super.addFaceMessage("user.tooShortSearch");
...@@ -154,13 +143,11 @@ public class ReaderView extends GenericCDIView { ...@@ -154,13 +143,11 @@ public class ReaderView extends GenericCDIView {
return null; return null;
} }
*/
public void initReaderList() {
if (super.requirePermissions(ShopPermission.SHOP_TO_OTHERS)) {
}
}
public List<Product> getAutoProducts() { public List<Product> getAutoProducts() {
List<Product> ret = new ArrayList<Product>(); List<Product> ret = new ArrayList<Product>();
...@@ -184,7 +171,7 @@ public class ReaderView extends GenericCDIView { ...@@ -184,7 +171,7 @@ public class ReaderView extends GenericCDIView {
public String saveReader() public String saveReader()
{ {
reader = readerbean.saveReader(reader); editReader = readerbean.saveReader(editReader);
return null; return null;
} }
...@@ -196,37 +183,7 @@ public class ReaderView extends GenericCDIView { ...@@ -196,37 +183,7 @@ public class ReaderView extends GenericCDIView {
this.namecontainer = namecontainer; this.namecontainer = namecontainer;
} }
public Integer getEventid() {
return eventid;
}
public void setEventid(Integer eventid) {
this.eventid = eventid;
}
public ReaderEvent getEvent() {
return event;
}
public void setEvent(ReaderEvent event) {
this.event = event;
}
public String getPlacecode() {
return placecode;
}
public void setPlacecode(String placecode) {
this.placecode = placecode;
}
public String getUsersearch() {
return usersearch;
}
public void setUsersearch(String usersearch) {
this.usersearch = usersearch;
}
public ListDataModel<UserCardWrapper> getUserlist() { public ListDataModel<UserCardWrapper> getUserlist() {
return userlist; return userlist;
...@@ -235,14 +192,14 @@ public class ReaderView extends GenericCDIView { ...@@ -235,14 +192,14 @@ public class ReaderView extends GenericCDIView {
public void setUserlist(ListDataModel<UserCardWrapper> userlist) { public void setUserlist(ListDataModel<UserCardWrapper> userlist) {
this.userlist = userlist; this.userlist = userlist;
} }
/*
public UserCardWrapper getNeighborUser() { public UserCardWrapper getNeighborUser() {
return neighborUser; return neighborUser;
} }
public void setNeighborUser(UserCardWrapper neighborUser) { public void setNeighborUser(UserCardWrapper neighborUser) {
this.neighborUser = neighborUser; this.neighborUser = neighborUser;
} }*/
public Integer getReaderid() { public Integer getReaderid() {
return readerid; return readerid;
...@@ -255,18 +212,10 @@ public class ReaderView extends GenericCDIView { ...@@ -255,18 +212,10 @@ public class ReaderView extends GenericCDIView {
public String setReaderToId(Integer readerid) { public String setReaderToId(Integer readerid) {
this.readerid = readerid; this.readerid = readerid;
this.namecontainer.setReaderId(readerid); this.namecontainer.setReaderId(readerid);
reader = readerbean.getReader(readerid); editReader = readerbean.getReader(readerid);
return "/admin/info/index"; return "/admin/info/index";
} }
public Reader getReader() {
return reader;
}
public void setReader(Reader reader) {
this.reader = reader;
}
public UserView getUserview() { public UserView getUserview() {
return userview; return userview;
} }
...@@ -280,29 +229,15 @@ public class ReaderView extends GenericCDIView { ...@@ -280,29 +229,15 @@ public class ReaderView extends GenericCDIView {
return ReaderType.values(); return ReaderType.values();
} }
public String getBarcode() {
if (pollingMode) {
ReaderEvent event = readerbean.getLastReaderEvent(namecontainer.getReaderId());
if (!event.equals(lastReadEvent)) {
return event.getValue();
}
}
if (readerEventList != null && readerEventList.isRowAvailable()) {
if (readerEventList.getRowData().getReader().getType() == ReaderType.BARCODE || readerEventList.getRowData().getReader().getType() == ReaderType.RFID) {
return readerEventList.getRowData().getValue();
}
}
return barcode;
}
public void setBarcode(String barcode) {
this.barcode = barcode;
}
public ReaderEvent getReaderEvent() { public ReaderEvent getReaderEvent() {
if(pollingMode && isNewCodes()) {
pollingCodeHandled();
return readerbean.getLastReaderEvent(namecontainer.getReaderId());
}
if (readerEventList == null) if (readerEventList == null)
return null; return null;
...@@ -313,61 +248,74 @@ public class ReaderView extends GenericCDIView { ...@@ -313,61 +248,74 @@ public class ReaderView extends GenericCDIView {
return null; return null;
} }
/**
* If last barcode or rfid was associated to user, get it
*
* @return
*/
public PrintedCard getPrintedCard() {
PrintedCard card = barcodebean.getPrintedCard(getBarcode());
if (card == null && readerEventList != null && readerEventList.isRowAvailable()) {
card = readerEventList.getRowData().getPrintedCard();
}
return card;
}
public void initializeForPolling() { public void initializeForPolling() {
// on polling mode, we do not use list, we use database and remember last readerEvent // on polling mode, we do not use list, we use database and remember last readerEvent
this.pollingMode = true; this.pollingMode = true;
this.barcode = null;
lastReadEvent = readerbean.getLastReaderEvent(namecontainer.getReaderId()); lastReadEvent = readerbean.getLastReaderEvent(namecontainer.getReaderId());
} }
public void pollingBarcodeHandled() { public void pollingCodeHandled() {
lastReadEvent = readerbean.getLastReaderEvent(namecontainer.getReaderId()); lastReadEvent = readerbean.getLastReaderEvent(namecontainer.getReaderId());
} }
public EventUser getUser() { public String saveUser() {
PrintedCard card = getPrintedCard(); userview.saveUser();
if (card != null) { return null;
return card.getUser(); }
}
public boolean isNewCodes() {
if (!pollingMode)
return false;
return userbean.getUserByBarcode(getBarcode()); return (!readerbean.getLastReaderEvent(namecontainer.getReaderId()).equals(lastReadEvent));
} }
public void clearBarcode() {
this.barcode = null; public String getUserInsertCode() {
return "";
} }
public String saveUser() { public void setUserInsertCode(String userInsertCode) {
userview.saveUser(); readerbean.checkCode(readerbean.getReader(readerid), userInsertCode);
}
return null;
public boolean isPollingMode() {
return pollingMode;
} }
public boolean isNewBarcodes() {
if (!pollingMode) public void setPollingMode(boolean pollingMode) {
return false;
if(!this.pollingMode && pollingMode) {
this.initializeForPolling();
}
this.pollingMode = pollingMode;
}
public void changeReader() {
namecontainer.setReaderId(null);
}
public Reader getCurrentReader() {
return readerbean.getReader(namecontainer.getReaderId());
}
return (!readerbean.getLastReaderEvent(namecontainer.getReaderId()).equals(lastReadEvent));
public Reader getEditReader() {
return editReader;
} }
public void setEditReader(Reader editReader) {
this.editReader = editReader;
}
} }
...@@ -25,8 +25,8 @@ import fi.codecrew.moya.model.Bill; ...@@ -25,8 +25,8 @@ import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.LanEventProperty; import fi.codecrew.moya.model.LanEventProperty;
import fi.codecrew.moya.model.LanEventPropertyKey; import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.Product; import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.ReaderEvent;
import fi.codecrew.moya.web.annotations.SelectedUser; import fi.codecrew.moya.web.annotations.SelectedUser;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.reader.ReaderView; import fi.codecrew.moya.web.cdiview.reader.ReaderView;
...@@ -425,24 +425,24 @@ public class ProductShopView extends GenericCDIView { ...@@ -425,24 +425,24 @@ public class ProductShopView extends GenericCDIView {
this.hasLimits = hasLimits; this.hasLimits = hasLimits;
} }
public String readBarcode() { public String readCode() {
PrintedCard card = readerView.getPrintedCard(); ReaderEvent event = readerView.getReaderEvent();
if (readerView.getBarcode() == null || readerView.getBarcode().trim().isEmpty()) { if(event == null) {
return null; return null;
} }
if (card != null) { if (event.getPrintedCard() != null) {
if (card.getUser() != null) { if (event.getPrintedCard().getUser() != null) {
userView.setUser(card.getUser()); userView.setUser(event.getPrintedCard().getUser());
this.user = card.getUser(); this.user = event.getPrintedCard().getUser();
initShopView(); initShopView();
return null; return null;
} }
} }
Product product = productBean.findByBarcode(readerView.getBarcode()); Product product = event.getProduct();
this.blip = false; this.blip = false;
// find product index, set index and add one // find product index, set index and add one
...@@ -461,7 +461,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -461,7 +461,7 @@ public class ProductShopView extends GenericCDIView {
} }
n++; n++;
} }
readerView.clearBarcode();
logger.debug("barcode read"); logger.debug("barcode read");
return "success"; return "success";
} }
......
package fi.codecrew.moya.web.cdiview.shop;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.ReaderBeanLocal;
import fi.codecrew.moya.model.ReaderEvent;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@RequestScoped
public class RfidView extends GenericCDIView {
/**
*
*/
private static final long serialVersionUID = -4013368780039067464L;
private String reader;
private String tag;
private String hash;
@EJB
private transient ReaderBeanLocal readerbean;
private static final Logger logger = LoggerFactory.getLogger(RfidView.class);
public void readTag() {
ReaderEvent revent = readerbean.checkTag(reader, tag);
logger.debug("at view Got readerevent from bean: {}", revent);
}
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;
}
public String getHash() {
return hash;
}
public void setHash(String hash) {
this.hash = hash;
}
}
...@@ -34,6 +34,7 @@ import fi.codecrew.moya.enums.apps.UserPermission; ...@@ -34,6 +34,7 @@ import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.CardTemplate; import fi.codecrew.moya.model.CardTemplate;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.PrintedCard; import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.ReaderEvent;
import fi.codecrew.moya.model.Role; import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.model.User; import fi.codecrew.moya.model.User;
import fi.codecrew.moya.model.UserImage; import fi.codecrew.moya.model.UserImage;
...@@ -347,30 +348,26 @@ public class UserView extends GenericCDIView { ...@@ -347,30 +348,26 @@ public class UserView extends GenericCDIView {
* *
* @return * @return
*/ */
public String attachBarcodeToCard() { public String attachCodeToCard() {
return attachCodeToCard(readerView.getReaderEvent());
PrintedCard card = readerView.getPrintedCard(); }
public String attachCodeToCard(ReaderEvent event ) {
if(event == null)
return null;
// already attached // already attached
if (card != null) { if (event.getPrintedCard() != null) {
super.addFaceMessage("usercard.alreadyassociated"); super.addFaceMessage("usercard.alreadyassociated");
return null; return null;
} }
// still there, we can get real card and update it's barcodes // still there, we can get real card and update it's barcodes
card = cardBean.checkPrintedCard(user); PrintedCard card = cardBean.checkPrintedCard(user);
if (readerView.getBarcode() != null && !readerView.getBarcode().isEmpty()) { readerbean.assocCodeToCard(event , card);
card.setBarcode(readerView.getBarcode());
card.setCardState(CardState.PRINTED);
//super.addFaceMessage("usercard.associated");
MessageHelper.info("usercard.associated");
logger.debug("barcode {} to card {} ", readerView.getBarcode(), card.getUser().getNick());
cardBean.saveCard(card);
} else if (readerView.getReaderEvent() != null) {
readerbean.assocTagToCard(readerView.getReaderEvent().getValue(), readerView.getReaderEvent().getReader().getIdentification(), card);
}
return null; return null;
} }
......
...@@ -24,6 +24,7 @@ import fi.codecrew.moya.enums.apps.UserPermission; ...@@ -24,6 +24,7 @@ import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GroupMembership; import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.PrintedCard; import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.ReaderEvent;
import fi.codecrew.moya.util.UserSearchQuery; import fi.codecrew.moya.util.UserSearchQuery;
import fi.codecrew.moya.utilities.SearchResult; import fi.codecrew.moya.utilities.SearchResult;
import fi.codecrew.moya.web.annotations.SelectedUser; import fi.codecrew.moya.web.annotations.SelectedUser;
...@@ -130,7 +131,7 @@ public class IncomingView extends GenericCDIView { ...@@ -130,7 +131,7 @@ public class IncomingView extends GenericCDIView {
if (!initialized) { if (!initialized) {
logger.debug("INITIALIZING!!!!"); logger.debug("INITIALIZING!!!!");
initializePoller(); //initializePoller();
initialized = true; initialized = true;
super.beginConversation(); super.beginConversation();
} }
...@@ -146,9 +147,7 @@ public class IncomingView extends GenericCDIView { ...@@ -146,9 +147,7 @@ public class IncomingView extends GenericCDIView {
return null; return null;
} }
public void initializePoller() {
readerView.initializeForPolling();
}
public String changeToIncomingView() { public String changeToIncomingView() {
//super.navihandler.redirectNavigation("printCard.jsf?userid="+user.getUser().getId()); //super.navihandler.redirectNavigation("printCard.jsf?userid="+user.getUser().getId());
...@@ -157,13 +156,14 @@ public class IncomingView extends GenericCDIView { ...@@ -157,13 +156,14 @@ public class IncomingView extends GenericCDIView {
public void polledRead() { public void polledRead() {
if (!readerView.isNewBarcodes()) { ReaderEvent event = readerView.getReaderEvent();
if(event == null)
return; return;
}
logger.debug(":Barcode:"); logger.debug(":got.code:");
EventUser user = readerView.getUser(); EventUser user = event.getUser();
if (user != null) { if (user != null) {
if (!user.equals(userview.getUser())) { if (!user.equals(userview.getUser())) {
logger.info("found user {}, redirecting", user.getNick()); logger.info("found user {}, redirecting", user.getNick());
...@@ -177,16 +177,17 @@ public class IncomingView extends GenericCDIView { ...@@ -177,16 +177,17 @@ public class IncomingView extends GenericCDIView {
// still there, it must be "clean" barcode // still there, it must be "clean" barcode
if (userview.getUser() != null) { if (userview.getUser() != null) {
userview.attachBarcodeToCard(); userview.attachCodeToCard(event);
} }
} }
readerView.pollingBarcodeHandled();
} }
public String selectUser() { public String selectUser() {
EventUser user = readerView.getUser();
ReaderEvent event = readerView.getReaderEvent();
EventUser user = event.getUser();
memberlist = null; memberlist = null;
if (user == null) { if (user == null) {
...@@ -250,10 +251,6 @@ public class IncomingView extends GenericCDIView { ...@@ -250,10 +251,6 @@ public class IncomingView extends GenericCDIView {
} }
public void changeReader() {
namecontainer.setReaderId(null);
super.navihandler.redirectNavigation("index.jsf");
}
......
...@@ -8,6 +8,7 @@ import org.slf4j.Logger; ...@@ -8,6 +8,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.ReaderEvent;
import fi.codecrew.moya.web.annotations.SelectedUser; import fi.codecrew.moya.web.annotations.SelectedUser;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.reader.ReaderView; import fi.codecrew.moya.web.cdiview.reader.ReaderView;
...@@ -41,7 +42,13 @@ public class InfoView extends GenericCDIView { ...@@ -41,7 +42,13 @@ public class InfoView extends GenericCDIView {
} }
public String selectUser() { public String selectUser() {
EventUser user = readerView.getUser();
ReaderEvent event = readerView.getReaderEvent();
if(event == null)
return null;
EventUser user = event.getUser();
if(user == null) { if(user == null) {
return null; return null;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!