Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e812d13a
authored
May 21, 2012
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final stream version
1 parent
3d8d4ac1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
41 deletions
code/LanBortalWeb/WebContent/poll/edit.xhtml
code/LanBortalWeb/WebContent/resources/cditools/poll/edit.xhtml
code/LanBortalWeb/WebContent/voting/details.xhtml
code/LanBortalWeb/WebContent/voting/vote.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/voting/CompoView.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/voting/VoteWrapper.java → code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/voting/EntryWrapper.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/voting/VotingDetailsView.java
code/LanBortalWeb/WebContent/poll/edit.xhtml
View file @
e812d13
<!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']}"
/>
...
...
code/LanBortalWeb/WebContent/resources/cditools/poll/edit.xhtml
View file @
e812d13
...
...
@@ -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>
...
...
code/LanBortalWeb/WebContent/voting/details.xhtml
View file @
e812d13
...
...
@@ -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>
...
...
code/LanBortalWeb/WebContent/voting/vote.xhtml
View file @
e812d13
...
...
@@ -9,7 +9,7 @@
<ui:define
name=
"content"
>
<!-- <h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" /> -->
<h1>
Vote in compo #{
votingDetailsView.compoN
ame}
</h1>
<h1>
Vote in compo #{
compoView.compo.n
ame}
</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>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/voting/CompoView.java
View file @
e812d13
...
...
@@ -48,7 +48,7 @@ public class CompoView extends GenericCDIView {
private
Integer
entryId
;
private
ListDataModel
<
Vote
Wrapper
>
voteEntries
;
private
ListDataModel
<
Entry
Wrapper
>
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
)
{
Vote
Wrapper
row
=
voteEntries
.
getRowData
();
Entry
Wrapper
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
(
Vote
Wrapper
vw
:
voteEntries
)
for
(
Entry
Wrapper
vw
:
voteEntries
)
{
votbean
.
saveVote
(
vw
.
getEntry
(),
vw
.
getVote
());
}
...
...
@@ -193,12 +193,12 @@ public class CompoView extends GenericCDIView {
this
.
entryId
=
entryId
;
}
public
ListDataModel
<
Vote
Wrapper
>
getVoteEntries
()
{
public
ListDataModel
<
Entry
Wrapper
>
getVoteEntries
()
{
logger
.
info
(
"Getting {} entries "
,
voteEntries
.
getRowCount
());
return
voteEntries
;
}
public
void
setVoteEntries
(
ListDataModel
<
Vote
Wrapper
>
voteEntries
)
{
public
void
setVoteEntries
(
ListDataModel
<
Entry
Wrapper
>
voteEntries
)
{
this
.
voteEntries
=
voteEntries
;
}
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/voting/
Vote
Wrapper.java
→
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/voting/
Entry
Wrapper.java
View file @
e812d13
...
...
@@ -13,36 +13,45 @@ import fi.insomnia.bortal.beans.VotingBeanLocal;
import
fi.insomnia.bortal.model.CompoEntry
;
import
fi.insomnia.bortal.model.Vote
;
public
class
Vote
Wrapper
implements
Serializable
{
public
class
Entry
Wrapper
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
(
Vote
Wrapper
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
Entry
Wrapper
.
class
);
public
VoteWrapper
(
CompoEntry
entry
,
Vote
voteEntit
y
)
{
public
EntryWrapper
(
CompoEntry
entry
,
Vote
voteEntity
,
boolean
calcSummar
y
)
{
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
<
Vote
Wrapper
>();
public
static
ListDataModel
<
EntryWrapper
>
init
(
List
<
CompoEntry
>
compoEntries
,
VotingBeanLocal
votbean
,
boolean
calcSummary
)
{
ArrayList
<
EntryWrapper
>
ret
=
new
ArrayList
<
Entry
Wrapper
>();
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
<
Vote
Wrapper
>(
ret
);
return
new
ListDataModel
<
Entry
Wrapper
>(
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
)
{
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/voting/VotingDetailsView.java
View file @
e812d13
...
...
@@ -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
();
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment