Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Riina Antikainen
/
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 233932df
authored
Mar 21, 2010
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
something, does not work, sorry
1 parent
cefdc478
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
3 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/RoleBean.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/RoleBeanLocal.java
code/LanBortalWeb/WebContent/resources/tools/role/form.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/view/RoleView.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/RoleBean.java
View file @
233932d
...
@@ -2,12 +2,14 @@
...
@@ -2,12 +2,14 @@
* To change this template, choose Tools | Templates
* To change this template, choose Tools | Templates
* and open the template in the editor.
* and open the template in the editor.
*/
*/
package
fi
.
insomnia
.
bortal
.
beans
;
package
fi
.
insomnia
.
bortal
.
beans
;
import
fi.insomnia.bortal.facade.RoleFacade
;
import
fi.insomnia.bortal.facade.RoleFacade
;
import
fi.insomnia.bortal.model.Role
;
import
fi.insomnia.bortal.model.Role
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.ejb.Stateless
;
import
javax.ejb.Stateless
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -22,7 +24,6 @@ public class RoleBean implements RoleBeanLocal {
...
@@ -22,7 +24,6 @@ public class RoleBean implements RoleBeanLocal {
@EJB
@EJB
private
RoleFacade
roleFacade
;
private
RoleFacade
roleFacade
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RoleBean
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RoleBean
.
class
);
public
List
<
Role
>
listRoles
()
{
public
List
<
Role
>
listRoles
()
{
...
@@ -42,7 +43,42 @@ public class RoleBean implements RoleBeanLocal {
...
@@ -42,7 +43,42 @@ public class RoleBean implements RoleBeanLocal {
return
role
;
return
role
;
}
}
public
List
<
Role
>
getPossibleParents
(
Role
role
)
{
List
<
Role
>
roleList
=
listRoles
();
List
<
Role
>
children
=
getAllChilds
(
role
,
new
HashSet
<
Role
>());
for
(
Role
unit
:
children
)
{
if
(
roleList
.
contains
(
role
))
{
roleList
.
remove
(
role
);
}
}
return
roleList
;
}
private
static
List
<
Role
>
getAllChilds
(
Role
role
,
Set
<
Role
>
checkedRoles
)
{
List
<
Role
>
returnList
=
new
ArrayList
<
Role
>();
if
(
checkedRoles
.
contains
(
role
))
{
return
returnList
;
}
for
(
Role
unit
:
role
.
getChildren
())
{
List
<
Role
>
someList
=
getAllChilds
(
unit
,
checkedRoles
);
returnList
.
addAll
(
someList
);
}
checkedRoles
.
add
(
role
);
return
returnList
;
}
// Add business logic below. (Right-click in editor and choose
// Add business logic below. (Right-click in editor and choose
// "Insert Code > Add Business Method")
// "Insert Code > Add Business Method")
}
}
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/RoleBeanLocal.java
View file @
233932d
...
@@ -22,4 +22,6 @@ public interface RoleBeanLocal {
...
@@ -22,4 +22,6 @@ public interface RoleBeanLocal {
public
Role
create
(
Role
role
);
public
Role
create
(
Role
role
);
public
List
<
Role
>
getPossibleParents
(
Role
role
);
}
}
code/LanBortalWeb/WebContent/resources/tools/role/form.xhtml
View file @
233932d
...
@@ -14,6 +14,8 @@
...
@@ -14,6 +14,8 @@
<ui:composition>
<ui:composition>
<h:panelGrid>
<h:panelGrid>
<h:outputText
value=
"#{i18n['role.name']}"
/><h:inputText
value=
"#{roleView.role.name}"
/>
<h:outputText
value=
"#{i18n['role.name']}"
/><h:inputText
value=
"#{roleView.role.name}"
/>
<h:selectManyListbox
value=
"#{roleView.possibleParents}"
/>
</h:panelGrid>
</h:panelGrid>
</ui:composition>
</ui:composition>
</html>
</html>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/view/RoleView.java
View file @
233932d
...
@@ -38,6 +38,8 @@ public class RoleView {
...
@@ -38,6 +38,8 @@ public class RoleView {
private
Role
role
=
new
Role
();
private
Role
role
=
new
Role
();
DataModel
<
Role
>
items
;
DataModel
<
Role
>
items
;
private
DataModel
<
Role
>
possibleParents
;
public
DataModel
<
Role
>
getRoles
()
{
public
DataModel
<
Role
>
getRoles
()
{
items
=
new
ListDataModel
<
Role
>(
roleBean
.
listRoles
());
items
=
new
ListDataModel
<
Role
>(
roleBean
.
listRoles
());
logger
.
info
(
"Fetching roles. Found {}"
,
items
.
getRowCount
());
logger
.
info
(
"Fetching roles. Found {}"
,
items
.
getRowCount
());
...
@@ -107,4 +109,13 @@ public class RoleView {
...
@@ -107,4 +109,13 @@ public class RoleView {
public
void
setSessionhandler
(
SessionHandler
sessionhandler
)
{
public
void
setSessionhandler
(
SessionHandler
sessionhandler
)
{
this
.
sessionhandler
=
sessionhandler
;
this
.
sessionhandler
=
sessionhandler
;
}
}
/**
* @return the possibleParents
*/
public
DataModel
<
Role
>
getPossibleParents
()
{
possibleParents
=
new
ListDataModel
<
Role
>(
roleBean
.
getPossibleParents
(
role
));
return
possibleParents
;
}
}
}
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