Commit 837ac95c by Tuukka Kivilahti

refactoring

1 parent edf86cf5
......@@ -15,6 +15,7 @@ import fi.codecrew.moya.facade.PrintedCardFacade;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.utilities.BarcodeUtils;
/**
......@@ -39,6 +40,10 @@ public class BarcodeBean implements BarcodeBeanLocal {
@EJB
UserBeanLocal userBean;
@EJB
ProductBeanLocal productBean;
/**
* Default constructor.
......@@ -212,4 +217,15 @@ public class BarcodeBean implements BarcodeBeanLocal {
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.facade.CardCodeFacade;
import fi.codecrew.moya.facade.PrintedCardFacade;
import fi.codecrew.moya.facade.ReaderEventFacade;
import fi.codecrew.moya.facade.ReaderFacade;
import fi.codecrew.moya.model.AccountEvent;
import fi.codecrew.moya.model.CardCode;
import fi.codecrew.moya.model.CardTemplate;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Place;
......@@ -38,6 +40,8 @@ public class ReaderBean implements ReaderBeanLocal {
private ReaderFacade readerfacade;
@EJB
private PrintedCardFacade cardfacade;
@EJB
private CardTemplateBeanLocal cardtemplatebean;
@EJB
......@@ -52,6 +56,11 @@ public class ReaderBean implements ReaderBeanLocal {
private ProductPBean productPBean;
@EJB
private CardCodeFacade cardCodeFacade;
@EJB
private BarcodeBeanLocal barcodeBean;
private static final Logger logger = LoggerFactory.getLogger(ReaderBean.class);
......@@ -149,14 +158,14 @@ public class ReaderBean implements ReaderBeanLocal {
@Override
public ReaderEvent assocTagToCard(String tag, String readerIdent, PrintedCard card) {
Reader reader = readerfacade.findOrCreateByIdent(readerIdent);
public ReaderEvent assocTagToCard(ReaderEvent readerEvent, PrintedCard card) {
CardCode code = new CardCode(card, readerEvent.getReader().getType(), readerEvent.getValue());
code = cardCodeFacade.create(code);
card = cardfacade.reload(card);
card.setRfidUid(tag);
// card = cardtemplatebean.setRfidUid(tag, card);
return createReaderEvent(reader, card);
return readerEvent;
}
@Override
......@@ -203,6 +212,9 @@ public class ReaderBean implements ReaderBeanLocal {
return ret;
}
// ok, let's comment this out, so I can see where this is used
/*
@Override
public ReaderEvent createCard(ReaderEvent event, EventUser user) {
ReaderEvent ret = null;
......@@ -227,6 +239,7 @@ public class ReaderBean implements ReaderBeanLocal {
}
return ret;
}
*/
@Override
public Reader getReader(Integer readerid) {
......
......@@ -7,9 +7,9 @@ import fi.codecrew.moya.model.CardCode;
@Stateless
@LocalBean
public class CardBarcodeFacade extends IntegerPkGenericFacade<CardCode> {
public class CardCodeFacade extends IntegerPkGenericFacade<CardCode> {
public CardBarcodeFacade() {
public CardCodeFacade() {
super(CardCode.class);
}
......
......@@ -8,6 +8,7 @@ import javax.ejb.Local;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.Product;
@Local
public interface BarcodeBeanLocal {
......@@ -20,5 +21,8 @@ public interface BarcodeBeanLocal {
public String getPlaceHexcode(Place place);
public Place getPlaceFromHexcode(String hexcode);
public String checkVrAuthCode(String code);
public Product getProduct(String barcode);
public Place getPlaceFromBarcode(String barcode);
}
......@@ -17,7 +17,7 @@ public interface ReaderBeanLocal {
// ReaderEvent assocTagToPlacecode(String tag, String readerIdent, String
// placecode) throws BortalCatchableException, PermissionDeniedException;
ReaderEvent assocTagToCard(String tag, String readerIdent, PrintedCard card);
ReaderEvent assocTagToCard(ReaderEvent readerEvent, PrintedCard card);
List<Reader> getReaders();
......@@ -27,7 +27,8 @@ public interface ReaderBeanLocal {
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);
......
......@@ -28,6 +28,16 @@ public class CardCode extends GenericEntity {
@ManyToOne()
@JoinColumn(name = "printed_cards_id")
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;
......
......@@ -58,8 +58,12 @@ public class PrintedCard extends GenericEntity {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "printedCard")
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;
@JoinColumn(name = "current_location_id", referencedColumnName = "id")
......@@ -133,6 +137,17 @@ public class PrintedCard extends GenericEntity {
this.currentLocation = currentLocation;
}
public List<CardCode> getCardCodes() {
return cardCodes;
}
public void setCardCodes(List<CardCode> cardCodes) {
this.cardCodes = cardCodes;
}
public EventUser getUser() {
return user;
}
......
......@@ -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">
<dependency-type>uses</dependency-type>
</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>
</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">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!