Jean-Francois Leveque

Refactoring int -> Integer pour les Id et changement nommage pour contourner ambiguïté Author

...@@ -9,7 +9,7 @@ import javax.persistence.Lob; ...@@ -9,7 +9,7 @@ import javax.persistence.Lob;
9 public class IndexedPublisher { 9 public class IndexedPublisher {
10 @Id 10 @Id
11 @Field 11 @Field
12 - private int publisherId; 12 + private Integer publisherId;
13 @Field 13 @Field
14 private String publisherName; 14 private String publisherName;
15 @Lob 15 @Lob
...@@ -32,7 +32,7 @@ public class IndexedPublisher { ...@@ -32,7 +32,7 @@ public class IndexedPublisher {
32 //no args constructor to make it proxyable 32 //no args constructor to make it proxyable
33 } 33 }
34 34
35 - public int getPublisherId() { 35 + public Integer getPublisherId() {
36 return publisherId; 36 return publisherId;
37 } 37 }
38 38
...@@ -44,7 +44,7 @@ public class IndexedPublisher { ...@@ -44,7 +44,7 @@ public class IndexedPublisher {
44 return publisherHistory; 44 return publisherHistory;
45 } 45 }
46 46
47 - public void setPublisherId(int publisherId) { 47 + public void setPublisherId(Integer publisherId) {
48 this.publisherId = publisherId; 48 this.publisherId = publisherId;
49 } 49 }
50 50
......
...@@ -15,7 +15,7 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { ...@@ -15,7 +15,7 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ {
15 // TODO Attention, en v2 Linkable implique Traceable (journalisable) qui devrait aussi être évalué 15 // TODO Attention, en v2 Linkable implique Traceable (journalisable) qui devrait aussi être évalué
16 @Id 16 @Id
17 @GeneratedValue(strategy = GenerationType.IDENTITY) 17 @GeneratedValue(strategy = GenerationType.IDENTITY)
18 - private int publisherId; 18 + private Integer publisherId;
19 19
20 @OneToOne 20 @OneToOne
21 private PublisherVersion validatedVersion; 21 private PublisherVersion validatedVersion;
...@@ -26,11 +26,11 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { ...@@ -26,11 +26,11 @@ public class Publisher /* extends org.roliste.data.DbLinkableEntity */ {
26 @OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER) 26 @OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER)
27 private Set<PublisherAction> actions; 27 private Set<PublisherAction> actions;
28 28
29 - public int getPublisherId() { 29 + public Integer getPublisherId() {
30 return publisherId; 30 return publisherId;
31 } 31 }
32 32
33 - public void setPublisherId(int publisherId) { 33 + public void setPublisherId(Integer publisherId) {
34 this.publisherId = publisherId; 34 this.publisherId = publisherId;
35 } 35 }
36 36
......
...@@ -10,12 +10,12 @@ import java.sql.Timestamp; ...@@ -10,12 +10,12 @@ import java.sql.Timestamp;
10 public class PublisherAction { 10 public class PublisherAction {
11 @Id 11 @Id
12 @GeneratedValue(strategy = GenerationType.IDENTITY) 12 @GeneratedValue(strategy = GenerationType.IDENTITY)
13 - private int publisherActionId; 13 + private Integer publisherActionId;
14 14
15 @Enumerated 15 @Enumerated
16 private ActionType actionType; 16 private ActionType actionType;
17 @ManyToOne 17 @ManyToOne
18 - private Account publisherActionAuthor; 18 + private Account publisherActionActor;
19 @ManyToOne 19 @ManyToOne
20 private PublisherVersion publisherVersion; 20 private PublisherVersion publisherVersion;
21 21
...@@ -25,8 +25,8 @@ public class PublisherAction { ...@@ -25,8 +25,8 @@ public class PublisherAction {
25 @ManyToOne 25 @ManyToOne
26 private Publisher publisher; 26 private Publisher publisher;
27 27
28 - public void setPublisherActionAuthor(Account publisherActionAuthor) { 28 + public void setPublisherActionActor(Account publisherActionActor) {
29 - this.publisherActionAuthor = publisherActionAuthor; 29 + this.publisherActionActor = publisherActionActor;
30 } 30 }
31 31
32 public void setPublisherActionDatetime(Timestamp publisherActionDatetime) { 32 public void setPublisherActionDatetime(Timestamp publisherActionDatetime) {
...@@ -49,8 +49,8 @@ public class PublisherAction { ...@@ -49,8 +49,8 @@ public class PublisherAction {
49 return actionType; 49 return actionType;
50 } 50 }
51 51
52 - public Account getPublisherActionAuthor() { 52 + public Account getPublisherActionActor() {
53 - return publisherActionAuthor; 53 + return publisherActionActor;
54 } 54 }
55 55
56 public PublisherVersion getPublisherVersion() { 56 public PublisherVersion getPublisherVersion() {
...@@ -65,10 +65,18 @@ public class PublisherAction { ...@@ -65,10 +65,18 @@ public class PublisherAction {
65 return publisher; 65 return publisher;
66 } 66 }
67 67
68 + public Integer getPublisherActionId() {
69 + return publisherActionId;
70 + }
71 +
72 + public void setPublisherActionId(Integer publisherActionId) {
73 + this.publisherActionId = publisherActionId;
74 + }
75 +
68 @Override 76 @Override
69 public String toString() { 77 public String toString() {
70 return "publisherActionId = " + publisherActionId + ", actionType = " + actionType + 78 return "publisherActionId = " + publisherActionId + ", actionType = " + actionType +
71 - ", publisherActionAuthor = " + publisherActionAuthor + ", publisherVersion = " + publisherVersion + 79 + ", publisherActionAuthor = " + publisherActionActor + ", publisherVersion = " + publisherVersion +
72 ", publisherActionDatetime = " + publisherActionDatetime + ", publisher = " + publisher; 80 ", publisherActionDatetime = " + publisherActionDatetime + ", publisher = " + publisher;
73 } 81 }
74 } 82 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -12,7 +12,7 @@ import java.sql.Timestamp; ...@@ -12,7 +12,7 @@ import java.sql.Timestamp;
12 public class PublisherVersion { 12 public class PublisherVersion {
13 @Id 13 @Id
14 @GeneratedValue(strategy = GenerationType.IDENTITY) 14 @GeneratedValue(strategy = GenerationType.IDENTITY)
15 - private int publisherVersionId; 15 + private Integer publisherVersionId;
16 @ManyToOne 16 @ManyToOne
17 private Publisher publisher; 17 private Publisher publisher;
18 private String publisherName; 18 private String publisherName;
...@@ -29,7 +29,7 @@ public class PublisherVersion { ...@@ -29,7 +29,7 @@ public class PublisherVersion {
29 @Lob 29 @Lob
30 private String publisherHistory; 30 private String publisherHistory;
31 @ManyToOne 31 @ManyToOne
32 - private Account publisherVersionAuthor; 32 + private Account publisherVersionCreator;
33 private Timestamp publisherVersionDatetime; 33 private Timestamp publisherVersionDatetime;
34 34
35 public Timestamp getPublisherVersionDatetime() { 35 public Timestamp getPublisherVersionDatetime() {
...@@ -112,11 +112,11 @@ public class PublisherVersion { ...@@ -112,11 +112,11 @@ public class PublisherVersion {
112 this.publisherURL = publisherURL; 112 this.publisherURL = publisherURL;
113 } 113 }
114 114
115 - public int getPublisherVersionId() { 115 + public Integer getPublisherVersionId() {
116 return publisherVersionId; 116 return publisherVersionId;
117 } 117 }
118 118
119 - public void setPublisherVersionId(int publisherVersionId) { 119 + public void setPublisherVersionId(Integer publisherVersionId) {
120 this.publisherVersionId = publisherVersionId; 120 this.publisherVersionId = publisherVersionId;
121 } 121 }
122 122
...@@ -136,12 +136,12 @@ public class PublisherVersion { ...@@ -136,12 +136,12 @@ public class PublisherVersion {
136 this.publisherAddressCountry = publisherAddressCountry; 136 this.publisherAddressCountry = publisherAddressCountry;
137 } 137 }
138 138
139 - public Account getPublisherVersionAuthor() { 139 + public Account getPublisherVersionCreator() {
140 - return publisherVersionAuthor; 140 + return publisherVersionCreator;
141 } 141 }
142 142
143 - public void setPublisherVersionAuthor(Account publisherVersionAuthor) { 143 + public void setPublisherVersionCreator(Account publisherVersionCreator) {
144 - this.publisherVersionAuthor = publisherVersionAuthor; 144 + this.publisherVersionCreator = publisherVersionCreator;
145 } 145 }
146 146
147 @Override 147 @Override
...@@ -151,7 +151,7 @@ public class PublisherVersion { ...@@ -151,7 +151,7 @@ public class PublisherVersion {
151 ", Region = " + publisherAddressRegion + ", Ville = " + publisherAddressLocality + ", Pays = " + 151 ", Region = " + publisherAddressRegion + ", Ville = " + publisherAddressLocality + ", Pays = " +
152 publisherAddressCountry + ", Telephone = " + publisherTelephone + ", email = " + publisherEmail + 152 publisherAddressCountry + ", Telephone = " + publisherTelephone + ", email = " + publisherEmail +
153 ", URL = " + publisherURL + ", History = " + publisherHistory + 153 ", URL = " + publisherURL + ", History = " + publisherHistory +
154 - ", Version Author = " + publisherVersionAuthor + ", Version DateTime = " + publisherVersionDatetime; 154 + ", Version Author = " + publisherVersionCreator + ", Version DateTime = " + publisherVersionDatetime;
155 } 155 }
156 156
157 public Publisher getPublisher() { 157 public Publisher getPublisher() {
......
...@@ -83,7 +83,7 @@ public class ListPublisherVersionsView implements Serializable { ...@@ -83,7 +83,7 @@ public class ListPublisherVersionsView implements Serializable {
83 */ 83 */
84 protected void filterOnID() { 84 protected void filterOnID() {
85 publisherVersions = publisherVersions.stream() 85 publisherVersions = publisherVersions.stream()
86 - .filter(version -> version.getPublisher().getPublisherId() == publisherId) 86 + .filter(version -> version.getPublisher().getPublisherId().equals(publisherId))
87 .collect(Collectors.toList()); 87 .collect(Collectors.toList());
88 } 88 }
89 89
......
...@@ -58,7 +58,7 @@ public class PublisherServiceDefault implements PublisherService { ...@@ -58,7 +58,7 @@ public class PublisherServiceDefault implements PublisherService {
58 publisherVersions.add(publisherVersion); 58 publisherVersions.add(publisherVersion);
59 publisher.setVersions(publisherVersions); 59 publisher.setVersions(publisherVersions);
60 publisherVersion.setPublisher(publisher); 60 publisherVersion.setPublisher(publisher);
61 - publisherVersion.setPublisherVersionAuthor(sharedService.getCurrentUser()); 61 + publisherVersion.setPublisherVersionCreator(sharedService.getCurrentUser());
62 publisherVersion.setPublisherVersionDatetime(new Timestamp(new Date().getTime())); 62 publisherVersion.setPublisherVersionDatetime(new Timestamp(new Date().getTime()));
63 this.savePublisherVersion(publisherVersion); 63 this.savePublisherVersion(publisherVersion);
64 this.savePublisher(publisher); 64 this.savePublisher(publisher);
...@@ -72,7 +72,7 @@ public class PublisherServiceDefault implements PublisherService { ...@@ -72,7 +72,7 @@ public class PublisherServiceDefault implements PublisherService {
72 publisherVersionSet.add(publisherVersion); 72 publisherVersionSet.add(publisherVersion);
73 publisher.setVersions(publisherVersionSet); 73 publisher.setVersions(publisherVersionSet);
74 publisherVersion.setPublisher(publisher); 74 publisherVersion.setPublisher(publisher);
75 - publisherVersion.setPublisherVersionAuthor(sharedService.getCurrentUser()); 75 + publisherVersion.setPublisherVersionCreator(sharedService.getCurrentUser());
76 publisherVersion.setPublisherVersionDatetime(new Timestamp(new Date().getTime())); 76 publisherVersion.setPublisherVersionDatetime(new Timestamp(new Date().getTime()));
77 this.savePublisherVersion(publisherVersion); 77 this.savePublisherVersion(publisherVersion);
78 this.savePublisher(publisher); 78 this.savePublisher(publisher);
...@@ -85,7 +85,7 @@ public class PublisherServiceDefault implements PublisherService { ...@@ -85,7 +85,7 @@ public class PublisherServiceDefault implements PublisherService {
85 Publisher publisher = publisherVersion.getPublisher(); 85 Publisher publisher = publisherVersion.getPublisher();
86 publisher.setValidatedVersion(publisherVersion); 86 publisher.setValidatedVersion(publisherVersion);
87 PublisherAction publisherAction = new PublisherAction(); 87 PublisherAction publisherAction = new PublisherAction();
88 - publisherAction.setPublisherActionAuthor(sharedService.getCurrentUser()); 88 + publisherAction.setPublisherActionActor(sharedService.getCurrentUser());
89 publisherAction.setPublisherActionDatetime(new Timestamp(new Date().getTime())); 89 publisherAction.setPublisherActionDatetime(new Timestamp(new Date().getTime()));
90 publisherAction.setActionType(ActionType.VALIDATE); 90 publisherAction.setActionType(ActionType.VALIDATE);
91 publisherAction.setPublisherVersion(publisherVersion); 91 publisherAction.setPublisherVersion(publisherVersion);
......
...@@ -199,7 +199,7 @@ public class PublisherVersionView implements Serializable { ...@@ -199,7 +199,7 @@ public class PublisherVersionView implements Serializable {
199 if (publisherVersion == null) { 199 if (publisherVersion == null) {
200 throw new IllegalStateException("Publisher version not found"); 200 throw new IllegalStateException("Publisher version not found");
201 } 201 }
202 - publisherVersionAuthor = publisherVersion.getPublisherVersionAuthor(); 202 + publisherVersionAuthor = publisherVersion.getPublisherVersionCreator();
203 publisherVersionDatetime = publisherVersion.getPublisherVersionDatetime(); 203 publisherVersionDatetime = publisherVersion.getPublisherVersionDatetime();
204 } 204 }
205 205
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
21 </h:column> 21 </h:column>
22 <h:column> 22 <h:column>
23 <f:facet name="header"/> 23 <f:facet name="header"/>
24 - ${action.publisherActionAuthor.displayName} 24 + ${action.publisherActionActor.displayName}
25 </h:column> 25 </h:column>
26 <h:column> 26 <h:column>
27 <f:facet name="header"/> 27 <f:facet name="header"/>
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
57 </h:column> 57 </h:column>
58 <h:column> 58 <h:column>
59 <f:facet name="header">Version Author</f:facet> 59 <f:facet name="header">Version Author</f:facet>
60 - ${action.publisherVersion.publisherVersionAuthor.displayName} 60 + ${action.publisherVersion.publisherVersionCreator.displayName}
61 </h:column> 61 </h:column>
62 <h:column> 62 <h:column>
63 <f:facet name="header">Version Datetime</f:facet> 63 <f:facet name="header">Version Datetime</f:facet>
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
41 <h:column> 41 <h:column>
42 <f:facet name="header"/> 42 <f:facet name="header"/>
43 <div jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}"> 43 <div jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">
44 - ${listPublisherVersionsView.getLastValidate(version.publisher).publisherActionAuthor.displayName} 44 + ${listPublisherVersionsView.getLastValidate(version.publisher).publisherActionActor.displayName}
45 </div> 45 </div>
46 </h:column> 46 </h:column>
47 <h:column> 47 <h:column>
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
80 </h:column> 80 </h:column>
81 <h:column> 81 <h:column>
82 <f:facet name="header">Version Author</f:facet> 82 <f:facet name="header">Version Author</f:facet>
83 - ${version.publisherVersionAuthor.displayName} 83 + ${version.publisherVersionCreator.displayName}
84 </h:column> 84 </h:column>
85 <h:column> 85 <h:column>
86 <f:facet name="header">Version Datetime</f:facet> 86 <f:facet name="header">Version Datetime</f:facet>
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
59 </h:column> 59 </h:column>
60 <h:column> 60 <h:column>
61 <f:facet name="header"/> 61 <f:facet name="header"/>
62 - ${action.publisherActionAuthor.displayName} 62 + ${action.publisherActionActor.displayName}
63 </h:column> 63 </h:column>
64 <h:column> 64 <h:column>
65 <f:facet name="header"/> 65 <f:facet name="header"/>
......
...@@ -55,8 +55,8 @@ public class ListPublisherVersionsViewTest { ...@@ -55,8 +55,8 @@ public class ListPublisherVersionsViewTest {
55 publisherVersion2.setPublisherVersionId(2); 55 publisherVersion2.setPublisherVersionId(2);
56 publisher = new Publisher(); 56 publisher = new Publisher();
57 publisher1 = new Publisher(); 57 publisher1 = new Publisher();
58 - publisher.setPublisherId(0); 58 + publisher.setPublisherId(new Integer(0));
59 - publisher1.setPublisherId(1); 59 + publisher1.setPublisherId(new Integer(1));
60 publisherVersion.setPublisher(publisher); 60 publisherVersion.setPublisher(publisher);
61 publisherVersion1.setPublisher(publisher1); 61 publisherVersion1.setPublisher(publisher1);
62 publisherVersion2.setPublisher(publisher); 62 publisherVersion2.setPublisher(publisher);
......