Toggle navigation
Toggle navigation
This project
Loading...
Sign in
grogv3
/
grog-cubi
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Francois Leveque
2016-10-20 15:56:07 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b498567ef3bb14f6520cb4e36160ae0cecb2ce7e
b498567e
1 parent
118666d8
https://tree.taiga.io/project/jr-utily-grog-v3/us/44
Implementer l'historisation pour les éditeurs
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
85 additions
and
5 deletions
src/main/java/org/legrog/application/PublisherService.java
src/main/java/org/legrog/application/PublisherServiceSpring.java
src/main/java/org/legrog/entities/Publisher.java
src/main/java/org/legrog/entities/PublisherRevision.java
src/main/java/org/legrog/presentation/AddPublisherBean.java
src/main/java/org/legrog/presentation/PublisherRevisionView.java
src/main/webapp/index.xhtml
src/main/webapp/listPublisherRevisions.xhtml
src/main/webapp/publisherRevision.xhtml
src/main/java/org/legrog/application/PublisherService.java
View file @
b498567
package
org
.
legrog
.
application
;
import
org.legrog.entities.Publisher
;
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
();
}
...
...
src/main/java/org/legrog/application/PublisherServiceSpring.java
View file @
b498567
...
...
@@ -3,10 +3,12 @@ package org.legrog.application;
import
org.legrog.entities.Publisher
;
import
org.legrog.entities.PublisherRepository
;
import
org.legrog.entities.PublisherRevision
;
import
javax.ejb.Stateless
;
import
javax.inject.Inject
;
import
java.util.List
;
import
java.util.Set
;
@Stateless
public
class
PublisherServiceSpring
implements
PublisherService
{
...
...
@@ -17,6 +19,14 @@ public class PublisherServiceSpring implements PublisherService {
publisherRepository
.
save
(
publisher
);
}
public
void
addRevisionToPublisher
(
Publisher
publisher
,
PublisherRevision
publisherRevision
)
{
Set
<
PublisherRevision
>
publisherRevisionSet
=
publisher
.
getRevisions
();
publisherRevisionSet
.
add
(
publisherRevision
);
publisher
.
setRevisions
(
publisherRevisionSet
);
publisherRevision
.
setPublisher
(
publisher
);
publisherRepository
.
save
(
publisher
);
}
public
List
<
Publisher
>
getAllPublishers
()
{
return
publisherRepository
.
findAll
();
}
...
...
src/main/java/org/legrog/entities/Publisher.java
View file @
b498567
...
...
@@ -22,7 +22,7 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ {
private
Timestamp
validationDateTime
;
@OneToMany
(
mappedBy
=
"publisher"
)
@OneToMany
(
mappedBy
=
"publisher"
,
fetch
=
FetchType
.
EAGER
)
private
Set
<
PublisherRevision
>
revisions
;
public
int
getPublisherId
()
{
...
...
src/main/java/org/legrog/entities/PublisherRevision.java
View file @
b498567
...
...
@@ -158,4 +158,12 @@ public class PublisherRevision {
", URL = "
+
publisherURL
+
", actif = "
+
publisherActive
+
", History = "
+
publisherHistory
+
", Revision Author = "
+
publisherRevisionAuthor
+
", Revision DateTime = "
+
publisherRevisionDatetime
;
}
public
Publisher
getPublisher
()
{
return
publisher
;
}
public
void
setPublisher
(
Publisher
publisher
)
{
this
.
publisher
=
publisher
;
}
}
\ No newline at end of file
...
...
src/main/java/org/legrog/presentation/AddPublisherBean.java
View file @
b498567
...
...
@@ -59,11 +59,11 @@ public class AddPublisherBean {
publisherRevisions
.
add
(
publisherRevision
);
publisher
.
setRevisions
(
publisherRevisions
);
logger
.
info
(
publisher
.
toString
());
publisherRevision
.
setPublisher
(
publisher
);
publisherRevision
.
setPublisherActive
(
publisherActive
);
publisherRevision
.
setPublisherAddressCountry
(
publisherAddressCountry
);
publisherRevision
.
setPublisherAddressLocality
(
publisherAddressLocality
);
publisherRevision
.
setPublisherAddressRegion
(
publisherAddressRegion
);
publisherRevision
.
setPublisherAddressLocality
(
publisherAddressLocality
);
publisherRevision
.
setPublisherEmail
(
publisherEmail
);
publisherRevision
.
setPublisherHistory
(
publisherHistory
);
publisherRevision
.
setPublisherName
(
publisherName
);
...
...
@@ -82,8 +82,8 @@ public class AddPublisherBean {
// End TODO
publisherRevision
.
setPublisherRevisionAuthor
(
user
);
logger
.
info
(
publisherRevision
.
toString
());
publisherRevisionService
.
addPublisherRevision
(
publisherRevision
);
publisherService
.
addPublisher
(
publisher
);
publisherRevisionService
.
addPublisherRevision
(
publisherRevision
);
// Test de récupération de l'Id
logger
.
info
(
publisherRevision
.
toString
());
return
"success"
;
...
...
src/main/java/org/legrog/presentation/PublisherRevisionView.java
View file @
b498567
package
org
.
legrog
.
presentation
;
import
org.legrog.application.PublisherRevisionService
;
import
org.legrog.application.PublisherService
;
import
org.legrog.application.SharedService
;
import
org.legrog.application.UserService
;
import
org.legrog.entities.Country
;
import
org.legrog.entities.Publisher
;
import
org.legrog.entities.PublisherRevision
;
import
org.legrog.entities.User
;
import
org.slf4j.Logger
;
...
...
@@ -14,7 +17,10 @@ import javax.inject.Inject;
import
javax.inject.Named
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Random
;
import
java.util.Set
;
@Named
@ViewScoped
...
...
@@ -22,8 +28,12 @@ public class PublisherRevisionView implements Serializable {
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Inject
private
PublisherService
publisherService
;
@Inject
PublisherRevisionService
publisherRevisionService
;
@Inject
UserService
userService
;
@Inject
private
SharedService
sharedService
;
private
boolean
editMode
;
...
...
@@ -44,6 +54,7 @@ public class PublisherRevisionView implements Serializable {
private
String
publisherHistory
;
private
User
publisherRevisionAuthor
;
private
Timestamp
publisherRevisionDatetime
;
private
Publisher
publisher
;
// Table de codification
private
List
<
Country
>
availableCountries
;
...
...
@@ -65,6 +76,36 @@ public class PublisherRevisionView implements Serializable {
return
editMode
;
}
public
void
update
()
{
PublisherRevision
publisherRevision
=
new
PublisherRevision
();
publisherRevision
.
setPublisherActive
(
publisherActive
);
publisherRevision
.
setPublisherAddressCountry
(
publisherAddressCountry
);
publisherRevision
.
setPublisherAddressLocality
(
publisherAddressLocality
);
publisherRevision
.
setPublisherAddressRegion
(
publisherAddressRegion
);
publisherRevision
.
setPublisherEmail
(
publisherEmail
);
publisherRevision
.
setPublisherHistory
(
publisherHistory
);
publisherRevision
.
setPublisherName
(
publisherName
);
publisherRevision
.
setPublisherPostalCode
(
publisherPostalCode
);
publisherRevision
.
setPublisherPostOfficeBoxNumber
(
publisherPostOfficeBoxNumber
);
publisherRevision
.
setPublisherStreetAddress
(
publisherStreetAddress
);
publisherRevision
.
setPublisherTelephone
(
publisherTelephone
);
publisherRevision
.
setPublisherURL
(
publisherURL
);
publisherRevision
.
setPublisherRevisionDatetime
(
new
Timestamp
(
new
Date
().
getTime
()));
// TODO Remplacer l'astuce par une vraie récupération de l'utilisateur
List
<
User
>
users
=
userService
.
getAllUsers
();
Random
random
=
new
Random
();
User
user
=
users
.
get
(
random
.
nextInt
(
users
.
size
()));
// End TODO
publisherRevision
.
setPublisherRevisionAuthor
(
user
);
publisherService
.
addRevisionToPublisher
(
publisher
,
publisherRevision
);
publisherRevisionService
.
addPublisherRevision
(
publisherRevision
);
editMode
=
false
;
}
public
void
loadData
()
{
logger
.
debug
(
"publisherRevisionId = {}"
,
this
.
publisherRevisionId
);
...
...
@@ -86,7 +127,9 @@ public class PublisherRevisionView implements Serializable {
publisherHistory
=
publisherRevision
.
getPublisherHistory
();
publisherRevisionAuthor
=
publisherRevision
.
getPublisherRevisionAuthor
();
publisherRevisionDatetime
=
publisherRevision
.
getPublisherRevisionDatetime
();
publisher
=
publisherRevision
.
getPublisher
();
logger
.
debug
(
"Found a publisher : {}"
,
publisher
.
toString
());
// Map<String,String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
//
...
...
src/main/webapp/index.xhtml
View file @
b498567
...
...
@@ -43,6 +43,11 @@
<h:outputText
value=
"Add Publisher"
/>
</h:commandLink>
</li>
<li>
<h:commandLink
action=
"listPublisherRevisions"
>
<h:outputText
value=
"List Publisher Revisions"
/>
</h:commandLink>
</li>
</ul>
</h:form>
</body>
...
...
src/main/webapp/listPublisherRevisions.xhtml
View file @
b498567
...
...
@@ -6,15 +6,25 @@
xmlns:ui=
"http://xmlns.jcp.org/jsf/facelets"
xmlns:f=
"http://xmlns.jcp.org/jsf/core"
>
<h:body>
<h:form>
<h:commandLink
action=
"home"
>
<h:outputText
value=
"Menu principal"
/>
</h:commandLink>
</h:form>
<h:outputText
rendered=
"#{listPublisherRevisionsBean.publisherRevisions.isEmpty()}"
>
Liste des révisions est vide
</h:outputText>
<h:dataTable
value=
"#{listPublisherRevisionsBean.publisherRevisions}"
var=
"revision"
>
<h:column>
<f:facet
name=
"header"
>
Visualiser
<!--ou Modifier-->
</f:facet>
<h:link
outcome=
"view"
>
Visualiser
<!--ou Modifier-->
<f:facet
name=
"header"
>
Visualiser
ou Modifier
</f:facet>
<h:link
outcome=
"view"
>
Visualiser
ou Modifier Version
<f:param
name=
"publisherRevisionId"
value=
"#{revision.publisherRevisionId}"
/>
</h:link>
</h:column>
<h:column>
<f:facet
name=
"header"
>
Editeur
</f:facet>
#{revision.publisher.publisherId}
</h:column>
<h:column>
<f:facet
name=
"header"
>
Name
</f:facet>
#{revision.publisherName}
</h:column>
...
...
src/main/webapp/publisherRevision.xhtml
View file @
b498567
...
...
@@ -62,6 +62,7 @@
<h:outputText
value=
"publisherRevisionDatetime"
/>
<h:outputText
value=
"#{publisherRevisionView.publisherRevisionDatetime}"
/>
<h:commandButton
value=
"Edit"
action=
"#{publisherRevisionView.edit}"
rendered=
"#{not publisherRevisionView.editMode}"
/>
<h:commandButton
value=
"Save"
action=
"#{publisherRevisionView.update}"
rendered=
"#{publisherRevisionView.editMode}"
/>
<h:commandButton
value=
"Cancel"
action=
"#{publisherRevisionView.cancel}"
rendered=
"#{publisherRevisionView.editMode}"
/>
<ui:remove>
<h:outputText
value=
'Add'
/>
...
...
Please
register
or
login
to post a comment