Commit 439d8512 by Tuukka Kivilahti

Merge branch 'devel' of codecrew.fi:bortal into devel

2 parents 033f3e9f b3829744
...@@ -271,4 +271,27 @@ public class CardTemplateBean implements CardTemplateBeanLocal { ...@@ -271,4 +271,27 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
return printedcardfacade.findByState(state); return printedcardfacade.findByState(state);
} }
@Override
public PrintedCard setCardState(int cardId, CardState state) throws Exception {
PrintedCard card = printedcardfacade.find(cardId);
switch (state)
{
case PRINTED:
card.setPrintCount(card.getPrintCount() + 1);
break;
case PRINTING_IN_PROGRESS:
if (card.getCardState().equals(CardState.PRINTING_IN_PROGRESS)
|| card.getCardState().equals(CardState.PRINTED)) {
String response = "Unable to change type to PRINTING_IN_PROGRESS value is already {}" + card.getCardState();
logger.warn(response);
throw new Exception(response);
}
break;
default:
break;
}
card.setCardState(state);
return card;
}
} }
...@@ -44,4 +44,6 @@ public interface CardTemplateBeanLocal extends EntityFinderBean<CardTemplate> { ...@@ -44,4 +44,6 @@ public interface CardTemplateBeanLocal extends EntityFinderBean<CardTemplate> {
List<PrintedCard> getCardsByState(CardState... pendingPrint); List<PrintedCard> getCardsByState(CardState... pendingPrint);
PrintedCard setCardState(int cardId, CardState printed) throws Exception;
} }
...@@ -8,7 +8,6 @@ public enum CardState { ...@@ -8,7 +8,6 @@ public enum CardState {
PENDING_VALIDATION, PENDING_VALIDATION,
REJECTED, REJECTED,
VALIDATED, VALIDATED,
PENDING_PRINT,
PRINTING_IN_PROGRESS, PRINTING_IN_PROGRESS,
PRINTED; PRINTED;
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="MoyaWeb"> <wb-module deploy-name="MoyaWeb">
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<!-- <f:event type="preRenderView" listener="#{userOverviewView.initView()}" /> -->
</f:metadata>
<ui:define name="content">
<h1>Create tournament</h1>
<h:form>
<p:wizard widgetVar="wiz" flowListener="#{tournamentCreateView.onFlowProcess}">
<p:tab id="selectGame" title="Select a game">
<p:panel header="Select a game">
<h:messages errorClass="error" />
Select a game
<p:selectOneMenu>
<f:selectItem itemLabel="" />
<f:selectItem itemLabel="spurdo spärde" />
<f:selectItem itemLabel="cockmaster" />
</p:selectOneMenu>
<h2>Create new game</h2>
<h:panelGrid columns="2">
<h:outputText value="Name" />
<h:outputText value="Description" />
<p:inputText />
<p:inputText />
<h:outputText value="Upload image" />
<h:outputText value="" />
<p:fileUpload mode="simple" />
</h:panelGrid>
</p:panel>
</p:tab>
<p:tab id="selectRuleset" title="Select a ruleset">
<p:panel header="Select a ruleset">
<h:messages errorClass="error" />
Select a ruleset
<p:selectOneMenu>
<f:selectItem itemLabel="" />
<f:selectItem itemLabel="Pro-rules" />
<f:selectItem itemLabel="N00b-rules" />
</p:selectOneMenu>
<br />
<h2>Create new ruleset</h2>
<h:outputText value="Rule Name" />
<br />
<p:inputText />
<br />
<h:outputText value="Description" />
<br />
<p:inputTextarea />
</p:panel>
</p:tab>
<p:tab id="selectRegTimes" title="Set registration times">
<p:panel header="Select registration times">
<h:messages errorClass="error" />
<h2>Registration</h2>
<h:panelGrid columns="2">
<h:outputText value="Opens" />
<h:outputText value="Closees" />
<p:calendar stepHour="1" stepMinute="10" pattern="dd.MM.yyyy hh:mm" />
<p:calendar stepHour="1" stepMinute="10" pattern="dd.MM.yyyy hh:mm" />
</h:panelGrid>
<h2>Event Start time</h2>
<h:panelGrid>
<h:outputText value="Start time" />
<p:calendar stepHour="1" stepMinute="10" pattern="dd.MM.yyyy hh:mm" />
</h:panelGrid>
</p:panel>
<div style="float: right;">
<p:commandButton icon="apply" value="Create event" />
</div>
</p:tab>
</p:wizard>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<!-- <f:event type="preRenderView" listener="#{userOverviewView.initView()}" /> -->
</f:metadata>
<ui:define name="content">
<h1>Tournaments</h1>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
...@@ -39,12 +39,35 @@ public class PrinterRestView { ...@@ -39,12 +39,35 @@ public class PrinterRestView {
private static final Logger logger = LoggerFactory.getLogger(PrinterRestView.class); private static final Logger logger = LoggerFactory.getLogger(PrinterRestView.class);
@GET @GET
@Path("/Reserve/{id}/")
public Response reserveCardForPrinting(@PathParam("id") int cardId, @QueryParam("key") String hash) throws Exception {
ResponseBuilder ret = null;
try {
PrintedCard card = cardbean.setCardState(cardId, CardState.PRINTING_IN_PROGRESS);
if (card.getCardState().equals(CardState.PRINTING_IN_PROGRESS)) {
ret = Response.ok(new PrintedCardRestPojo(card));
}
} catch (Exception e) {
ret = null;
logger.warn("Caught exception while reserving card for printing" + cardId, e);
}
if (ret == null) {
ret = Response.status(Response.Status.CONFLICT);
}
return ret.build();
}
@GET
@Path("/Printed/{id}/") @Path("/Printed/{id}/")
public PrintedCardRestPojo setCardPrinted(@PathParam("id") int cardId, @QueryParam("key") String hash) throws Exception { public PrintedCardRestPojo setCardPrinted(@PathParam("id") int cardId, @QueryParam("key") String hash) throws Exception {
PrintedCard card = cardbean.findCard(cardId); return new PrintedCardRestPojo(cardbean.setCardState(cardId, CardState.PRINTED));
card.setCardState(CardState.PRINTED); // PrintedCard card = cardbean.findCard(cardId);
card = cardbean.saveCard(card); // card.setCardState(CardState.PRINTED);
return new PrintedCardRestPojo(card); // card.setPrintCount(card.getPrintCount() + 1);
// card = cardbean.saveCard(card);
// return new PrintedCardRestPojo(card);
} }
@GET @GET
...@@ -76,7 +99,7 @@ public class PrinterRestView { ...@@ -76,7 +99,7 @@ public class PrinterRestView {
@GET @GET
@Path("/ListUnprinted") @Path("/ListUnprinted")
public List<PrintedCardRestPojo> getUserCard(@QueryParam("key") String key) throws Exception { public List<PrintedCardRestPojo> getUserCard(@QueryParam("key") String key) throws Exception {
List<PrintedCardRestPojo> ret = PrintedCardRestPojo.parseCards(cardbean.getCardsByState(CardState.PENDING_PRINT)); List<PrintedCardRestPojo> ret = PrintedCardRestPojo.parseCards(cardbean.getCardsByState(CardState.VALIDATED));
logger.info("Returning card pojos: {} for key {}", ret, key); logger.info("Returning card pojos: {} for key {}", ret, key);
return ret; return ret;
} }
......
package fi.codecrew.moya.web.cdiview.tournaments;
import java.io.Serializable;
import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.faces.event.ActionEvent;
import javax.inject.Named;
import org.primefaces.event.FlowEvent;
@Named
@ConversationScoped
public class TournamentCreateView implements Serializable {
/**
*
*/
private static final long serialVersionUID = 2547358764980373797L;
// called on finish
public void save(ActionEvent actionEvent) {
}
public String onFlowProcess(FlowEvent event) {
return event.getNewStep();
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!