Commit 837ac95c by Tuukka Kivilahti

refactoring

1 parent edf86cf5
...@@ -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.
...@@ -212,4 +217,15 @@ public class BarcodeBean implements BarcodeBeanLocal { ...@@ -212,4 +217,15 @@ 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) {
// 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
}
} }
...@@ -13,10 +13,12 @@ import javax.ejb.Stateless; ...@@ -13,10 +13,12 @@ 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.Place;
...@@ -38,6 +40,8 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -38,6 +40,8 @@ public class ReaderBean implements ReaderBeanLocal {
private ReaderFacade readerfacade; private ReaderFacade readerfacade;
@EJB @EJB
private PrintedCardFacade cardfacade; private PrintedCardFacade cardfacade;
@EJB @EJB
private CardTemplateBeanLocal cardtemplatebean; private CardTemplateBeanLocal cardtemplatebean;
@EJB @EJB
...@@ -52,6 +56,11 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -52,6 +56,11 @@ public class ReaderBean implements ReaderBeanLocal {
private ProductPBean productPBean; private ProductPBean productPBean;
@EJB @EJB
private CardCodeFacade cardCodeFacade;
@EJB
private BarcodeBeanLocal barcodeBean; private BarcodeBeanLocal barcodeBean;
private static final Logger logger = LoggerFactory.getLogger(ReaderBean.class); private static final Logger logger = LoggerFactory.getLogger(ReaderBean.class);
...@@ -149,14 +158,14 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -149,14 +158,14 @@ public class ReaderBean implements ReaderBeanLocal {
@Override @Override
public ReaderEvent assocTagToCard(String tag, String readerIdent, PrintedCard card) { public ReaderEvent assocTagToCard(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
...@@ -203,6 +212,9 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -203,6 +212,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;
...@@ -227,6 +239,7 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -227,6 +239,7 @@ public class ReaderBean implements ReaderBeanLocal {
} }
return ret; return ret;
} }
*/
@Override @Override
public Reader getReader(Integer readerid) { public Reader getReader(Integer readerid) {
......
...@@ -7,9 +7,9 @@ import fi.codecrew.moya.model.CardCode; ...@@ -7,9 +7,9 @@ import fi.codecrew.moya.model.CardCode;
@Stateless @Stateless
@LocalBean @LocalBean
public class CardBarcodeFacade extends IntegerPkGenericFacade<CardCode> { public class CardCodeFacade extends IntegerPkGenericFacade<CardCode> {
public CardBarcodeFacade() { public CardCodeFacade() {
super(CardCode.class); super(CardCode.class);
} }
......
...@@ -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);
} }
...@@ -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 assocTagToCard(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);
......
...@@ -28,6 +28,16 @@ public class CardCode extends GenericEntity { ...@@ -28,6 +28,16 @@ public class CardCode extends GenericEntity {
@ManyToOne() @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() { public ReaderType getType() {
return type; return type;
......
...@@ -58,8 +58,12 @@ public class PrintedCard extends GenericEntity { ...@@ -58,8 +58,12 @@ public class PrintedCard extends GenericEntity {
@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")
...@@ -133,6 +137,17 @@ public class PrintedCard extends GenericEntity { ...@@ -133,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;
} }
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
<dependent-module archiveName="jrobin-1.5.9.jar" deploy-path="/lib" handle="module:/classpath/var/M2_REPO/org/jrobin/jrobin/1.5.9/jrobin-1.5.9.jar"> <dependent-module archiveName="jrobin-1.5.9.jar" deploy-path="/lib" handle="module:/classpath/var/M2_REPO/org/jrobin/jrobin/1.5.9/jrobin-1.5.9.jar">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module archiveName="moya-mgmt-web-0.2.0.war" deploy-path="/" handle="module:/resource/MoyaEventMgmtWeb/MoyaEventMgmtWeb"> <dependent-module archiveName="moya-mgmt-web-0.2.0.war" deploy-path="/" handle="module:/classpath/var/M2_REPO/fi/codecrew/moya/moya-mgmt-web/0.2.0/moya-mgmt-web-0.2.0.war">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module archiveName="commons-digester-2.1.jar" deploy-path="/lib" handle="module:/classpath/var/M2_REPO/commons-digester/commons-digester/2.1/commons-digester-2.1.jar"> <dependent-module archiveName="commons-digester-2.1.jar" deploy-path="/lib" handle="module:/classpath/var/M2_REPO/commons-digester/commons-digester/2.1/commons-digester-2.1.jar">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!