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 86d1a3dd
authored
Nov 06, 2010
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lisätty pollit
1 parent
246af718
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
116 additions
and
4 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/JaasBean.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/UserFacade.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/PollQuestion.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/PossibleAnswer.java
code/LanBortalWeb/WebContent/layout/insomnia1/template.xhtml
code/LanBortalWeb/WebContent/poll/show.xhtml
code/LanBortalWeb/WebContent/poll/start.xhtml
code/LanBortalWeb/WebContent/resources/style/insomnia1/style.css
code/LanBortalWeb/src/fi/insomnia/bortal/view/PollView.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/JaasBean.java
View file @
86d1a3d
...
@@ -39,6 +39,7 @@ public class JaasBean implements JaasBeanLocal, JaasBeanRemote {
...
@@ -39,6 +39,7 @@ public class JaasBean implements JaasBeanLocal, JaasBeanRemote {
public
User
tryLogin
(
String
username
,
String
password
)
{
public
User
tryLogin
(
String
username
,
String
password
)
{
User
user
=
userfacade
.
findByLogin
(
username
.
trim
());
User
user
=
userfacade
.
findByLogin
(
username
.
trim
());
logger
.
debug
(
"Trying to login as {}"
,
username
);
logger
.
debug
(
"Trying to login as {}"
,
username
);
User
ret
=
null
;
User
ret
=
null
;
...
...
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/facade/UserFacade.java
View file @
86d1a3d
...
@@ -36,9 +36,16 @@ public class UserFacade extends GenericFacade<Integer, User> {
...
@@ -36,9 +36,16 @@ public class UserFacade extends GenericFacade<Integer, User> {
return
em
;
return
em
;
}
}
/**
* Find user by username. Username is converted to lowercase before
* searching.
*
* @param login
* @return
*/
public
User
findByLogin
(
String
login
)
{
public
User
findByLogin
(
String
login
)
{
TypedQuery
<
User
>
q
=
em
.
createNamedQuery
(
"User.findByLogin"
,
User
.
class
);
TypedQuery
<
User
>
q
=
em
.
createNamedQuery
(
"User.findByLogin"
,
User
.
class
);
q
.
setParameter
(
"login"
,
login
);
q
.
setParameter
(
"login"
,
login
.
toLowerCase
()
);
return
getSingleNullableResult
(
q
);
return
getSingleNullableResult
(
q
);
}
}
...
@@ -48,5 +55,15 @@ public class UserFacade extends GenericFacade<Integer, User> {
...
@@ -48,5 +55,15 @@ public class UserFacade extends GenericFacade<Integer, User> {
return
this
.
search
(
name
,
NAMEFIELDS
,
"login"
);
return
this
.
search
(
name
,
NAMEFIELDS
,
"login"
);
}
}
@Override
public
void
create
(
User
user
)
{
user
.
setLogin
(
user
.
getLogin
().
toLowerCase
().
trim
());
super
.
create
(
user
);
}
@Override
public
User
merge
(
User
user
)
{
user
.
setLogin
(
user
.
getLogin
().
toLowerCase
().
trim
());
return
super
.
merge
(
user
);
}
}
}
code/LanBortalDatabase/src/fi/insomnia/bortal/model/PollQuestion.java
View file @
86d1a3d
...
@@ -59,6 +59,7 @@ public class PollQuestion extends GenericEventChild {
...
@@ -59,6 +59,7 @@ public class PollQuestion extends GenericEventChild {
return
(
answers
.
size
()
==
1
&&
answers
.
get
(
0
).
getTextanswer
());
return
(
answers
.
size
()
==
1
&&
answers
.
get
(
0
).
getTextanswer
());
}
}
public
void
setQuestion
(
String
question
)
{
public
void
setQuestion
(
String
question
)
{
this
.
question
=
question
;
this
.
question
=
question
;
}
}
...
...
code/LanBortalDatabase/src/fi/insomnia/bortal/model/PossibleAnswer.java
View file @
86d1a3d
...
@@ -43,7 +43,7 @@ public class PossibleAnswer extends GenericEventChild {
...
@@ -43,7 +43,7 @@ public class PossibleAnswer extends GenericEventChild {
private
String
description
;
private
String
description
;
@JoinColumns
({
@JoinColumns
({
@JoinColumn
(
name
=
"question_id"
,
referencedColumnName
=
"id"
,
nullable
=
false
),
@JoinColumn
(
name
=
"question_id"
,
referencedColumnName
=
"id"
,
nullable
=
false
),
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_id"
,
nullable
=
false
,
updatable
=
false
,
insertable
=
false
)
})
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_id"
,
nullable
=
false
,
updatable
=
false
,
insertable
=
false
)
})
@ManyToOne
@ManyToOne
private
PollQuestion
question
;
private
PollQuestion
question
;
...
@@ -99,4 +99,14 @@ public class PossibleAnswer extends GenericEventChild {
...
@@ -99,4 +99,14 @@ public class PossibleAnswer extends GenericEventChild {
return
textanswer
;
return
textanswer
;
}
}
public
int
getCheckedAnswers
()
{
int
ret
=
0
;
for
(
PollAnswer
and
:
answers
)
{
if
(
and
.
getAnswerBoolean
())
{
++
ret
;
}
}
return
ret
;
}
}
}
code/LanBortalWeb/WebContent/layout/insomnia1/template.xhtml
View file @
86d1a3d
...
@@ -38,10 +38,10 @@
...
@@ -38,10 +38,10 @@
outcome="/product/createBill" value="#{i18n['topmenu.shoppings']}" /></div>
outcome="/product/createBill" value="#{i18n['topmenu.shoppings']}" /></div>
-->
-->
</tools:isLoggedIn>
<tools:can
Read
target=
"POLL"
>
</tools:isLoggedIn>
<tools:can
Execute
target=
"POLL"
>
<div
class=
"link#{i18n[util.concat(thispage,'.pagegroup')] == 'poll'?'a': ''}"
><h:link
<div
class=
"link#{i18n[util.concat(thispage,'.pagegroup')] == 'poll'?'a': ''}"
><h:link
outcome=
"/poll/start"
value=
"#{i18n['topmenu.poll']}"
/></div>
outcome=
"/poll/start"
value=
"#{i18n['topmenu.poll']}"
/></div>
</tools:can
Read
>
</tools:can
Execute
>
<div
class=
"link#{i18n[util.concat(thispage,'.pagegroup')] == 'placemap'?'a':''}"
><h:link
<div
class=
"link#{i18n[util.concat(thispage,'.pagegroup')] == 'placemap'?'a':''}"
><h:link
outcome=
"/place/placemap"
value=
"#{i18n['topmenu.placemap']}"
/></div>
outcome=
"/place/placemap"
value=
"#{i18n['topmenu.placemap']}"
/></div>
...
...
code/LanBortalWeb/WebContent/poll/show.xhtml
0 → 100644
View file @
86d1a3d
<!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:users=
"http://java.sun.com/jsf/composite/tools/user"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<h:body>
<ui:composition
template=
"/layout/#{sessionHandler.layout}/template.xhtml"
>
<ui:param
name=
"thispage"
value=
"page.poll.answer"
/>
<ui:define
name=
"content"
>
<table
id=
"pollresultstable"
border=
"1"
>
<tr>
<ui:repeat
value=
"#{pollView.poll.questions}"
var=
"question"
>
<th><h:outputText
value=
"#{question.question}"
/></th>
</ui:repeat>
</tr>
<tr>
<ui:repeat
value=
"#{pollView.poll.questions}"
var=
"question"
>
<td>
<table
id=
"pollresultsubform"
>
<ui:repeat
rendered=
"#{question.freeText}"
value=
"#{question.answers}"
var=
"posAns"
>
<ui:repeat
value=
"#{posAns.answers}"
var=
"ans"
>
<tr>
<td><h:outputText
value=
"#{ans.answerText}"
/></td>
</tr>
</ui:repeat>
</ui:repeat>
<h:panelGroup
rendered=
"#{!question.freeText}"
>
<ui:repeat
rendered=
"#{!question.freeText}"
value=
"#{question.answers}"
var=
"posAns"
>
<tr>
<td><h:outputText
value=
"#{posAns.answer}"
/></td>
<td><h:outputText
value=
"#{posAns.checkedAnswers}"
/></td>
</tr>
</ui:repeat>
</h:panelGroup>
</table>
</td>
</ui:repeat>
</tr>
</table>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/LanBortalWeb/WebContent/poll/start.xhtml
View file @
86d1a3d
...
@@ -19,6 +19,10 @@
...
@@ -19,6 +19,10 @@
<h:column>
<h:column>
<h:commandButton
action=
"#{pollView.beginPoll()}"
value=
"#{i18n['poll.answer']}"
/>
<h:commandButton
action=
"#{pollView.beginPoll()}"
value=
"#{i18n['poll.answer']}"
/>
</h:column>
</h:column>
<h:column
rendered=
"#{sessionHandler.hasPermission('POLL','READ')}"
>
<h:commandButton
action=
"#{pollView.showPoll()}"
value=
"#{i18n['poll.show']}"
/>
</h:column>
</h:dataTable>
</h:dataTable>
...
...
code/LanBortalWeb/WebContent/resources/style/insomnia1/style.css
View file @
86d1a3d
...
@@ -202,3 +202,22 @@ h1 {
...
@@ -202,3 +202,22 @@ h1 {
.placegroupPadding
{
.placegroupPadding
{
padding-right
:
50px
;
padding-right
:
50px
;
}
}
#pollresultsubform
tr
td
{
text-align
:
top
;
margin-bottom
:
10px
;
border-style
:
solid
;
border-color
:
#000
;
border-width
:
0
0
1px
0
;
margin-bottom
:
10px
;
}
#pollresultstable
{
border-style
:
solid
;
border-color
:
#000
;
border-width
:
1px
;
}
#pollresultstable
tr
td
{
vertical-align
:
top
;
}
code/LanBortalWeb/src/fi/insomnia/bortal/view/PollView.java
View file @
86d1a3d
...
@@ -14,6 +14,9 @@ import org.slf4j.Logger;
...
@@ -14,6 +14,9 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
fi.insomnia.bortal.beans.PollBeanLocal
;
import
fi.insomnia.bortal.beans.PollBeanLocal
;
import
fi.insomnia.bortal.beans.UserBeanLocal
;
import
fi.insomnia.bortal.enums.Permission
;
import
fi.insomnia.bortal.enums.RolePermission
;
import
fi.insomnia.bortal.model.Poll
;
import
fi.insomnia.bortal.model.Poll
;
import
fi.insomnia.bortal.model.PollAnswer
;
import
fi.insomnia.bortal.model.PollAnswer
;
import
fi.insomnia.bortal.model.PollQuestion
;
import
fi.insomnia.bortal.model.PollQuestion
;
...
@@ -33,6 +36,9 @@ public class PollView extends GenericView {
...
@@ -33,6 +36,9 @@ public class PollView extends GenericView {
private
Poll
poll
;
private
Poll
poll
;
@EJB
private
UserBeanLocal
userbean
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PollView
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PollView
.
class
);
public
void
initPollList
()
{
public
void
initPollList
()
{
...
@@ -63,6 +69,13 @@ public class PollView extends GenericView {
...
@@ -63,6 +69,13 @@ public class PollView extends GenericView {
return
"/poll/answerToPoll"
;
return
"/poll/answerToPoll"
;
}
}
public
String
showPoll
()
{
userbean
.
fatalPermission
(
Permission
.
POLL
,
RolePermission
.
READ
);
poll
=
polls
.
getRowData
();
return
"/poll/show"
;
}
public
String
savePoll
()
{
public
String
savePoll
()
{
if
(
validate
(
this
))
{
if
(
validate
(
this
))
{
...
...
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