Commit e812d13a by Tuomas Riihimäki

Final stream version

1 parent 3d8d4ac1
<!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:poll="http://java.sun.com/jsf/composite/cditools/poll" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui"
>
<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:poll="http://java.sun.com/jsf/composite/cditools/poll" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{pollView.initCreate}" />
<f:viewParam name="pollid" value="#{pollView.pollId}" />
<f:event type="preRenderView" listener="#{pollView.initPoll}" />
</f:metadata>
<ui:param name="thispage" value="page.user.edit" />
<ui:define name="content">
<poll:edit commitaction="#{pollView.savePollEntity()}" commitvalue="#{i18n['poll.save']}" />
......
......@@ -31,9 +31,10 @@
<p:calendar id="end" value="#{pollView.poll.end}" style="simple" pattern="#{sessionHandler.datetimeFormat}" />
<h:message for="end" />
<h:outputLabel for="description" value="#{i18n['poll.name']}" />
<h:inputTextarea id="description" name="#{pollView.poll.name}" />
<h:outputLabel for="description" value="#{i18n['poll.description']}" />
<h:inputTextarea id="description" name="#{pollView.poll.description}" />
<h:message for="description" />
</h:panelGrid>
<h:commandButton id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" />
</h:form>
......
......@@ -23,42 +23,56 @@
<f:facet name="header">
<h:outputText value="Title" />
</f:facet>
<h:outputText value="#{entry.title}" />
<h:outputText value="#{entry.entry.title}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Author" />
</f:facet>
<h:outputText value="#{entry.author}" />
<h:outputText value="#{entry.entry.author}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="notes" />
</f:facet>
<h:outputText value="#{entry.notes}" />
<h:outputText value="#{entry.entry.notes}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="screenmessage" />
</f:facet>
<h:outputText value="#{entry.screenMessage}" />
<h:outputText value="#{entry.entry.screenMessage}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="creator" />
</f:facet>
<h:outputText value="#{entry.creator.user.wholeName} / #{entry.creator.nick}" />
<h:link outcome="/useradmin/edit" value="#{entry.entry.creator.user.nick}">
<f:param name="userid" value="#{entry.entry.creator.user.id}" />
</h:link>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="sort" />
</f:facet>
<h:inputText value="#{entry.sort}" />
<h:inputText value="#{entry.entry.sort}" size="4" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Vote total" />
</f:facet>
<h:outputText value="#{entry.votetotal}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Vote count" />
</f:facet>
<h:outputText value="#{entry.entry.votes.size()}" />
</h:column>
<h:column>
<h:link outcome="/voting/submitEntry" value="#{i18n['entry.edit']}">
<f:param name="entryId" value="#{entry.id}" />
<f:param name="entryId" value="#{entry.entry.id}" />
</h:link>
</h:column>
......
......@@ -9,7 +9,7 @@
<ui:define name="content">
<!-- <h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" /> -->
<h1>Vote in compo #{votingDetailsView.compoName}</h1>
<h1>Vote in compo #{compoView.compo.name}</h1>
<h:form id="voteform">
......@@ -39,7 +39,7 @@
</h:column>
</h:dataTable>
<h:commandButton action="#{compoView.saveVotes}" value="#{i18n['compo.saveVotes']}" />
<!-- <h:commandButton action="#{compoView.saveVotes}" value="#{i18n['compo.saveVotes']}" /> -->
</h:form>
......
......@@ -48,7 +48,7 @@ public class CompoView extends GenericCDIView {
private Integer entryId;
private ListDataModel<VoteWrapper> voteEntries;
private ListDataModel<EntryWrapper> voteEntries;
public ListDataModel<CompoWrapper> getCompos() {
return compolist;
......@@ -72,7 +72,7 @@ public class CompoView extends GenericCDIView {
public String startVote()
{
compo = compolist.getRowData().getCompo();
setVoteEntries(VoteWrapper.init(compo.getCompoEntries(), votbean));
setVoteEntries(EntryWrapper.init(compo.getCompoEntries(), votbean, false));
logger.info("Initializing voting with entries {}, {}", compo.getCompoEntries().size(), voteEntries.getRowCount());
super.beginConversation();
return "/voting/vote";
......@@ -80,7 +80,7 @@ public class CompoView extends GenericCDIView {
public void handleVoteRate(RateEvent rateEvent)
{
VoteWrapper row = voteEntries.getRowData();
EntryWrapper row = voteEntries.getRowData();
Integer vote = (Integer) rateEvent.getRating() - 3;
if (vote < -2 || vote > 2)
{
......@@ -91,7 +91,7 @@ public class CompoView extends GenericCDIView {
}
public String saveVotes() {
for (VoteWrapper vw : voteEntries)
for (EntryWrapper vw : voteEntries)
{
votbean.saveVote(vw.getEntry(), vw.getVote());
}
......@@ -193,12 +193,12 @@ public class CompoView extends GenericCDIView {
this.entryId = entryId;
}
public ListDataModel<VoteWrapper> getVoteEntries() {
public ListDataModel<EntryWrapper> getVoteEntries() {
logger.info("Getting {} entries ", voteEntries.getRowCount());
return voteEntries;
}
public void setVoteEntries(ListDataModel<VoteWrapper> voteEntries) {
public void setVoteEntries(ListDataModel<EntryWrapper> voteEntries) {
this.voteEntries = voteEntries;
}
......
......@@ -13,36 +13,45 @@ import fi.insomnia.bortal.beans.VotingBeanLocal;
import fi.insomnia.bortal.model.CompoEntry;
import fi.insomnia.bortal.model.Vote;
public class VoteWrapper implements Serializable {
public class EntryWrapper implements Serializable {
/**
*
*/
private static final long serialVersionUID = -8261328741517788115L;
private Integer votetotal;
private final CompoEntry entry;
private Integer vote = 0;
private static final Logger logger = LoggerFactory.getLogger(VoteWrapper.class);
private static final Logger logger = LoggerFactory.getLogger(EntryWrapper.class);
public VoteWrapper(CompoEntry entry, Vote voteEntity) {
public EntryWrapper(CompoEntry entry, Vote voteEntity, boolean calcSummary) {
this.entry = entry;
if (voteEntity != null)
{
vote = voteEntity.getScore();
}
if (calcSummary) {
votetotal = 0;
for (Vote v : entry.getVotes()) {
votetotal += v.getScore();
}
}
}
public static ListDataModel<VoteWrapper> init(List<CompoEntry> compoEntries, VotingBeanLocal votbean) {
ArrayList<VoteWrapper> ret = new ArrayList<VoteWrapper>();
public static ListDataModel<EntryWrapper> init(List<CompoEntry> compoEntries, VotingBeanLocal votbean, boolean calcSummary) {
ArrayList<EntryWrapper> ret = new ArrayList<EntryWrapper>();
for (CompoEntry entry : compoEntries)
{
if (entry.getSort() != null && entry.getSort() > 0)
{
Vote voteEntity = votbean.saveVote(entry, null);
ret.add(new VoteWrapper(entry, voteEntity));
EntryWrapper wrap = new EntryWrapper(entry, voteEntity, calcSummary);
ret.add(wrap);
}
}
return new ListDataModel<VoteWrapper>(ret);
return new ListDataModel<EntryWrapper>(ret);
}
public CompoEntry getEntry() {
......@@ -61,12 +70,17 @@ public class VoteWrapper implements Serializable {
}
}
public int getRatingVote()
public Integer getVotetotal()
{
return votetotal;
}
public Integer getRatingVote()
{
return vote + 3;
}
public void setRatingVote(int vot)
public void setRatingVote(Integer vot)
{
if (vot < 1 || vot > 5)
{
......
......@@ -11,7 +11,6 @@ import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.VotingBeanLocal;
import fi.insomnia.bortal.enums.apps.CompoPermission;
import fi.insomnia.bortal.model.Compo;
import fi.insomnia.bortal.model.CompoEntry;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
......@@ -31,7 +30,7 @@ public class VotingDetailsView extends GenericCDIView {
private Compo compo;
private ListDataModel<CompoEntry> entries;
private ListDataModel<EntryWrapper> entries;
private static final Logger logger = LoggerFactory.getLogger(VotingDetailsView.class);
......@@ -41,11 +40,11 @@ public class VotingDetailsView extends GenericCDIView {
public String saveSort()
{
for (CompoEntry e : entries)
for (EntryWrapper e : entries)
{
setCompo(votingBean.saveSort(e).getCompo());
setCompo(votingBean.saveSort(e.getEntry()).getCompo());
}
entries = new ListDataModel<CompoEntry>(getCompo().getCompoEntries());
entries = EntryWrapper.init(getCompo().getCompoEntries(), votingBean, true);
return null;
}
......@@ -54,7 +53,7 @@ public class VotingDetailsView extends GenericCDIView {
this.compoId = compoId;
}
public ListDataModel<CompoEntry> getEntries() {
public ListDataModel<EntryWrapper> getEntries() {
return entries;
}
......@@ -62,7 +61,7 @@ public class VotingDetailsView extends GenericCDIView {
if (super.requirePermissions(CompoPermission.MANAGE))
{
setCompo(votingBean.getCompoById(compoId));
entries = new ListDataModel<CompoEntry>(getCompo().getCompoEntries());
entries = EntryWrapper.init(getCompo().getCompoEntries(), votingBean, true);
super.beginConversation();
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!