Commit 37c7b3d1 by Tuukka Kivilahti

double print card fix

1 parent 5b025711
......@@ -358,15 +358,26 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
@Override
public PrintedCard setCardState(Integer cardId, CardState state) throws Exception {
PrintedCard card = printedcardfacade.find(cardId);
switch (state) {
case VALIDATED:
Calendar mustBePrintedBefore = Calendar.getInstance();
mustBePrintedBefore.add(Calendar.MINUTE, -1);
if(card.getCardState().equals(CardState.PRINTED) && card.getPrintTime().before(mustBePrintedBefore)) {
String response = "Already printed in one minute.";
throw new Exception(response);
}
break;
case PRINTED:
card.setPrintCount(card.getPrintCount() + 1);
card.setPrintTime(Calendar.getInstance());
break;
case PRINTING_IN_PROGRESS:
if (card.getCardState().equals(CardState.PRINTING_IN_PROGRESS)
|| card.getCardState().equals(CardState.PRINTED)) {
|| card.getCardState().equals(CardState.PRINTED)
|| card.getCardState().equals(CardState.DELIVERED)) {
String response = "Unable to change type to PRINTING_IN_PROGRESS value is already {}" + card.getCardState();
logger.warn(response);
throw new Exception(response);
......
......@@ -26,6 +26,8 @@ import javax.enterprise.context.SessionScoped;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import fi.codecrew.moya.model.EventOrganiser;
import fi.codecrew.moya.model.LanEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -53,7 +55,9 @@ public class SessionStore implements Serializable {
Locale ret = locale;
if (ret == null || ret.toString().equals(""))
{
String retStr = eventbean.getCurrentEvent().getOrganiser().getBundleCountry();
LanEvent e = eventbean.getCurrentEvent();
EventOrganiser o = e.getOrganiser();
String retStr = o.getBundleCountry();
if (retStr != null && !retStr.isEmpty()) {
try {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!