Jean-Francois Leveque
......@@ -15,4 +15,8 @@ public class ActionType {
private int actionTypeId;
private String actionTypeName;
public String getActionTypeName() {
return actionTypeName;
}
}
\ No newline at end of file
......
......@@ -23,7 +23,7 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ {
@OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER)
private Set<PublisherVersion> versions;
@OneToMany(mappedBy = "publisher")
@OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER)
private Set<PublisherAction> actions;
public int getPublisherId() {
......
package org.legrog.web.publisher;
import org.legrog.entities.PublisherAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
/*
Vue de listPublisherVersions.xhtml
Permet de voir l'ensemble des actions des éditeurs.
Permet de voir l'ensemble des actions d'un éditeur.
*/
@Named
@ViewScoped
public class ListPublisherActionsView implements Serializable {
Logger logger = LoggerFactory.getLogger(getClass());
protected PublisherService publisherService;
private Integer publisherId;
private boolean viewAll;
private List<PublisherAction> publisherActions;
@Inject
public ListPublisherActionsView(PublisherService publisherService) {
this.publisherService = publisherService;
}
//no args constructor to make it proxyable
ListPublisherActionsView() {
}
public void setView() {
logger.trace("setView : publisherId = {}", publisherId);
publisherActions = publisherService.getAllPublisherActions();
viewAll = (publisherId == null);
if (!viewAll) {
logger.trace("setView : !viewAll");
filterOnID();
}
}
public void filterOnID() {
publisherActions = publisherActions.stream()
.filter(action -> action.getPublisher().getPublisherId() == publisherId)
.collect(Collectors.toList());
}
public void setPublisherId(Integer publisherId) {
this.publisherId = publisherId;
}
public List<PublisherAction> getPublisherActions() {
return publisherActions;
}
public boolean isViewAll() {
return viewAll;
}
public Integer getPublisherId() {
return publisherId;
}
public void setViewAll(boolean viewAll) {
this.viewAll = viewAll;
}
public void setPublisherActions(List<PublisherAction> publisherActions) {
this.publisherActions = publisherActions;
}
}
......@@ -23,4 +23,6 @@ public interface PublisherService {
PublisherVersion getPublisherVersion(Integer publisherVersionId);
PublisherAction getLastValidate(Publisher publisher);
List<PublisherAction> getAllPublisherActions();
}
......
......@@ -102,9 +102,12 @@ public class PublisherServiceSpring implements PublisherService {
return publisherVersionRepository.findOne(publisherVersionId);
}
@Override
public PublisherAction getLastValidate(Publisher publisher) {
return publisherActionRepository.publisherLastValidate(publisher);
}
public List<PublisherAction> getAllPublisherActions() {
return publisherActionRepository.findAll();
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
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>
<body>
<ul>
<li>
<a jsf:outcome="/index">Menu principal</a>
</li>
<li>
<a jsf:outcome="listPublisherVersions">Liste des versions des éditeurs</a>
</li>
<li>
<a jsf:outcome="publisherVersion">Ajouter un éditeur</a>
</li>
</ul>
<a jsf:outcome="listPublisherActions" jsf:rendered="#{not listPublisherActionsView.viewAll}">Voir toutes les actions</a>
<h:dataTable value="#{listPublisherActionsView.publisherActions}" var="action">
<h:column>
<f:facet name="header">Action</f:facet>
${action.actionType.actionTypeName}
</h:column>
<h:column>
<f:facet name="header">Author</f:facet>
${action.publisherActionAuthor.displayName}
</h:column>
<h:column>
<f:facet name="header">Action Datetime</f:facet>
${action.publisherActionDatetime}
</h:column>
<h:column>
<f:facet name="header">Name</f:facet>
${action.publisherVersion.publisherName}
</h:column>
<h:column>
<f:facet name="header">Address</f:facet>
${action.publisherVersion.publisherPostOfficeBoxNumber}<br />
${action.publisherVersion.publisherStreetAddress}<br />
${action.publisherVersion.publisherPostalCode} ${action.publisherVersion.publisherAddressLocality}<br />
${action.publisherVersion.publisherAddressRegion}<br />
${action.publisherVersion.publisherAddressCountry.countryName}
</h:column>
<h:column>
<f:facet name="header">Telephone</f:facet>
${action.publisherVersion.publisherTelephone}
</h:column>
<h:column>
<f:facet name="header">Email</f:facet>
${action.publisherVersion.publisherEmail}
</h:column>
<h:column>
<f:facet name="header">URL</f:facet>
${action.publisherVersion.publisherURL}
</h:column>
<h:column>
<f:facet name="header">Active ?</f:facet>
${action.publisherVersion.publisherActive}
</h:column>
<h:column>
<f:facet name="header">History</f:facet>
${action.publisherVersion.publisherHistory}
</h:column>
<h:column>
<f:facet name="header">Version Author</f:facet>
${action.publisherVersion.publisherVersionAuthor.displayName}
</h:column>
<h:column>
<f:facet name="header">Version Datetime</f:facet>
${action.publisherVersion.publisherVersionDatetime}
</h:column>
</h:dataTable>
</body>
</html>
\ No newline at end of file
......@@ -10,15 +10,7 @@
<f:viewAction action="#{listPublisherVersionsView.setView}"/>
</f:metadata>
<head>
<style type="text/css">
table {
border-collapse: collapse;
}
table, th, td {
border-style: solid;
border-width: 1px;
}
</style>
<link rel="stylesheet" type="text/css" href="/minimal.css"/>
</head>
<body>
<ul>
......@@ -26,11 +18,14 @@
<a jsf:outcome="/index">Menu principal</a>
</li>
<li>
<a jsf:outcome="listPublisherActions">Liste des actions des éditeurs</a>
</li>
<li>
<a jsf:outcome="publisherVersion">Ajouter un éditeur</a>
</li>
</ul>
<a jsf:outcome="listPublisherVersions" jsf:rendered="#{not listPublisherVersionsView.viewAll}">Voir tous les éditeurs</a>
<a jsf:outcome="listPublisherVersions" jsf:rendered="#{not listPublisherVersionsView.viewAll}">Voir toutes les versions d'éditeurs</a>
<p jsf:rendered="#{listPublisherVersionsView.publisherVersions.isEmpty()}">Liste des révisions est vide</p>
<h:dataTable value="#{listPublisherVersionsView.publisherVersions}" var="version">
<h:column>
......@@ -46,6 +41,13 @@
</a>
</h:column>
<h:column>
<f:facet name="header">Actions</f:facet>
<p jsf:rendered="#{version.publisher.actions.size() == 0}">Aucune action à lister</p>
<a jsf:outcome="listPublisherActions" jsf:rendered="#{version.publisher.actions.size() > 0}">Voir les actions
<f:param name="publisherId" value="#{version.publisher.publisherId}"/>
</a>
</h:column>
<h:column>
<f:facet name="header">Valide</f:facet>
<p jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">Validé</p>
<p jsf:rendered="#{listPublisherVersionsView.viewAll and version.publisherVersionId != version.publisher.validatedVersion.publisherVersionId}">Non validé</p>
......
......@@ -20,7 +20,10 @@
<a jsf:outcome="/index">Menu principal</a>
</li>
<li>
<a jsf:outcome="listPublisherVersions">Versions des éditeurs</a>
<a jsf:outcome="listPublisherVersions">Liste des versions des éditeurs</a>
</li>
<li>
<a jsf:outcome="listPublisherActions">Liste des actions des éditeurs</a>
</li>
</ul>
......
......@@ -6,10 +6,13 @@
<body>
<ul>
<li>
<a jsf:outcome="publisher/publisherVersion">Ajouter un éditeur</a>
<a jsf:outcome="publisher/listPublisherVersions">Liste des versions des éditeurs</a>
</li>
<li>
<a jsf:outcome="publisher/listPublisherVersions">Liste des versions des éditeurs</a>
<a jsf:outcome="publisher/listPublisherActions">Liste des actions des éditeurs</a>
</li>
<li>
<a jsf:outcome="publisher/publisherVersion">Ajouter un éditeur</a>
</li>
</ul>
</body>
......
table {
border-collapse: collapse;
}
table, th, td {
border-style: solid;
border-width: 1px;
}
\ No newline at end of file