Commit 8e9138de by Tuomas Riihimäki

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

Conflicts:
	code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/UserView.java
2 parents 998d70a9 d9cdc68a
Showing with 668 additions and 61 deletions
...@@ -205,6 +205,19 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -205,6 +205,19 @@ public class ReaderBean implements ReaderBeanLocal {
Reader reader = readerfacade.find(readerId); Reader reader = readerfacade.find(readerId);
return readerEventFacade.findLastEvents(reader, 20); return readerEventFacade.findLastEvents(reader, 20);
} }
@Override
public ReaderEvent getLastReaderEvent(Integer readerId) {
Reader reader = readerfacade.find(readerId);
List<ReaderEvent> list = readerEventFacade.findLastEvents(reader, 1);
if(list.size() > 0)
return list.get(0);
return null;
}
@Override @Override
public ReaderEvent getEvent(Integer eventid) { public ReaderEvent getEvent(Integer eventid) {
...@@ -271,4 +284,5 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -271,4 +284,5 @@ public class ReaderBean implements ReaderBeanLocal {
readerfacade.create(reader); readerfacade.create(reader);
} }
} }
package fi.codecrew.moya.facade;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.codecrew.moya.model.Tournament;
@Stateless
@LocalBean
public class TournamentFacade extends IntegerPkGenericFacade<Tournament> {
public TournamentFacade() {
super(Tournament.class);
}
}
package fi.codecrew.moya.facade;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.codecrew.moya.model.TournamentGame;
@Stateless
@LocalBean
public class TournamentGameFacade extends IntegerPkGenericFacade<TournamentGame> {
public TournamentGameFacade() {
super(TournamentGame.class);
}
}
package fi.codecrew.moya.facade;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.codecrew.moya.model.TournamentMatch;
@Stateless
@LocalBean
public class TournamentMatchFacade extends IntegerPkGenericFacade<TournamentMatch> {
public TournamentMatchFacade() {
super(TournamentMatch.class);
}
}
\ No newline at end of file
package fi.codecrew.moya.facade;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.codecrew.moya.model.TournamentMatchResult;
@Stateless
@LocalBean
public class TournamentMatchResultFacade extends IntegerPkGenericFacade<TournamentMatchResult> {
public TournamentMatchResultFacade() {
super(TournamentMatchResult.class);
}
}
\ No newline at end of file
package fi.codecrew.moya.facade;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.codecrew.moya.model.TournamentParticipant;
@Stateless
@LocalBean
public class TournamentParticipantFacade extends IntegerPkGenericFacade<TournamentParticipant> {
public TournamentParticipantFacade() {
super(TournamentParticipant.class);
}
}
package fi.codecrew.moya.facade;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.codecrew.moya.model.TournamentRule;
@Stateless
@LocalBean
public class TournamentRuleFacade extends IntegerPkGenericFacade<TournamentRule> {
public TournamentRuleFacade() {
super(TournamentRule.class);
}
}
...@@ -37,4 +37,6 @@ public interface ReaderBeanLocal { ...@@ -37,4 +37,6 @@ public interface ReaderBeanLocal {
void createReader(Reader reader); void createReader(Reader reader);
ReaderEvent getLastReaderEvent(Integer readerId);
} }
package fi.codecrew.moya.model;
import fi.codecrew.moya.enums.TournamentStatus;
import fi.codecrew.moya.enums.TournamentType;
import fi.codecrew.moya.model.GenericEntity;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
/**
* Entity implementation class for Entity: Tournament
*
*/
@Entity
@Table(name="tournaments")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class Tournament extends GenericEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="talyn_tournament_id", nullable=true)
private Integer talynTournamentId;
@JoinColumn(name = "event_id", nullable = false)
private LanEvent lanEvent;
@Column(name="tournament_name")
private String tournamentName;
@Column(name="registration_opens_at")
@Temporal(TemporalType.TIMESTAMP)
private Date registrationOpensAt;
@Column(name="registration_closes_at")
@Temporal(TemporalType.TIMESTAMP)
private Date registrationClosesAt;
@Column(name="begins_at")
@Temporal(TemporalType.TIMESTAMP)
private Date beginsAt;
@Column(name="tournament_type")
@Enumerated(EnumType.STRING)
private TournamentType tournamentType;
@Column(name="tournament_status")
@Enumerated(EnumType.STRING)
private TournamentStatus tournamentStatus;
@JoinColumn(name="tournament_root")
private TournamentMatch tournamentRoot;
@Column(name="players_per_match")
private Integer playersPerMatch;
@Column(name="players_per_team")
private Integer playersPerTeam;
@OneToMany
@OrderBy("id ASC")
private List<Tournament> subTournaments;
public Tournament() { super(); }
public Integer getTalynTournamentId() {
return talynTournamentId;
}
public void setTalynTournamentId(Integer talynTournamendId) {
this.talynTournamentId = talynTournamendId;
}
public String getTournamentName() {
return tournamentName;
}
public void setTournamentName(String tournamentName) {
this.tournamentName = tournamentName;
}
public Date getRegistrationOpensAt() {
return registrationOpensAt;
}
public void setRegistrationOpensAt(Date registrationOpensAt) {
this.registrationOpensAt = registrationOpensAt;
}
public Date getRegistrationClosesAt() {
return registrationClosesAt;
}
public void setRegistrationClosesAt(Date registrationClosesAt) {
this.registrationClosesAt = registrationClosesAt;
}
public TournamentType getTournamentType() {
return tournamentType;
}
public void setTournamentType(TournamentType tournamentType) {
this.tournamentType = tournamentType;
}
}
package fi.codecrew.moya.model;
import static javax.persistence.FetchType.LAZY;
import fi.codecrew.moya.enums.TournamentType;
import fi.codecrew.moya.model.GenericEntity;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
/**
* Entity implementation class for Entity: Tournament
*
*/
@Entity
@Table(name="tournament_games")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class TournamentGame extends GenericEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="name")
private String name;
@Column(name="description")
private String description;
@Lob
@Column(name = "game_image")
@Basic(fetch = LAZY)
private byte[] gameImage;
@Column(name = "expected_single_game_duration")
private Integer expectedSingleGameDuration;
@JoinColumn(name = "event_id", nullable = false)
private LanEvent lanEvent;
@OneToMany
private List<TournamentRule> availableRules;
public TournamentGame() { super(); }
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<TournamentRule> getAvailableRules() {
return availableRules;
}
public void setAvailableRules(List<TournamentRule> availableRules) {
this.availableRules = availableRules;
}
}
package fi.codecrew.moya.model;
import fi.codecrew.moya.enums.MatchStatus;
import fi.codecrew.moya.model.GenericEntity;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
/**
* Entity implementation class for Entity: Match
*
*/
@Entity
@Table(name="matches")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class TournamentMatch extends GenericEntity implements Serializable {
private static final long serialVersionUID = 1L;
@OneToMany
private List<TournamentMatch> sourceMatches;
@ManyToMany
private List<TournamentParticipant> matchParticipants;
@Column(name="play_count_max")
private Integer playCountMax = 1;
@Column(name="play_count")
private Integer playCount;
@Column(name="match_status")
@Enumerated(EnumType.STRING)
private MatchStatus matchStatus;
@Temporal(TemporalType.TIMESTAMP)
private Date startTime;
@Temporal(TemporalType.TIMESTAMP)
private Date endTime;
@OneToMany
@OrderBy("rank")
private List<TournamentMatchResult> matchResults;
public TournamentMatch() {
super();
}
public List<TournamentMatch> getSourceMatches() {
return sourceMatches;
}
public void setSourceMatches(List<TournamentMatch> sourceMatches) {
this.sourceMatches = sourceMatches;
}
public List<TournamentParticipant> getMatchParticipants() {
return matchParticipants;
}
public void setMatchParticipants(List<TournamentParticipant> matchParticipants) {
this.matchParticipants = matchParticipants;
}
public List<TournamentMatchResult> getMatchResults() {
return matchResults;
}
public void setMatchResults(List<TournamentMatchResult> matchResults) {
this.matchResults = matchResults;
}
}
package fi.codecrew.moya.model;
import java.io.Serializable;
import javax.persistence.*;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
/**
* Entity implementation class for Entity: MatchResult
*
*/
@Entity
@Table(name="match_results")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class TournamentMatchResult extends GenericEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="score")
private Integer score;
@Column(name="rank")
private Integer rank;
@JoinColumn(name="tournament_participant")
private TournamentParticipant tournamentParticipant;
public TournamentMatchResult() {
super();
}
public Integer getScore() {
return score;
}
public void setScore(Integer score) {
this.score = score;
}
public Integer getRank() {
return rank;
}
public void setRank(Integer rank) {
this.rank = rank;
}
public TournamentParticipant getTournamentParticipant() {
return tournamentParticipant;
}
public void setTournamentParticipant(TournamentParticipant tournamentParticipant) {
this.tournamentParticipant = tournamentParticipant;
}
}
package fi.codecrew.moya.model;
import fi.codecrew.moya.model.GenericEntity;
import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
/**
* Entity implementation class for Entity: TournamentParticipant
*
*/
@Entity
@Table(name="tournament_participants")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class TournamentParticipant extends GenericEntity implements Serializable {
private static final long serialVersionUID = 1L;
@JoinColumn(name="participator")
private EventUser participator;
@OneToMany
private List<EventUser> teamMembers;
public TournamentParticipant() {
super();
}
}
package fi.codecrew.moya.model;
import static javax.persistence.FetchType.LAZY;
import fi.codecrew.moya.enums.TournamentType;
import fi.codecrew.moya.model.GenericEntity;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
/**
* Entity implementation class for Entity: Tournament
*
*/
@Entity
@Table(name="tournament_rules")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class TournamentRule extends GenericEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="name")
private String name;
@Lob
@Column(name="description")
private String description;
@Lob
@Column(name="rules")
private String rules;
@ManyToOne
@JoinColumn(name = "tournament_game_id")
private TournamentGame tournamentGame;
public TournamentRule() { super(); }
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getRules() {
return rules;
}
public void setRules(String rules) {
this.rules = rules;
}
}
package fi.codecrew.moya.enums;
public enum MatchStatus {
UNFINISHED,
FINISHED
}
package fi.codecrew.moya.enums;
public enum TournamentStatus {
SETUP,
IN_PROGRESS,
COMPLETED
}
package fi.codecrew.moya.enums;
public enum TournamentType {
SINGLE_ELIMINATION,
DOUBLE_ELIMINATION
}
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<context-param> <context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name> <param-name>javax.faces.PROJECT_STAGE</param-name>
<!-- Production | Development --> <!-- Production | Development -->
<param-value>Development</param-value> <param-value>Production</param-value>
</context-param> </context-param>
<context-param> <context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name> <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
......
...@@ -8,13 +8,15 @@ ...@@ -8,13 +8,15 @@
<f:metadata> <f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" /> <f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{userView.initView}" /> <f:event type="preRenderView" listener="#{incomingView.initPrintCardView}" />
<f:event type="preRenderView" listener="#{userView.prepareCardDownload}" />
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" /> <h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
<h:panelGrid columns="3"> <h:panelGrid columns="3">
<h:form>
<p:poll interval="1" listener="#{incomingView.polledRead}" />
</h:form>
<h:panelGroup> <h:panelGroup>
<user:edit commitaction="#{incomingView.saveUser()}" commitvalue="#{i18n['user.save']}" /> <user:edit commitaction="#{incomingView.saveUser()}" commitvalue="#{i18n['user.save']}" />
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
<h:outputLabel for="billnr" value="#{i18n['bill.billNumber']}:" /> <h:outputLabel for="billnr" value="#{i18n['bill.billNumber']}:" />
<h:outputText id="billnr" value="#{cc.attrs.bill.billNumber}" /> <h:outputText id="billnr" value="#{cc.attrs.bill.billNumber}" />
<h:outputLabel rendered="{!cc.attrs.bill.expired}" for="refnr" value="#{i18n['bill.referencenumber']}" /> <h:outputLabel rendered="{!cc.attrs.bill.expired and sessionHandler.isEventBoolProperty('ALLOW_BILLING') }" for="refnr" value="#{i18n['bill.referencenumber']}" />
<h:outputText rendered="{!cc.attrs.bill.expired}" id="refnr" value="#{cc.attrs.bill.referenceNumber}" /> <h:outputText rendered="{!cc.attrs.bill.expired and sessionHandler.isEventBoolProperty('ALLOW_BILLING') }" id="refnr" value="#{cc.attrs.bill.referenceNumber}" />
<h:outputLabel for="billAmount" value="#{i18n['bill.billAmount']}" /> <h:outputLabel for="billAmount" value="#{i18n['bill.billAmount']}" />
<h:outputText id="billAmount" value="#{cc.attrs.bill.totalPrice()}"> <h:outputText id="billAmount" value="#{cc.attrs.bill.totalPrice()}">
...@@ -28,11 +28,11 @@ ...@@ -28,11 +28,11 @@
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText> </h:outputText>
<h:outputLabel for="paymenttime" value="#{i18n['bill.paymentTime']}:" /> <h:outputLabel for="paymenttime" rendered=" #{sessionHandler.isEventBoolProperty('ALLOW_BILLING')}" value="#{i18n['bill.paymentTime']}:" />
<h:outputText id="paymenttime" value="#{cc.attrs.bill.paymentTime eq 0 ? i18n['bill.paymentTime.now'] : cc.attrs.bill.paymentTime}" /> <h:outputText id="paymenttime" rendered=" #{sessionHandler.isEventBoolProperty('ALLOW_BILLING')}" value="#{cc.attrs.bill.paymentTime eq 0 ? i18n['bill.paymentTime.now'] : cc.attrs.bill.paymentTime}" />
<h:outputLabel rendered="{!cc.attrs.bill.expired}" for="noticetime" value="#{i18n['bill.noticetime']}:" /> <h:outputLabel rendered="{!cc.attrs.bill.expired and sessionHandler.isEventBoolProperty('ALLOW_BILLING') }" for="noticetime" value="#{i18n['bill.noticetime']}:" />
<h:outputText rendered="{!cc.attrs.bill.expired}" id="noticetime" value="#{cc.attrs.bill.noticetime}" /> <h:outputText rendered="{!cc.attrs.bill.expired and sessionHandler.isEventBoolProperty('ALLOW_BILLING')}" id="noticetime" value="#{cc.attrs.bill.noticetime}" />
<h:outputLabel rendered="#{cc.attrs.bill != null}" for="expires" value="#{i18n['bill.expires']}:" /> <h:outputLabel rendered="#{cc.attrs.bill != null}" for="expires" value="#{i18n['bill.expires']}:" />
<h:outputText rendered="#{cc.attrs.bill != null}" id="expires" value="#{cc.attrs.bill.expires.time}"> <h:outputText rendered="#{cc.attrs.bill != null}" id="expires" value="#{cc.attrs.bill.expires.time}">
......
...@@ -87,6 +87,8 @@ error.error = You have encountered an error. ...@@ -87,6 +87,8 @@ error.error = You have encountered an error.
eventorg.create = Create eventorg.create = Create
game.active = Aktiivinen game.active = Aktiivinen
usercart.showoverview=Vie tarkastusn\u00E4kym\u00E4\u00E4n
usercart.downloadCsv=CSV
game.codecount = Avattuja game.codecount = Avattuja
game.codes.available = Lisenssikoodit game.codes.available = Lisenssikoodit
game.codes.opened = Avatut lisenssikoodit game.codes.opened = Avatut lisenssikoodit
...@@ -165,7 +167,7 @@ resetMail.username = Username ...@@ -165,7 +167,7 @@ resetMail.username = Username
resetmailSent.body = Email has been sent containing a link where you can change the password. resetmailSent.body = Email has been sent containing a link where you can change the password.
resetmailSent.header = Email sent resetmailSent.header = Email sent
subnavi.cards = \u0009\u0009 subnavi.cards = \t\t
topnavi.license = Lisenssikoodit topnavi.license = Lisenssikoodit
......
...@@ -43,6 +43,9 @@ public class ReaderView extends GenericCDIView { ...@@ -43,6 +43,9 @@ public class ReaderView extends GenericCDIView {
private String usersearch; private String usersearch;
private String barcode; private String barcode;
private Reader reader; private Reader reader;
private boolean pollingMode = false;
private ReaderEvent lastReadEvent = null;
private transient ListDataModel<UserCardWrapper> userlist; private transient ListDataModel<UserCardWrapper> userlist;
private ListDataModel<ReaderEvent> readerEventList; private ListDataModel<ReaderEvent> readerEventList;
...@@ -272,6 +275,14 @@ public class ReaderView extends GenericCDIView { ...@@ -272,6 +275,14 @@ public class ReaderView extends GenericCDIView {
} }
public String getBarcode() { public String getBarcode() {
if(pollingMode) {
ReaderEvent event = readerbean.getLastReaderEvent(namecontainer.getReaderId());
if(!event.equals(lastReadEvent)) {
return event.getValue();
}
}
if(readerEventList != null && readerEventList.isRowAvailable()) { if(readerEventList != null && readerEventList.isRowAvailable()) {
if(readerEventList.getRowData().getReader().getType() == ReaderType.BARCODE) { if(readerEventList.getRowData().getReader().getType() == ReaderType.BARCODE) {
return readerEventList.getRowData().getValue(); return readerEventList.getRowData().getValue();
...@@ -314,6 +325,19 @@ public class ReaderView extends GenericCDIView { ...@@ -314,6 +325,19 @@ public class ReaderView extends GenericCDIView {
} }
public void initializeForPolling() {
// on polling mode, we do not use list, we use database and remember last readerEvent
this.pollingMode = true;
this.barcode = null;
lastReadEvent = readerbean.getLastReaderEvent(namecontainer.getReaderId());
}
public void pollingBarcodeHandled() {
lastReadEvent = readerbean.getLastReaderEvent(namecontainer.getReaderId());
}
public EventUser getUser() { public EventUser getUser() {
...@@ -336,4 +360,12 @@ public class ReaderView extends GenericCDIView { ...@@ -336,4 +360,12 @@ public class ReaderView extends GenericCDIView {
return null; return null;
} }
public boolean isNewBarcodes() {
if(!pollingMode)
return false;
return (!readerbean.getLastReaderEvent(namecontainer.getReaderId()).equals(lastReadEvent));
}
} }
...@@ -54,20 +54,20 @@ public class UserView extends GenericCDIView { ...@@ -54,20 +54,20 @@ public class UserView extends GenericCDIView {
@EJB @EJB
private transient UserBeanLocal userbean; private transient UserBeanLocal userbean;
@EJB @EJB
private transient ReaderBeanLocal readerbean; private transient ReaderBeanLocal readerbean;
private Integer userid; private Integer userid;
private transient UploadedFile image; private transient UploadedFile image;
private CroppedImage croppedImage; private CroppedImage croppedImage;
private EventUser user; private EventUser user;
@Inject @Inject
private transient Conversation conversation; private transient Conversation conversation;
@Inject @Inject
private transient ReaderView readerView; private transient ReaderView readerView;
...@@ -86,7 +86,7 @@ public class UserView extends GenericCDIView { ...@@ -86,7 +86,7 @@ public class UserView extends GenericCDIView {
@EJB @EJB
private transient CardTemplateBeanLocal cardBean; private transient CardTemplateBeanLocal cardBean;
private List<Role> usersRoles; private List<Role> usersRoles;
@EJB @EJB
private transient RoleBeanLocal rolebean; private transient RoleBeanLocal rolebean;
...@@ -100,7 +100,7 @@ public class UserView extends GenericCDIView { ...@@ -100,7 +100,7 @@ public class UserView extends GenericCDIView {
private MassPrintResult mpr = null; private MassPrintResult mpr = null;
private boolean waitForAcceptance = false; private boolean waitForAcceptance = false;
private String captureForwardUrl = ""; private String captureForwardUrl = "";
@Produces @Produces
@LoggedIn @LoggedIn
public EventUser getCurrentUser() { public EventUser getCurrentUser() {
...@@ -112,7 +112,7 @@ public class UserView extends GenericCDIView { ...@@ -112,7 +112,7 @@ public class UserView extends GenericCDIView {
byte[] data = captureEvent.getData(); byte[] data = captureEvent.getData();
UserImage img = userbean.uploadImage(user, "image/png", data, "userimage.png", "Uploaded image"); UserImage img = userbean.uploadImage(user, "image/png", data, "userimage.png", "Uploaded image");
user = userbean.getEventUser(img.getUser()); user = userbean.getEventUser(img.getUser());
// super.navihandler.forward("/admin/adduser/capturesuccess"); // super.navihandler.forward("/admin/adduser/capturesuccess");
if (getCaptureForwardUrl().equals("")) if (getCaptureForwardUrl().equals(""))
super.navihandler.forward(getCaptureForwardUrl()); super.navihandler.forward(getCaptureForwardUrl());
} }
...@@ -179,7 +179,7 @@ public class UserView extends GenericCDIView { ...@@ -179,7 +179,7 @@ public class UserView extends GenericCDIView {
try { try {
mpr = cardPrintBean.getUserCardAsPrintablePdf(getSelectedUser().getId()); mpr = cardPrintBean.getUserCardAsPrintablePdf(getSelectedUser().getId());
ByteArrayInputStream pdfstream = new ByteArrayInputStream(mpr.getPdf()); ByteArrayInputStream pdfstream = new ByteArrayInputStream(mpr.getPdf());
setStreamedFile(new DefaultStreamedContent(pdfstream, "application/pdf", "user_" + getSelectedUser().getId() + "_card.pdf")); setStreamedFile(new DefaultStreamedContent(pdfstream, "application/pdf","user_" + getSelectedUser().getId() + "_card.pdf"));
logger.info("user_" + getSelectedUser().getId() + "_card.pdf"); logger.info("user_" + getSelectedUser().getId() + "_card.pdf");
} catch (Exception e) { } catch (Exception e) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(e.getMessage())); FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(e.getMessage()));
...@@ -208,13 +208,13 @@ public class UserView extends GenericCDIView { ...@@ -208,13 +208,13 @@ public class UserView extends GenericCDIView {
} }
public String sendImage() { public String sendImage() {
if (getImage() == null) if (getImage() == null)
{ {
super.addFaceMessage("user.imageUpload.imageNotFound"); super.addFaceMessage("user.imageUpload.imageNotFound");
} else { } else {
UserImage userimage = userbean.uploadImage(user, getImage().getContentType(), getImage().getContents(), getImage().getFileName(), ""); UserImage userimage = userbean.uploadImage(user, getImage().getContentType(), getImage().getContents(), getImage().getFileName(), "");
user = userbean.getEventUser(userimage.getUser()); user = userbean.getEventUser(userimage.getUser());
super.addFaceMessage("user.imageUploaded"); super.addFaceMessage("user.imageUploaded");
...@@ -228,7 +228,7 @@ public class UserView extends GenericCDIView { ...@@ -228,7 +228,7 @@ public class UserView extends GenericCDIView {
super.beginConversation(); super.beginConversation();
} }
} }
public void initView() { public void initView() {
/* /*
...@@ -298,33 +298,33 @@ public class UserView extends GenericCDIView { ...@@ -298,33 +298,33 @@ public class UserView extends GenericCDIView {
{ {
return permbean.isCurrentUser(user); return permbean.isCurrentUser(user);
} }
/** /**
* attach barcode or rfid to card * attach barcode or rfid to card
* *
* @return * @return
*/ */
public String attachBarcodeToCard() { public String attachBarcodeToCard() {
PrintedCard card = readerView.getPrintedCard(); PrintedCard card = readerView.getPrintedCard();
// already attached // already attached
if (card != null) { if(card != null) {
super.addFaceMessage("usercard.alreadyassociated"); super.addFaceMessage("usercard.alreadyassociated");
return null; return null;
} }
// still there, we can get real card and update it's barcodes // still there, we can get real card and update it's barcodes
card = cardBean.checkPrintedCard(user); card = cardBean.checkPrintedCard(user);
if (readerView.getBarcode() != null && !readerView.getBarcode().isEmpty()) { if(readerView.getBarcode() != null && !readerView.getBarcode().isEmpty()) {
card.setBarcode(readerView.getBarcode()); card.setBarcode(readerView.getBarcode());
logger.debug("barcode {} to card {} ",readerView.getBarcode(),card.getUser().getNick());
cardBean.saveCard(card); cardBean.saveCard(card);
} } else if(readerView.getReaderEvent() != null) {
// todo: kato että liittäminen tukee kanssa "barcode" -lukijoita jne.
// kato kanssa korttihaku, että se tuklee niitä, kuitenkin tarvitaa ne
if (readerView.getReaderEvent() != null) {
readerbean.assocTagToCard(readerView.getReaderEvent().getValue(), readerView.getReaderEvent().getReader().getIdentification(), card); readerbean.assocTagToCard(readerView.getReaderEvent().getValue(), readerView.getReaderEvent().getReader().getIdentification(), card);
} }
return null; return null;
} }
...@@ -332,7 +332,7 @@ public class UserView extends GenericCDIView { ...@@ -332,7 +332,7 @@ public class UserView extends GenericCDIView {
userbean.createNewUser(user, getPassword()); userbean.createNewUser(user, getPassword());
return "/user/created"; return "/user/created";
} }
public String createUserAdduserView() { public String createUserAdduserView() {
userbean.createNewUser(user, getPassword()); userbean.createNewUser(user, getPassword());
authView.executeAdduserAutoLogin(user, getPassword()); authView.executeAdduserAutoLogin(user, getPassword());
...@@ -423,7 +423,7 @@ public class UserView extends GenericCDIView { ...@@ -423,7 +423,7 @@ public class UserView extends GenericCDIView {
} }
public StreamedContent getStreamedFile() { public StreamedContent getStreamedFile() {
if (streamedFile == null) if(streamedFile == null)
logger.info("Tried to get empty streamed file"); logger.info("Tried to get empty streamed file");
return streamedFile; return streamedFile;
} }
......
...@@ -20,40 +20,84 @@ public class IncomingView extends GenericCDIView { ...@@ -20,40 +20,84 @@ public class IncomingView extends GenericCDIView {
private static final long serialVersionUID = 802344850073689859L; private static final long serialVersionUID = 802344850073689859L;
private static final Logger logger = LoggerFactory.getLogger(IncomingView.class); private static final Logger logger = LoggerFactory.getLogger(IncomingView.class);
@Inject @Inject
@SelectedUser @SelectedUser
private transient EventUser user; private transient EventUser user;
@Inject @Inject
private UserView userview; private UserView userview;
@Inject @Inject
private ReaderView readerView; private ReaderView readerView;
public void initView() { public void initView() {
super.beginConversation();
}
private boolean initialized = false;
public void initPrintCardView() {
if (!initialized) {
logger.debug("INITIALIZING!!!!");
initializePoller();
initialized = true;
super.beginConversation(); super.beginConversation();
} }
}
public String saveUser() {
logger.info("Saving user in incomingView"); public String saveUser() {
userview.saveUser(); logger.info("Saving user in incomingView");
return null; userview.saveUser();
return null;
}
public void initializePoller() {
readerView.initializeForPolling();
}
public void polledRead() {
if (!readerView.isNewBarcodes()) {
return;
} }
public String selectUser() { logger.debug(":Barcode:");
EventUser user = readerView.getUser();
EventUser user = readerView.getUser();
if(user == null) { if (user != null) {
logger.debug("got no user from barcode"); if (!user.equals(userview.getUser())) {
return null; logger.info("found user {}, redirecting", user.getNick());
userview.setUser(user);
// userview.prepareCardDownload();
// PURKKAAA, sori tästä, koitan refaktoroida kauniiksi ku kerkiän -TKwtf
super.navihandler.redirectNavigation("printCard.jsf?userid="+user.getUser().getId());
} }
logger.debug("got user from barcode"); } else {
userview.setUser(user); // still there, it must be "clean" barcode
userview.prepareCardDownload(); if (userview.getUser() != null) {
return "printCard"; userview.attachBarcodeToCard();
}
} }
readerView.pollingBarcodeHandled();
}
public String selectUser() {
EventUser user = readerView.getUser();
if (user == null) {
logger.debug("got no user from barcode");
return null;
}
logger.debug("got user from barcode");
userview.setUser(user);
//userview.prepareCardDownload();
return "printCard";
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!