Commit ccab4169 by Tuomas Riihimäki

Votestuff

1 parent 87dd6924
...@@ -13,13 +13,11 @@ import javax.ejb.Stateless; ...@@ -13,13 +13,11 @@ import javax.ejb.Stateless;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.codecrew.moya.enums.apps.CompoPermission;
import fi.codecrew.moya.facade.CompoEntryFacade; import fi.codecrew.moya.facade.CompoEntryFacade;
import fi.codecrew.moya.facade.CompoEntryFileFacade; import fi.codecrew.moya.facade.CompoEntryFileFacade;
import fi.codecrew.moya.facade.CompoFacade; import fi.codecrew.moya.facade.CompoFacade;
import fi.codecrew.moya.facade.VoteFacade; 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.Compo;
import fi.codecrew.moya.model.CompoEntry; import fi.codecrew.moya.model.CompoEntry;
import fi.codecrew.moya.model.CompoEntryFile; import fi.codecrew.moya.model.CompoEntryFile;
...@@ -91,7 +89,9 @@ public class VotingBean implements VotingBeanLocal { ...@@ -91,7 +89,9 @@ public class VotingBean implements VotingBeanLocal {
CompoPermission.S_MANAGE, CompoPermission.S_MANAGE,
}) })
public Compo addEntry(CompoEntry entry) { 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) { if (co.getCompoEntries() == null) {
co.setCompoEntries(new ArrayList<CompoEntry>()); co.setCompoEntries(new ArrayList<CompoEntry>());
} }
...@@ -105,7 +105,9 @@ public class VotingBean implements VotingBeanLocal { ...@@ -105,7 +105,9 @@ public class VotingBean implements VotingBeanLocal {
@Override @Override
public CompoEntry saveEntry(CompoEntry entry) { public CompoEntry saveEntry(CompoEntry entry) {
return compoEntryFacade.merge(entry); return compoEntryFacade.merge(entry);
} }
@Override @Override
...@@ -124,6 +126,15 @@ public class VotingBean implements VotingBeanLocal { ...@@ -124,6 +126,15 @@ public class VotingBean implements VotingBeanLocal {
} }
@Override @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) { public CompoEntry saveSort(CompoEntry e) {
CompoEntry entry = compoEntryFacade.find(e.getId()); CompoEntry entry = compoEntryFacade.find(e.getId());
entry.setSort(e.getSort()); entry.setSort(e.getSort());
...@@ -161,4 +172,5 @@ public class VotingBean implements VotingBeanLocal { ...@@ -161,4 +172,5 @@ public class VotingBean implements VotingBeanLocal {
} }
return voteEntity; return voteEntity;
} }
} }
...@@ -13,13 +13,13 @@ import javax.persistence.criteria.Root; ...@@ -13,13 +13,13 @@ import javax.persistence.criteria.Root;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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.beans.EventBeanLocal;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.GroupMembership; 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.PlaceGroup_;
import fi.codecrew.moya.model.Place_;
import fi.codecrew.moya.utilities.PasswordFunctions; import fi.codecrew.moya.utilities.PasswordFunctions;
@Stateless @Stateless
......
...@@ -33,4 +33,6 @@ public interface VotingBeanLocal { ...@@ -33,4 +33,6 @@ public interface VotingBeanLocal {
public Vote saveVote(CompoEntry entry, Integer vote); public Vote saveVote(CompoEntry entry, Integer vote);
public CompoEntry findEntryWithFiles(Integer entryId);
} }
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
package fi.codecrew.moya.model; package fi.codecrew.moya.model;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
...@@ -50,11 +51,11 @@ public class Compo extends GenericEntity { ...@@ -50,11 +51,11 @@ public class Compo extends GenericEntity {
*/ */
@Column(name = "compo_start") @Column(name = "compo_start")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar startTime; private Date startTime;
@Column(name = "compo_end") @Column(name = "compo_end")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar endTime; private Date endTime;
/** /**
* When the voting should start * When the voting should start
...@@ -63,19 +64,19 @@ public class Compo extends GenericEntity { ...@@ -63,19 +64,19 @@ public class Compo extends GenericEntity {
*/ */
@Column(name = "vote_start") @Column(name = "vote_start")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar voteStart; private Date voteStart;
@Column(name = "vote_end") @Column(name = "vote_end")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar voteEnd; private Date voteEnd;
@Column(name = "submit_start") @Column(name = "submit_start")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar submitStart; private Date submitStart;
@Column(name = "submit_end") @Column(name = "submit_end")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar submitEnd; private Date submitEnd;
@Lob @Lob
@Column(name = "description") @Column(name = "description")
...@@ -106,6 +107,20 @@ public class Compo extends GenericEntity { ...@@ -106,6 +107,20 @@ public class Compo extends GenericEntity {
this.holdVoting = holdVoting; 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() { public Compo() {
super(); super();
} }
...@@ -118,43 +133,43 @@ public class Compo extends GenericEntity { ...@@ -118,43 +133,43 @@ public class Compo extends GenericEntity {
this.name = compoName; this.name = compoName;
} }
public Calendar getStartTime() { public Date getStartTime() {
return startTime; return startTime;
} }
public void setStartTime(Calendar compoStart) { public void setStartTime(Date compoStart) {
this.startTime = compoStart; this.startTime = compoStart;
} }
public Calendar getVoteStart() { public Date getVoteStart() {
return voteStart; return voteStart;
} }
public void setVoteStart(Calendar voteStart) { public void setVoteStart(Date voteStart) {
this.voteStart = voteStart; this.voteStart = voteStart;
} }
public Calendar getVoteEnd() { public Date getVoteEnd() {
return voteEnd; return voteEnd;
} }
public void setVoteEnd(Calendar voteEnd) { public void setVoteEnd(Date voteEnd) {
this.voteEnd = voteEnd; this.voteEnd = voteEnd;
} }
public Calendar getSubmitStart() { public Date getSubmitStart() {
return submitStart; return submitStart;
} }
public void setSubmitStart(Calendar submitStart) { public void setSubmitStart(Date submitStart) {
this.submitStart = submitStart; this.submitStart = submitStart;
} }
public Calendar getSubmitEnd() { public Date getSubmitEnd() {
return submitEnd; return submitEnd;
} }
public void setSubmitEnd(Calendar submitEnd) { public void setSubmitEnd(Date submitEnd) {
this.submitEnd = submitEnd; this.submitEnd = submitEnd;
} }
...@@ -205,11 +220,11 @@ public class Compo extends GenericEntity { ...@@ -205,11 +220,11 @@ public class Compo extends GenericEntity {
this.event = event; this.event = event;
} }
public Calendar getEndTime() { public Date getEndTime() {
return endTime; return endTime;
} }
public void setEndTime(Calendar endTime) { public void setEndTime(Date endTime) {
this.endTime = endTime; this.endTime = endTime;
} }
} }
...@@ -76,10 +76,19 @@ public class CompoEntry extends GenericEntity { ...@@ -76,10 +76,19 @@ public class CompoEntry extends GenericEntity {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entry") @OneToMany(cascade = CascadeType.ALL, mappedBy = "entry")
private List<CompoEntryParticipant> participants; 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 @ManyToOne
private EventUser creator; private EventUser creator;
public Integer getVotetotal()
{
int votetotal = 0;
for (Vote v : getVotes()) {
votetotal += v.getScore();
}
return votetotal;
}
public CompoEntry() { public CompoEntry() {
super(); super();
} }
......
Manifest-Version: 1.0 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 @@ ...@@ -6,7 +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>
</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>
......
...@@ -100,18 +100,7 @@ ...@@ -100,18 +100,7 @@
<f:param name="pagename" value="#{layoutView.pagepath}:bottom" /> <f:param name="pagename" value="#{layoutView.pagepath}:bottom" />
</h:link> </h:link>
<div class="container bottom"> <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>
</div> </div>
......
...@@ -96,27 +96,25 @@ ...@@ -96,27 +96,25 @@
</h:outputText> </h:outputText>
</div> </div>
<br />
<br /> <h:panelGrid columns="2" >
<h:outputLabel value="#{i18n['shop.toAccountValue']}" /> <h:outputLabel value="#{i18n['shop.toAccountValue']}" />
<h:inputText styleClass="inputval" size="5" value="#{productShopView.cash}"> <h:inputText styleClass="inputval" size="5" value="#{productShopView.cash}">
<f:ajax render="@form" event="valueChange" listener="#{productShopView.cashChanged}" /> <f:ajax render="@form" event="valueChange" listener="#{productShopView.cashChanged}" />
</h:inputText> </h:inputText>
<br />
<h:outputLabel value="#{i18n['shop.cashGiven']}" /> <h:outputLabel value="#{i18n['shop.cashGiven']}" />
<input id="returnval" type="text" size="5" value="0" disabled="disabled"/> <input id="returnval" type="text" size="5" value="0" disabled="disabled"/>
<h:outputLabel value="#{i18n['shop.cashBack']}" /> <h:outputLabel value="#{i18n['shop.cashBack']}" />
<input id="returnval" type="text" size="5" value="0" disabled="disabled"/> <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}"> <h:outputText value=" #{productShopView.balanceAfterTransaction}">
<f:convertNumber /> <f:convertNumber />
</h:outputText> </h:outputText>
</h:panelGrid>
<h:commandButton action="#{productShopView.commitShoppingcart()}" value="#{i18n['shop.buy']}" /> <h:commandButton action="#{productShopView.commitShoppingCart()}" value="#{i18n['shop.buy']}" />
</h:panelGroup> </h:panelGroup>
</h:panelGrid> </h:panelGrid>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<composite:implementation> <composite:implementation>
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" /> <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> <p:column>
<f:facet name="header"> <f:facet name="header">
<h:link value="#{i18n['user.nick']}" includeViewParams="true"> <h:link value="#{i18n['user.nick']}" includeViewParams="true">
...@@ -39,9 +39,13 @@ ...@@ -39,9 +39,13 @@
</p:column> </p:column>
<p:column> <p:column>
<p:commandButton onClick="location.replace('#{request.contextPath}/useradmin/edit.jsf?userid=#{user.id}')">#{i18n['user.edit']}</p:commandButton> <h:link outcome="/useradmin/edit" value="#{i18n['user.edit']}">
<p:commandButton id="userinfoBtn" value="Info" type="button" /> <f:param name="userid" value="#{user.id}" />
<p:overlayPanel for="userinfoBtn"> </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"> <h:panelGrid columns="2">
<img style="width:100px;" src="#{request.contextPath}/dydata/userimage/#{user.currentImage.id}.img" alt="image" /> <img style="width:100px;" src="#{request.contextPath}/dydata/userimage/#{user.currentImage.id}.img" alt="image" />
...@@ -57,8 +61,8 @@ ...@@ -57,8 +61,8 @@
</h:panelGroup> </h:panelGroup>
</h:panelGrid> </h:panelGrid>
</p:overlayPanel> </p:overlayPanel>
-->
</p:column> </p:column>
<!-- <h:column> <!-- <h:column>
<h:commandButton action="#{userView.shop()}" value="#{i18n['user.shop']}" /> <h:commandButton action="#{userView.shop()}" value="#{i18n['user.shop']}" />
......
...@@ -3,12 +3,15 @@ ...@@ -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" <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:c="http://java.sun.com/jsp/jstl/core">
<h:body> <h:body>
<ui:composition template="/resources/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:define name="page"> <ui:define name="content">
#{sessionHandler.flushCache()} #{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:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<h1>#{i18n['voting.compoentryadd.title']}</h1> <h1>#{i18n['voting.compoentryadd.title']}</h1>
<p>#{i18n['voting.compoentryadd.description']} #{votingCompoAddEntryView.compoName}</p> <p>#{i18n['voting.compoentryadd.description']} #{votingCompoAddEntryView.compoName}</p>
<h:form enctype="multipart/form-data"> <h:form >
<h:panelGrid columns="3"> <h:panelGrid columns="3">
<h:outputLabel value="#{i18n['voting.compoentryadd.entryname']}" for="name"/> <h:outputLabel value="#{i18n['voting.compoentryadd.entryname']}" for="name"/>
<h:inputText value="#{votingCompoAddEntryView.name}" id="name" /> <h:inputText value="#{votingCompoAddEntryView.name}" id="name" />
......
...@@ -20,14 +20,14 @@ ...@@ -20,14 +20,14 @@
<f:facet name="header"> <f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.name']}" /> <h:outputText value="#{i18n['voting.allcompos.name']}" />
</f:facet> </f:facet>
<h:outputText value="#{compo.compo.name}" /> <h:outputText value="#{compo.name}" />
</h:column> </h:column>
<!-- <h:column rendered="#{compoView.curEntries}"> --> <!-- <h:column rendered="#{compoView.curEntries}"> -->
<!-- <f:facet name="header"> --> <!-- <f:facet name="header"> -->
<!-- <h:outputText value="#{i18n['voting.allcompos.curEntries']}" /> --> <!-- <h:outputText value="#{i18n['voting.allcompos.curEntries']}" /> -->
<!-- </f:facet> --> <!-- </f:facet> -->
<!-- <h:outputText value="#{compo.compoEntries.size()}" /> --> <!-- <h:outputText value="#{compoEntries.size()}" /> -->
<!-- </h:column> --> <!-- </h:column> -->
<!-- <h:column rendered="#{compoView.maxParts}"> --> <!-- <h:column rendered="#{compoView.maxParts}"> -->
<!-- <f:facet name="header"> --> <!-- <f:facet name="header"> -->
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<f:facet name="header"> <f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.startTime']}" /> <h:outputText value="#{i18n['voting.allcompos.startTime']}" />
</f:facet> </f:facet>
<h:outputText value="#{compo.compo.startTime.time}"> <h:outputText value="#{compo.startTime.time}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText> </h:outputText>
</h:column> </h:column>
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
<f:facet name="header"> <f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.voteEnd']}" /> <h:outputText value="#{i18n['voting.allcompos.voteEnd']}" />
</f:facet> </f:facet>
<h:outputText value="#{compo.compo.voteEnd.time}"> <h:outputText value="#{compo.voteEnd.time}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText> </h:outputText>
</h:column> </h:column>
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<f:facet name="header"> <f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.submitEnd']}" /> <h:outputText value="#{i18n['voting.allcompos.submitEnd']}" />
</f:facet> </f:facet>
<h:outputText value="#{compo.compo.submitEnd.time}"> <h:outputText value="#{compo.submitEnd.time}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText> </h:outputText>
</h:column> </h:column>
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
</h:column> </h:column>
<h:column rendered="#{compoView.manage}"> <h:column rendered="#{compoView.manage}">
<h:link outcome="details" value="#{i18n['compo.edit']}"> <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:link>
</h:column> </h:column>
</h:dataTable> </h:dataTable>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<h:body> <h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata> <f:metadata>
<!-- f:event type="preRenderView" listener="#{newsListView.initView}" /--> <f:event type="preRenderView" listener="#{votingCreateView.initCreate}" />
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<!-- <h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" /> --> <!-- <h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" /> -->
...@@ -20,42 +20,42 @@ ...@@ -20,42 +20,42 @@
<h:form> <h:form>
<h:panelGrid columns="3"> <h:panelGrid columns="3">
<h:outputLabel value="#{i18n['voting.create.name']}:" for="name"/> <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:message for="name" />
<h:outputLabel value="#{i18n['voting.create.description']}:" for="desc"/> <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:message for="desc" />
<h:outputLabel value="#{i18n['voting.create.maxParticipants']}:" for="maxPar" /> <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:message for="maxPar" />
<h:outputLabel value="#{i18n['voting.create.compoStart']}:" for="cStart" /> <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:message for="cStart" />
<h:outputLabel value="#{i18n['voting.create.compoEnd']}:" for="cEnd"/> <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:message for="cEnd" />
<h:outputLabel value="#{i18n['voting.create.voteStart']}:" for="vStart" /> <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:message for="vStart" />
<h:outputLabel value="#{i18n['voting.create.voteEnd']}:" for="vEnd" /> <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:message for="vEnd" />
<h:outputLabel value="#{i18n['voting.create.submitStart']}:" for="sStart" /> <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:message for="sStart" />
<h:outputLabel value="#{i18n['voting.create.submitEnd']}:" for="sEnd" /> <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: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:panelGrid>
</h:form> </h:form>
......
...@@ -23,39 +23,39 @@ ...@@ -23,39 +23,39 @@
<f:facet name="header"> <f:facet name="header">
<h:outputText value="Title" /> <h:outputText value="Title" />
</f:facet> </f:facet>
<h:outputText value="#{entry.entry.title}" /> <h:outputText value="#{entry.title}" />
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="Author" /> <h:outputText value="Author" />
</f:facet> </f:facet>
<h:outputText value="#{entry.entry.author}" /> <h:outputText value="#{entry.author}" />
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="notes" /> <h:outputText value="notes" />
</f:facet> </f:facet>
<h:outputText value="#{entry.entry.notes}" /> <h:outputText value="#{entry.notes}" />
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="screenmessage" /> <h:outputText value="screenmessage" />
</f:facet> </f:facet>
<h:outputText value="#{entry.entry.screenMessage}" /> <h:outputText value="#{entry.screenMessage}" />
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="creator" /> <h:outputText value="creator" />
</f:facet> </f:facet>
<h:link outcome="/useradmin/edit" value="#{entry.entry.creator.user.nick}"> <h:link outcome="/useradmin/edit" value="#{entry.creator.user.nick}">
<f:param name="userid" value="#{entry.entry.creator.user.id}" /> <f:param name="userid" value="#{entry.creator.user.id}" />
</h:link> </h:link>
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="sort" /> <h:outputText value="sort" />
</f:facet> </f:facet>
<h:inputText value="#{entry.entry.sort}" size="4" /> <h:inputText value="#{entry.sort}" size="4" />
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
...@@ -67,12 +67,12 @@ ...@@ -67,12 +67,12 @@
<f:facet name="header"> <f:facet name="header">
<h:outputText value="Vote count" /> <h:outputText value="Vote count" />
</f:facet> </f:facet>
<h:outputText value="#{entry.entry.votes.size()}" /> <h:outputText value="#{entry.votes.size()}" />
</h:column> </h:column>
<h:column> <h:column>
<h:link outcome="/voting/submitEntry" value="#{i18n['entry.edit']}"> <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:link>
</h:column> </h:column>
......
package fi.codecrew.moya; package fi.codecrew.moya;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.ConcurrentLinkedQueue;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
...@@ -96,13 +95,16 @@ public class HostnameFilter implements Filter { ...@@ -96,13 +95,16 @@ public class HostnameFilter implements Filter {
BortalLocalContextHolder.setHostname(hostname); BortalLocalContextHolder.setHostname(hostname);
BortalLocalContextHolder.setInDevelopmentMode(developmentMode); BortalLocalContextHolder.setInDevelopmentMode(developmentMode);
//
Object hostname_session_id = httpRequest.getSession().getAttribute(HTTP_HOSTNAME_ID); // Object hostname_session_id =
if (hostname_session_id != null && hostname_session_id instanceof Integer) { // httpRequest.getSession().getAttribute(HTTP_HOSTNAME_ID);
BortalLocalContextHolder.setHostnameId((Integer) hostname_session_id); // if (hostname_session_id != null && hostname_session_id instanceof
} else { // Integer) {
BortalLocalContextHolder.setHostnameId(null); // BortalLocalContextHolder.setHostnameId((Integer)
} // hostname_session_id);
// } else {
// BortalLocalContextHolder.setHostnameId(null);
// }
if (httpRequest.getUserPrincipal() == null) { if (httpRequest.getUserPrincipal() == null) {
try { try {
...@@ -117,22 +119,23 @@ public class HostnameFilter implements Filter { ...@@ -117,22 +119,23 @@ public class HostnameFilter implements Filter {
sessionmgmt.updateSessionUser(httpRequest.getSession().getId(), httpRequest.getUserPrincipal().getName()); sessionmgmt.updateSessionUser(httpRequest.getSession().getId(), httpRequest.getUserPrincipal().getName());
} }
Object trailO = httpRequest.getSession().getAttribute(HTTP_TRAIL_NAME); // Object trailO =
ConcurrentLinkedQueue<Object> trail = null; // httpRequest.getSession().getAttribute(HTTP_TRAIL_NAME);
if (trailO != null && trailO instanceof ConcurrentLinkedQueue) // ConcurrentLinkedQueue<Object> trail = null;
{ // if (trailO != null && trailO instanceof ConcurrentLinkedQueue)
trail = (ConcurrentLinkedQueue<Object>) trailO; // {
} else { // trail = (ConcurrentLinkedQueue<Object>) trailO;
trail = new ConcurrentLinkedQueue<Object>(); // } else {
httpRequest.getSession().setAttribute(HTTP_TRAIL_NAME, trail); // trail = new ConcurrentLinkedQueue<Object>();
} // httpRequest.getSession().setAttribute(HTTP_TRAIL_NAME, trail);
for (int remove = trail.size() - 10; remove > 0; --remove) { // }
Object removed = trail.poll(); // for (int remove = trail.size() - 10; remove > 0; --remove) {
logger.debug("Removed {} from http trail", removed); // Object removed = trail.poll();
} // logger.debug("Removed {} from http trail", removed);
if (!httpRequest.getRequestURI().matches(".*(resource).*")) { // }
trail.add(httpRequest.getRequestURI()); // if (!httpRequest.getRequestURI().matches(".*(resource).*")) {
} // trail.add(httpRequest.getRequestURI());
// }
} }
// pass the request along the filter chain // pass the request along the filter chain
......
...@@ -35,7 +35,7 @@ public class CompoView extends GenericCDIView { ...@@ -35,7 +35,7 @@ public class CompoView extends GenericCDIView {
private boolean manage; private boolean manage;
private transient ListDataModel<CompoWrapper> compolist; private transient ListDataModel<Compo> compolist;
@Produces @Produces
private CompoEntry entry; private CompoEntry entry;
...@@ -50,7 +50,7 @@ public class CompoView extends GenericCDIView { ...@@ -50,7 +50,7 @@ public class CompoView extends GenericCDIView {
private transient ListDataModel<EntryWrapper> voteEntries; private transient ListDataModel<EntryWrapper> voteEntries;
public ListDataModel<CompoWrapper> getCompos() { public ListDataModel<Compo> getCompos() {
return compolist; return compolist;
} }
...@@ -71,7 +71,7 @@ public class CompoView extends GenericCDIView { ...@@ -71,7 +71,7 @@ public class CompoView extends GenericCDIView {
public String startVote() public String startVote()
{ {
compo = compolist.getRowData().getCompo(); compo = compolist.getRowData();
setVoteEntries(EntryWrapper.init(compo.getCompoEntries(), votbean, false)); setVoteEntries(EntryWrapper.init(compo.getCompoEntries(), votbean, false));
logger.info("Initializing voting with entries {}, {}", compo.getCompoEntries().size(), voteEntries.getRowCount()); logger.info("Initializing voting with entries {}, {}", compo.getCompoEntries().size(), voteEntries.getRowCount());
super.beginConversation(); super.beginConversation();
...@@ -101,7 +101,7 @@ public class CompoView extends GenericCDIView { ...@@ -101,7 +101,7 @@ public class CompoView extends GenericCDIView {
public String submitEntry() public String submitEntry()
{ {
setCompo(compolist.getRowData().getCompo()); setCompo(compolist.getRowData());
setEntry(new CompoEntry()); setEntry(new CompoEntry());
getEntry().setCompo(getCompo()); getEntry().setCompo(getCompo());
...@@ -110,7 +110,7 @@ public class CompoView extends GenericCDIView { ...@@ -110,7 +110,7 @@ public class CompoView extends GenericCDIView {
public String createEntry() public String createEntry()
{ {
votbean.addEntry(getEntry()); compo = votbean.addEntry(getEntry());
return null; return null;
} }
...@@ -123,6 +123,13 @@ public class CompoView extends GenericCDIView { ...@@ -123,6 +123,13 @@ public class CompoView extends GenericCDIView {
public String submitEntryfile() public String submitEntryfile()
{ {
if (getUploadedFile() == null)
{
super.addFaceMessage("compo.fileuploadFailed");
return null;
}
CompoEntryFile cef = new CompoEntryFile(getEntry()); CompoEntryFile cef = new CompoEntryFile(getEntry());
cef.setFileData(this.getUploadedFile().getContents()); cef.setFileData(this.getUploadedFile().getContents());
logger.info("Got file name {} length {}", getUploadedFile().getFileName(), cef.getFileData().length); logger.info("Got file name {} length {}", getUploadedFile().getFileName(), cef.getFileData().length);
...@@ -142,7 +149,7 @@ public class CompoView extends GenericCDIView { ...@@ -142,7 +149,7 @@ public class CompoView extends GenericCDIView {
public void initListView() { public void initListView() {
if (requirePermissions(CompoPermission.VIEW_COMPOS) && compolist == null) { if (requirePermissions(CompoPermission.VIEW_COMPOS) && compolist == null) {
compolist = CompoWrapper.list(votbean.getCompoList()); compolist = new ListDataModel<Compo>(votbean.getCompoList());
setManage(hasPermission(CompoPermission.MANAGE)); setManage(hasPermission(CompoPermission.MANAGE));
logger.info("Permission to view full compo listing."); logger.info("Permission to view full compo listing.");
super.beginConversation(); 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; package fi.codecrew.moya.web.cdiview.voting;
import java.util.Calendar;
import java.util.Date;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.ConversationScoped;
import javax.inject.Named; import javax.inject.Named;
import javax.validation.constraints.Min;
import javax.validation.constraints.Size;
import fi.codecrew.moya.beans.VotingBeanLocal; import fi.codecrew.moya.beans.VotingBeanLocal;
import fi.codecrew.moya.model.Compo; import fi.codecrew.moya.model.Compo;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named @Named
@RequestScoped @ConversationScoped
public class VotingCreateView extends GenericCDIView { public class VotingCreateView extends GenericCDIView {
/** /**
...@@ -25,122 +20,29 @@ public class VotingCreateView extends GenericCDIView { ...@@ -25,122 +20,29 @@ public class VotingCreateView extends GenericCDIView {
@EJB @EJB
private transient VotingBeanLocal votbean; private transient VotingBeanLocal votbean;
@Size(min = 4, message = "{voting.create.nameError}") private Compo compo;
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;
}
public void setCompoStart(Date compoStart) { public void initCreate()
this.compoStart = compoStart; {
if (super.requirePermissions(fi.codecrew.moya.enums.apps.CompoPermission.MANAGE) && compo == null)
{
compo = new Compo();
super.beginConversation();
}
} }
public Date getCompoEnd() { public String create() {
return compoEnd;
}
public void setCompoEnd(Date compoEnd) { votbean.createCompo(compo);
this.compoEnd = compoEnd; return "success";
}
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;
} }
public void setSubmitEnd(Date submitEnd) { public Compo getCompo() {
this.submitEnd = submitEnd; return compo;
} }
public String send() { public void setCompo(Compo compo) {
Compo co = new Compo(); this.compo = 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";
} }
} }
...@@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; ...@@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.VotingBeanLocal; import fi.codecrew.moya.beans.VotingBeanLocal;
import fi.codecrew.moya.enums.apps.CompoPermission; import fi.codecrew.moya.enums.apps.CompoPermission;
import fi.codecrew.moya.model.Compo; import fi.codecrew.moya.model.Compo;
import fi.codecrew.moya.model.CompoEntry;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named @Named
...@@ -30,7 +31,7 @@ public class VotingDetailsView extends GenericCDIView { ...@@ -30,7 +31,7 @@ public class VotingDetailsView extends GenericCDIView {
private Compo compo; private Compo compo;
private transient ListDataModel<EntryWrapper> entries; private transient ListDataModel<CompoEntry> entries;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(VotingDetailsView.class); private static final Logger logger = LoggerFactory.getLogger(VotingDetailsView.class);
...@@ -41,11 +42,11 @@ public class VotingDetailsView extends GenericCDIView { ...@@ -41,11 +42,11 @@ public class VotingDetailsView extends GenericCDIView {
public String saveSort() 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; return null;
} }
...@@ -54,15 +55,15 @@ public class VotingDetailsView extends GenericCDIView { ...@@ -54,15 +55,15 @@ public class VotingDetailsView extends GenericCDIView {
this.compoId = compoId; this.compoId = compoId;
} }
public ListDataModel<EntryWrapper> getEntries() { public ListDataModel<CompoEntry> getEntries() {
return entries; return entries;
} }
public void initView() { public void initView() {
if (super.requirePermissions(CompoPermission.MANAGE)) if (super.requirePermissions(CompoPermission.MANAGE) && entries == null)
{ {
setCompo(votingBean.getCompoById(compoId)); setCompo(votingBean.getCompoById(compoId));
entries = EntryWrapper.init(getCompo().getCompoEntries(), votingBean, true); entries = new ListDataModel<CompoEntry>(getCompo().getCompoEntries());
super.beginConversation(); super.beginConversation();
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!