Ajout de lien retour.
Corrections JPA mineures (oubli @Entity). Ajout de méthodes de base (get/set). Uniformisation finale userAction. Fin adaptation méthode validate. Adaptation setUp test validate PublisherService (répository supplémentaire)
Showing
6 changed files
with
69 additions
and
2 deletions
... | @@ -24,6 +24,9 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { | ... | @@ -24,6 +24,9 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { |
24 | @OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER) | 24 | @OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER) |
25 | private Set<PublisherVersion> versions; | 25 | private Set<PublisherVersion> versions; |
26 | 26 | ||
27 | + @OneToMany(mappedBy = "publisher") | ||
28 | + private Set<PublisherAction> actions; | ||
29 | + | ||
27 | public int getPublisherId() { | 30 | public int getPublisherId() { |
28 | return publisherId; | 31 | return publisherId; |
29 | } | 32 | } |
... | @@ -48,6 +51,14 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { | ... | @@ -48,6 +51,14 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { |
48 | this.versions = versions; | 51 | this.versions = versions; |
49 | } | 52 | } |
50 | 53 | ||
54 | + public Set<PublisherAction> getActions() { | ||
55 | + return actions; | ||
56 | + } | ||
57 | + | ||
58 | + public void setActions(Set<PublisherAction> actions) { | ||
59 | + this.actions = actions; | ||
60 | + } | ||
61 | + | ||
51 | @Override | 62 | @Override |
52 | public String toString() { | 63 | public String toString() { |
53 | return "PUBLISHER_ID = " + publisherId + ", Validated Version = " + validatedVersion; | 64 | return "PUBLISHER_ID = " + publisherId + ", Validated Version = " + validatedVersion; | ... | ... |
... | @@ -6,13 +6,14 @@ import java.sql.Timestamp; | ... | @@ -6,13 +6,14 @@ import java.sql.Timestamp; |
6 | /** | 6 | /** |
7 | * Classe des actions sur des (versions d') éditeurs. | 7 | * Classe des actions sur des (versions d') éditeurs. |
8 | */ | 8 | */ |
9 | +@Entity | ||
9 | public class PublisherAction { | 10 | public class PublisherAction { |
10 | @Id | 11 | @Id |
11 | @GeneratedValue(strategy = GenerationType.AUTO) | 12 | @GeneratedValue(strategy = GenerationType.AUTO) |
12 | private int publisherActionId; | 13 | private int publisherActionId; |
13 | 14 | ||
14 | @ManyToOne | 15 | @ManyToOne |
15 | - private UserAction action; | 16 | + private UserAction userAction; |
16 | @ManyToOne | 17 | @ManyToOne |
17 | private User publisherActionAuthor; | 18 | private User publisherActionAuthor; |
18 | @ManyToOne | 19 | @ManyToOne |
... | @@ -31,4 +32,43 @@ public class PublisherAction { | ... | @@ -31,4 +32,43 @@ public class PublisherAction { |
31 | public void setPublisherActionDatetime(Timestamp publisherActionDatetime) { | 32 | public void setPublisherActionDatetime(Timestamp publisherActionDatetime) { |
32 | this.publisherActionDatetime = publisherActionDatetime; | 33 | this.publisherActionDatetime = publisherActionDatetime; |
33 | } | 34 | } |
35 | + | ||
36 | + public void setUserAction(UserAction userAction) { | ||
37 | + this.userAction = userAction; | ||
38 | + } | ||
39 | + | ||
40 | + public void setPublisherVersion(PublisherVersion publisherVersion) { | ||
41 | + this.publisherVersion = publisherVersion; | ||
42 | + } | ||
43 | + | ||
44 | + public void setPublisher(Publisher publisher) { | ||
45 | + this.publisher = publisher; | ||
46 | + } | ||
47 | + | ||
48 | + public UserAction getUserAction() { | ||
49 | + return userAction; | ||
50 | + } | ||
51 | + | ||
52 | + public User getPublisherActionAuthor() { | ||
53 | + return publisherActionAuthor; | ||
54 | + } | ||
55 | + | ||
56 | + public PublisherVersion getPublisherVersion() { | ||
57 | + return publisherVersion; | ||
58 | + } | ||
59 | + | ||
60 | + public Timestamp getPublisherActionDatetime() { | ||
61 | + return publisherActionDatetime; | ||
62 | + } | ||
63 | + | ||
64 | + public Publisher getPublisher() { | ||
65 | + return publisher; | ||
66 | + } | ||
67 | + | ||
68 | + @Override | ||
69 | + public String toString() { | ||
70 | + return "publisherActionId = " + publisherActionId + ", userAction = " + userAction + | ||
71 | + ", publisherActionAuthor = " + publisherActionAuthor + ", publisherVersion = " + publisherVersion + | ||
72 | + ", publisherActionDatetime = " + publisherActionDatetime + ", publisher = " + publisher; | ||
73 | + } | ||
34 | } | 74 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | package org.legrog.entities; | 1 | package org.legrog.entities; |
2 | 2 | ||
3 | +import javax.persistence.Entity; | ||
3 | import javax.persistence.GeneratedValue; | 4 | import javax.persistence.GeneratedValue; |
4 | import javax.persistence.GenerationType; | 5 | import javax.persistence.GenerationType; |
5 | import javax.persistence.Id; | 6 | import javax.persistence.Id; |
... | @@ -7,6 +8,7 @@ import javax.persistence.Id; | ... | @@ -7,6 +8,7 @@ import javax.persistence.Id; |
7 | /** | 8 | /** |
8 | * Classe des actions possibles. | 9 | * Classe des actions possibles. |
9 | */ | 10 | */ |
11 | +@Entity | ||
10 | public class UserAction { | 12 | public class UserAction { |
11 | @Id | 13 | @Id |
12 | @GeneratedValue(strategy = GenerationType.AUTO) | 14 | @GeneratedValue(strategy = GenerationType.AUTO) | ... | ... |
... | @@ -25,16 +25,19 @@ public class PublisherServiceSpring implements PublisherService { | ... | @@ -25,16 +25,19 @@ public class PublisherServiceSpring implements PublisherService { |
25 | PublisherRepository publisherRepository; | 25 | PublisherRepository publisherRepository; |
26 | PublisherVersionRepository publisherVersionRepository; | 26 | PublisherVersionRepository publisherVersionRepository; |
27 | PublisherActionRepository publisherActionRepository; | 27 | PublisherActionRepository publisherActionRepository; |
28 | + UserActionRepository userActionRepository; | ||
28 | SharedService sharedService; | 29 | SharedService sharedService; |
29 | 30 | ||
30 | @Inject | 31 | @Inject |
31 | public PublisherServiceSpring(PublisherRepository publisherRepository, | 32 | public PublisherServiceSpring(PublisherRepository publisherRepository, |
32 | PublisherVersionRepository publisherVersionRepository, | 33 | PublisherVersionRepository publisherVersionRepository, |
33 | PublisherActionRepository publisherActionRepository, | 34 | PublisherActionRepository publisherActionRepository, |
35 | + UserActionRepository userActionRepository, | ||
34 | SharedService sharedService) { | 36 | SharedService sharedService) { |
35 | this.publisherRepository = publisherRepository; | 37 | this.publisherRepository = publisherRepository; |
36 | this.publisherVersionRepository = publisherVersionRepository; | 38 | this.publisherVersionRepository = publisherVersionRepository; |
37 | this.publisherActionRepository = publisherActionRepository; | 39 | this.publisherActionRepository = publisherActionRepository; |
40 | + this.userActionRepository = userActionRepository; | ||
38 | this.sharedService = sharedService; | 41 | this.sharedService = sharedService; |
39 | } | 42 | } |
40 | 43 | ||
... | @@ -74,6 +77,9 @@ public class PublisherServiceSpring implements PublisherService { | ... | @@ -74,6 +77,9 @@ public class PublisherServiceSpring implements PublisherService { |
74 | PublisherAction publisherAction = new PublisherAction(); | 77 | PublisherAction publisherAction = new PublisherAction(); |
75 | publisherAction.setPublisherActionAuthor(sharedService.getCurrentUser()); | 78 | publisherAction.setPublisherActionAuthor(sharedService.getCurrentUser()); |
76 | publisherAction.setPublisherActionDatetime(new Timestamp(new Date().getTime())); | 79 | publisherAction.setPublisherActionDatetime(new Timestamp(new Date().getTime())); |
80 | + publisherAction.setUserAction(userActionRepository.findByUserActionName("Validate")); | ||
81 | + publisherAction.setPublisherVersion(publisherVersion); | ||
82 | + publisherAction.setPublisher(publisher); | ||
77 | this.savePublisher(publisher); | 83 | this.savePublisher(publisher); |
78 | publisherActionRepository.save(publisherAction); | 84 | publisherActionRepository.save(publisherAction); |
79 | } | 85 | } | ... | ... |
... | @@ -33,9 +33,10 @@ public class PublisherServiceSpringTest { | ... | @@ -33,9 +33,10 @@ public class PublisherServiceSpringTest { |
33 | public void setUp(@Mock PublisherRepository publisherRepository, | 33 | public void setUp(@Mock PublisherRepository publisherRepository, |
34 | @Mock PublisherVersionRepository publisherVersionRepository, | 34 | @Mock PublisherVersionRepository publisherVersionRepository, |
35 | @Mock PublisherActionRepository publisherActionRepository, | 35 | @Mock PublisherActionRepository publisherActionRepository, |
36 | + @Mock UserActionRepository userActionRepository, | ||
36 | @Mock SharedService sharedService) throws Exception { | 37 | @Mock SharedService sharedService) throws Exception { |
37 | publisherServiceSpring = new PublisherServiceSpring(publisherRepository, | 38 | publisherServiceSpring = new PublisherServiceSpring(publisherRepository, |
38 | - publisherVersionRepository, publisherActionRepository, sharedService); | 39 | + publisherVersionRepository, publisherActionRepository, userActionRepository, sharedService); |
39 | publisherVersion = new PublisherVersion(); | 40 | publisherVersion = new PublisherVersion(); |
40 | publisherVersion1 = new PublisherVersion(); | 41 | publisherVersion1 = new PublisherVersion(); |
41 | this.publisherRepository = publisherRepository; | 42 | this.publisherRepository = publisherRepository; | ... | ... |
-
Please register or login to post a comment