Commit ccab4169 by Tuomas Riihimäki

Votestuff

1 parent 87dd6924
......@@ -13,13 +13,11 @@ import javax.ejb.Stateless;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.enums.apps.CompoPermission;
import fi.codecrew.moya.facade.CompoEntryFacade;
import fi.codecrew.moya.facade.CompoEntryFileFacade;
import fi.codecrew.moya.facade.CompoFacade;
import fi.codecrew.moya.facade.VoteFacade;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.VotingBeanLocal;
import fi.codecrew.moya.enums.apps.CompoPermission;
import fi.codecrew.moya.model.Compo;
import fi.codecrew.moya.model.CompoEntry;
import fi.codecrew.moya.model.CompoEntryFile;
......@@ -91,7 +89,9 @@ public class VotingBean implements VotingBeanLocal {
CompoPermission.S_MANAGE,
})
public Compo addEntry(CompoEntry entry) {
Compo co = compoFacade.find(entry.getCompo().getId());
Compo co = compoFacade.reload(entry.getCompo());
entry.setCreator(permissionBean.getCurrentUser());
if (co.getCompoEntries() == null) {
co.setCompoEntries(new ArrayList<CompoEntry>());
}
......@@ -105,7 +105,9 @@ public class VotingBean implements VotingBeanLocal {
@Override
public CompoEntry saveEntry(CompoEntry entry) {
return compoEntryFacade.merge(entry);
}
@Override
......@@ -124,6 +126,15 @@ public class VotingBean implements VotingBeanLocal {
}
@Override
public CompoEntry findEntryWithFiles(Integer entryId) {
CompoEntry ret = compoEntryFacade.find(entryId);
logger.debug("Found files {}", ret.getFiles().size());
return ret;
}
@Override
public CompoEntry saveSort(CompoEntry e) {
CompoEntry entry = compoEntryFacade.find(e.getId());
entry.setSort(e.getSort());
......@@ -161,4 +172,5 @@ public class VotingBean implements VotingBeanLocal {
}
return voteEntity;
}
}
......@@ -13,13 +13,13 @@ import javax.persistence.criteria.Root;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.model.GroupMembership_;
import fi.codecrew.moya.model.PlaceGroup_;
import fi.codecrew.moya.model.Place_;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GroupMembership;
import fi.codecrew.moya.model.GroupMembership_;
import fi.codecrew.moya.model.PlaceGroup;
import fi.codecrew.moya.model.PlaceGroup_;
import fi.codecrew.moya.model.Place_;
import fi.codecrew.moya.utilities.PasswordFunctions;
@Stateless
......
......@@ -33,4 +33,6 @@ public interface VotingBeanLocal {
public Vote saveVote(CompoEntry entry, Integer vote);
public CompoEntry findEntryWithFiles(Integer entryId);
}
......@@ -6,6 +6,7 @@
package fi.codecrew.moya.model;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
......@@ -50,11 +51,11 @@ public class Compo extends GenericEntity {
*/
@Column(name = "compo_start")
@Temporal(TemporalType.TIMESTAMP)
private Calendar startTime;
private Date startTime;
@Column(name = "compo_end")
@Temporal(TemporalType.TIMESTAMP)
private Calendar endTime;
private Date endTime;
/**
* When the voting should start
......@@ -63,19 +64,19 @@ public class Compo extends GenericEntity {
*/
@Column(name = "vote_start")
@Temporal(TemporalType.TIMESTAMP)
private Calendar voteStart;
private Date voteStart;
@Column(name = "vote_end")
@Temporal(TemporalType.TIMESTAMP)
private Calendar voteEnd;
private Date voteEnd;
@Column(name = "submit_start")
@Temporal(TemporalType.TIMESTAMP)
private Calendar submitStart;
private Date submitStart;
@Column(name = "submit_end")
@Temporal(TemporalType.TIMESTAMP)
private Calendar submitEnd;
private Date submitEnd;
@Lob
@Column(name = "description")
......@@ -106,6 +107,20 @@ public class Compo extends GenericEntity {
this.holdVoting = holdVoting;
}
public boolean isSubmit()
{
Calendar now = Calendar.getInstance();
return now.after(getSubmitStart()) && now.before(getSubmitEnd());
}
public boolean isVote()
{
Calendar now = Calendar.getInstance();
return !getHoldVoting() &&
now.after(getVoteStart()) &&
now.before(getVoteEnd());
}
public Compo() {
super();
}
......@@ -118,43 +133,43 @@ public class Compo extends GenericEntity {
this.name = compoName;
}
public Calendar getStartTime() {
public Date getStartTime() {
return startTime;
}
public void setStartTime(Calendar compoStart) {
public void setStartTime(Date compoStart) {
this.startTime = compoStart;
}
public Calendar getVoteStart() {
public Date getVoteStart() {
return voteStart;
}
public void setVoteStart(Calendar voteStart) {
public void setVoteStart(Date voteStart) {
this.voteStart = voteStart;
}
public Calendar getVoteEnd() {
public Date getVoteEnd() {
return voteEnd;
}
public void setVoteEnd(Calendar voteEnd) {
public void setVoteEnd(Date voteEnd) {
this.voteEnd = voteEnd;
}
public Calendar getSubmitStart() {
public Date getSubmitStart() {
return submitStart;
}
public void setSubmitStart(Calendar submitStart) {
public void setSubmitStart(Date submitStart) {
this.submitStart = submitStart;
}
public Calendar getSubmitEnd() {
public Date getSubmitEnd() {
return submitEnd;
}
public void setSubmitEnd(Calendar submitEnd) {
public void setSubmitEnd(Date submitEnd) {
this.submitEnd = submitEnd;
}
......@@ -205,11 +220,11 @@ public class Compo extends GenericEntity {
this.event = event;
}
public Calendar getEndTime() {
public Date getEndTime() {
return endTime;
}
public void setEndTime(Calendar endTime) {
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
}
......@@ -76,10 +76,19 @@ public class CompoEntry extends GenericEntity {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entry")
private List<CompoEntryParticipant> participants;
@JoinColumn(name = "creator_eventuser_id", referencedColumnName = EventUser.ID_COLUMN)
@JoinColumn(name = "creator_eventuser_id", referencedColumnName = EventUser.ID_COLUMN, nullable = false)
@ManyToOne
private EventUser creator;
public Integer getVotetotal()
{
int votetotal = 0;
for (Vote v : getVotes()) {
votetotal += v.getScore();
}
return votetotal;
}
public CompoEntry() {
super();
}
......
Manifest-Version: 1.0
Class-Path: lib/MoyaUtilities.jar
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
<glassfish-web-app error-url="">
<context-root>/MoyaWeb</context-root>
<class-loader delegate="true" />
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class java code.</description>
</property>
</jsp-config>
<parameter-encoding default-charset="UTF-8" />
</glassfish-web-app>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
<sun-web-app error-url="">
<context-root>/MoyaWeb2</context-root>
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class java code.</description>
</property>
</jsp-config>
</sun-web-app>
......@@ -6,7 +6,8 @@
</session-config>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
<!-- <param-value>Development</param-value> -->
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
......
......@@ -100,18 +100,7 @@
<f:param name="pagename" value="#{layoutView.pagepath}:bottom" />
</h:link>
<div class="container bottom">
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://jolez.pingtimeout.net/piwik/" : "http://jolez.pingtimeout.net/piwik/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 5);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://jolez.pingtimeout.net/piwik/piwik.php?idsite=5" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->
</div>
</div>
......
......@@ -96,27 +96,25 @@
</h:outputText>
</div>
<br />
<br />
<h:panelGrid columns="2" >
<h:outputLabel value="#{i18n['shop.toAccountValue']}" />
<h:inputText styleClass="inputval" size="5" value="#{productShopView.cash}">
<f:ajax render="@form" event="valueChange" listener="#{productShopView.cashChanged}" />
</h:inputText>
<br />
<h:outputLabel value="#{i18n['shop.cashGiven']}" />
<input id="returnval" type="text" size="5" value="0" disabled="disabled"/>
<h:outputLabel value="#{i18n['shop.cashBack']}" />
<input id="returnval" type="text" size="5" value="0" disabled="disabled"/>
<br />
<h:outputLabel value="#{i18n['shop.']}" />
<h:outputLabel value="#{i18n['shop.afterBalance']}" />
<h:outputText value=" #{productShopView.balanceAfterTransaction}">
<f:convertNumber />
</h:outputText>
<h:commandButton action="#{productShopView.commitShoppingcart()}" value="#{i18n['shop.buy']}" />
</h:panelGrid>
<h:commandButton action="#{productShopView.commitShoppingCart()}" value="#{i18n['shop.buy']}" />
</h:panelGroup>
</h:panelGrid>
......
......@@ -9,7 +9,7 @@
<composite:implementation>
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
<p:dataTable id="user" value="#{userSearchView.results}" var="user">
<p:dataTable id="user" value="#{userSearchView.results}" var="user" >
<p:column>
<f:facet name="header">
<h:link value="#{i18n['user.nick']}" includeViewParams="true">
......@@ -39,9 +39,13 @@
</p:column>
<p:column>
<p:commandButton onClick="location.replace('#{request.contextPath}/useradmin/edit.jsf?userid=#{user.id}')">#{i18n['user.edit']}</p:commandButton>
<p:commandButton id="userinfoBtn" value="Info" type="button" />
<p:overlayPanel for="userinfoBtn">
<h:link outcome="/useradmin/edit" value="#{i18n['user.edit']}">
<f:param name="userid" value="#{user.id}" />
</h:link>
<!-- <p:commandButton onClick="location.replace('#{request.contextPath}/useradmin/edit.jsf?userid=#{user.id}')">#{i18n['user.edit']}</p:commandButton>
<p:overlayPanel for="userinfoBtn">
<h:panelGrid columns="2">
<img style="width:100px;" src="#{request.contextPath}/dydata/userimage/#{user.currentImage.id}.img" alt="image" />
......@@ -57,8 +61,8 @@
</h:panelGroup>
</h:panelGrid>
</p:overlayPanel>
-->
</p:column>
<!-- <h:column>
<h:commandButton action="#{userView.shop()}" value="#{i18n['user.shop']}" />
......
......@@ -3,12 +3,15 @@
<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">
<h:body>
<ui:composition template="/resources/#{sessionHandler.layout}/template.xhtml">
<ui:define name="page">
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:define name="content">
#{sessionHandler.flushCache()}
<h:form>
<h:commandButton action="#{testView.resetMenu()}" value="Reset to newui menu" onclick="return confirm('THIS WILL RESET ALL MODIFICATIONS TO DEFAULT MENU!!\n Are you really sure?!');" />
<h:commandButton action="#{testView.resetOldMenu()}" value="Reset to old menu" onclick="return confirm('THIS WILL RESET ALL MODIFICATIONS TO DEFAULT MENU!!\n Are you really sure?!');" />
</h:form>
</ui:define>
</ui:composition>
</h:body>
......
......@@ -17,7 +17,7 @@
<h1>#{i18n['voting.compoentryadd.title']}</h1>
<p>#{i18n['voting.compoentryadd.description']} #{votingCompoAddEntryView.compoName}</p>
<h:form enctype="multipart/form-data">
<h:form >
<h:panelGrid columns="3">
<h:outputLabel value="#{i18n['voting.compoentryadd.entryname']}" for="name"/>
<h:inputText value="#{votingCompoAddEntryView.name}" id="name" />
......
......@@ -20,14 +20,14 @@
<f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.name']}" />
</f:facet>
<h:outputText value="#{compo.compo.name}" />
<h:outputText value="#{compo.name}" />
</h:column>
<!-- <h:column rendered="#{compoView.curEntries}"> -->
<!-- <f:facet name="header"> -->
<!-- <h:outputText value="#{i18n['voting.allcompos.curEntries']}" /> -->
<!-- </f:facet> -->
<!-- <h:outputText value="#{compo.compoEntries.size()}" /> -->
<!-- <h:outputText value="#{compoEntries.size()}" /> -->
<!-- </h:column> -->
<!-- <h:column rendered="#{compoView.maxParts}"> -->
<!-- <f:facet name="header"> -->
......@@ -39,7 +39,7 @@
<f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.startTime']}" />
</f:facet>
<h:outputText value="#{compo.compo.startTime.time}">
<h:outputText value="#{compo.startTime.time}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</h:column>
......@@ -48,7 +48,7 @@
<f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.voteEnd']}" />
</f:facet>
<h:outputText value="#{compo.compo.voteEnd.time}">
<h:outputText value="#{compo.voteEnd.time}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</h:column>
......@@ -57,7 +57,7 @@
<f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.submitEnd']}" />
</f:facet>
<h:outputText value="#{compo.compo.submitEnd.time}">
<h:outputText value="#{compo.submitEnd.time}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</h:column>
......@@ -70,7 +70,7 @@
</h:column>
<h:column rendered="#{compoView.manage}">
<h:link outcome="details" value="#{i18n['compo.edit']}">
<f:param name="compoId" value="#{compo.compo.id}" />
<f:param name="compoId" value="#{compo.id}" />
</h:link>
</h:column>
</h:dataTable>
......
......@@ -9,7 +9,7 @@
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<!-- f:event type="preRenderView" listener="#{newsListView.initView}" /-->
<f:event type="preRenderView" listener="#{votingCreateView.initCreate}" />
</f:metadata>
<ui:define name="content">
<!-- <h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" /> -->
......@@ -20,42 +20,42 @@
<h:form>
<h:panelGrid columns="3">
<h:outputLabel value="#{i18n['voting.create.name']}:" for="name"/>
<h:inputText value="#{votingCreateView.name}" id="name" />
<h:inputText value="#{votingCreateView.compo.name}" id="name" />
<h:message for="name" />
<h:outputLabel value="#{i18n['voting.create.description']}:" for="desc"/>
<h:inputText value="#{votingCreateView.description}" id="desc" />
<h:inputText value="#{votingCreateView.compo.description}" id="desc" />
<h:message for="desc" />
<h:outputLabel value="#{i18n['voting.create.maxParticipants']}:" for="maxPar" />
<h:inputText value="#{votingCreateView.maxParticipants}" id="maxPar" />
<h:inputText value="#{votingCreateView.compo.maxParticipantCount}" id="maxPar" />
<h:message for="maxPar" />
<h:outputLabel value="#{i18n['voting.create.compoStart']}:" for="cStart" />
<p:calendar validator="#{votingDateValidator.saveCStart}" value="#{votingCreateView.compoStart}" pattern="dd/MM/yyyy HH:mm" id="cStart" />
<p:calendar validator="#{votingDateValidator.saveCStart}" value="#{votingCreateView.compo.startTime}" pattern="dd/MM/yyyy HH:mm" id="cStart" />
<h:message for="cStart" />
<h:outputLabel value="#{i18n['voting.create.compoEnd']}:" for="cEnd"/>
<p:calendar validator="#{votingDateValidator.validateCompo}" value="#{votingCreateView.compoEnd}" pattern="dd/MM/yyyy HH:mm" id="cEnd" />
<p:calendar validator="#{votingDateValidator.validateCompo}" value="#{votingCreateView.compo.endTime}" pattern="dd/MM/yyyy HH:mm" id="cEnd" />
<h:message for="cEnd" />
<h:outputLabel value="#{i18n['voting.create.voteStart']}:" for="vStart" />
<p:calendar validator="#{votingDateValidator.saveVStart}" value="#{votingCreateView.voteStart}" pattern="dd/MM/yyyy HH:mm" id="vStart" />
<p:calendar validator="#{votingDateValidator.saveVStart}" value="#{votingCreateView.compo.voteStart}" pattern="dd/MM/yyyy HH:mm" id="vStart" />
<h:message for="vStart" />
<h:outputLabel value="#{i18n['voting.create.voteEnd']}:" for="vEnd" />
<p:calendar validator="#{votingDateValidator.validateVote}" value="#{votingCreateView.voteEnd}" pattern="dd/MM/yyyy HH:mm" id="vEnd" />
<p:calendar validator="#{votingDateValidator.validateVote}" value="#{votingCreateView.compo.voteEnd}" pattern="dd/MM/yyyy HH:mm" id="vEnd" />
<h:message for="vEnd" />
<h:outputLabel value="#{i18n['voting.create.submitStart']}:" for="sStart" />
<p:calendar validator="#{votingDateValidator.saveSStart}" value="#{votingCreateView.submitStart}" pattern="dd/MM/yyyy HH:mm" id="sStart" />
<p:calendar validator="#{votingDateValidator.saveSStart}" value="#{votingCreateView.compo.submitStart}" pattern="dd/MM/yyyy HH:mm" id="sStart" />
<h:message for="sStart" />
<h:outputLabel value="#{i18n['voting.create.submitEnd']}:" for="sEnd" />
<p:calendar validator="#{votingDateValidator.validateSubmit}" value="#{votingCreateView.submitEnd}" pattern="dd/MM/yyyy HH:mm" id="sEnd" />
<p:calendar validator="#{votingDateValidator.validateSubmit}" value="#{votingCreateView.compo.submitEnd}" pattern="dd/MM/yyyy HH:mm" id="sEnd" />
<h:message for="sEnd" />
<h:commandButton action="#{votingCreateView.send}" value="#{i18n['voting.create.createButton']}" />
<h:commandButton action="#{votingCreateView.create}" value="#{i18n['voting.create.createButton']}" />
</h:panelGrid>
</h:form>
......
......@@ -23,39 +23,39 @@
<f:facet name="header">
<h:outputText value="Title" />
</f:facet>
<h:outputText value="#{entry.entry.title}" />
<h:outputText value="#{entry.title}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Author" />
</f:facet>
<h:outputText value="#{entry.entry.author}" />
<h:outputText value="#{entry.author}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="notes" />
</f:facet>
<h:outputText value="#{entry.entry.notes}" />
<h:outputText value="#{entry.notes}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="screenmessage" />
</f:facet>
<h:outputText value="#{entry.entry.screenMessage}" />
<h:outputText value="#{entry.screenMessage}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="creator" />
</f:facet>
<h:link outcome="/useradmin/edit" value="#{entry.entry.creator.user.nick}">
<f:param name="userid" value="#{entry.entry.creator.user.id}" />
<h:link outcome="/useradmin/edit" value="#{entry.creator.user.nick}">
<f:param name="userid" value="#{entry.creator.user.id}" />
</h:link>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="sort" />
</f:facet>
<h:inputText value="#{entry.entry.sort}" size="4" />
<h:inputText value="#{entry.sort}" size="4" />
</h:column>
<h:column>
<f:facet name="header">
......@@ -67,12 +67,12 @@
<f:facet name="header">
<h:outputText value="Vote count" />
</f:facet>
<h:outputText value="#{entry.entry.votes.size()}" />
<h:outputText value="#{entry.votes.size()}" />
</h:column>
<h:column>
<h:link outcome="/voting/submitEntry" value="#{i18n['entry.edit']}">
<f:param name="entryId" value="#{entry.entry.id}" />
<f:param name="entryId" value="#{entry.id}" />
</h:link>
</h:column>
......
package fi.codecrew.moya;
import java.io.IOException;
import java.util.concurrent.ConcurrentLinkedQueue;
import javax.ejb.EJB;
import javax.faces.context.FacesContext;
......@@ -96,13 +95,16 @@ public class HostnameFilter implements Filter {
BortalLocalContextHolder.setHostname(hostname);
BortalLocalContextHolder.setInDevelopmentMode(developmentMode);
Object hostname_session_id = httpRequest.getSession().getAttribute(HTTP_HOSTNAME_ID);
if (hostname_session_id != null && hostname_session_id instanceof Integer) {
BortalLocalContextHolder.setHostnameId((Integer) hostname_session_id);
} else {
BortalLocalContextHolder.setHostnameId(null);
}
//
// Object hostname_session_id =
// httpRequest.getSession().getAttribute(HTTP_HOSTNAME_ID);
// if (hostname_session_id != null && hostname_session_id instanceof
// Integer) {
// BortalLocalContextHolder.setHostnameId((Integer)
// hostname_session_id);
// } else {
// BortalLocalContextHolder.setHostnameId(null);
// }
if (httpRequest.getUserPrincipal() == null) {
try {
......@@ -117,22 +119,23 @@ public class HostnameFilter implements Filter {
sessionmgmt.updateSessionUser(httpRequest.getSession().getId(), httpRequest.getUserPrincipal().getName());
}
Object trailO = httpRequest.getSession().getAttribute(HTTP_TRAIL_NAME);
ConcurrentLinkedQueue<Object> trail = null;
if (trailO != null && trailO instanceof ConcurrentLinkedQueue)
{
trail = (ConcurrentLinkedQueue<Object>) trailO;
} else {
trail = new ConcurrentLinkedQueue<Object>();
httpRequest.getSession().setAttribute(HTTP_TRAIL_NAME, trail);
}
for (int remove = trail.size() - 10; remove > 0; --remove) {
Object removed = trail.poll();
logger.debug("Removed {} from http trail", removed);
}
if (!httpRequest.getRequestURI().matches(".*(resource).*")) {
trail.add(httpRequest.getRequestURI());
}
// Object trailO =
// httpRequest.getSession().getAttribute(HTTP_TRAIL_NAME);
// ConcurrentLinkedQueue<Object> trail = null;
// if (trailO != null && trailO instanceof ConcurrentLinkedQueue)
// {
// trail = (ConcurrentLinkedQueue<Object>) trailO;
// } else {
// trail = new ConcurrentLinkedQueue<Object>();
// httpRequest.getSession().setAttribute(HTTP_TRAIL_NAME, trail);
// }
// for (int remove = trail.size() - 10; remove > 0; --remove) {
// Object removed = trail.poll();
// logger.debug("Removed {} from http trail", removed);
// }
// if (!httpRequest.getRequestURI().matches(".*(resource).*")) {
// trail.add(httpRequest.getRequestURI());
// }
}
// pass the request along the filter chain
......
......@@ -35,7 +35,7 @@ public class CompoView extends GenericCDIView {
private boolean manage;
private transient ListDataModel<CompoWrapper> compolist;
private transient ListDataModel<Compo> compolist;
@Produces
private CompoEntry entry;
......@@ -50,7 +50,7 @@ public class CompoView extends GenericCDIView {
private transient ListDataModel<EntryWrapper> voteEntries;
public ListDataModel<CompoWrapper> getCompos() {
public ListDataModel<Compo> getCompos() {
return compolist;
}
......@@ -71,7 +71,7 @@ public class CompoView extends GenericCDIView {
public String startVote()
{
compo = compolist.getRowData().getCompo();
compo = compolist.getRowData();
setVoteEntries(EntryWrapper.init(compo.getCompoEntries(), votbean, false));
logger.info("Initializing voting with entries {}, {}", compo.getCompoEntries().size(), voteEntries.getRowCount());
super.beginConversation();
......@@ -101,7 +101,7 @@ public class CompoView extends GenericCDIView {
public String submitEntry()
{
setCompo(compolist.getRowData().getCompo());
setCompo(compolist.getRowData());
setEntry(new CompoEntry());
getEntry().setCompo(getCompo());
......@@ -110,7 +110,7 @@ public class CompoView extends GenericCDIView {
public String createEntry()
{
votbean.addEntry(getEntry());
compo = votbean.addEntry(getEntry());
return null;
}
......@@ -123,6 +123,13 @@ public class CompoView extends GenericCDIView {
public String submitEntryfile()
{
if (getUploadedFile() == null)
{
super.addFaceMessage("compo.fileuploadFailed");
return null;
}
CompoEntryFile cef = new CompoEntryFile(getEntry());
cef.setFileData(this.getUploadedFile().getContents());
logger.info("Got file name {} length {}", getUploadedFile().getFileName(), cef.getFileData().length);
......@@ -142,7 +149,7 @@ public class CompoView extends GenericCDIView {
public void initListView() {
if (requirePermissions(CompoPermission.VIEW_COMPOS) && compolist == null) {
compolist = CompoWrapper.list(votbean.getCompoList());
compolist = new ListDataModel<Compo>(votbean.getCompoList());
setManage(hasPermission(CompoPermission.MANAGE));
logger.info("Permission to view full compo listing.");
super.beginConversation();
......
package fi.codecrew.moya.web.cdiview.voting;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.faces.model.ListDataModel;
import fi.codecrew.moya.model.Compo;
public class CompoWrapper {
private final Compo compo;
public CompoWrapper(Compo c) {
compo = c;
}
public static ListDataModel<CompoWrapper> list(List<Compo> list) {
ArrayList<CompoWrapper> ret = new ArrayList<CompoWrapper>();
for (Compo c : list) {
ret.add(new CompoWrapper(c));
}
return new ListDataModel<CompoWrapper>(ret);
}
public boolean isSubmit()
{
Calendar now = Calendar.getInstance();
return now.after(getCompo().getSubmitStart()) && now.before(getCompo().getSubmitEnd());
}
public boolean isVote()
{
Calendar now = Calendar.getInstance();
return !getCompo().getHoldVoting() &&
now.after(getCompo().getVoteStart()) &&
now.before(getCompo().getVoteEnd());
}
public Compo getCompo() {
return compo;
}
}
package fi.codecrew.moya.web.cdiview.voting;
import java.util.Calendar;
import java.util.Date;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import javax.validation.constraints.Min;
import javax.validation.constraints.Size;
import fi.codecrew.moya.beans.VotingBeanLocal;
import fi.codecrew.moya.model.Compo;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@RequestScoped
@ConversationScoped
public class VotingCreateView extends GenericCDIView {
/**
......@@ -25,122 +20,29 @@ public class VotingCreateView extends GenericCDIView {
@EJB
private transient VotingBeanLocal votbean;
@Size(min = 4, message = "{voting.create.nameError}")
private String name;
private String description;
@Min(value = 1, message = "{voting.create.participantsError}")
private Integer maxParticipants;
private Date compoStart;
private Date compoEnd;
private Date voteStart;
private Date voteEnd;
private Date submitStart;
private Date submitEnd;
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 Integer getMaxParticipants() {
return maxParticipants;
}
public void setMaxParticipants(Integer maxParticipants) {
this.maxParticipants = maxParticipants;
}
public Date getCompoStart() {
return compoStart;
}
private Compo compo;
public void setCompoStart(Date compoStart) {
this.compoStart = compoStart;
public void initCreate()
{
if (super.requirePermissions(fi.codecrew.moya.enums.apps.CompoPermission.MANAGE) && compo == null)
{
compo = new Compo();
super.beginConversation();
}
}
public Date getCompoEnd() {
return compoEnd;
}
public String create() {
public void setCompoEnd(Date compoEnd) {
this.compoEnd = compoEnd;
}
public Date getVoteStart() {
return voteStart;
}
public void setVoteStart(Date voteStart) {
this.voteStart = voteStart;
}
public Date getVoteEnd() {
return voteEnd;
}
public void setVoteEnd(Date voteEnd) {
this.voteEnd = voteEnd;
}
public Date getSubmitStart() {
return submitStart;
}
public void setSubmitStart(Date submitStart) {
this.submitStart = submitStart;
}
public Date getSubmitEnd() {
return submitEnd;
votbean.createCompo(compo);
return "success";
}
public void setSubmitEnd(Date submitEnd) {
this.submitEnd = submitEnd;
public Compo getCompo() {
return compo;
}
public String send() {
Compo co = new Compo();
co.setName(name);
co.setDescription(description);
co.setMaxParticipantCount(maxParticipants);
Calendar ct = Calendar.getInstance();
ct.setTime(compoStart);
co.setStartTime(ct);
Calendar ce = Calendar.getInstance();
ce.setTime(compoEnd);
co.setEndTime(ce);
Calendar vs = Calendar.getInstance();
vs.setTime(voteStart);
co.setVoteStart(vs);
Calendar ve = Calendar.getInstance();
ve.setTime(voteEnd);
co.setVoteEnd(ve);
Calendar ss = Calendar.getInstance();
ss.setTime(submitStart);
co.setSubmitStart(ss);
Calendar se = Calendar.getInstance();
se.setTime(submitEnd);
co.setSubmitEnd(se);
votbean.createCompo(co);
return "success";
public void setCompo(Compo compo) {
this.compo = compo;
}
}
......@@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.VotingBeanLocal;
import fi.codecrew.moya.enums.apps.CompoPermission;
import fi.codecrew.moya.model.Compo;
import fi.codecrew.moya.model.CompoEntry;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
......@@ -30,7 +31,7 @@ public class VotingDetailsView extends GenericCDIView {
private Compo compo;
private transient ListDataModel<EntryWrapper> entries;
private transient ListDataModel<CompoEntry> entries;
@SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(VotingDetailsView.class);
......@@ -41,11 +42,11 @@ public class VotingDetailsView extends GenericCDIView {
public String saveSort()
{
for (EntryWrapper e : entries)
for (CompoEntry e : entries)
{
setCompo(votingBean.saveSort(e.getEntry()).getCompo());
setCompo(votingBean.saveSort(e).getCompo());
}
entries = EntryWrapper.init(getCompo().getCompoEntries(), votingBean, true);
entries = new ListDataModel<CompoEntry>(getCompo().getCompoEntries());
return null;
}
......@@ -54,15 +55,15 @@ public class VotingDetailsView extends GenericCDIView {
this.compoId = compoId;
}
public ListDataModel<EntryWrapper> getEntries() {
public ListDataModel<CompoEntry> getEntries() {
return entries;
}
public void initView() {
if (super.requirePermissions(CompoPermission.MANAGE))
if (super.requirePermissions(CompoPermission.MANAGE) && entries == null)
{
setCompo(votingBean.getCompoById(compoId));
entries = EntryWrapper.init(getCompo().getCompoEntries(), votingBean, true);
entries = new ListDataModel<CompoEntry>(getCompo().getCompoEntries());
super.beginConversation();
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!