Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Max Mecklin
/
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 3d8d4ac1
authored
May 20, 2012
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compo voting, muokkaus, ym
1 parent
a339c322
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
321 additions
and
90 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/TestDataBean.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/VotingBean.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/VoteFacade.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/VotingBeanLocal.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/CompoEntry.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/EventUser.java
code/LanBortalWeb/WebContent/resources/script/hidecancel.js
code/LanBortalWeb/WebContent/resources/style/insomnia2/css/tyyli.css
code/LanBortalWeb/WebContent/resources/style/rating.css
code/LanBortalWeb/WebContent/voting/compolist.xhtml
code/LanBortalWeb/WebContent/voting/details.xhtml
code/LanBortalWeb/WebContent/voting/myEntries.xhtml
code/LanBortalWeb/WebContent/voting/submitEntry.xhtml
code/LanBortalWeb/WebContent/voting/vote.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/resources/i18n_en.properties
code/LanBortalWeb/src/fi/insomnia/bortal/resources/i18n_fi.properties
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/voting/CompoFileDownloadView.java
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/VotingCompoAddEntryView.java
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/voting/VotingDetailsView.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/TestDataBean.java
View file @
3d8d4ac
...
...
@@ -294,13 +294,13 @@ public class TestDataBean implements TestDataBeanLocal {
CompoEntry
compoEntry1
=
new
CompoEntry
();
compoEntry1
.
setCompo
(
compo
);
compoEntry1
.
setCreated
(
Calendar
.
getInstance
());
compoEntry1
.
set
Nam
e
(
"Test entry for test compo"
);
compoEntry1
.
set
Titl
e
(
"Test entry for test compo"
);
compoEntryFacade
.
create
(
compoEntry1
);
CompoEntry
compoEntry2
=
new
CompoEntry
();
compoEntry2
.
setCompo
(
compo
);
compoEntry2
.
setCreated
(
Calendar
.
getInstance
());
compoEntry2
.
set
Nam
e
(
"Another test entry for test compo"
);
compoEntry2
.
set
Titl
e
(
"Another test entry for test compo"
);
compoEntryFacade
.
create
(
compoEntry2
);
}
...
...
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/VotingBean.java
View file @
3d8d4ac
...
...
@@ -10,6 +10,9 @@ import javax.ejb.EJB;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.insomnia.bortal.enums.apps.CompoPermission
;
import
fi.insomnia.bortal.facade.CompoEntryFacade
;
import
fi.insomnia.bortal.facade.CompoEntryFileFacade
;
...
...
@@ -18,6 +21,7 @@ import fi.insomnia.bortal.facade.VoteFacade;
import
fi.insomnia.bortal.model.Compo
;
import
fi.insomnia.bortal.model.CompoEntry
;
import
fi.insomnia.bortal.model.CompoEntryFile
;
import
fi.insomnia.bortal.model.EventUser
;
import
fi.insomnia.bortal.model.Vote
;
/**
...
...
@@ -42,6 +46,7 @@ public class VotingBean implements VotingBeanLocal {
private
EventBean
eventBean
;
@EJB
private
PermissionBeanLocal
permissionBean
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
VotingBean
.
class
);
/**
* Default constructor.
...
...
@@ -116,4 +121,42 @@ public class VotingBean implements VotingBeanLocal {
return
compoEntryFacade
.
find
(
entryId
);
}
@Override
public
CompoEntry
saveSort
(
CompoEntry
e
)
{
CompoEntry
entry
=
compoEntryFacade
.
find
(
e
.
getId
());
entry
.
setSort
(
e
.
getSort
());
return
entry
;
}
@Override
public
Vote
saveVote
(
CompoEntry
entry
,
Integer
vote
)
{
entry
=
compoEntryFacade
.
find
(
entry
.
getId
());
EventUser
user
=
permissionBean
.
getCurrentUser
();
Vote
voteEntity
=
voteFacade
.
find
(
entry
,
user
);
if
(
vote
!=
null
)
{
if
(
voteEntity
==
null
)
{
voteEntity
=
new
Vote
();
if
(
user
.
getVotes
()
==
null
)
{
user
.
setVotes
(
new
ArrayList
<
Vote
>());
}
if
(
entry
.
getVotes
()
==
null
)
{
entry
.
setVotes
(
new
ArrayList
<
Vote
>());
}
voteEntity
.
setVoter
(
user
);
user
.
getVotes
().
add
(
voteEntity
);
voteEntity
.
setCompoEntry
(
entry
);
entry
.
getVotes
().
add
(
voteEntity
);
voteFacade
.
create
(
voteEntity
);
}
voteEntity
.
setScore
(
vote
);
logger
.
info
(
"Setting vote to {} on {}"
,
vote
,
voteEntity
);
voteEntity
.
setTime
(
Calendar
.
getInstance
());
}
return
voteEntity
;
}
}
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/VoteFacade.java
View file @
3d8d4ac
...
...
@@ -2,8 +2,14 @@ package fi.insomnia.bortal.facade;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Root
;
import
fi.insomnia.bortal.model.CompoEntry
;
import
fi.insomnia.bortal.model.EventUser
;
import
fi.insomnia.bortal.model.Vote
;
import
fi.insomnia.bortal.model.Vote_
;
@Stateless
@LocalBean
...
...
@@ -13,4 +19,14 @@ public class VoteFacade extends IntegerPkGenericFacade<Vote> {
super
(
Vote
.
class
);
}
public
Vote
find
(
CompoEntry
entry
,
EventUser
user
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
Vote
>
cq
=
cb
.
createQuery
(
Vote
.
class
);
Root
<
Vote
>
root
=
cq
.
from
(
Vote
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
Vote_
.
voter
),
user
),
cb
.
equal
(
root
.
get
(
Vote_
.
compoEntry
),
entry
)
);
return
super
.
getSingleNullableResult
(
getEm
().
createQuery
(
cq
));
}
}
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/VotingBeanLocal.java
View file @
3d8d4ac
...
...
@@ -7,6 +7,7 @@ import javax.ejb.Local;
import
fi.insomnia.bortal.model.Compo
;
import
fi.insomnia.bortal.model.CompoEntry
;
import
fi.insomnia.bortal.model.CompoEntryFile
;
import
fi.insomnia.bortal.model.Vote
;
@Local
public
interface
VotingBeanLocal
{
...
...
@@ -28,4 +29,8 @@ public interface VotingBeanLocal {
public
CompoEntry
findEntry
(
Integer
entryId
);
public
CompoEntry
saveSort
(
CompoEntry
e
);
public
Vote
saveVote
(
CompoEntry
entry
,
Integer
vote
);
}
code/LanBortalDatabase/src/fi/insomnia/bortal/model/CompoEntry.java
View file @
3d8d4ac
...
...
@@ -42,8 +42,11 @@ public class CompoEntry extends GenericEntity {
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Calendar
created
=
Calendar
.
getInstance
();
@Column
(
name
=
"entry_name"
,
nullable
=
false
)
private
String
name
;
@Column
(
name
=
"title"
,
nullable
=
false
)
private
String
title
;
@Column
(
name
=
"author"
)
private
String
author
;
@Lob
@Column
(
name
=
"notes"
)
...
...
@@ -89,14 +92,6 @@ public class CompoEntry extends GenericEntity {
this
.
created
=
entryCreated
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
entryName
)
{
this
.
name
=
entryName
;
}
public
String
getNotes
()
{
return
notes
;
}
...
...
@@ -178,4 +173,20 @@ public class CompoEntry extends GenericEntity {
return
currentFile
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getAuthor
()
{
return
author
;
}
public
void
setAuthor
(
String
author
)
{
this
.
author
=
author
;
}
}
code/LanBortalDatabase/src/fi/insomnia/bortal/model/EventUser.java
View file @
3d8d4ac
...
...
@@ -44,7 +44,7 @@ public class EventUser extends GenericEntity implements IUser {
private
static
final
long
serialVersionUID
=
6042691271548196815L
;
@OneToMany
(
mappedBy
=
"voter"
,
cascade
=
CascadeType
.
ALL
)
@OneToMany
(
mappedBy
=
"voter"
)
private
List
<
Vote
>
votes
;
@OneToMany
(
mappedBy
=
"user"
,
cascade
=
CascadeType
.
ALL
)
...
...
code/LanBortalWeb/WebContent/resources/script/hidecancel.js
0 → 100644
View file @
3d8d4ac
$
(
document
).
ready
(
function
()
{
$
(
".rating-cancel"
).
hide
();
alert
(
"trying to hide"
);
});
\ No newline at end of file
code/LanBortalWeb/WebContent/resources/style/insomnia2/css/tyyli.css
View file @
3d8d4ac
...
...
@@ -13,6 +13,18 @@ body,html {
margin
:
0
auto
;
}
td
span
span
div
.rating-cancel
{
display
:
none
;
}
#voteform
div
.rating-cancel
{
display
:
none
;
}
#logo
{
width
:
255px
;
height
:
52px
;
...
...
code/LanBortalWeb/WebContent/resources/style/rating.css
0 → 100644
View file @
3d8d4ac
td
span
span
div
.rating-cancel
{
display
:
none
;
}
div
.rating-cancel
{
display
:
none
;
}
\ No newline at end of file
code/LanBortalWeb/WebContent/voting/compolist.xhtml
View file @
3d8d4ac
...
...
@@ -62,7 +62,7 @@
</h:outputText>
</h:column>
<h:column>
<h:commandButton
rendered=
"#{compo.vote or compoView.manage}"
action=
"#{compoView.
v
ote()}"
value=
"#{i18n['voting.compo.vote']}"
/>
<h:commandButton
rendered=
"#{compo.vote or compoView.manage}"
action=
"#{compoView.
startV
ote()}"
value=
"#{i18n['voting.compo.vote']}"
/>
</h:column>
<h:column>
<h:commandButton
rendered=
"#{compo.submit or compoView.manage}"
action=
"#{compoView.submitEntry()}"
value=
"#{i18n['voting.compo.submit']}"
/>
...
...
code/LanBortalWeb/WebContent/voting/details.xhtml
View file @
3d8d4ac
...
...
@@ -13,7 +13,7 @@
</f:metadata>
<ui:define
name=
"content"
>
<!-- <h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" /> -->
<h1>
Compo: #{votingDetailsView.compo
N
ame}
</h1>
<h1>
Compo: #{votingDetailsView.compo
.n
ame}
</h1>
<p>
Infoa compon entryistä
</p>
...
...
@@ -21,9 +21,15 @@
<h:dataTable
styleClass=
"bordertable"
rowClasses=
"roweven,rowodd"
id=
"compolisttable"
value=
"#{votingDetailsView.entries}"
var=
"entry"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"
nimi
"
/>
<h:outputText
value=
"
Title
"
/>
</f:facet>
<h:outputText
value=
"#{entry.name}"
/>
<h:outputText
value=
"#{entry.title}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"Author"
/>
</f:facet>
<h:outputText
value=
"#{entry.author}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
...
...
@@ -41,13 +47,13 @@
<f:facet
name=
"header"
>
<h:outputText
value=
"creator"
/>
</f:facet>
<h:outputText
value=
"#{entry.creator.
wholeName
}"
/>
<h:outputText
value=
"#{entry.creator.
user.wholeName} / #{entry.creator.nick
}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"sort"
/>
</f:facet>
<h:
out
putText
value=
"#{entry.sort}"
/>
<h:
in
putText
value=
"#{entry.sort}"
/>
</h:column>
<h:column>
...
...
@@ -57,7 +63,7 @@
</h:column>
</h:dataTable>
<h:commandButton
action=
"#{votingDetailsView.saveSort}"
value=
"#{i18n['compo.savesort']}"
/>
</h:form>
...
...
code/LanBortalWeb/WebContent/voting/myEntries.xhtml
View file @
3d8d4ac
...
...
@@ -17,9 +17,15 @@
<h:dataTable
styleClass=
"bordertable"
rowClasses=
"roweven,rowodd"
id=
"compolisttable"
value=
"#{userView.user.compoEntries}"
var=
"entry"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"
Nam
e"
/>
<h:outputText
value=
"
Titl
e"
/>
</f:facet>
<h:outputText
value=
"#{entry.name}"
/>
<h:outputText
value=
"#{entry.title}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"Author"
/>
</f:facet>
<h:outputText
value=
"#{entry.author}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
...
...
code/LanBortalWeb/WebContent/voting/submitEntry.xhtml
View file @
3d8d4ac
...
...
@@ -17,10 +17,14 @@
<h:form>
<h:panelGrid
columns=
"3"
>
<h:outputLabel
value=
"
#{i18n['voting.compoentryadd.entryname']}
"
for=
"name"
/>
<h:inputText
value=
"#{compoView.entry.
nam
e}"
id=
"name"
/>
<h:outputLabel
value=
"
Title
"
for=
"name"
/>
<h:inputText
value=
"#{compoView.entry.
titl
e}"
id=
"name"
/>
<h:message
for=
"name"
/>
<h:outputLabel
value=
"Author"
for=
"author"
/>
<h:inputText
value=
"#{compoView.entry.author}"
id=
"author"
/>
<h:message
for=
"author"
/>
<h:outputLabel
value=
"#{i18n['voting.compoentryadd.notes']}"
for=
"notes"
/>
<h:inputTextarea
value=
"#{compoView.entry.notes}"
id=
"notes"
/>
<h:message
for=
"notes"
/>
...
...
code/LanBortalWeb/WebContent/voting/vote.xhtml
View file @
3d8d4ac
...
...
@@ -7,53 +7,39 @@
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<ui:define
name=
"content"
>
<ui:define
name=
"content"
>
<!-- <h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" /> -->
<h1>
Compo: #{votingDetailsView.compoName}
</h1>
<p>
Infoa compon entryistä
</p>
<h1>
Vote in compo #{votingDetailsView.compoName}
</h1>
<h:form>
<h:dataTable
styleClass=
"bordertable"
rowClasses=
"roweven,rowodd"
id=
"
compolisttable"
value=
"#{compoView..e
ntries}"
var=
"entry"
>
<h:form
id=
"voteform"
>
<h:dataTable
styleClass=
"bordertable"
rowClasses=
"roweven,rowodd"
id=
"
votetable"
value=
"#{compoView.voteE
ntries}"
var=
"entry"
>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"nimi"
/>
</f:facet>
<h:outputText
value=
"#{entry.name}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"notes"
/>
</f:facet>
<h:outputText
value=
"#{entry.notes}"
/>
#
<h:outputText
value=
"#{entry.entry.sort}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"
screenmessag
e"
/>
<h:outputText
value=
"
Titl
e"
/>
</f:facet>
<h:outputText
value=
"#{entry.
screenMessag
e}"
/>
<h:outputText
value=
"#{entry.
entry.titl
e}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"
creat
or"
/>
<h:outputText
value=
"
Auth
or"
/>
</f:facet>
<h:outputText
value=
"#{entry.
creator.wholeName
}"
/>
<h:outputText
value=
"#{entry.
entry.author
}"
/>
</h:column>
<h:column>
<f:facet
name=
"header"
>
<h:outputText
value=
"sort"
/>
</f:facet>
<h:outputText
value=
"#{entry.sort}"
/>
<p:rating
id=
"vote"
value=
"#{entry.ratingVote}"
cancel=
"true"
stars=
"5"
required=
"true"
>
<p:ajax
event=
"rate"
listener=
"#{compoView.handleVoteRate}"
update=
":voteform"
/>
</p:rating>
</h:column>
<h:column>
<h:link
outcome=
"/voting/submitEntry"
value=
"#{i18n['entry.edit']}"
>
<f:param
name=
"entryId"
value=
"#{entry.id}"
/>
</h:link>
<h:outputText
value=
"#{entry.vote}"
/>
</h:column>
</h:dataTable>
<h:commandButton
action=
"#{compoView.saveVotes}"
value=
"#{i18n['compo.saveVotes']}"
/>
</h:form>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/resources/i18n_en.properties
View file @
3d8d4ac
...
...
@@ -72,6 +72,8 @@ cardTemplate.power = Card power
cardTemplate.roles
=
Associated roles
compo.edit
=
Edit compo
compo.saveVotes
=
Save votes
compo.votesSaved
=
Votes saved
compofile.download
=
Download
compofile.download.header
=
Download file
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/resources/i18n_fi.properties
View file @
3d8d4ac
...
...
@@ -70,6 +70,8 @@ cardTemplate.power = Teho
cardTemplate.roles
=
Yhdistetyt roolit
compo.edit
=
Muokkaa compoa
compo.saveVotes
=
Tallenna
\u
00E4
\u
00E4net
compo.votesSaved
=
\u
00C4
\u
00E4net tallennettu
compofile.download
=
lataa
compofile.download.header
=
Lataa tiedosto
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/voting/CompoFileDownloadView.java
View file @
3d8d4ac
...
...
@@ -9,6 +9,8 @@ import javax.inject.Inject;
import
javax.inject.Named
;
import
org.primefaces.model.DefaultStreamedContent
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.insomnia.bortal.beans.VotingBeanLocal
;
import
fi.insomnia.bortal.model.CompoEntry
;
...
...
@@ -29,6 +31,7 @@ public class CompoFileDownloadView extends GenericCDIView {
private
CompoEntryFile
file
;
private
DefaultStreamedContent
dlfile
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CompoFileDownloadView
.
class
);
public
ListDataModel
<
CompoEntryFile
>
getFiles
()
{
...
...
@@ -47,7 +50,9 @@ public class CompoFileDownloadView extends GenericCDIView {
this
.
file
=
file
;
if
(
file
!=
null
)
{
dlfile
=
new
DefaultStreamedContent
(
new
ByteArrayInputStream
(
file
.
getFileData
()),
file
.
getMimeType
(),
file
.
getFileName
());
logger
.
info
(
"Uploading file {}, length {}"
,
file
.
getFileName
(),
file
.
getFileData
().
length
);
}
}
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/voting/CompoView.java
View file @
3d8d4ac
...
...
@@ -8,6 +8,7 @@ import javax.enterprise.inject.Produces;
import
javax.faces.model.ListDataModel
;
import
javax.inject.Named
;
import
org.primefaces.event.RateEvent
;
import
org.primefaces.model.UploadedFile
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -47,6 +48,8 @@ public class CompoView extends GenericCDIView {
private
Integer
entryId
;
private
ListDataModel
<
VoteWrapper
>
voteEntries
;
public
ListDataModel
<
CompoWrapper
>
getCompos
()
{
return
compolist
;
}
...
...
@@ -66,10 +69,34 @@ public class CompoView extends GenericCDIView {
}
}
public
String
voteCompo
()
public
String
startVote
()
{
compo
=
compolist
.
getRowData
().
getCompo
();
return
"/votes/vote"
;
setVoteEntries
(
VoteWrapper
.
init
(
compo
.
getCompoEntries
(),
votbean
));
logger
.
info
(
"Initializing voting with entries {}, {}"
,
compo
.
getCompoEntries
().
size
(),
voteEntries
.
getRowCount
());
super
.
beginConversation
();
return
"/voting/vote"
;
}
public
void
handleVoteRate
(
RateEvent
rateEvent
)
{
VoteWrapper
row
=
voteEntries
.
getRowData
();
Integer
vote
=
(
Integer
)
rateEvent
.
getRating
()
-
3
;
if
(
vote
<
-
2
||
vote
>
2
)
{
vote
=
0
;
}
votbean
.
saveVote
(
row
.
getEntry
(),
vote
);
}
public
String
saveVotes
()
{
for
(
VoteWrapper
vw
:
voteEntries
)
{
votbean
.
saveVote
(
vw
.
getEntry
(),
vw
.
getVote
());
}
super
.
addFaceMessage
(
"compo.votesSaved"
);
return
null
;
}
public
String
submitEntry
()
...
...
@@ -98,6 +125,7 @@ public class CompoView extends GenericCDIView {
{
CompoEntryFile
cef
=
new
CompoEntryFile
(
getEntry
());
cef
.
setFileData
(
this
.
getUploadedFile
().
getContents
());
logger
.
info
(
"Got file name {} length {}"
,
getUploadedFile
().
getFileName
(),
cef
.
getFileData
().
length
);
cef
.
setFileName
(
getUploadedFile
().
getFileName
());
cef
.
setMimeType
(
getUploadedFile
().
getContentType
());
if
(
getEntry
().
getFiles
()
==
null
)
{
...
...
@@ -165,4 +193,13 @@ public class CompoView extends GenericCDIView {
this
.
entryId
=
entryId
;
}
public
ListDataModel
<
VoteWrapper
>
getVoteEntries
()
{
logger
.
info
(
"Getting {} entries "
,
voteEntries
.
getRowCount
());
return
voteEntries
;
}
public
void
setVoteEntries
(
ListDataModel
<
VoteWrapper
>
voteEntries
)
{
this
.
voteEntries
=
voteEntries
;
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/voting/VoteWrapper.java
0 → 100644
View file @
3d8d4ac
package
fi
.
insomnia
.
bortal
.
web
.
cdiview
.
voting
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.faces.model.ListDataModel
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.insomnia.bortal.beans.VotingBeanLocal
;
import
fi.insomnia.bortal.model.CompoEntry
;
import
fi.insomnia.bortal.model.Vote
;
public
class
VoteWrapper
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
-
8261328741517788115L
;
private
final
CompoEntry
entry
;
private
Integer
vote
=
0
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
VoteWrapper
.
class
);
public
VoteWrapper
(
CompoEntry
entry
,
Vote
voteEntity
)
{
this
.
entry
=
entry
;
if
(
voteEntity
!=
null
)
{
vote
=
voteEntity
.
getScore
();
}
}
public
static
ListDataModel
<
VoteWrapper
>
init
(
List
<
CompoEntry
>
compoEntries
,
VotingBeanLocal
votbean
)
{
ArrayList
<
VoteWrapper
>
ret
=
new
ArrayList
<
VoteWrapper
>();
for
(
CompoEntry
entry
:
compoEntries
)
{
if
(
entry
.
getSort
()
!=
null
&&
entry
.
getSort
()
>
0
)
{
Vote
voteEntity
=
votbean
.
saveVote
(
entry
,
null
);
ret
.
add
(
new
VoteWrapper
(
entry
,
voteEntity
));
}
}
return
new
ListDataModel
<
VoteWrapper
>(
ret
);
}
public
CompoEntry
getEntry
()
{
return
entry
;
}
public
Integer
getVote
()
{
return
vote
;
}
public
void
setVote
(
Integer
vot
)
{
if
(
vot
==
null
)
{
this
.
vote
=
0
;
}
else
{
this
.
vote
=
vot
;
}
}
public
int
getRatingVote
()
{
return
vote
+
3
;
}
public
void
setRatingVote
(
int
vot
)
{
if
(
vot
<
1
||
vot
>
5
)
{
vot
=
3
;
}
this
.
vote
=
vot
-
3
;
logger
.
info
(
"setting ratevote {} to realvote {}"
,
vot
,
vote
);
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/voting/VotingCompoAddEntryView.java
View file @
3d8d4ac
...
...
@@ -79,7 +79,7 @@ public class VotingCompoAddEntryView {
public
void
send
()
{
CompoEntry
compoEntry
=
new
CompoEntry
();
compoEntry
.
set
Nam
e
(
name
);
compoEntry
.
set
Titl
e
(
name
);
compoEntry
.
setNotes
(
notes
);
compoEntry
.
setScreenMessage
(
screenMessage
);
compoEntry
.
setCompo
(
votingBean
.
getCompoById
(
compoId
));
...
...
@@ -88,7 +88,7 @@ public class VotingCompoAddEntryView {
cef
.
setFileName
(
uploadedFile
.
getFileName
());
votingBean
.
addEntry
(
compoEntry
,
cef
);
}
public
void
initView
()
{
compoName
=
votingBean
.
getCompoById
(
compoId
).
getName
();
}
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/web/cdiview/voting/VotingDetailsView.java
View file @
3d8d4ac
package
fi
.
insomnia
.
bortal
.
web
.
cdiview
.
voting
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.
Request
Scoped
;
import
javax.enterprise.context.
Conversation
Scoped
;
import
javax.faces.model.ListDataModel
;
import
javax.inject.Named
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.insomnia.bortal.beans.VotingBeanLocal
;
import
fi.insomnia.bortal.web.cdiview.GenericCDIView
;
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
@
Request
Scoped
@
Conversation
Scoped
public
class
VotingDetailsView
extends
GenericCDIView
{
/**
*
*/
private
static
final
long
serialVersionUID
=
-
8373473936336396427L
;
@EJB
private
VotingBeanLocal
votingBean
;
private
Integer
compoId
;
private
Integer
compoId2
;
private
String
compoName
;
private
Compo
compo
;
private
ListDataModel
<
CompoEntry
>
entries
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
VotingDetailsView
.
class
);
public
Integer
getCompoId
()
{
return
compoId
;
}
public
String
saveSort
()
{
for
(
CompoEntry
e
:
entries
)
{
setCompo
(
votingBean
.
saveSort
(
e
).
getCompo
());
}
entries
=
new
ListDataModel
<
CompoEntry
>(
getCompo
().
getCompoEntries
());
return
null
;
}
public
void
setCompoId
(
Integer
compoId
)
{
this
.
compoId
=
compoId
;
}
public
List
<
CompoEntry
>
getEntries
(){
//return votingBean.getCompoById(compoId).getCompoEntries();
compo
=
votingBean
.
getCompoById
(
compoId
);
logger
.
info
(
"compoId "
+
compoId
);
if
(
compo
==
null
)
{
return
null
;
}
return
compo
.
getCompoEntries
();
}
public
void
initView
()
{
compoName
=
votingBean
.
getCompoById
(
compoId
).
getName
();
}
public
Integer
getCompoId2
()
{
return
compoId2
;
public
ListDataModel
<
CompoEntry
>
getEntries
()
{
return
entries
;
}
public
void
setCompoId2
(
Integer
compoId2
)
{
this
.
compoId2
=
compoId2
;
public
void
initView
()
{
if
(
super
.
requirePermissions
(
CompoPermission
.
MANAGE
))
{
setCompo
(
votingBean
.
getCompoById
(
compoId
));
entries
=
new
ListDataModel
<
CompoEntry
>(
getCompo
().
getCompoEntries
());
super
.
beginConversation
();
}
}
public
String
getCompoName
()
{
return
compoName
;
}
public
void
setCompoName
(
String
compoName
)
{
this
.
compoName
=
compoName
;
}
public
Compo
getCompo
()
{
return
compo
;
}
public
void
setCompo
(
Compo
compo
)
{
this
.
compo
=
compo
;
}
}
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