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
21a192c70b472e8a4010272002722876c4840dbe
21a192c7
1 parent
0f832301
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 @
21a192c
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 @
21a192c
...
...
@@ -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 @
21a192c
...
...
@@ -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 @
21a192c
...
...
@@ -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 @
21a192c
...
...
@@ -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 @
21a192c
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
;
...
...
@@ -15,7 +18,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
...
...
@@ -23,8 +29,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
;
...
...
@@ -45,6 +55,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
;
...
...
@@ -66,6 +77,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
);
...
...
@@ -87,7 +128,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 @
21a192c
...
...
@@ -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 @
21a192c
...
...
@@ -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 @
21a192c
...
...
@@ -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