Jean-Francois Leveque
...@@ -15,4 +15,8 @@ public class ActionType { ...@@ -15,4 +15,8 @@ public class ActionType {
15 private int actionTypeId; 15 private int actionTypeId;
16 16
17 private String actionTypeName; 17 private String actionTypeName;
18 +
19 + public String getActionTypeName() {
20 + return actionTypeName;
21 + }
18 } 22 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -23,7 +23,7 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { ...@@ -23,7 +23,7 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ {
23 @OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER) 23 @OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER)
24 private Set<PublisherVersion> versions; 24 private Set<PublisherVersion> versions;
25 25
26 - @OneToMany(mappedBy = "publisher") 26 + @OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER)
27 private Set<PublisherAction> actions; 27 private Set<PublisherAction> actions;
28 28
29 public int getPublisherId() { 29 public int getPublisherId() {
......
1 +package org.legrog.web.publisher;
2 +
3 +import org.legrog.entities.PublisherAction;
4 +import org.slf4j.Logger;
5 +import org.slf4j.LoggerFactory;
6 +
7 +import javax.faces.view.ViewScoped;
8 +import javax.inject.Inject;
9 +import javax.inject.Named;
10 +import java.io.Serializable;
11 +import java.util.List;
12 +import java.util.stream.Collectors;
13 +
14 +/*
15 + Vue de listPublisherVersions.xhtml
16 + Permet de voir l'ensemble des actions des éditeurs.
17 + Permet de voir l'ensemble des actions d'un éditeur.
18 + */
19 +@Named
20 +@ViewScoped
21 +public class ListPublisherActionsView implements Serializable {
22 +
23 + Logger logger = LoggerFactory.getLogger(getClass());
24 +
25 + protected PublisherService publisherService;
26 +
27 + private Integer publisherId;
28 + private boolean viewAll;
29 + private List<PublisherAction> publisherActions;
30 +
31 + @Inject
32 + public ListPublisherActionsView(PublisherService publisherService) {
33 + this.publisherService = publisherService;
34 + }
35 +
36 + //no args constructor to make it proxyable
37 + ListPublisherActionsView() {
38 + }
39 +
40 + public void setView() {
41 + logger.trace("setView : publisherId = {}", publisherId);
42 + publisherActions = publisherService.getAllPublisherActions();
43 + viewAll = (publisherId == null);
44 + if (!viewAll) {
45 + logger.trace("setView : !viewAll");
46 + filterOnID();
47 + }
48 + }
49 +
50 + public void filterOnID() {
51 + publisherActions = publisherActions.stream()
52 + .filter(action -> action.getPublisher().getPublisherId() == publisherId)
53 + .collect(Collectors.toList());
54 + }
55 +
56 + public void setPublisherId(Integer publisherId) {
57 + this.publisherId = publisherId;
58 + }
59 +
60 + public List<PublisherAction> getPublisherActions() {
61 + return publisherActions;
62 + }
63 +
64 + public boolean isViewAll() {
65 + return viewAll;
66 + }
67 +
68 + public Integer getPublisherId() {
69 + return publisherId;
70 + }
71 +
72 + public void setViewAll(boolean viewAll) {
73 + this.viewAll = viewAll;
74 + }
75 +
76 + public void setPublisherActions(List<PublisherAction> publisherActions) {
77 + this.publisherActions = publisherActions;
78 + }
79 +}
...@@ -23,4 +23,6 @@ public interface PublisherService { ...@@ -23,4 +23,6 @@ public interface PublisherService {
23 PublisherVersion getPublisherVersion(Integer publisherVersionId); 23 PublisherVersion getPublisherVersion(Integer publisherVersionId);
24 24
25 PublisherAction getLastValidate(Publisher publisher); 25 PublisherAction getLastValidate(Publisher publisher);
26 +
27 + List<PublisherAction> getAllPublisherActions();
26 } 28 }
......
...@@ -102,9 +102,12 @@ public class PublisherServiceSpring implements PublisherService { ...@@ -102,9 +102,12 @@ public class PublisherServiceSpring implements PublisherService {
102 return publisherVersionRepository.findOne(publisherVersionId); 102 return publisherVersionRepository.findOne(publisherVersionId);
103 } 103 }
104 104
105 - @Override
106 public PublisherAction getLastValidate(Publisher publisher) { 105 public PublisherAction getLastValidate(Publisher publisher) {
107 return publisherActionRepository.publisherLastValidate(publisher); 106 return publisherActionRepository.publisherLastValidate(publisher);
108 } 107 }
109 108
109 + public List<PublisherAction> getAllPublisherActions() {
110 + return publisherActionRepository.findAll();
111 + }
112 +
110 } 113 }
......
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 +<html xmlns="http://www.w3.org/1999/xhtml"
5 + xmlns:h="http://xmlns.jcp.org/jsf/html"
6 + xmlns:jsf="http://xmlns.jcp.org/jsf"
7 + xmlns:f="http://xmlns.jcp.org/jsf/core">
8 +<f:metadata>
9 + <f:viewParam name="publisherId" value="#{listPublisherActionsView.publisherId}"/>
10 + <f:viewAction action="#{listPublisherActionsView.setView}"/>
11 +</f:metadata>
12 +<head>
13 + <link rel="stylesheet" type="text/css" href="/minimal.css"/>
14 +</head>
15 +<body>
16 +<ul>
17 + <li>
18 + <a jsf:outcome="/index">Menu principal</a>
19 + </li>
20 + <li>
21 + <a jsf:outcome="listPublisherVersions">Liste des versions des éditeurs</a>
22 + </li>
23 + <li>
24 + <a jsf:outcome="publisherVersion">Ajouter un éditeur</a>
25 + </li>
26 +</ul>
27 +
28 +<a jsf:outcome="listPublisherActions" jsf:rendered="#{not listPublisherActionsView.viewAll}">Voir toutes les actions</a>
29 +
30 +<h:dataTable value="#{listPublisherActionsView.publisherActions}" var="action">
31 + <h:column>
32 + <f:facet name="header">Action</f:facet>
33 + ${action.actionType.actionTypeName}
34 + </h:column>
35 + <h:column>
36 + <f:facet name="header">Author</f:facet>
37 + ${action.publisherActionAuthor.displayName}
38 + </h:column>
39 + <h:column>
40 + <f:facet name="header">Action Datetime</f:facet>
41 + ${action.publisherActionDatetime}
42 + </h:column>
43 + <h:column>
44 + <f:facet name="header">Name</f:facet>
45 + ${action.publisherVersion.publisherName}
46 + </h:column>
47 + <h:column>
48 + <f:facet name="header">Address</f:facet>
49 + ${action.publisherVersion.publisherPostOfficeBoxNumber}<br />
50 + ${action.publisherVersion.publisherStreetAddress}<br />
51 + ${action.publisherVersion.publisherPostalCode} ${action.publisherVersion.publisherAddressLocality}<br />
52 + ${action.publisherVersion.publisherAddressRegion}<br />
53 + ${action.publisherVersion.publisherAddressCountry.countryName}
54 + </h:column>
55 + <h:column>
56 + <f:facet name="header">Telephone</f:facet>
57 + ${action.publisherVersion.publisherTelephone}
58 + </h:column>
59 + <h:column>
60 + <f:facet name="header">Email</f:facet>
61 + ${action.publisherVersion.publisherEmail}
62 + </h:column>
63 + <h:column>
64 + <f:facet name="header">URL</f:facet>
65 + ${action.publisherVersion.publisherURL}
66 + </h:column>
67 + <h:column>
68 + <f:facet name="header">Active ?</f:facet>
69 + ${action.publisherVersion.publisherActive}
70 + </h:column>
71 + <h:column>
72 + <f:facet name="header">History</f:facet>
73 + ${action.publisherVersion.publisherHistory}
74 + </h:column>
75 + <h:column>
76 + <f:facet name="header">Version Author</f:facet>
77 + ${action.publisherVersion.publisherVersionAuthor.displayName}
78 + </h:column>
79 + <h:column>
80 + <f:facet name="header">Version Datetime</f:facet>
81 + ${action.publisherVersion.publisherVersionDatetime}
82 + </h:column>
83 +
84 +</h:dataTable>
85 +
86 +</body>
87 +</html>
...\ No newline at end of file ...\ No newline at end of file
...@@ -10,27 +10,22 @@ ...@@ -10,27 +10,22 @@
10 <f:viewAction action="#{listPublisherVersionsView.setView}"/> 10 <f:viewAction action="#{listPublisherVersionsView.setView}"/>
11 </f:metadata> 11 </f:metadata>
12 <head> 12 <head>
13 - <style type="text/css"> 13 + <link rel="stylesheet" type="text/css" href="/minimal.css"/>
14 - table {
15 - border-collapse: collapse;
16 - }
17 - table, th, td {
18 - border-style: solid;
19 - border-width: 1px;
20 - }
21 - </style>
22 </head> 14 </head>
23 <body> 15 <body>
24 <ul> 16 <ul>
25 <li> 17 <li>
26 <a jsf:outcome="/index">Menu principal</a> 18 <a jsf:outcome="/index">Menu principal</a>
27 </li> 19 </li>
20 + <li>
21 + <a jsf:outcome="listPublisherActions">Liste des actions des éditeurs</a>
22 + </li>
28 <li> 23 <li>
29 <a jsf:outcome="publisherVersion">Ajouter un éditeur</a> 24 <a jsf:outcome="publisherVersion">Ajouter un éditeur</a>
30 </li> 25 </li>
31 </ul> 26 </ul>
32 27
33 - <a jsf:outcome="listPublisherVersions" jsf:rendered="#{not listPublisherVersionsView.viewAll}">Voir tous les éditeurs</a> 28 + <a jsf:outcome="listPublisherVersions" jsf:rendered="#{not listPublisherVersionsView.viewAll}">Voir toutes les versions d'éditeurs</a>
34 <p jsf:rendered="#{listPublisherVersionsView.publisherVersions.isEmpty()}">Liste des révisions est vide</p> 29 <p jsf:rendered="#{listPublisherVersionsView.publisherVersions.isEmpty()}">Liste des révisions est vide</p>
35 <h:dataTable value="#{listPublisherVersionsView.publisherVersions}" var="version"> 30 <h:dataTable value="#{listPublisherVersionsView.publisherVersions}" var="version">
36 <h:column> 31 <h:column>
...@@ -46,6 +41,13 @@ ...@@ -46,6 +41,13 @@
46 </a> 41 </a>
47 </h:column> 42 </h:column>
48 <h:column> 43 <h:column>
44 + <f:facet name="header">Actions</f:facet>
45 + <p jsf:rendered="#{version.publisher.actions.size() == 0}">Aucune action à lister</p>
46 + <a jsf:outcome="listPublisherActions" jsf:rendered="#{version.publisher.actions.size() > 0}">Voir les actions
47 + <f:param name="publisherId" value="#{version.publisher.publisherId}"/>
48 + </a>
49 + </h:column>
50 + <h:column>
49 <f:facet name="header">Valide</f:facet> 51 <f:facet name="header">Valide</f:facet>
50 <p jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">Validé</p> 52 <p jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">Validé</p>
51 <p jsf:rendered="#{listPublisherVersionsView.viewAll and version.publisherVersionId != version.publisher.validatedVersion.publisherVersionId}">Non validé</p> 53 <p jsf:rendered="#{listPublisherVersionsView.viewAll and version.publisherVersionId != version.publisher.validatedVersion.publisherVersionId}">Non validé</p>
......
...@@ -20,7 +20,10 @@ ...@@ -20,7 +20,10 @@
20 <a jsf:outcome="/index">Menu principal</a> 20 <a jsf:outcome="/index">Menu principal</a>
21 </li> 21 </li>
22 <li> 22 <li>
23 - <a jsf:outcome="listPublisherVersions">Versions des éditeurs</a> 23 + <a jsf:outcome="listPublisherVersions">Liste des versions des éditeurs</a>
24 + </li>
25 + <li>
26 + <a jsf:outcome="listPublisherActions">Liste des actions des éditeurs</a>
24 </li> 27 </li>
25 </ul> 28 </ul>
26 29
......
...@@ -6,10 +6,13 @@ ...@@ -6,10 +6,13 @@
6 <body> 6 <body>
7 <ul> 7 <ul>
8 <li> 8 <li>
9 - <a jsf:outcome="publisher/publisherVersion">Ajouter un éditeur</a> 9 + <a jsf:outcome="publisher/listPublisherVersions">Liste des versions des éditeurs</a>
10 </li> 10 </li>
11 <li> 11 <li>
12 - <a jsf:outcome="publisher/listPublisherVersions">Liste des versions des éditeurs</a> 12 + <a jsf:outcome="publisher/listPublisherActions">Liste des actions des éditeurs</a>
13 + </li>
14 + <li>
15 + <a jsf:outcome="publisher/publisherVersion">Ajouter un éditeur</a>
13 </li> 16 </li>
14 </ul> 17 </ul>
15 </body> 18 </body>
......
1 +table {
2 + border-collapse: collapse;
3 +}
4 +table, th, td {
5 + border-style: solid;
6 + border-width: 1px;
7 +}
...\ No newline at end of file ...\ No newline at end of file