Toggle navigation
Toggle navigation
This project
Loading...
Sign in
grogv3
/
grog-cubi
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Francois Leveque
2017-02-15 12:13:13 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e36b2e9fdb68597c95368870c804d97e06afd6d6
e36b2e9f
1 parent
d53ab52e
ListPublisherActions en Rewrite
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
11 deletions
src/main/java/org/legrog/web/publisher/ListPublisherActionsView.java
src/main/java/org/legrog/web/publisher/listPublisherActions.xhtml
src/test/java/org/legrog/web/publisher/ListPublisherActionsViewTest.java
src/main/java/org/legrog/web/publisher/ListPublisherActionsView.java
View file @
e36b2e9
package
org
.
legrog
.
web
.
publisher
;
import
org.legrog.entities.PublisherAction
;
import
org.ocpsoft.rewrite.annotation.Join
;
import
org.ocpsoft.rewrite.annotation.Parameter
;
import
org.ocpsoft.rewrite.annotation.RequestAction
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.annotation.PostConstruct
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.view.ViewScoped
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
...
...
@@ -17,9 +22,13 @@ import java.util.stream.Collectors;
* Permet de voir l'ensemble des actions d'un éditeur.
*/
@Named
@ViewScoped
@RequestScoped
@Join
(
path
=
"/ListPublisherActions/{stringId}"
,
to
=
"/publisher/listPublisherActions.jsf"
)
public
class
ListPublisherActionsView
implements
Serializable
{
@Parameter
String
stringId
;
transient
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
protected
transient
PublisherService
publisherService
;
...
...
@@ -41,13 +50,23 @@ public class ListPublisherActionsView implements Serializable {
ListPublisherActionsView
()
{
//no args constructor to make it proxyable
}
@PostConstruct
@RequestAction
public
void
init
()
{
if
(
stringId
!=
null
)
{
try
{
publisherId
=
new
Integer
(
stringId
);
}
catch
(
NumberFormatException
ne
)
{
publisherId
=
null
;
}
}
else
{
publisherId
=
null
;
}
public
void
setView
()
{
logger
.
trace
(
"setView : publisherId = {}"
,
publisherId
);
publisherActions
=
publisherService
.
getAllPublisherActions
();
viewAll
=
publisherId
==
null
;
if
(!
viewAll
)
{
logger
.
trace
(
"setView : !viewAll"
);
filterOnID
();
}
}
...
...
@@ -81,4 +100,12 @@ public class ListPublisherActionsView implements Serializable {
public
void
setPublisherActions
(
List
<
PublisherAction
>
publisherActions
)
{
this
.
publisherActions
=
publisherActions
;
}
public
String
getStringId
()
{
return
stringId
;
}
public
void
setStringId
(
String
stringId
)
{
this
.
stringId
=
stringId
;
}
}
...
...
src/main/java/org/legrog/web/publisher/listPublisherActions.xhtml
View file @
e36b2e9
...
...
@@ -5,10 +5,6 @@
xmlns:h=
"http://xmlns.jcp.org/jsf/html"
xmlns:jsf=
"http://xmlns.jcp.org/jsf"
xmlns:f=
"http://xmlns.jcp.org/jsf/core"
>
<f:metadata>
<f:viewParam
name=
"publisherId"
value=
"#{listPublisherActionsView.publisherId}"
/>
<f:viewAction
action=
"#{listPublisherActionsView.setView}"
/>
</f:metadata>
<head>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"/minimal.css"
/>
</head>
...
...
src/test/java/org/legrog/web/publisher/ListPublisherActionsViewTest.java
View file @
e36b2e9
...
...
@@ -48,7 +48,7 @@ public class ListPublisherActionsViewTest {
public
void
showAll
(
@Mock
PublisherService
publisherServiceMock
)
{
listPublisherActionsView
.
setPublisherId
(
null
);
listPublisherActionsView
.
setViewAll
(
false
);
listPublisherActionsView
.
setView
();
listPublisherActionsView
.
init
();
Mockito
.
verify
(
publisherServiceMock
).
getAllPublisherActions
();
assertThat
(
listPublisherActionsView
.
isViewAll
()).
isTrue
();
assertThat
(
filtered
).
isFalse
();
...
...
@@ -57,9 +57,9 @@ public class ListPublisherActionsViewTest {
@Test
@DisplayName
(
"when publisher is set, should be in filtered not all actions state"
)
public
void
showFiltered
(
@Mock
PublisherService
publisherServiceMock
)
{
listPublisherActionsView
.
set
PublisherId
(
1
);
listPublisherActionsView
.
set
StringId
(
"1"
);
listPublisherActionsView
.
setViewAll
(
true
);
listPublisherActionsView
.
setView
();
listPublisherActionsView
.
init
();
Mockito
.
verify
(
publisherServiceMock
).
getAllPublisherActions
();
assertThat
(
listPublisherActionsView
.
isViewAll
()).
isFalse
();
assertThat
(
filtered
).
isTrue
();
...
...
Please
register
or
login
to post a comment