JR Utily

moved everything for more readibility

Showing 34 changed files with 144 additions and 117 deletions
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 ListPublisherRevisionsBean {
Logger logger = LoggerFactory.getLogger(getClass());
@Inject
PublisherRevisionService publisherRevisionService;
PublisherService publisherRevisionService;
private Integer publisherId;
......
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;
......@@ -20,7 +18,6 @@ import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.Set;
@Named
@ViewScoped
......@@ -29,8 +26,7 @@ public class PublisherRevisionView implements Serializable {
@Inject
private PublisherService publisherService;
@Inject
PublisherRevisionService publisherRevisionService;
@Inject
UserService userService;
@Inject
......@@ -101,15 +97,17 @@ public class PublisherRevisionView implements Serializable {
// End TODO
publisherRevision.setPublisherRevisionAuthor(user);
// FIXME un seul appel logique à faire (pour la gestion du rollback)
publisherService.addRevisionToPublisher(publisher, publisherRevision);
publisherRevisionService.addPublisherRevision(publisherRevision);
publisherService.addPublisherRevision(publisherRevision);
editMode = false;
}
public void loadData() {
logger.debug("publisherRevisionId = {}", this.publisherRevisionId);
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,9 +6,16 @@ import org.legrog.entities.PublisherRevision;
import java.util.List;
public interface PublisherService {
void addPublisher(Publisher publisher);
void addRevisionToPublisher(Publisher publisher, PublisherRevision publisherRevision);
List<Publisher> getAllPublishers();
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;
}
}
......@@ -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;
......