Commit 92f1f4e6 by Tuukka Kivilahti

fixed it

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