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
2016-11-15 15:32:32 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0ddac29fbdae575e886c50499e27031776ab0686
0ddac29f
1 parent
196f1aa9
Refactoring de la validation d'une version.
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
20 deletions
src/main/java/org/legrog/web/publisher/ListPublisherVersionsView.java
src/main/java/org/legrog/web/publisher/PublisherService.java
src/main/java/org/legrog/web/publisher/PublisherServiceSpring.java
src/main/java/org/legrog/web/publisher/listPublisherVersions.xhtml
src/main/java/org/legrog/web/publisher/ListPublisherVersionsView.java
View file @
0ddac29
package
org
.
legrog
.
web
.
publisher
;
import
org.legrog.entities.Publisher
;
import
org.legrog.entities.PublisherVersion
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -37,12 +36,11 @@ public class ListPublisherVersionsView implements Serializable {
// View Action being executed at view loading
public
void
setView
()
{
logger
.
trace
(
"setView"
);
logger
.
debug
(
"publisherId = {}"
,
publisherId
);
logger
.
trace
(
"setView : publisherId = {}"
,
publisherId
);
publisherVersions
=
publisherService
.
getAllPublisherVersions
();
viewAll
=
(
publisherId
==
null
)
;
if
(!
viewAll
)
{
logger
.
trace
(
"!viewAll"
);
logger
.
trace
(
"
setView :
!viewAll"
);
filterOnID
();
}
}
...
...
@@ -54,16 +52,13 @@ public class ListPublisherVersionsView implements Serializable {
}
public
void
validate
(
Integer
publisherVersionId
)
{
public
void
validate
(
PublisherVersion
publisherVersion
)
{
logger
.
trace
(
"validate"
);
Publisher
publisher
=
publisherService
.
getPublisher
(
publisherId
);
logger
.
debug
(
"publisher (pre-validate) = {}"
,
publisher
);
publisherService
.
validatePublisherVersion
(
publisher
,
publisherVersionId
);
publisherService
.
validatePublisherVersion
(
publisher
Version
);
publisherVersions
=
publisherService
.
getAllPublisherVersions
();
filterOnID
();
logger
.
debug
(
"publisher (post-validate) = {}"
,
publisher
);
}
/** no args constructor to make it proxyable */
...
...
@@ -101,4 +96,9 @@ public class ListPublisherVersionsView implements Serializable {
public
void
setPublisherVersions
(
List
<
PublisherVersion
>
publisherVersions
)
{
this
.
publisherVersions
=
publisherVersions
;
}
@Override
public
String
toString
()
{
return
"publisherId = "
+
publisherId
+
", viewAll = "
+
viewAll
+
", publisherVersions = "
+
publisherVersions
;
}
}
\ No newline at end of file
...
...
src/main/java/org/legrog/web/publisher/PublisherService.java
View file @
0ddac29
...
...
@@ -15,9 +15,7 @@ public interface PublisherService {
void
addVersionToPublisher
(
Publisher
publisher
,
PublisherVersion
publisherVersion
);
void
validatePublisherVersion
(
Publisher
publisher
,
Integer
publisherVersionId
);
Publisher
getPublisher
(
Integer
publisherId
);
void
validatePublisherVersion
(
PublisherVersion
publisherVersion
);
List
<
PublisherVersion
>
getAllPublisherVersions
();
...
...
src/main/java/org/legrog/web/publisher/PublisherServiceSpring.java
View file @
0ddac29
...
...
@@ -35,7 +35,7 @@ public class PublisherServiceSpring implements PublisherService {
SharedService
sharedService
;
public
void
addPublisherWithVersion
(
Publisher
publisher
,
PublisherVersion
publisherVersion
)
{
Set
<
PublisherVersion
>
publisherVersions
=
new
HashSet
<
PublisherVersion
>();
Set
<
PublisherVersion
>
publisherVersions
=
new
HashSet
<>();
publisherVersions
.
add
(
publisherVersion
);
publisher
.
setVersions
(
publisherVersions
);
publisherVersion
.
setPublisher
(
publisher
);
...
...
@@ -58,8 +58,9 @@ public class PublisherServiceSpring implements PublisherService {
logger
.
trace
(
"fin addVersionToPublisher, publisherVersion = {}"
,
publisherVersion
);
}
public
void
validatePublisherVersion
(
Publisher
publisher
,
Integer
publisherVersionId
)
{
publisher
.
setValidatedVersion
(
this
.
getPublisherVersion
(
publisherVersionId
));
public
void
validatePublisherVersion
(
PublisherVersion
publisherVersion
)
{
Publisher
publisher
=
publisherVersion
.
getPublisher
();
publisher
.
setValidatedVersion
(
publisherVersion
);
publisher
.
setValidator
(
sharedService
.
getCurrentUser
());
publisher
.
setValidationDateTime
(
new
Timestamp
(
new
Date
().
getTime
()));
this
.
savePublisher
(
publisher
);
...
...
@@ -82,8 +83,4 @@ public class PublisherServiceSpring implements PublisherService {
return
publisherVersionRepository
.
findOne
(
publisherVersionId
);
}
public
Publisher
getPublisher
(
Integer
publisherId
)
{
return
publisherRepository
.
findOne
(
publisherId
);
}
}
...
...
src/main/java/org/legrog/web/publisher/listPublisherVersions.xhtml
View file @
0ddac29
...
...
@@ -51,7 +51,7 @@
<p
jsf:rendered=
"#{listPublisherVersionsView.viewAll and version.publisherVersionId != version.publisher.validatedVersion.publisherVersionId}"
>
Non validé
</p>
<!-- https://www.mkyong.com/jsf2/4-ways-to-pass-parameter-from-jsf-page-to-backing-bean/ f:param, problème avec Method expression -->
<form
action=
""
jsf:rendered=
"#{not listPublisherVersionsView.viewAll and version.publisherVersionId != version.publisher.validatedVersion.publisherVersionId}"
>
<button
jsf:action=
"#{listPublisherVersionsView.validate(version
.publisherVersionId
)}"
>
Valider
<button
jsf:action=
"#{listPublisherVersionsView.validate(version)}"
>
Valider
</button>
</form>
</h:column>
...
...
Please
register
or
login
to post a comment