Jean-Francois Leveque

https://tree.taiga.io/project/jr-utily-grog-v3/us/44 Implementer l'historisation pour les éditeurs

https://tree.taiga.io/project/jr-utily-grog-v3/task/83 Ajouter les commentaires de début de classe
classes contenues dans src/main/java/org/legrog/web/publisher/
......@@ -14,6 +14,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/*
Vue de listPublisherRevisions.xhtml
Permet de voir l'ensemble des versions des éditeurs.
Permet de voir l'ensemble des versions d'un éditeur et de valider l'une d'elles.
*/
@Named
@RequestScoped
public class ListPublisherRevisionsView {
......@@ -28,10 +33,6 @@ public class ListPublisherRevisionsView {
private List<PublisherRevision> publisherRevisions;
public List<PublisherRevision> getPublisherRevisions() {
return publisherRevisions;
}
public void validate() {
logger.debug("validate");
Publisher publisher = publisherService.getPublisher(publisherId);
......@@ -64,16 +65,20 @@ public class ListPublisherRevisionsView {
}
public void setView() {
logger.info("setView");
logger.info("publisherId = " + publisherId);
logger.debug("setView");
logger.debug("publisherId = " + publisherId);
viewAll = ( publisherId == null ) ;
if (!viewAll) {
logger.info("!viewAll");
logger.debug("!viewAll");
publisherRevisions = filter();
}
}
// get, set et is
public List<PublisherRevision> getPublisherRevisions() {
return publisherRevisions;
}
public Integer getPublisherId() {
return publisherId;
}
......
......@@ -16,6 +16,12 @@ import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;
/*
Vue de publisherRevision.xhtml
Permet la création, l'affichage et la modification d'une version d'éditeur.
La création d'une version crée l'éditeur et sa version initiale.
Le modification crée une nouvelle version liée à l'éditeur.
*/
@Named
@ViewScoped
public class PublisherRevisionView implements Serializable {
......@@ -29,7 +35,6 @@ public class PublisherRevisionView implements Serializable {
private boolean editMode;
private boolean newPublisher;
// Données temporaires d'un PublisherRevision
private int publisherRevisionId;
private String publisherName;
private String publisherStreetAddress;
......@@ -47,7 +52,6 @@ public class PublisherRevisionView implements Serializable {
private Timestamp publisherRevisionDatetime;
private Publisher publisher;
// Table de codification
private List<Country> availableCountries;
@PostConstruct
......@@ -63,10 +67,6 @@ public class PublisherRevisionView implements Serializable {
editMode = false;
}
public boolean isEditMode() {
return editMode;
}
public void save() {
logger.debug("save()");
if (newPublisher) {
......@@ -93,6 +93,14 @@ public class PublisherRevisionView implements Serializable {
publisherRevision.setPublisherURL(publisherURL);
}
private void getImmutableValues() {
PublisherRevision publisherRevision;
publisherRevision = publisherService.getPublisherRevision(publisherRevisionId);
publisherRevisionAuthor = publisherRevision.getPublisherRevisionAuthor();
publisherRevisionDatetime = publisherRevision.getPublisherRevisionDatetime();
}
public void add() {
Publisher publisher = new Publisher();
PublisherRevision publisherRevision = new PublisherRevision();
......@@ -103,8 +111,9 @@ public class PublisherRevisionView implements Serializable {
newPublisher = false;
publisherRevisionId = publisherRevision.getPublisherRevisionId();
this.publisher = publisher;
publisherRevisionAuthor = publisherRevision.getPublisherRevisionAuthor();
publisherRevisionDatetime = publisherRevision.getPublisherRevisionDatetime();
getImmutableValues();
editMode = false;
}
......@@ -114,6 +123,10 @@ public class PublisherRevisionView implements Serializable {
publisherService.addRevisionToPublisher(publisher, publisherRevision);
publisherRevisionId = publisherRevision.getPublisherRevisionId();
getImmutableValues();
editMode = false;
}
......@@ -138,10 +151,10 @@ public class PublisherRevisionView implements Serializable {
publisherURL = publisherRevision.getPublisherURL();
publisherActive = publisherRevision.isPublisherActive();
publisherHistory = publisherRevision.getPublisherHistory();
publisherRevisionAuthor = publisherRevision.getPublisherRevisionAuthor();
publisherRevisionDatetime = publisherRevision.getPublisherRevisionDatetime();
publisher = publisherRevision.getPublisher();
getImmutableValues();
logger.debug("Found a publisher : {}", publisher.toString());
newPublisher = false;
} else {
......@@ -284,4 +297,9 @@ public class PublisherRevisionView implements Serializable {
public boolean isNewPublisher() {
return newPublisher;
}
public boolean isEditMode() {
return editMode;
}
}
\ No newline at end of file
......
......@@ -5,15 +5,17 @@ import org.legrog.entities.PublisherRevision;
import java.util.List;
/*
Interface correspondant à la gestion des éditeurs et de leurs versions.
Contient des signatures méthodes d'ajout, de modification et de validation de version ainsi que de restitution.
*/
public interface PublisherService {
void addPublisherWithRevision(Publisher publisher, PublisherRevision publisherRevision);
void validatePublisherRevision(Publisher publisher, Integer publisherRevisionId);
void addRevisionToPublisher(Publisher publisher, PublisherRevision publisherRevision);
// List<Publisher> getAllPublishers();
void validatePublisherRevision(Publisher publisher, Integer publisherRevisionId);
Publisher getPublisher(Integer publisherId);
......
package org.legrog.web.publisher;
import org.legrog.entities.*;
import org.legrog.entities.Publisher;
import org.legrog.entities.PublisherRepository;
import org.legrog.entities.PublisherRevision;
import org.legrog.entities.PublisherRevisionRepository;
import org.legrog.web.xyz.SharedService;
import javax.ejb.Stateless;
......@@ -12,6 +15,10 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
/*
Implémentation de l'interface PublisherService
*/
@Stateless
public class PublisherServiceSpring implements PublisherService {
@Inject
......@@ -72,9 +79,5 @@ public class PublisherServiceSpring implements PublisherService {
public Publisher getPublisher(Integer publisherId) {
return publisherRepository.findOne(publisherId);
}
/*
public List<Publisher> getAllPublishers() {
return publisherRepository.findAll();
}
*/
}
......
......@@ -14,7 +14,7 @@
</head>
<body>
<form jsf:id="publisherRevisionView" action="">
<h:form>
<ul>
<li>
<a jsf:outcome="/index">Menu principal</a>
......@@ -65,6 +65,6 @@
<button jsf:rendered="#{publisherRevisionView.editMode}" jsf:action="#{publisherRevisionView.save}">Save</button>
<button jsf:rendered="#{publisherRevisionView.editMode}" jsf:action="#{publisherRevisionView.cancel}">Cancel</button>
</h:panelGrid>
</form>
</h:form>
</body>
</html>
\ No newline at end of file
......