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 10:34:19 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ff31db191ecc9206afd6927496a8958503a79344
ff31db19
1 parent
933274f7
Problème lors du passage à Rewrite : la liste complète ne fonctionne plus.
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
28 deletions
src/main/java/org/legrog/configuration/RewriteConfigurationProvider.java
src/main/java/org/legrog/web/publisher/ListPublisherVersionsView.java
src/main/java/org/legrog/web/publisher/listPublisherVersions.xhtml
src/test/java/org/legrog/web/publisher/ListPublisherVersionsViewTest.java
src/main/java/org/legrog/configuration/RewriteConfigurationProvider.java
0 → 100644
View file @
ff31db1
package
org
.
legrog
.
configuration
;
import
org.ocpsoft.rewrite.annotation.RewriteConfiguration
;
import
org.ocpsoft.rewrite.config.Configuration
;
import
org.ocpsoft.rewrite.config.ConfigurationBuilder
;
import
org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider
;
import
javax.servlet.ServletContext
;
/**
* Rewrite configuration provider
*/
@RewriteConfiguration
public
class
RewriteConfigurationProvider
extends
HttpConfigurationProvider
{
@Override
public
int
priority
()
{
return
10
;
}
@Override
public
Configuration
getConfiguration
(
final
ServletContext
context
)
{
return
ConfigurationBuilder
.
begin
();
}
}
\ No newline at end of file
src/main/java/org/legrog/web/publisher/ListPublisherVersionsView.java
View file @
ff31db1
...
...
@@ -3,10 +3,14 @@ package org.legrog.web.publisher;
import
org.legrog.entities.Publisher
;
import
org.legrog.entities.PublisherAction
;
import
org.legrog.entities.PublisherVersion
;
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.faces.view.ViewScoped
;
import
javax.enterprise.context.RequestScoped
;
//import javax.faces.view.ViewScoped;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
java.io.Serializable
;
...
...
@@ -19,17 +23,50 @@ import java.util.stream.Collectors;
* Permet de voir l'ensemble des versions d'un éditeur et de valider l'une d'elles.
*/
@Named
@ViewScoped
@RequestScoped
@Join
(
path
=
"/ListPublisherVersions/{stringId}"
,
to
=
"/publisher/listPublisherVersions.jsf"
)
public
class
ListPublisherVersionsView
implements
Serializable
{
@Parameter
String
stringId
;
private
Integer
publisherId
;
transient
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
protected
transient
PublisherService
publisherService
;
private
Integer
publisherId
;
private
boolean
viewAll
;
private
transient
List
<
PublisherVersion
>
publisherVersions
;
@RequestAction
public
void
init
()
{
if
(
stringId
!=
null
)
{
try
{
publisherId
=
new
Integer
(
stringId
);
}
catch
(
NumberFormatException
ne
)
{
publisherId
=
null
;
}
}
else
{
publisherId
=
null
;
}
logger
.
trace
(
"setView : publisherId = {}"
,
publisherId
);
publisherVersions
=
publisherService
.
getAllPublisherVersions
();
viewAll
=
publisherId
==
null
;
if
(!
viewAll
)
{
logger
.
trace
(
"setView : !viewAll"
);
filterOnID
();
}
}
protected
void
filterOnID
()
{
publisherVersions
=
publisherVersions
.
stream
()
.
filter
(
version
->
version
.
getPublisher
().
getPublisherId
()
==
publisherId
)
.
collect
(
Collectors
.
toList
());
}
/**
* Uses PublisherService to access data
*
...
...
@@ -55,23 +92,10 @@ public class ListPublisherVersionsView implements Serializable {
}
// View Action being executed at view loading
/*
public void setView() {
logger
.
trace
(
"setView : publisherId = {}"
,
publisherId
);
publisherVersions
=
publisherService
.
getAllPublisherVersions
();
viewAll
=
publisherId
==
null
;
if
(!
viewAll
)
{
logger
.
trace
(
"setView : !viewAll"
);
filterOnID
();
}
}
protected
void
filterOnID
()
{
publisherVersions
=
publisherVersions
.
stream
()
.
filter
(
version
->
version
.
getPublisher
().
getPublisherId
()
==
publisherId
)
.
collect
(
Collectors
.
toList
());
}
*/
/**
* Validates a PublisherVersion for its Publisher
*
...
...
@@ -86,6 +110,13 @@ public class ListPublisherVersionsView implements Serializable {
filterOnID
();
}
public
String
getStringId
()
{
return
stringId
;
}
public
void
setStringId
(
String
stringId
)
{
this
.
stringId
=
stringId
;
}
public
PublisherService
getPublisherService
()
{
return
publisherService
;
...
...
src/main/java/org/legrog/web/publisher/listPublisherVersions.xhtml
View file @
ff31db1
...
...
@@ -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=
"#{listPublisherVersionsView.publisherId}"
/>
<f:viewAction
action=
"#{listPublisherVersionsView.setView}"
/>
</f:metadata>
<head>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"/minimal.css"
/>
</head>
...
...
@@ -36,9 +32,7 @@
</h:column>
<h:column
rendered=
"#{listPublisherVersionsView.viewAll}"
>
<f:facet
name=
"header"
/>
<a
jsf:outcome=
"listPublisherVersions"
>
Visualiser ou valider version éditeur
<f:param
name=
"publisherId"
value=
"#{version.publisher.publisherId}"
/>
</a>
<a
jsf:outcome=
"/ListPublisherVersions/#{version.publisher.publisherId}"
>
Visualiser ou valider version éditeur
</a>
</h:column>
<h:column>
<f:facet
name=
"header"
/>
...
...
src/test/java/org/legrog/web/publisher/ListPublisherVersionsViewTest.java
View file @
ff31db1
...
...
@@ -78,7 +78,7 @@ public class ListPublisherVersionsViewTest {
@DisplayName
(
"when publisher is not set, should list all versions"
)
public
void
testSetViewAll
()
{
listPublisherVersionsView
.
setPublisherId
(
null
);
listPublisherVersionsView
.
setView
();
listPublisherVersionsView
.
init
();
Mockito
.
verify
(
publisherService
).
getAllPublisherVersions
();
assertThat
(
listPublisherVersionsView
.
isViewAll
()).
isTrue
();
assertThat
(
listPublisherVersionsView
.
getPublisherVersions
()).
isEqualTo
(
publisherVersions
);
...
...
@@ -87,8 +87,8 @@ public class ListPublisherVersionsViewTest {
@Test
@DisplayName
(
"when publisher is set, should list pulisher's versions"
)
public
void
testSetViewNotAllAlsoTestingFilterOnId
()
{
listPublisherVersionsView
.
set
PublisherId
(
1
);
listPublisherVersionsView
.
setView
();
listPublisherVersionsView
.
set
StringId
(
"1"
);
listPublisherVersionsView
.
init
();
Mockito
.
verify
(
publisherService
).
getAllPublisherVersions
();
assertThat
(
listPublisherVersionsView
.
isViewAll
()).
isFalse
();
assertThat
(
listPublisherVersionsView
.
getPublisherVersions
()).
containsExactly
(
publisherVersion1
);
...
...
Please
register
or
login
to post a comment