Commit 92f1f4e6 by Tuukka Kivilahti

fixed it

1 parent 6db7f37d
......@@ -79,7 +79,7 @@ public class BarcodeBean implements BarcodeBeanLocal {
// it's our special front barcode
try {
if (barcode.startsWith(PRINTED_CARD_PREFIX)) {
int id = Integer.parseInt(barcode.substring(3));
int id = Integer.parseInt(barcode.substring(3, barcode.length()-1));
PrintedCard card = printedCardFacade.find(id);
if(card != null)
......@@ -95,10 +95,12 @@ public class BarcodeBean implements BarcodeBeanLocal {
if(barcode == null || barcode.isEmpty())
return null;
// it's our special front barcode
try {
// it's our special front barcode
if (barcode.startsWith(EVENTUSER_PREFIX)) {
int id = Integer.parseInt(barcode.substring(3));
int id = Integer.parseInt(barcode.substring(3, barcode.length()-1 ));
logger.debug("finding user with barcode {} and id {}", barcode, id);
EventUser user = userBean.findByEventUserId(id);
return user;
......
......@@ -21,6 +21,7 @@ import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.Reader;
import fi.codecrew.moya.model.ReaderEvent;
import fi.codecrew.moya.model.ReaderType;
import fi.codecrew.moya.model.User;
/**
......@@ -51,20 +52,27 @@ public class ReaderBean implements ReaderBeanLocal {
@Override
public ReaderEvent checkTag(String readerIdent, String tag, String hash) {
Reader reader = readerfacade.findOrCreateByIdent(readerIdent);
tag = tag.replace("\"\b", "");
if (Pattern.matches("^.*000000$", tag))
{
tag = tag.replace("000000", "");
}
StringBuilder sb = new StringBuilder(tag);
while (sb.length() < 16)
{
sb.insert(0, "0");
if(reader.getType() == ReaderType.RFID) {
if (Pattern.matches("^.*000000$", tag))
{
tag = tag.replace("000000", "");
}
StringBuilder sb = new StringBuilder(tag);
while (sb.length() < 16)
{
sb.insert(0, "0");
}
tag = sb.toString();
}
tag = sb.toString();
PrintedCard card = cardfacade.findByRfid(tag);
Reader reader = readerfacade.findOrCreateByIdent(readerIdent);
logger.info("reader {}, card {}", reader, card);
// RfidEvent revent = reventcontainer.foundTag(reader, tag);
......
......@@ -523,7 +523,14 @@ public class UserBean implements UserBeanLocal {
public EventUser getUserByBarcode(String barcode) {
PrintedCard tmpCard = barcodeBean.getPrintedCard(barcode);
return (tmpCard == null) ? null : tmpCard.getUser();
EventUser user = null;
if(tmpCard == null) {
user = barcodeBean.getUser(barcode);
} else {
user = tmpCard.getUser();
}
return user;
}
@Override
......
......@@ -9,7 +9,7 @@ public enum LanEventPropertyKey {
ADMIN_MAIL(Type.TEXT, "moya@codecrew.fi"),
EVENT_LAYOUT(Type.TEXT, "template1"),
SHOP_DEFAULT_CASH(Type.BOOL, null),
PLACECODE_FROM_USER(Type.BOOL, null),
PLACECODE_FROM_USER(Type.BOOL, "1"),
PLACECODE_PRINT_ONLY_OWN(Type.BOOL, null),
CHECK_BILL_STATS_PERMISSION(Type.BOOL, null),
GATHER_OTHER_BILL_INFO(Type.BOOL, null),
......
......@@ -323,9 +323,7 @@ public class ReaderView extends GenericCDIView {
return card.getUser();
}
// todo: palauta tarvittaessa käyttäjä paikkaviivakoodista
// todo: siirrä käyttämään userbeanin getUserByBarcode-häsmäkkää
return null;
return userbean.getUserByBarcode(getBarcode());
}
public void clearBarcode() {
......
......@@ -44,9 +44,12 @@ public class IncomingView extends GenericCDIView {
EventUser user = readerView.getUser();
if(user == null) {
logger.debug("got no user from barcode");
return null;
}
logger.debug("got user from barcode");
userview.setUser(user);
userview.prepareCardDownload();
return "printCard";
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!