Commit 9add6114 by Tuomas Riihimäki

Pientä kaikkea skyneteille.

1 parent 6d11ea6b
package fi.codecrew.moya.beans;
import java.io.IOException;
import java.io.InputStream;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.utilities.BarcodeUtils;
/**
* Session Bean implementation class BarcodeBean
*/
@Stateless
@LocalBean
public class BarcodeBean implements BarcodeBeanLocal {
private static final String PRINTED_CARD_PREFIX = "200";
private static final Logger logger = LoggerFactory.getLogger(BarcodeBean.class);
/**
* Default constructor.
*/
public BarcodeBean() {
// TODO Auto-generated constructor stub
}
public InputStream getCardBarcode(PrintedCard printedCard) throws IOException {
StringBuilder sb = new StringBuilder();
sb.append(PRINTED_CARD_PREFIX);
String idStr = printedCard.getId().toString();
for (int i = 12 - idStr.length() - sb.length(); i > 0; --i) {
sb.append("0");
}
sb.append(idStr);
String barcode = sb.toString();
logger.debug("Geneating barcode for card {} : {}", printedCard, barcode);
return BarcodeUtils.getBarcodeEAN(barcode);
}
}
......@@ -22,12 +22,10 @@ import com.pdfjet.TextLine;
import fi.codecrew.moya.facade.CardTemplateFacade;
import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.facade.UserFacade;
import fi.codecrew.moya.beans.CardPrintBeanLocal;
import fi.codecrew.moya.model.CardTemplate;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.util.MassPrintResult;
import fi.codecrew.moya.utilities.BarcodeUtils;
/**
* Session Bean implementation class CardPrintBean
......@@ -46,6 +44,8 @@ public class CardPrintBean implements CardPrintBeanLocal {
private CardTemplateFacade cardTemplateFacade;
@EJB
private UserFacade userfacade;
@EJB
private BarcodeBean barcodeBean;
/**
* Default constructor.
......@@ -111,13 +111,14 @@ public class CardPrintBean implements CardPrintBeanLocal {
cardTemplate.getImage()));
BufferedImage faceBufferedImage = ImageIO
.read(new ByteArrayInputStream(user.getCurrentImage()
.getImageData()));
if(faceBufferedImage.getWidth() > 1024 || faceBufferedImage.getHeight() > 1024) {
throw new Exception("Image dimensions too large, please take/upload smaller!");
}
.read(new ByteArrayInputStream(user.getCurrentImage().getImageData()));
/*
* if (faceBufferedImage.getWidth() > 1024 ||
* faceBufferedImage.getHeight() > 1024) { throw new
* Exception("Image dimensions too large, please take/upload smaller!"
* ); }
*/
int originalWidth = faceBufferedImage.getWidth();
int originalHeight = faceBufferedImage.getHeight();
......@@ -184,14 +185,15 @@ public class CardPrintBean implements CardPrintBeanLocal {
roleTextLine.drawOn(page);
// Barcode
String barcodeString = String.valueOf(user.getUser().getCreated()
.getTime().getTime());
barcodeString = barcodeString.substring(barcodeString.length() - 12);
BufferedImage barCodeBufferedImage = ImageIO.read(BarcodeUtils
.getBarcodeEAN(barcodeString));
Image barCodeImage = new Image(pdf,
convertBufferedImageToPng(barCodeBufferedImage), ImageType.PNG);
barCodeImage.setPosition(0.0, 243.5);
// String barcodeString =
// String.valueOf(user.getUser().getCreated().getTime().getTime());
// barcodeString = barcodeString.substring(barcodeString.length() -
// 12);
BufferedImage barCodeBufferedImage = ImageIO.read(barcodeBean.getCardBarcode(printedCard));
Image barCodeImage = new Image(pdf, convertBufferedImageToPng(barCodeBufferedImage), ImageType.PNG);
barCodeImage.setPosition(0.0, 230);// 243.5);
barCodeImage.scaleBy(0.7);
barCodeImage.drawOn(page);
......
......@@ -17,16 +17,12 @@ import javax.imageio.ImageIO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.facade.CardTemplateFacade;
import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.facade.GroupMembershipFacade;
import fi.codecrew.moya.facade.LanEventPropertyFacade;
import fi.codecrew.moya.facade.PrintedCardFacade;
import fi.codecrew.moya.beans.CardTemplateBeanLocal;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.beans.UtilBeanLocal;
import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.CardTemplate;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.LanEvent;
......@@ -179,6 +175,8 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
} else {
logger.info("User {} has power {} and roles has power {}", new Object[] { user.getUser().getLogin(), existingPower, newPower });
}
eventPropertyFacade.flush();
return biggestCard;
}
......
......@@ -15,10 +15,6 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.facade.PrintedCardFacade;
import fi.codecrew.moya.facade.ReaderEventFacade;
import fi.codecrew.moya.facade.ReaderFacade;
import fi.codecrew.moya.beans.CardTemplateBeanLocal;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.ReaderBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.model.AccountEvent;
import fi.codecrew.moya.model.CardTemplate;
import fi.codecrew.moya.model.EventUser;
......@@ -260,4 +256,11 @@ public class ReaderBean implements ReaderBeanLocal {
}
return readerfacade.merge(reader);
}
@Override
public void createReader(Reader reader) {
reader.setEvent(eventbean.getCurrentEvent());
readerfacade.create(reader);
}
}
......@@ -92,6 +92,10 @@ public class VotingBean implements VotingBeanLocal {
Compo co = compoFacade.reload(entry.getCompo());
entry.setCreator(permissionBean.getCurrentUser());
if (entry.getTitle() == null)
{
entry.setTitle("");
}
if (co.getCompoEntries() == null) {
co.setCompoEntries(new ArrayList<CompoEntry>());
}
......
package fi.codecrew.moya.beans;
import javax.ejb.Local;
@Local
public interface BarcodeBeanLocal {
}
......@@ -35,4 +35,6 @@ public interface ReaderBeanLocal {
Reader saveReader(Reader reader);
void createReader(Reader reader);
}
......@@ -43,21 +43,21 @@ public class CompoEntry extends GenericEntity {
private Calendar created = Calendar.getInstance();
@Column(name = "title", nullable = false)
private String title;
private String title = "";
@Column(name = "author")
private String author;
private String author = "";
@Lob
@Column(name = "notes")
private String notes;
private String notes = "";
@Lob
@Column(name = "screen_message")
private String screenMessage;
private String screenMessage = "";
@Column(name = "sort")
private Integer sort;
private Integer sort = 10;
@Column(name = "final_position")
private Integer finalPosition;
......
......@@ -36,7 +36,9 @@
</h:panelGroup>
</h:panelGrid>
</div>
<div style="">
<h:link style="margin: 0 auto; font-size: 3em;" outcome="/admin/adduser/start" value="Valmis"/>
</div>
<script>
function dophoto(pc) {
......
......@@ -14,13 +14,15 @@
<h1>#{i18n['card.massprint.title']}</h1>
</ui:define>
<ui:define name="content">
<h:form rendered="#{cardMassPrintView.file!=null}">
<h:form rendered="#{!empty cardMassPrintView.streamedFile}">
<p:commandButton id="downloadLink" value="Download" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop)" icon="ui-icon-arrowthichk-s">
<p:fileDownload value="#{cardMassPrintView.streamedFile}" />
</p:commandButton>
<p:commandButton value="Accept printout" action="#{cardMassPrintView.acceptPrintout()}" rendered="#{cardMassPrintView.waitForAcceptance}" />
</h:form>
<h:outputText value="Error generating mass output!" rendered="#{empty cardMassPrintView.streamedFile}"/>
</ui:define>
</ui:composition>
</h:body>
......
......@@ -10,7 +10,11 @@
<composite:implementation>
<h:form>
<p:poll interval="3" />
<p:poll interval="3" />
<h:dataTable border="1" id="event" value="#{readerView.readerEvents}" var="event">
<h:column>
<f:facet name="header">
......
<!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:shop="http://java.sun.com/jsf/composite/cditools/shop" xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{readerView.initCreateReader}" />
</f:metadata>
<ui:define name="content">
<h:form>
<h:panelGrid columns="3">
<h:outputLabel for="name" value="#{i18n['reader.identification']}" />
<h:inputText id="name" value="#{readerView.reader.identification}" />
<h:message for="name" />
<h:outputLabel for="type" value="#{i18n['reader.type']}" />
<h:selectOneMenu value="#{readerView.reader.type}">
<f:selectItems value="#{readerView.readerTypes}" />
</h:selectOneMenu>
</h:panelGrid>
<h:commandButton action="#{readerView.createReader}" value="#{i18n['reader.create']}" />
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -6,7 +6,8 @@
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{userCartView.initView}" />
<!-- f:event type="preRenderView" listener="#{userCartView.initView}" />
-->
</f:metadata>
<ui:define name="title">
......
......@@ -7,16 +7,19 @@
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:viewParam name="compoId" value="#{compoView.compoId}" />
<f:viewParam name="entryId" value="#{compoView.entryId}" />
<f:event type="preRenderView" listener="#{compoView.initEntryView}" />
</f:metadata>
<ui:define name="content">
<!-- <h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" /> -->
<h1>#{i18n['voting.compoentryadd.title']}</h1>
<p>#{i18n['voting.compoentryadd.description']} #{compoView.compo.name}</p>
<p>#{i18n['voting.compoentryadd.description']}<h:outputText value="#{compoView.compo.name}" /></p>
<p>
<h:outputText value="#{compoView.compo.description}" />
</p>
<h:form>
<h:panelGrid columns="3">
<!-- <h:panelGrid columns="3">
<h:outputLabel value="Title" for="name" />
<h:inputText value="#{compoView.entry.title}" id="name" />
<h:message for="name" />
......@@ -32,14 +35,18 @@
<h:outputLabel value="#{i18n['voting.compoentryadd.screenmessage']}" for="screenmessage" />
<h:inputTextarea value="#{compoView.entry.screenMessage}" id="screenmessage" />
<h:message for="screenmessage" />
<h:commandButton rendered="#{empty compoView.entry.id}" action="#{compoView.createEntry()}" value="#{i18n['voting.compoentryadd.button']}" />
<h:commandButton rendered="#{!empty compoView.entry.id}" action="#{compoView.saveEntry()}" value="#{i18n['voting.compoentrysave.button']}" />
<h:commandButton rendered="#{!empty compoView.entry.id}" action="#{compoView.saveEntry()}" value="#{i18n['voting.compoentrysave.button']}" />
</h:panelGrid>
</h:form>
-->
<h:commandButton rendered="#{empty compoView.entry.id}" action="#{compoView.createEntry()}" value="Ilmoittaudu kilpailuun" />
</h:form>
<ui:fragment rendered="#{!empty compoView.entry.id}">
<h:form enctype="multipart/form-data">
<!-- <h:form enctype="multipart/form-data">
<p:fileUpload value="#{compoView.uploadedFile}" id="uploadedfile" mode="simple" />
<h:commandButton action="#{compoView.submitEntryfile}" value="#{i18n['compofile.upload']}" />
</h:form>
......@@ -54,6 +61,8 @@
<p:fileDownload value="#{compoFileDownloadView.dlfile}" />
</h:commandButton>
</h:form>
-->
Ilmoittautuminen otettu vastaan.
</ui:fragment>
</ui:define>
......
......@@ -868,12 +868,12 @@ voting.allcompos.voteStart = \u00C4\u00E4nestys auki
voting.compo.submit = L\u00E4het\u00E4 kappale
voting.compo.vote = \u00C4\u00E4nest\u00E4
voting.compoentryadd.button = L\u00E4het\u00E4
voting.compoentryadd.description = Lis\u00E4\u00E4 uusi entry compoon
voting.compoentryadd.description = Ilmoittaudu kilpailuun:
voting.compoentryadd.entryname = Nimi
voting.compoentryadd.file = Tiedosto
voting.compoentryadd.notes = Huomatuksia
voting.compoentryadd.screenmessage = Screenmessage
voting.compoentryadd.title = Lis\u00E4\u00E4 entry
voting.compoentryadd.title = Ilmoittaudu
voting.compoentryadd.uploadedFile = asdsda
voting.compoentrysave.button = Tallenna
voting.create.compoEnd = Lopetusaika
......
package fi.codecrew.moya.web.cdiview.card;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
......@@ -15,6 +14,8 @@ import javax.inject.Named;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.CardPrintBeanLocal;
import fi.codecrew.moya.model.EventUser;
......@@ -32,11 +33,11 @@ public class CardMassPrintView extends GenericCDIView implements Serializable {
@EJB
private CardPrintBeanLocal cardPrintBean;
private File file;
private StreamedContent streamedFile;
private MassPrintResult mpr = null;
private boolean waitForAcceptance = true;
private static final Logger logger = LoggerFactory.getLogger(CardMassPrintView.class);
public CardMassPrintView() {
// TODO Auto-generated constructor stub
......@@ -49,9 +50,8 @@ public class CardMassPrintView extends GenericCDIView implements Serializable {
userIdList.add(eu.getId());
}
file = null;
try {
mpr = cardPrintBean.getUserCardsAsPrintablePdf(userIdList);
waitForAcceptance = true;
......@@ -89,14 +89,6 @@ public class CardMassPrintView extends GenericCDIView implements Serializable {
this.userCartView = userCartView;
}
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public StreamedContent getStreamedFile() {
return streamedFile;
}
......
......@@ -19,10 +19,9 @@ import fi.codecrew.moya.web.cdiview.user.UserView;
public class BarcodeView extends GenericCDIView {
private static final long serialVersionUID = -5723180869625883034L;
private String barcode;
private static final Logger logger = LoggerFactory
.getLogger(BarcodeView.class);
private static final Logger logger = LoggerFactory.getLogger(BarcodeView.class);
@Inject
private UserView userView;
......
......@@ -14,7 +14,6 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.beans.ReaderBeanLocal;
import fi.codecrew.moya.beans.RoleBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.enums.apps.ShopPermission;
import fi.codecrew.moya.enums.apps.UserPermission;
......@@ -46,7 +45,7 @@ public class ReaderView extends GenericCDIView {
@Inject
private ReaderNameContainer namecontainer;
@EJB
private transient ReaderBeanLocal readerbean;
......@@ -81,10 +80,27 @@ public class ReaderView extends GenericCDIView {
// card.getPrintedCard());
return null;
}
public List<Role> getUserRoles(EventUser user) {
return userbean.findUsersRoles(user);
}
public void initCreateReader()
{
if (super.requirePermissions(ShopPermission.SHOP_TO_OTHERS) && reader == null)
{
reader = new Reader();
super.beginConversation();
}
}
public String createReader()
{
readerbean.createReader(reader);
namecontainer.setReaderId(reader.getId());
return "/shop/showReaderEvents";
}
public void initUserassocView() {
if (super.requirePermissions(UserPermission.CREATE_NEW) && event == null) {
event = readerbean.getEvent(eventid);
......@@ -95,9 +111,11 @@ public class ReaderView extends GenericCDIView {
super.beginConversation();
}
}
public boolean isReaderSelected() {
return this.readerid != null;
return this.readerid != null;
}
public String assocToCard()
{
......@@ -123,10 +141,10 @@ public class ReaderView extends GenericCDIView {
public void initReaderList() {
if (super.requirePermissions(ShopPermission.SHOP_TO_OTHERS)) {
}
}
public List<Product> getAutoProducts() {
List<Product> ret = new ArrayList<Product>();
......@@ -239,4 +257,8 @@ public class ReaderView extends GenericCDIView {
this.userview = userview;
}
public ReaderType[] getReaderTypes()
{
return ReaderType.values();
}
}
......@@ -47,6 +47,7 @@ public class CompoView extends GenericCDIView {
private Compo compo;
private Integer entryId;
private Integer compoId;
private transient ListDataModel<EntryWrapper> voteEntries;
......@@ -56,17 +57,34 @@ public class CompoView extends GenericCDIView {
public void initEntryView()
{
if (entry == null)
if (super.requirePermissions(CompoPermission.SUBMIT_ENTRY) && entry == null)
{
entry = votbean.findEntry(entryId);
if (entry == null || !super.requirePermissions(super.hasPermission(CompoPermission.MANAGE) || permbean.isCurrentUser(entry.getCreator())))
if (entryId == null)
{
entry = null;
} else {
super.beginConversation();
entry = new CompoEntry();
if (compo == null && compoId != null) {
compo = votbean.getCompoById(compoId);
entry.setCompo(compo);
}
super.beginConversation();
} else {
entry = votbean.findEntry(entryId);
if (entry == null ||
!super.requirePermissions(
super.hasPermission(CompoPermission.MANAGE) ||
permbean.isCurrentUser(entry.getCreator()))) {
entry = null;
compo = null;
} else {
compo = entry.getCompo();
super.beginConversation();
}
}
}
logger.info("Initializing entry view {} {}", entry, compo);
}
public String startVote()
......@@ -110,6 +128,7 @@ public class CompoView extends GenericCDIView {
public String createEntry()
{
compo = votbean.addEntry(getEntry());
return null;
}
......@@ -209,4 +228,12 @@ public class CompoView extends GenericCDIView {
this.voteEntries = voteEntries;
}
public Integer getCompoId() {
return compoId;
}
public void setCompoId(Integer compoId) {
this.compoId = compoId;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!