Jean-Francois Leveque

Debut ajout Editeur

1 +package org.legrog.application;
2 +
3 +import org.legrog.entities.Publisher;
4 +
5 +import java.util.List;
6 +
7 +public interface PublisherService {
8 + void addPublisher(Publisher publisher);
9 +
10 + List<Publisher> getAllPublishers();
11 +}
1 +package org.legrog.application;
2 +
3 +
4 +import org.legrog.entities.Publisher;
5 +import org.legrog.entities.PublisherRepository;
6 +
7 +import javax.ejb.Stateless;
8 +import javax.inject.Inject;
9 +import java.util.List;
10 +
11 +@Stateless
12 +public class PublisherServiceSpring implements PublisherService {
13 + @Inject
14 + PublisherRepository publisherRepository;
15 +
16 + public void addPublisher(Publisher publisher) {
17 + publisherRepository.save(publisher);
18 + }
19 +
20 + public List<Publisher> getAllPublishers() {
21 + return publisherRepository.findAll();
22 + }
23 +}
...@@ -3,9 +3,7 @@ package org.legrog.entities; ...@@ -3,9 +3,7 @@ package org.legrog.entities;
3 import javax.persistence.*; 3 import javax.persistence.*;
4 4
5 @Entity 5 @Entity
6 -//@Table(name="pays")
7 public class Country /* extends org.roliste.data.DbEntity */ { 6 public class Country /* extends org.roliste.data.DbEntity */ {
8 - // @Column(name = "ID_PAYS")
9 @Id 7 @Id
10 @GeneratedValue(strategy = GenerationType.IDENTITY) /* Permet la population */ 8 @GeneratedValue(strategy = GenerationType.IDENTITY) /* Permet la population */
11 @Column(name="COUNTRY_ID") 9 @Column(name="COUNTRY_ID")
......
1 +package org.legrog.entities;
2 +
3 +import org.springframework.data.jpa.repository.JpaRepository;
4 +
5 +public interface PublisherRepository extends JpaRepository<Publisher, Integer> {
6 +}
1 +package org.legrog.presentation;
2 +
3 +import org.legrog.application.SharedService;
4 +import org.legrog.entities.Country;
5 +import org.legrog.entities.User;
6 +
7 +import javax.annotation.PostConstruct;
8 +import javax.enterprise.context.RequestScoped;
9 +import javax.inject.Inject;
10 +import javax.inject.Named;
11 +import java.sql.Timestamp;
12 +import java.util.List;
13 +
14 +@Named
15 +@RequestScoped
16 +public class AddPublisherBean {
17 + @Inject
18 + private SharedService sharedService;
19 +
20 + private String publisherName;
21 + private String publisherStreetAddress;
22 + private String publisherPostalCode;
23 + private String publisherPostOfficeBoxNumber;
24 + private String publisherAddressRegion;
25 + private String publisherAddressLocality;
26 + private Country publisherAddressCountry;
27 + private String publisherTelephone;
28 + private String publisherEmail;
29 + private String publisherURL;
30 + private boolean publisherActive;
31 + private String publisherHistory;
32 + private User publisherRevisionAuthor;
33 + private Timestamp publisherRevisionDatetime;
34 +
35 + private List<Country> availableCountries;
36 +
37 + public String add() {
38 + return "success";
39 + }
40 +
41 + @PostConstruct
42 + public void init() {
43 + availableCountries = sharedService.getAllCountries();
44 + }
45 +
46 + public String getPublisherName() {
47 + return publisherName;
48 + }
49 +
50 + public void setPublisherName(String publisherName) {
51 + this.publisherName = publisherName;
52 + }
53 +
54 + public String getPublisherStreetAddress() {
55 + return publisherStreetAddress;
56 + }
57 +
58 + public void setPublisherStreetAddress(String publisherStreetAddress) {
59 + this.publisherStreetAddress = publisherStreetAddress;
60 + }
61 +
62 + public String getPublisherPostalCode() {
63 + return publisherPostalCode;
64 + }
65 +
66 + public void setPublisherPostalCode(String publisherPostalCode) {
67 + this.publisherPostalCode = publisherPostalCode;
68 + }
69 +
70 + public String getPublisherPostOfficeBoxNumber() {
71 + return publisherPostOfficeBoxNumber;
72 + }
73 +
74 + public void setPublisherPostOfficeBoxNumber(String publisherPostOfficeBoxNumber) {
75 + this.publisherPostOfficeBoxNumber = publisherPostOfficeBoxNumber;
76 + }
77 +
78 + public String getPublisherAddressRegion() {
79 + return publisherAddressRegion;
80 + }
81 +
82 + public void setPublisherAddressRegion(String publisherAddressRegion) {
83 + this.publisherAddressRegion = publisherAddressRegion;
84 + }
85 +
86 + public String getPublisherAddressLocality() {
87 + return publisherAddressLocality;
88 + }
89 +
90 + public void setPublisherAddressLocality(String publisherAddressLocality) {
91 + this.publisherAddressLocality = publisherAddressLocality;
92 + }
93 +
94 + public Country getPublisherAddressCountry() {
95 + return publisherAddressCountry;
96 + }
97 +
98 + public void setPublisherAddressCountry(Country publisherAddressCountry) {
99 + this.publisherAddressCountry = publisherAddressCountry;
100 + }
101 +
102 + public String getPublisherTelephone() {
103 + return publisherTelephone;
104 + }
105 +
106 + public void setPublisherTelephone(String publisherTelephone) {
107 + this.publisherTelephone = publisherTelephone;
108 + }
109 +
110 + public String getPublisherEmail() {
111 + return publisherEmail;
112 + }
113 +
114 + public void setPublisherEmail(String publisherEmail) {
115 + this.publisherEmail = publisherEmail;
116 + }
117 +
118 + public String getPublisherURL() {
119 + return publisherURL;
120 + }
121 +
122 + public void setPublisherURL(String publisherURL) {
123 + this.publisherURL = publisherURL;
124 + }
125 +
126 + public boolean isPublisherActive() {
127 + return publisherActive;
128 + }
129 +
130 + public void setPublisherActive(boolean publisherActive) {
131 + this.publisherActive = publisherActive;
132 + }
133 +
134 + public String getPublisherHistory() {
135 + return publisherHistory;
136 + }
137 +
138 + public void setPublisherHistory(String publisherHistory) {
139 + this.publisherHistory = publisherHistory;
140 + }
141 +
142 + public List<Country> getAvailableCountries() {
143 + return availableCountries;
144 + }
145 +
146 + public void setAvailableCountries(List<Country> availableCountries) {
147 + this.availableCountries = availableCountries;
148 + }
149 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -39,6 +39,10 @@ ...@@ -39,6 +39,10 @@
39 <from-outcome>listUsers</from-outcome> 39 <from-outcome>listUsers</from-outcome>
40 <to-view-id>/listUsers.xhtml</to-view-id> 40 <to-view-id>/listUsers.xhtml</to-view-id>
41 </navigation-case> 41 </navigation-case>
42 + <navigation-case>
43 + <from-outcome>addPublisher</from-outcome>
44 + <to-view-id>/addPublisher.xhtml</to-view-id>
45 + </navigation-case>
42 </navigation-rule> 46 </navigation-rule>
43 47
44 <navigation-rule> 48 <navigation-rule>
......
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:ui="http://xmlns.jcp.org/jsf/facelets"
7 + xmlns:f="http://xmlns.jcp.org/jsf/core">
8 +<f:view>
9 + <h:form>
10 + <h:commandLink action="home">
11 + <h:outputText value="Menu principal"/>
12 + </h:commandLink>
13 +
14 + <h:panelGrid columns="2">
15 + <h:outputText value='publisherName'/>
16 + <h:inputText value='#{addPublisherBean.publisherName}'/>
17 + <h:outputText value='publisherStreetAddress'/>
18 + <h:inputText value='#{addPublisherBean.publisherStreetAddress}'/>
19 + <h:outputText value='publisherPostalCode'/>
20 + <h:inputText value='#{addPublisherBean.publisherPostalCode}'/>
21 + <h:outputText value='publisherPostOfficeBoxNumber'/>
22 + <h:inputText value='#{addPublisherBean.publisherPostOfficeBoxNumber}'/>
23 + <h:outputText value='publisherAddressRegion'/>
24 + <h:inputText value='#{addPublisherBean.publisherAddressRegion}'/>
25 + <h:outputText value='publisherAddressLocality'/>
26 + <h:inputText value='#{addPublisherBean.publisherAddressLocality}'/>
27 +
28 + <h:outputText value='publisherAddressCountry'/>
29 + <h:selectOneMenu value="#{addPublisherBean.publisherAddressCountry}" converter="omnifaces.SelectItemsConverter">
30 + <f:selectItems value="#{addPublisherBean.availableCountries}" var="country" itemLabel="#{country.countryName}"/>
31 + </h:selectOneMenu>
32 +
33 + <h:outputText value='publisherTelephone'/>
34 + <h:inputText value='#{addPublisherBean.publisherTelephone}'/>
35 + <h:outputText value='publisherEmail'/>
36 + <h:inputText value='#{addPublisherBean.publisherEmail}'/>
37 + <h:outputText value='publisherURL'/>
38 + <h:inputText value='#{addPublisherBean.publisherURL}'/>
39 +
40 + <h:outputText value='publisherActive'/>
41 + <h:selectBooleanCheckbox value="#{addPublisherBean.publisherActive}"/>
42 +
43 + <h:outputText value='publisherHistory'/>
44 + <h:inputTextarea value='#{addPublisherBean.publisherHistory}'/>
45 + <h:outputText value='Add'/>
46 + <h:commandButton action="#{addPublisherBean.add}" value="Add"/>
47 + </h:panelGrid>
48 + </h:form>
49 +</f:view>
50 +</html>
...@@ -38,6 +38,11 @@ ...@@ -38,6 +38,11 @@
38 <h:outputText value="List users"/> 38 <h:outputText value="List users"/>
39 </h:commandLink> 39 </h:commandLink>
40 </li> 40 </li>
41 + <li>
42 + <h:commandLink action="addPublisher">
43 + <h:outputText value="Add Publisher"/>
44 + </h:commandLink>
45 + </li>
41 </ul> 46 </ul>
42 </h:form> 47 </h:form>
43 </body> 48 </body>
......