Commit 3d8c9485 by Tuukka Kivilahti

Merge branch 'readersToEwerywhere' into devel

2 parents 6b1f948c 4a6f4d4a
Showing with 628 additions and 95 deletions
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
<name>MoyaAuthModule</name> <name>MoyaAuthModule</name>
<comment></comment> <comment></comment>
<projects> <projects>
<project>lib-AuthModule-depends</project>
<project>MoyaAuthModuleClient</project>
<project>MoyaBeansClient</project> <project>MoyaBeansClient</project>
</projects> </projects>
<buildSpec> <buildSpec>
......
...@@ -3,12 +3,16 @@ package fi.codecrew.moya.beans; ...@@ -3,12 +3,16 @@ package fi.codecrew.moya.beans;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import javax.ejb.EJB;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.sun.xml.bind.v2.model.core.ID;
import fi.codecrew.moya.facade.PrintedCardFacade;
import fi.codecrew.moya.model.PrintedCard; import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.utilities.BarcodeUtils; import fi.codecrew.moya.utilities.BarcodeUtils;
...@@ -19,9 +23,12 @@ import fi.codecrew.moya.utilities.BarcodeUtils; ...@@ -19,9 +23,12 @@ import fi.codecrew.moya.utilities.BarcodeUtils;
@LocalBean @LocalBean
public class BarcodeBean implements BarcodeBeanLocal { public class BarcodeBean implements BarcodeBeanLocal {
private static final String PRINTED_CARD_PREFIX = "200"; private static final String PRINTED_CARD_PREFIX = "277";
private static final Logger logger = LoggerFactory.getLogger(BarcodeBean.class); private static final Logger logger = LoggerFactory.getLogger(BarcodeBean.class);
@EJB
PrintedCardFacade printedCardFacade;
/** /**
* Default constructor. * Default constructor.
*/ */
...@@ -40,6 +47,26 @@ public class BarcodeBean implements BarcodeBeanLocal { ...@@ -40,6 +47,26 @@ public class BarcodeBean implements BarcodeBeanLocal {
sb.append(idStr); sb.append(idStr);
String barcode = sb.toString(); String barcode = sb.toString();
logger.debug("Geneating barcode for card {} : {}", printedCard, barcode); logger.debug("Geneating barcode for card {} : {}", printedCard, barcode);
return BarcodeUtils.getBarcodeEAN(barcode); return BarcodeUtils.getBarcodeEAN(barcode);
} }
public PrintedCard getPrintedCard(String barcode) {
if(barcode == null || barcode.isEmpty())
return null;
// it's our special front barcode
try {
if (barcode.startsWith(PRINTED_CARD_PREFIX)) {
int id = Integer.parseInt(barcode.substring(3));
PrintedCard card = printedCardFacade.find(id);
if(card != null)
return card;
}
} catch (NumberFormatException x) {
}
return printedCardFacade.findByBarcode(barcode);
}
} }
package fi.codecrew.moya.beans;
import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.facade.PrintedCardFacade;
import fi.codecrew.moya.model.PrintedCard;
/**
* Session Bean implementation class CardTemplateBean
*/
@Stateless
@LocalBean
@DeclareRoles({ UserPermission.S_WRITE_ROLES })
public class PrintedCardBean implements PrintedCardBeanLocal {
private static final Logger logger = LoggerFactory.getLogger(PrintedCardBean.class);
/**
* Default constructor.
*/
public PrintedCardBean() {
// TODO Auto-generated constructor stub
}
@EJB
private PrintedCardFacade printedCardFacade;
@RolesAllowed(UserPermission.S_WRITE_ROLES)
@Override
public PrintedCard save(PrintedCard card) {
return printedCardFacade.merge(card);
}
@Override
@RolesAllowed(UserPermission.S_WRITE_ROLES)
public PrintedCard find(Integer id) {
return printedCardFacade.find(id);
}
}
...@@ -26,6 +26,8 @@ import javax.persistence.PersistenceContext; ...@@ -26,6 +26,8 @@ import javax.persistence.PersistenceContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.facade.EventUserFacade; import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.facade.FeedbackFacade; import fi.codecrew.moya.facade.FeedbackFacade;
import fi.codecrew.moya.facade.GroupMembershipFacade; import fi.codecrew.moya.facade.GroupMembershipFacade;
...@@ -33,16 +35,6 @@ import fi.codecrew.moya.facade.PlaceGroupFacade; ...@@ -33,16 +35,6 @@ import fi.codecrew.moya.facade.PlaceGroupFacade;
import fi.codecrew.moya.facade.RoleFacade; import fi.codecrew.moya.facade.RoleFacade;
import fi.codecrew.moya.facade.UserFacade; import fi.codecrew.moya.facade.UserFacade;
import fi.codecrew.moya.facade.UserImageFacade; import fi.codecrew.moya.facade.UserImageFacade;
import fi.codecrew.moya.beans.AccountEventBeanLocal;
import fi.codecrew.moya.beans.CardTemplateBeanLocal;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.LoggingBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.SecurityLogType;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.beans.UtilBeanLocal;
import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.Feedback; import fi.codecrew.moya.model.Feedback;
import fi.codecrew.moya.model.GroupMembership; import fi.codecrew.moya.model.GroupMembership;
...@@ -50,6 +42,7 @@ import fi.codecrew.moya.model.IUser; ...@@ -50,6 +42,7 @@ import fi.codecrew.moya.model.IUser;
import fi.codecrew.moya.model.LanEvent; import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.LanEventPropertyKey; import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.PlaceGroup; import fi.codecrew.moya.model.PlaceGroup;
import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.Role; import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.model.User; import fi.codecrew.moya.model.User;
import fi.codecrew.moya.model.UserImage; import fi.codecrew.moya.model.UserImage;
...@@ -97,6 +90,10 @@ public class UserBean implements UserBeanLocal { ...@@ -97,6 +90,10 @@ public class UserBean implements UserBeanLocal {
@EJB @EJB
private CardTemplateBeanLocal ctbean; private CardTemplateBeanLocal ctbean;
@EJB
private BarcodeBeanLocal barcodeBean;
@EJB @EJB
private AccountEventBeanLocal acbean; private AccountEventBeanLocal acbean;
...@@ -509,8 +506,9 @@ public class UserBean implements UserBeanLocal { ...@@ -509,8 +506,9 @@ public class UserBean implements UserBeanLocal {
@Override @Override
@RolesAllowed(UserPermission.S_VIEW_ALL) @RolesAllowed(UserPermission.S_VIEW_ALL)
public EventUser getUserByBarcode(String barcode) { public EventUser getUserByBarcode(String barcode) {
EventUser user = eventUserFacade.findByBarcode(barcode); PrintedCard tmpCard = barcodeBean.getPrintedCard(barcode);
return user;
return (tmpCard == null) ? null : tmpCard.getUser();
} }
@Override @Override
...@@ -527,7 +525,22 @@ public class UserBean implements UserBeanLocal { ...@@ -527,7 +525,22 @@ public class UserBean implements UserBeanLocal {
@Override @Override
public SearchResult<EventUser> getThisEventsUsers(UserSearchQuery searchQuery) { public SearchResult<EventUser> getThisEventsUsers(UserSearchQuery searchQuery) {
return eventUserFacade.searchEventUsers(searchQuery); SearchResult<EventUser> returnUsers = eventUserFacade.searchEventUsers(searchQuery);
// search users by barcode, if found, return it first
EventUser user = getUserByBarcode(searchQuery.getSearch());
if (user != null) {
List<EventUser> newSearchList = new ArrayList<EventUser>();
newSearchList.add(user);
newSearchList.addAll(returnUsers.getResults());
returnUsers = new SearchResult<EventUser>(newSearchList, (long) newSearchList.size());
}
return returnUsers;
} }
@Override @Override
......
...@@ -79,19 +79,6 @@ public class EventUserFacade extends IntegerPkGenericFacade<EventUser> { ...@@ -79,19 +79,6 @@ public class EventUserFacade extends IntegerPkGenericFacade<EventUser> {
return getEm().createQuery(cq).getResultList(); return getEm().createQuery(cq).getResultList();
} }
public EventUser findByBarcode(String barcode) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<EventUser> cq = cb.createQuery(EventUser.class);
Root<PrintedCard> root = cq.from(PrintedCard.class);
cq.select(root.get(PrintedCard_.user));
cq.where(
cb.equal(root.get(PrintedCard_.barcode), barcode),
cb.equal(root.get(PrintedCard_.event), eventBean.getCurrentEvent())
);
return getSingleNullableResult(getEm().createQuery(cq));
}
public SearchResult<EventUser> searchEventUsers(UserSearchQuery query) { public SearchResult<EventUser> searchEventUsers(UserSearchQuery query) {
ArrayList<FacadeCallback<EventUser>> callbacks = new ArrayList<FacadeCallback<EventUser>>(); ArrayList<FacadeCallback<EventUser>> callbacks = new ArrayList<FacadeCallback<EventUser>>();
callbacks.add(new OrderCallback<EventUser>(false, EventUser_.id)); callbacks.add(new OrderCallback<EventUser>(false, EventUser_.id));
......
...@@ -39,6 +39,18 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> { ...@@ -39,6 +39,18 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
return getSingleNullableResult(getEm().createQuery(cq)); return getSingleNullableResult(getEm().createQuery(cq));
} }
public PrintedCard findByBarcode(String barcode) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<PrintedCard> cq = cb.createQuery(PrintedCard.class);
Root<PrintedCard> root = cq.from(PrintedCard.class);
cq.where(cb.equal(root.get(PrintedCard_.barcode), barcode),
cb.equal(root.get(PrintedCard_.event), eventbean.getCurrentEvent()));
return getSingleNullableResult(getEm().createQuery(cq));
}
public List<PrintedCard> findAllEnabled(LanEvent currentEvent) { public List<PrintedCard> findAllEnabled(LanEvent currentEvent) {
......
package fi.codecrew.moya.beans; package fi.codecrew.moya.beans;
import java.io.IOException;
import java.io.InputStream;
import javax.ejb.Local; import javax.ejb.Local;
import fi.codecrew.moya.model.PrintedCard;
@Local @Local
public interface BarcodeBeanLocal { public interface BarcodeBeanLocal {
public PrintedCard getPrintedCard(String barcode) ;
public InputStream getCardBarcode(PrintedCard printedCard) throws IOException;
} }
package fi.codecrew.moya.beans;
import javax.ejb.Local;
import fi.codecrew.moya.model.CardTemplate;
import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.utilities.jsf.EntityFinderBean;
@Local
public interface PrintedCardBeanLocal extends EntityFinderBean<PrintedCard> {
PrintedCard save(PrintedCard card);
}
...@@ -3,9 +3,12 @@ ...@@ -3,9 +3,12 @@
<name>MoyaEar</name> <name>MoyaEar</name>
<comment></comment> <comment></comment>
<projects> <projects>
<project>lib-AuthModule-depends</project>
<project>MoyaAuthModule</project>
<project>MoyaAuthModuleClient</project> <project>MoyaAuthModuleClient</project>
<project>MoyaBeans</project> <project>MoyaBeans</project>
<project>MoyaBeansClient</project> <project>MoyaBeansClient</project>
<project>MoyaCardPrinter</project>
<project>MoyaDatabase</project> <project>MoyaDatabase</project>
<project>MoyaTerminalWeb</project> <project>MoyaTerminalWeb</project>
<project>MoyaUtilities</project> <project>MoyaUtilities</project>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 6 (MacOS X Default)">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/com.sun.enterprise.jst.server.runtimeTarget/GlassFish 3.1.2"> <classpathentry kind="con" path="org.eclipse.jst.server.core.container/com.sun.enterprise.jst.server.runtimeTarget/GlassFish 3.1.2">
<attributes> <attributes>
<attribute name="owner.project.facets" value="jst.web"/> <attribute name="owner.project.facets" value="jst.web"/>
...@@ -13,5 +8,6 @@ ...@@ -13,5 +8,6 @@
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="build/classes"/> <classpathentry kind="output" path="build/classes"/>
</classpath> </classpath>
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
</session-config> </session-config>
<context-param> <context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name> <param-name>javax.faces.PROJECT_STAGE</param-name>
<!-- <param-value>Development</param-value> --> <param-value>Development</param-value>
<param-value>Production</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>
......
<!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:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui"
xmlns:shop="http://java.sun.com/jsf/composite/cditools/shop"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
xmlns:tools="http://java.sun.com/jsf/composite/cditools">
<h:body>
<ui:composition
template="/layout/#{sessionHandler.fullscreen}/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{barcodeView.initView}" />
</f:metadata>
<f:metadata>
<f:event type="preRenderView" listener="#{readerListDataView.initView}" />
<f:event type="preRenderView" listener="#{readerList.initReaderList}" />
</f:metadata>
<ui:define name="content">
<br />
<br />
<!-- reader eventtiles -->
<h:form>
<p:poll interval="3" />
<ui:repeat value="#{readerView.readerEvents}" var="event" >
<h:link styleClass="userimagetile" outcome="/admin/incoming/printCard"
rendered="#{!empty event.printedCard.user}">
<div>
<img
src="#{request.contextPath}/dydata/userimage/#{event.printedCard.user.currentImage.id}.img" />
<br />
<h:outputText styleClass="usertilenick"
value="#{event.printedCard.user.nick}" />
<br />
<h:outputText value="#{event.printedCard.user.wholeName}" />
<br />
<ui:repeat
value="#{readerView.getUserRoles(event.printedCard.user)}"
var="role">
<h:outputText value="#{role.name}" />
<br />
</ui:repeat>
</div>
<f:param name="userid" value="#{event.printedCard.user.user.id}" />
</h:link>
</ui:repeat>
</h:form>
</ui:define>
<ui:define name="sidebar">
<reader:readerlisttiles />
<br />
<h:form>
<reader:barcode selectvalue="#{i18n['barcodeReader.readBarcode']}" selectaction="#{barcodeView.readBarcode}" />
</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:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui"
xmlns:shop="http://java.sun.com/jsf/composite/cditools/shop"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:user="http://java.sun.com/jsf/composite/cditools/user">
<h:body>
<ui:composition
template="/layout/#{sessionHandler.fullscreen}/template.xhtml">
<f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{incomingView.initView}" />
</f:metadata>
<ui:define name="content">
<h:outputText value="#{userView.user.user.login}" />
<h:form>
<user:edit commitaction="#{userCartView.saveUser()}" commitvalue="#{i18n['user.save']}" />
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui" xmlns:p="http://primefaces.org/ui"
xmlns:shop="http://java.sun.com/jsf/composite/cditools/shop" xmlns:shop="http://java.sun.com/jsf/composite/cditools/shop"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
xmlns:tools="http://java.sun.com/jsf/composite/cditools"> xmlns:tools="http://java.sun.com/jsf/composite/cditools">
<h:body> <h:body>
<ui:composition <ui:composition
...@@ -25,18 +26,17 @@ ...@@ -25,18 +26,17 @@
<br /> <br />
<br /> <br />
<shop:readeventtiles />
<reader:readeventtiles />
</ui:define> </ui:define>
<ui:define name="sidebar"> <ui:define name="sidebar">
<shop:readerlisttiles /> <reader:readerlisttiles />
<br /> <br />
<h:form> <h:form>
<h:inputText name="barcode" value="#{barcodeView.barcode}" /> <reader:barcode selectvalue="#{i18n['barcodeReader.readBarcode']}" selectaction="#{barcodeView.readBarcode}" />
<h:commandButton action="#{barcodeView.readBarcode}"
value="#{i18n['barcodeReader.readBarcode']}" />
</h:form> </h:form>
</ui:define> </ui:define>
......
...@@ -25,5 +25,6 @@ ...@@ -25,5 +25,6 @@
</ui:repeat> </ui:repeat>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
</html> </html>
\ No newline at end of file
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:login="http://java.sun.com/jsf/composite/cditools/login" xmlns:tools="http://java.sun.com/jsf/composite/cditools">
<composite:interface>
<composite:attribute name="selectvalue" required="false" />
<composite:attribute name="selectaction" method-signature="java.lang.String action()" required="false" />
</composite:interface>
<composite:implementation>
<h:form>
<h:outputLabel value="#{i18n['shop.barcode']}" />
<h:inputText id="barcode" value="#{readerView.barcode}" />
<h:commandButton action="#{cc.attrs.selectaction}" value="#{cc.attrs.selectvalue}" />
</h:form>
</composite:implementation>
</html>
\ No newline at end of file
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:login="http://java.sun.com/jsf/composite/cditools/login"
xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
>
<composite:interface>
<composite:attribute name="selectvalue" required="false" />
<composite:attribute name="selectaction" method-signature="java.lang.String action()" required="false" />
<composite:attribute name="linkvalue" required="false" />
<composite:attribute name="linkoutcome" required="false" />
</composite:interface>
<composite:implementation>
<reader:barcode selectvalue="#{cc.attrs.selectvalue}" selectaction="#{cc.attrs.selectaction}" /> <br />
<reader:rfid selectvalue="#{cc.attrs.selectvalue}" selectaction="#{cc.attrs.selectaction}" linkvalue="#{cc.attrs.linkvalue}" linkoutcome="#{cc.attrs.linkoutcome}" /> <br />
</composite:implementation>
</html>
\ No newline at end of file
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:login="http://java.sun.com/jsf/composite/cditools/login"
xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
>
<composite:interface>
<composite:attribute name="selectvalue" required="false" />
<composite:attribute name="selectaction" method-signature="java.lang.String action()" required="false" />
<composite:attribute name="linkvalue" required="false" />
<composite:attribute name="linkoutcome" required="false" />
</composite:interface>
<composite:implementation>
todo: kato tapahtuman conffeista kumpi käytössä: <br />
<reader:barcode selectvalue="#{cc.attrs.selectvalue}" selectaction="#{cc.attrs.selectaction}" /> <br />
<reader:rfid selectvalue="#{cc.attrs.selectvalue}" selectaction="#{cc.attrs.selectaction}" linkvalue="#{cc.attrs.linkvalue}" linkoutcome="#{cc.attrs.linkoutcome}" /> <br />
</composite:implementation>
</html>
\ No newline at end of file
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
<composite:interface> <composite:interface>
<composite:attribute name="selectvalue" required="false" />
<composite:attribute name="selectaction" method-signature="java.lang.String action()" required="false" />
<composite:attribute name="linkvalue" required="false" />
<composite:attribute name="linkoutcome" required="false" />
</composite:interface> </composite:interface>
<composite:implementation> <composite:implementation>
...@@ -13,8 +18,6 @@ ...@@ -13,8 +18,6 @@
<p:poll interval="3" /> <p:poll interval="3" />
<h:dataTable border="1" id="event" value="#{readerView.readerEvents}" var="event"> <h:dataTable border="1" id="event" value="#{readerView.readerEvents}" var="event">
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
...@@ -45,13 +48,26 @@ ...@@ -45,13 +48,26 @@
<h:outputText value="#{event.gamePoint}" /> <h:outputText value="#{event.gamePoint}" />
</h:column> </h:column>
<h:column> <h:column>
<h:link rendered="#{!empty event.printedCard}" outcome="/shop/shopToUser" value="#{i18n['readerevent.shopToUser']}"> <h:link rendered="#{!empty event.printedCard and !empty cc.attrs.linkoutcome}" outcome="#{cc.attrs.linkoutcome}" value="#{cc.attrs.linkvalue}">
<f:param name="userid" value="#{event.printedCard.user.user.id}" /> <f:param name="userid" value="#{event.printedCard.user.user.id}" />
</h:link> </h:link>
<h:link rendered="#{empty event.printedCard}" outcome="/shop/assocToUser" value="#{i18n['readerevent.associateToUser']}"> <h:commandLink rendered="#{!empty cc.attrs.selectaction}" action="#{cc.attrs.selectaction}" value="#{cc.attrs.selectvalue}" />
<h:link rendered="#{empty event.printedCard and !empty cc.attrs.showAssociateToUser}" outcome="/shop/assocToUser" value="#{i18n['readerevent.associateToUser']}">
<f:param name="eventid" value="#{event.id}" /> <f:param name="eventid" value="#{event.id}" />
</h:link> </h:link>
<!--
<h: link rendered="#{!empty event.printedCard} AND !empty cc.attrs.linkoutcome" outcome="/shop/shopToUser" value="#{i18n['readerevent.shopToUser']}">
<f:param name="userid" value="#{event.printedCard.user.user.id}" />
</h:link>
<h:commandButton action="#{cc.attrs.commitaction}" id="commitbutton-botton" value="#{cc.attrs.commitValue}" />
<h:link rendered="#{empty event.printedCard}" outcome="/shop/assocToUser" value="#{i18n['readerevent.associateToUser']}">
<f:param name="eventid" value="#{event.id}" />
</h:link> -->
</h:column> </h:column>
</h:dataTable> </h:dataTable>
......
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:login="http://java.sun.com/jsf/composite/cditools/login" xmlns:tools="http://java.sun.com/jsf/composite/cditools"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
>
<composite:interface>
<composite:attribute name="selectvalue" required="false" />
<composite:attribute name="selectaction" method-signature="java.lang.String action()" required="false" />
<composite:attribute name="linkvalue" required="false" />
<composite:attribute name="linkoutcome" required="false" />
<composite:attribute name="showAssociateToUser" required="false" />
</composite:interface>
<composite:implementation>
<h:form rendered="#{empty readerNameContainer.readerId}">
<h:dataTable border="1" id="reader" value="#{readerListDataView.readers}" var="rr">
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['reader.name']}" />
</f:facet>
<h:outputText value="#{rr}" />
</h:column>
<h:column>
<h:commandButton action="#{readerListDataView.selectReader}" value="#{i18n['reader.select']}" />
</h:column>
</h:dataTable>
</h:form>
<reader:readerevents rendered="#{!empty readerNameContainer.readerId}" showAssociateToUser="#{cc.attrs.showAssociateToUser}" selectvalue="#{cc.attrs.selectvalue}" selectaction="#{cc.attrs.selectaction}" linkvalue="#{cc.attrs.linkvalue}" linkoutcome="#{cc.attrs.linkoutcome}" />
</composite:implementation>
</html>
\ No newline at end of file
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools" xmlns:p="http://primefaces.org/ui"> xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
xmlns:p="http://primefaces.org/ui"
>
<composite:interface> <composite:interface>
...@@ -36,11 +40,9 @@ ...@@ -36,11 +40,9 @@
<h:panelGroup> <h:panelGroup>
<h:outputLabel value="#{i18n['shop.barcode']}" />
<h:inputText id="barcode" value="#{productShopView.barcode}" /> <reader:barcode selectaction="#{productShopView.readBarcode}" selectvalue="#{i18n['shop.readBarcode']}" />
<h:commandButton action="#{productShopView.readBarcode}" value="#{i18n['shop.readBarcode']}">
<f:ajax render="@form" onevent="barcodeReadEvent" execute="@form" />
</h:commandButton>
<br /> <br />
<p:dataTable id="prods" value="#{productShopView.boughtItems}" var="prods"> <p:dataTable id="prods" value="#{productShopView.boughtItems}" var="prods">
<p:column> <p:column>
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "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:f="http://java.sun.com/jsf/core" <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:f="http://java.sun.com/jsf/core"
xmlns:shop="http://java.sun.com/jsf/composite/cditools/shop" xmlns:c="http://java.sun.com/jsp/jstl/core"> xmlns:shop="http://java.sun.com/jsf/composite/cditools/shop" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
>
<h:body> <h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata> <f:metadata>
...@@ -13,7 +15,7 @@ ...@@ -13,7 +15,7 @@
<ui:define name="content"> <ui:define name="content">
<shop:readerlist /> <reader:readerlist />
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "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:f="http://java.sun.com/jsf/core" <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:f="http://java.sun.com/jsf/core"
xmlns:shop="http://java.sun.com/jsf/composite/cditools/shop" xmlns:c="http://java.sun.com/jsp/jstl/core"> xmlns:shop="http://java.sun.com/jsf/composite/cditools/shop" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
>
<h:body> <h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata> <f:metadata>
...@@ -12,8 +14,8 @@ ...@@ -12,8 +14,8 @@
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<shop:readerevents rendered="#{!empty readerNameContainer.readerId}" /> <reader:readerevents rendered="#{!empty readerNameContainer.readerId}" />
<shop:readerlist rendered="#{empty readerNameContainer.readerId}" /> <reader:readerlist rendered="#{empty readerNameContainer.readerId}" />
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "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:f="http://java.sun.com/jsf/core" <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:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:p="http://primefaces.org/ui" xmlns:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:p="http://primefaces.org/ui" xmlns:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:shop="http://java.sun.com/jsf/composite/cditools/shop"> xmlns:shop="http://java.sun.com/jsf/composite/cditools/shop"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
>
<h:body> <h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.user.create" /> <ui:param name="thispage" value="page.user.create" />
...@@ -68,24 +70,11 @@ ...@@ -68,24 +70,11 @@
</h:dataTable> </h:dataTable>
</h:form>--> </h:form>-->
<h3>RFID</h3> <h3>RFID</h3>
<h:form rendered="#{empty readerNameContainer.readerId}">
<h:dataTable border="1" id="reader" value="#{readerListDataView.readers}" var="rr"> <!-- reader:rfid linkoutcome="/shop/shopToUser" linkvalue="#{i18n['readerevent.shopToUser']}" / -->
<h:column> <reader:barcode_rfid selectvalue="#{i18n['readerevent.associateToUser']}" selectaction="#{userView.attachBarcodeToCard()}"/>
<f:facet name="header">
<h:outputText value="${i18n['reader.name']}" />
</f:facet>
<h:outputText value="#{rr}" />
</h:column>
<h:column>
<h:commandButton action="#{readerListDataView.selectReader}" />
</h:column>
</h:dataTable>
</h:form>
<shop:readerevents rendered="#{!empty readerNameContainer.readerId}" />
</ui:fragment> </ui:fragment>
......
package fi.codecrew.moya.web.cdiview.shop; package fi.codecrew.moya.web.cdiview.reader;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.faces.model.ListDataModel; import javax.faces.model.ListDataModel;
import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -24,6 +25,9 @@ public class ReaderListDataView extends GenericCDIView { ...@@ -24,6 +25,9 @@ public class ReaderListDataView extends GenericCDIView {
@EJB @EJB
private transient ReaderBeanLocal readerbean; private transient ReaderBeanLocal readerbean;
@Inject
private transient ReaderNameContainer readerNameContainer;
private transient ListDataModel<Reader> readers; private transient ListDataModel<Reader> readers;
...@@ -41,5 +45,13 @@ public class ReaderListDataView extends GenericCDIView { ...@@ -41,5 +45,13 @@ public class ReaderListDataView extends GenericCDIView {
} }
return readers; return readers;
} }
public String selectReader() {
if(readers.isRowAvailable()) {
readerNameContainer.setReaderId(readers.getRowData().getId());
}
return null;
}
} }
package fi.codecrew.moya.web.cdiview.shop; package fi.codecrew.moya.web.cdiview.reader;
import java.io.Serializable; import java.io.Serializable;
......
package fi.codecrew.moya.web.cdiview.shop; package fi.codecrew.moya.web.cdiview.reader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -12,6 +12,7 @@ import javax.inject.Named; ...@@ -12,6 +12,7 @@ import javax.inject.Named;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.BarcodeBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal; import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.beans.ReaderBeanLocal; import fi.codecrew.moya.beans.ReaderBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal; import fi.codecrew.moya.beans.UserBeanLocal;
...@@ -27,6 +28,7 @@ import fi.codecrew.moya.model.Role; ...@@ -27,6 +28,7 @@ import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.model.User; import fi.codecrew.moya.model.User;
import fi.codecrew.moya.utilities.SearchQuery; import fi.codecrew.moya.utilities.SearchQuery;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.shop.UserCardWrapper;
import fi.codecrew.moya.web.cdiview.user.UserView; import fi.codecrew.moya.web.cdiview.user.UserView;
@Named @Named
...@@ -39,9 +41,11 @@ public class ReaderView extends GenericCDIView { ...@@ -39,9 +41,11 @@ public class ReaderView extends GenericCDIView {
private String placecode; private String placecode;
private String usersearch; private String usersearch;
private String barcode;
private Reader reader; private Reader reader;
private transient ListDataModel<UserCardWrapper> userlist; private transient ListDataModel<UserCardWrapper> userlist;
private ListDataModel<ReaderEvent> readerEventList;
@Inject @Inject
private ReaderNameContainer namecontainer; private ReaderNameContainer namecontainer;
...@@ -54,6 +58,9 @@ public class ReaderView extends GenericCDIView { ...@@ -54,6 +58,9 @@ public class ReaderView extends GenericCDIView {
@EJB @EJB
private transient UserBeanLocal userbean; private transient UserBeanLocal userbean;
@EJB
private transient BarcodeBeanLocal barcodebean;
private UserCardWrapper neighborUser; private UserCardWrapper neighborUser;
private static final Logger logger = LoggerFactory.getLogger(ReaderView.class); private static final Logger logger = LoggerFactory.getLogger(ReaderView.class);
...@@ -159,9 +166,11 @@ public class ReaderView extends GenericCDIView { ...@@ -159,9 +166,11 @@ public class ReaderView extends GenericCDIView {
return ReaderType.values(); return ReaderType.values();
} }
public List<ReaderEvent> getReaderEvents() public ListDataModel<ReaderEvent> getReaderEvents()
{ {
return readerbean.getReaderEvents(namecontainer.getReaderId()); readerEventList = new ListDataModel<ReaderEvent>(readerbean.getReaderEvents(namecontainer.getReaderId()));
return readerEventList;
} }
public String saveReader() public String saveReader()
...@@ -261,4 +270,51 @@ public class ReaderView extends GenericCDIView { ...@@ -261,4 +270,51 @@ public class ReaderView extends GenericCDIView {
{ {
return ReaderType.values(); return ReaderType.values();
} }
public String getBarcode() {
if(readerEventList != null && readerEventList.isRowAvailable()) {
if(readerEventList.getRowData().getReader().getType() == ReaderType.BARCODE) {
return readerEventList.getRowData().getValue();
}
}
return barcode;
}
public void setBarcode(String barcode) {
this.barcode = barcode;
}
public ReaderEvent getReaderEvent() {
if (readerEventList == null)
return null;
if (readerEventList.isRowAvailable()) {
return readerEventList.getRowData();
}
return null;
}
/**
* If last barcode or rfid was associated to user, get it
*
* @return
*/
public PrintedCard getPrintedCard() {
PrintedCard card = barcodebean.getPrintedCard(getBarcode());
if (card == null && readerEventList != null && readerEventList.isRowAvailable()) {
card = readerEventList.getRowData().getPrintedCard();
}
return card;
}
public void clearBarcode() {
this.barcode = null;
}
} }
...@@ -2,7 +2,6 @@ package fi.codecrew.moya.web.cdiview.shop; ...@@ -2,7 +2,6 @@ package fi.codecrew.moya.web.cdiview.shop;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
...@@ -25,9 +24,12 @@ import fi.codecrew.moya.model.Bill; ...@@ -25,9 +24,12 @@ import fi.codecrew.moya.model.Bill;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.LanEventProperty; import fi.codecrew.moya.model.LanEventProperty;
import fi.codecrew.moya.model.LanEventPropertyKey; import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.Product; import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.web.annotations.SelectedUser; import fi.codecrew.moya.web.annotations.SelectedUser;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.reader.ReaderView;
import fi.codecrew.moya.web.cdiview.user.UserView;
import fi.codecrew.moya.web.helpers.ProductShopItem; import fi.codecrew.moya.web.helpers.ProductShopItem;
@Named @Named
...@@ -60,13 +62,19 @@ public class ProductShopView extends GenericCDIView { ...@@ -60,13 +62,19 @@ public class ProductShopView extends GenericCDIView {
private boolean payInstant = true; private boolean payInstant = true;
private BigDecimal cash = BigDecimal.ZERO; private BigDecimal cash = BigDecimal.ZERO;
private String barcode;
private transient ListDataModel<ProductShopItem> shoppingcart; private transient ListDataModel<ProductShopItem> shoppingcart;
@Inject @Inject
private BillListView billListView; private BillListView billListView;
@Inject @Inject
private ReaderView readerView;
@Inject
private UserView userView;
@Inject
private BillEditView billEditView; private BillEditView billEditView;
private boolean hasLimits = false; private boolean hasLimits = false;
private boolean blip = false; private boolean blip = false;
...@@ -354,16 +362,26 @@ public class ProductShopView extends GenericCDIView { ...@@ -354,16 +362,26 @@ public class ProductShopView extends GenericCDIView {
this.hasLimits = hasLimits; this.hasLimits = hasLimits;
} }
public String getBarcode() {
return barcode;
}
public void setBarcode(String barcode) {
this.barcode = barcode;
}
public String readBarcode() { public String readBarcode() {
Product product = productBean.findByBarcode(this.barcode);
PrintedCard card = readerView.getPrintedCard();
if(readerView.getBarcode() == null || readerView.getBarcode().trim() == "") {
return null;
}
if(card != null) {
if(card.getUser() != null) {
userView.setUser(card.getUser());
this.user = card.getUser();
initShopView();
return null;
}
}
Product product = productBean.findByBarcode(readerView.getBarcode());
this.blip = false; this.blip = false;
// find product index, set index and add one // find product index, set index and add one
...@@ -381,7 +399,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -381,7 +399,7 @@ public class ProductShopView extends GenericCDIView {
} }
n++; n++;
} }
this.barcode = null; readerView.clearBarcode();
logger.debug("barcode read"); logger.debug("barcode read");
return "success"; return "success";
} }
...@@ -401,5 +419,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -401,5 +419,7 @@ public class ProductShopView extends GenericCDIView {
public void setBoughtItems(ListDataModel<ProductShopItem> boughtItems) { public void setBoughtItems(ListDataModel<ProductShopItem> boughtItems) {
this.boughtItems = boughtItems; this.boughtItems = boughtItems;
} }
} }
package fi.codecrew.moya.web.cdiview.user;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.primefaces.model.UploadedFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.CardTemplateBeanLocal;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.CardTemplate;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.utilities.I18n;
import fi.codecrew.moya.web.annotations.SelectedUser;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class IncomingView extends GenericCDIView {
private static final long serialVersionUID = -9115983838324313414L;
@Inject
@SelectedUser
private transient EventUser user;
@Inject
private UserView userview;
public void initView() {
super.beginConversation();
}
public String saveUser() {
userview.saveUser();
return null;
}
}
...@@ -13,7 +13,6 @@ import javax.faces.context.FacesContext; ...@@ -13,7 +13,6 @@ import javax.faces.context.FacesContext;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import org.apache.http.HttpRequest;
import org.primefaces.event.CaptureEvent; import org.primefaces.event.CaptureEvent;
import org.primefaces.model.CroppedImage; import org.primefaces.model.CroppedImage;
import org.primefaces.model.DefaultStreamedContent; import org.primefaces.model.DefaultStreamedContent;
...@@ -25,6 +24,8 @@ import org.slf4j.LoggerFactory; ...@@ -25,6 +24,8 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.CardPrintBeanLocal; import fi.codecrew.moya.beans.CardPrintBeanLocal;
import fi.codecrew.moya.beans.CardTemplateBeanLocal; import fi.codecrew.moya.beans.CardTemplateBeanLocal;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.PrintedCardBeanLocal;
import fi.codecrew.moya.beans.ReaderBeanLocal;
import fi.codecrew.moya.beans.RoleBeanLocal; import fi.codecrew.moya.beans.RoleBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal; import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.enums.apps.UserPermission; import fi.codecrew.moya.enums.apps.UserPermission;
...@@ -38,6 +39,7 @@ import fi.codecrew.moya.util.MassPrintResult; ...@@ -38,6 +39,7 @@ import fi.codecrew.moya.util.MassPrintResult;
import fi.codecrew.moya.web.annotations.LoggedIn; import fi.codecrew.moya.web.annotations.LoggedIn;
import fi.codecrew.moya.web.annotations.SelectedUser; import fi.codecrew.moya.web.annotations.SelectedUser;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.reader.ReaderView;
@Named() @Named()
@ConversationScoped @ConversationScoped
...@@ -53,17 +55,23 @@ public class UserView extends GenericCDIView { ...@@ -53,17 +55,23 @@ public class UserView extends GenericCDIView {
@EJB @EJB
private transient UserBeanLocal userbean; private transient UserBeanLocal userbean;
@EJB
private transient ReaderBeanLocal readerbean;
private Integer userid; private Integer userid;
private transient UploadedFile image; private transient UploadedFile image;
@EJB
private transient CardTemplateBeanLocal ctbean;
private CroppedImage croppedImage; private CroppedImage croppedImage;
private EventUser user; private EventUser user;
@Inject @Inject
private transient Conversation conversation; private transient Conversation conversation;
@Inject
private transient ReaderView readerView;
public String getConversationId() { public String getConversationId() {
if (conversation != null) if (conversation != null)
...@@ -80,6 +88,10 @@ public class UserView extends GenericCDIView { ...@@ -80,6 +88,10 @@ public class UserView extends GenericCDIView {
@EJB @EJB
private transient CardTemplateBeanLocal cardBean; private transient CardTemplateBeanLocal cardBean;
@EJB
private transient PrintedCardBeanLocal printedCardBean;
private List<Role> usersRoles; private List<Role> usersRoles;
@EJB @EJB
private transient RoleBeanLocal rolebean; private transient RoleBeanLocal rolebean;
...@@ -205,11 +217,13 @@ public class UserView extends GenericCDIView { ...@@ -205,11 +217,13 @@ public class UserView extends GenericCDIView {
} }
public String sendImage() { public String sendImage() {
logger.debug("sending image");
if (getImage() == null) if (getImage() == null)
{ {
logger.debug("NO image to send!");
super.addFaceMessage("user.imageUpload.imageNotFound"); super.addFaceMessage("user.imageUpload.imageNotFound");
} else { } else {
logger.debug("uploading image");
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");
...@@ -282,7 +296,7 @@ public class UserView extends GenericCDIView { ...@@ -282,7 +296,7 @@ public class UserView extends GenericCDIView {
public CardTemplate getUsersCardtemplate() public CardTemplate getUsersCardtemplate()
{ {
CardTemplate ret = ctbean.getUsersCardtype(user); CardTemplate ret = cardBean.getUsersCardtype(user);
logger.info("Users cardtemplate is {}", ret); logger.info("Users cardtemplate is {}", ret);
return ret; return ret;
} }
...@@ -291,6 +305,34 @@ public class UserView extends GenericCDIView { ...@@ -291,6 +305,34 @@ public class UserView extends GenericCDIView {
{ {
return permbean.isCurrentUser(user); return permbean.isCurrentUser(user);
} }
/**
* attach barcode or rfid to card
* @return
*/
public String attachBarcodeToCard() {
PrintedCard card = readerView.getPrintedCard();
// already attached
if(card != null) {
super.addFaceMessage("usercard.alreadyassociated");
return null;
}
// still there, we can get real card and update it's barcodes
card = cardBean.checkPrintedCard(user);
if(readerView.getBarcode() != null && !readerView.getBarcode().isEmpty()) {
card.setBarcode(readerView.getBarcode());
printedCardBean.save(card);
}
// 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);
}
return null;
}
public String createUser() { public String createUser() {
userbean.createNewUser(user, getPassword()); userbean.createNewUser(user, getPassword());
...@@ -349,6 +391,7 @@ public class UserView extends GenericCDIView { ...@@ -349,6 +391,7 @@ public class UserView extends GenericCDIView {
} }
public void setImage(UploadedFile image) { public void setImage(UploadedFile image) {
logger.debug("setting image");
this.image = image; this.image = image;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!