JR Utily

Merge branch 'infra' into historiqueEditeur

Conflicts:
	src/main/java/org/legrog/presentation/ListPublisherRevisionsBean.java
	src/main/java/org/legrog/presentation/ListPublisherRevisionsView.java
	src/main/java/org/legrog/web/publisher/ListPublisherRevisionsBean.java
	src/main/java/org/legrog/web/publisher/PublisherRevisionView.java
	src/main/java/org/legrog/web/publisher/PublisherService.java
Showing 37 changed files with 171 additions and 124 deletions
This diff is collapsed. Click to expand it.
package org.legrog.application;
import org.legrog.entities.PublisherRevision;
import java.util.List;
public interface PublisherRevisionService {
void addPublisherRevision(PublisherRevision publisherRevision);
List<PublisherRevision> getAllPublisherRevisions();
PublisherRevision getPublisherRevision(Integer publisherRevisionId);
}
package org.legrog.application;
import org.legrog.entities.PublisherRevision;
import org.legrog.entities.PublisherRevisionRepository;
import javax.ejb.Stateless;
import javax.inject.Inject;
import java.util.List;
@Stateless
public class PublisherRevisionServiceSpring implements PublisherRevisionService {
@Inject
PublisherRevisionRepository publisherRevisionRepository;
public void addPublisherRevision(PublisherRevision publisherRevision) {
publisherRevisionRepository.save(publisherRevision);
}
public List<PublisherRevision> getAllPublisherRevisions() {
return publisherRevisionRepository.findAll();
}
public PublisherRevision getPublisherRevision(Integer publisherRevisionId) {
return publisherRevisionRepository.findOne(publisherRevisionId);
}
}
\ No newline at end of file
package org.legrog.presentation;
package org.legrog.web.book;
import org.legrog.application.BookService;
import org.legrog.entities.Book;
import javax.enterprise.context.RequestScoped;
......
package org.legrog.application;
package org.legrog.web.book;
import org.legrog.entities.Book;
......
package org.legrog.application;
package org.legrog.web.book;
import org.legrog.entities.Book;
import org.slf4j.Logger;
......@@ -8,7 +8,6 @@ import javax.ejb.Stateless;
import javax.enterprise.inject.Alternative;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.criteria.CriteriaQuery;
import java.util.List;
......
package org.legrog.application;
package org.legrog.web.book;
import org.legrog.entities.Book;
import org.legrog.entities.BookRepository;
import org.legrog.web.book.BookService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ejb.Stateless;
import javax.enterprise.inject.Alternative;
import javax.inject.Inject;
import java.util.List;
......
package org.legrog.presentation;
package org.legrog.web.publisher;
import org.legrog.application.PublisherRevisionService;
import org.legrog.application.PublisherService;
import org.legrog.application.SharedService;
import org.legrog.application.UserService;
import org.legrog.web.xyz.SharedService;
import org.legrog.web.user.UserService;
import org.legrog.entities.Country;
import org.legrog.entities.Publisher;
import org.legrog.entities.PublisherRevision;
......@@ -15,9 +13,8 @@ import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.Date;
import java.sql.Timestamp;
import java.time.ZoneId;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
......@@ -33,8 +30,7 @@ public class AddPublisherBean {
private UserService userService;
@Inject
private PublisherService publisherService;
@Inject
private PublisherRevisionService publisherRevisionService;
private String publisherName;
private String publisherStreetAddress;
......@@ -82,8 +78,11 @@ public class AddPublisherBean {
// End TODO
publisherRevision.setPublisherRevisionAuthor(user);
logger.info(publisherRevision.toString());
// FIXME un seul appel logique à faire (pour la gestion du rollback)
publisherService.addPublisher(publisher);
publisherRevisionService.addPublisherRevision(publisherRevision);
publisherService.addPublisherRevision(publisherRevision);
// Test de récupération de l'Id
logger.info(publisherRevision.toString());
return "success";
......
package org.legrog.presentation;
package org.legrog.web.publisher;
import org.legrog.application.PublisherRevisionService;
import org.legrog.application.PublisherService;
import org.legrog.entities.Publisher;
import org.legrog.entities.PublisherRevision;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -11,8 +8,6 @@ import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@Named
......@@ -21,7 +16,7 @@ public class ListPublisherRevisionsView {
Logger logger = LoggerFactory.getLogger(getClass());
@Inject
PublisherRevisionService publisherRevisionService;
PublisherService publisherService;
private Integer publisherId;
......@@ -48,17 +43,14 @@ public class ListPublisherRevisionsView {
*/
@PostConstruct
public void init() {
publisherRevisions = publisherRevisionService.getAllPublisherRevisions();
publisherRevisions = publisherService.getAllPublisherRevisions();
logger.info("init");
}
public void setView() {
logger.info("setView");
logger.info("publisherId = " + publisherId);
viewAll = false;
if (publisherId == null) {
viewAll = true;
}
viewAll = ( publisherId == null ) ;
}
public Integer getPublisherId() {
......
package org.legrog.presentation;
package org.legrog.web.publisher;
import org.legrog.application.PublisherRevisionService;
import org.legrog.application.PublisherService;
import org.legrog.application.SharedService;
import org.legrog.application.UserService;
import org.legrog.web.xyz.SharedService;
import org.legrog.web.user.UserService;
import org.legrog.entities.Country;
import org.legrog.entities.Publisher;
import org.legrog.entities.PublisherRevision;
......@@ -17,7 +15,11 @@ import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.*;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
@Named
@ViewScoped
......@@ -26,8 +28,7 @@ public class PublisherRevisionView implements Serializable {
@Inject
private PublisherService publisherService;
@Inject
PublisherRevisionService publisherRevisionService;
@Inject
UserService userService;
@Inject
......@@ -111,7 +112,7 @@ public class PublisherRevisionView implements Serializable {
public void add() {
Publisher publisher = new Publisher();
PublisherRevision publisherRevision = new PublisherRevision();
HashSet<PublisherRevision> publisherRevisions = new HashSet<PublisherRevision>();
Set<PublisherRevision> publisherRevisions = new HashSet<PublisherRevision>();
publisherRevisions.add(publisherRevision);
publisher.setRevisions(publisherRevisions);
......@@ -119,8 +120,10 @@ public class PublisherRevisionView implements Serializable {
setValues(publisherRevision);
// FIXME un seul appel logique à faire (pour la gestion du rollback)
publisherService.addPublisher(publisher);
publisherRevisionService.addPublisherRevision(publisherRevision);
publisherService.addPublisherRevision(publisherRevision);
newPublisher = false;
publisherRevisionId = publisherRevision.getPublisherRevisionId();
publisherId = publisher.getPublisherId();
......@@ -135,8 +138,10 @@ public class PublisherRevisionView implements Serializable {
setValues(publisherRevision);
// FIXME un seul appel logique à faire (pour la gestion du rollback)
publisherService.addRevisionToPublisher(publisher, publisherRevision);
publisherRevisionService.addPublisherRevision(publisherRevision);
publisherService.addPublisherRevision(publisherRevision);
editMode = false;
}
......@@ -144,7 +149,8 @@ public class PublisherRevisionView implements Serializable {
logger.debug("publisherRevisionId = {}", this.publisherRevisionId);
if (publisherRevisionId != 0) {
PublisherRevision publisherRevision = publisherRevisionService.getPublisherRevision(publisherRevisionId);
PublisherRevision publisherRevision = publisherService.getPublisherRevision(publisherRevisionId);
logger.debug("Found a publisher revision : {}", publisherRevision.toString());
......
package org.legrog.application;
package org.legrog.web.publisher;
import org.legrog.entities.Publisher;
import org.legrog.entities.PublisherRevision;
......@@ -6,6 +6,7 @@ import org.legrog.entities.PublisherRevision;
import java.util.List;
public interface PublisherService {
void addPublisher(Publisher publisher);
void addRevisionToPublisher(Publisher publisher, PublisherRevision publisherRevision);
......@@ -13,4 +14,10 @@ public interface PublisherService {
List<Publisher> getAllPublishers();
Publisher getPublisher(Integer publisherId);
void addPublisherRevision(PublisherRevision publisherRevision);
List<PublisherRevision> getAllPublisherRevisions();
PublisherRevision getPublisherRevision(Integer publisherRevisionId);
}
......
package org.legrog.application;
package org.legrog.web.publisher;
import org.legrog.entities.Publisher;
import org.legrog.entities.PublisherRepository;
import org.legrog.entities.PublisherRevision;
import org.legrog.entities.PublisherRevisionRepository;
import javax.ejb.Stateless;
import javax.inject.Inject;
......@@ -15,6 +16,21 @@ public class PublisherServiceSpring implements PublisherService {
@Inject
PublisherRepository publisherRepository;
@Inject
PublisherRevisionRepository publisherRevisionRepository;
public void addPublisherRevision(PublisherRevision publisherRevision) {
publisherRevisionRepository.save(publisherRevision);
}
public List<PublisherRevision> getAllPublisherRevisions() {
return publisherRevisionRepository.findAll();
}
public PublisherRevision getPublisherRevision(Integer publisherRevisionId) {
return publisherRevisionRepository.findOne(publisherRevisionId);
}
public void addPublisher(Publisher publisher) {
publisherRepository.save(publisher);
}
......
package org.legrog.presentation;
package org.legrog.web.user;
import org.legrog.application.UserService;
import org.legrog.entities.User;
import javax.annotation.PostConstruct;
......
package org.legrog.presentation;
package org.legrog.web.user;
import org.legrog.application.SharedService;
import org.legrog.application.UserService;
import org.legrog.web.xyz.SharedService;
import org.legrog.entities.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......
package org.legrog.application;
package org.legrog.web.user;
import org.legrog.entities.User;
......
package org.legrog.application;
package org.legrog.web.user;
import org.legrog.entities.User;
import org.legrog.entities.UserRepository;
......
package org.legrog.presentation;
package org.legrog.web.xyz;
import org.legrog.application.SharedService;
import org.legrog.entities.Country;
import javax.enterprise.context.RequestScoped;
......
package org.legrog.presentation;
package org.legrog.web.xyz;
import org.legrog.application.SharedService;
import org.legrog.entities.Country;
import javax.annotation.PostConstruct;
......
package org.legrog.application;
package org.legrog.web.xyz;
import org.legrog.entities.Country;
import org.legrog.entities.DisplayNameMask;
......
package org.legrog.application;
package org.legrog.web.xyz;
import org.legrog.entities.*;
//import org.slf4j.Logger;
......
<?xml version="1.0" encoding="UTF-8"?>
<body jsf:id="root-body" xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:jsf="http://xmlns.jcp.org/jsf">
<p>
I'm looking for something
</p>
<p>
And this is my string : #{testRootView.foo}
</p>
<p>
And this is another string : #{testRootView.bar}
</p>
</body>
package org.legrog.web.xyz;
import javax.inject.Named;
import java.io.Serializable;
@Named
@javax.enterprise.context.RequestScoped
//@URLMapping(id = "testroot", pattern = "/testRoot/#{bar : testRootView.bar}", viewId = "xyz/TestRoot.jsf")
public class TestRootView implements Serializable {
String foo = "my first String";
String bar ="";
//
// public void init() {
// if (number == null) {
// foo = "my second String";
// } else {
// foo = "my string #"+number;
// }
//
// }
public String getFoo() {
return foo;
}
public void setFoo(String foo) {
this.foo = foo;
}
public String getBar() {
return bar;
}
public void setBar(String bar) {
this.bar = bar;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender>
<logger name="org.legrog" level="DEBUG"/>
<root level="warn">
<appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
......@@ -17,92 +17,92 @@
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>addBook</from-outcome>
<to-view-id>/book.xhtml</to-view-id>
<to-view-id>/book/book.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>listBooks</from-outcome>
<to-view-id>/result.xhtml</to-view-id>
<to-view-id>/book/result.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>addCountry</from-outcome>
<to-view-id>/addCountry.xhtml</to-view-id>
<to-view-id>/xyz/addCountry.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>listCountries</from-outcome>
<to-view-id>/listCountries.xhtml</to-view-id>
<to-view-id>/xyz/listCountries.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>addUser</from-outcome>
<to-view-id>/updateUser.xhtml</to-view-id>
<to-view-id>/user/updateUser.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>listUsers</from-outcome>
<to-view-id>/listUsers.xhtml</to-view-id>
<to-view-id>/user/listUsers.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/addPublisher.xhtml</from-view-id>
<from-view-id>/publisher/addPublisher.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/listPublisherRevisions.xhtml</to-view-id>
<to-view-id>/publisher/listPublisherRevisions.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/addCountry.xhtml</from-view-id>
<from-view-id>/xyz/addCountry.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/listCountries.xhtml</to-view-id>
<to-view-id>/xyz/listCountries.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/addUser_short.xhtml</from-view-id>
<from-view-id>/user/addUser_short.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/listUsers_short.xhtml</to-view-id>
<to-view-id>/user/listUsers_short.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/book.xhtml</from-view-id>
<from-view-id>/book/book.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/result.xhtml</to-view-id>
<to-view-id>/book/result.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/result.xhtml</from-view-id>
<from-view-id>/book/result.xhtml</from-view-id>
<navigation-case>
<from-outcome>back</from-outcome>
<to-view-id>/book.xhtml</to-view-id>
<to-view-id>/book/book.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/updateUser.xhtml</from-view-id>
<from-view-id>/user/updateUser.xhtml</from-view-id>
<navigation-case>
<from-outcome>cancel</from-outcome>
<to-view-id>/listUsers.xhtml</to-view-id>
<to-view-id>/user/listUsers.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/listUsers.xhtml</to-view-id>
<to-view-id>/user/listUsers.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/listUsers.xhtml</from-view-id>
<from-view-id>/user/listUsers.xhtml</from-view-id>
<navigation-case>
<from-outcome>add</from-outcome>
<to-view-id>/updateUser.xhtml</to-view-id>
<to-view-id>/user/updateUser.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/listPublisherRevisions.xhtml</from-view-id>
<from-view-id>/publisher/listPublisherRevisions.xhtml</from-view-id>
<navigation-case>
<from-outcome>view</from-outcome>
<to-view-id>/publisherRevision.xhtml</to-view-id>
<to-view-id>/publisher/publisherRevision.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
\ No newline at end of file
......
package org.legrog.application;
package org.legrog.web.book;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.legrog.entities.Book;
import org.legrog.web.book.BookServiceOld;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.Mockito;
......