Skip to content

Commit 5ddb191

Browse files
committed
refactored History
1 parent c92704a commit 5ddb191

File tree

27 files changed

+622
-632
lines changed

27 files changed

+622
-632
lines changed

logicaldoc-core/src/main/java/com/logicaldoc/core/communication/EventCollector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import com.logicaldoc.core.document.Document;
1717
import com.logicaldoc.core.document.DocumentDAO;
1818
import com.logicaldoc.core.history.AbstractDocumentHistory;
19-
import com.logicaldoc.core.history.History;
19+
import com.logicaldoc.core.history.ExtendedHistory;
2020
import com.logicaldoc.core.threading.ThreadPools;
2121
import com.logicaldoc.util.Context;
2222

@@ -64,7 +64,7 @@ public void removeListener(EventListener listener) {
6464
* @param history
6565
* @return true if it was not remembered already, false otherwise
6666
*/
67-
private boolean rememberHistory(History history) {
67+
private boolean rememberHistory(ExtendedHistory history) {
6868
Queue<Long> fifo = fifos.get(history.getClass().getName());
6969
if (fifo == null) {
7070
fifo = new CircularFifoQueue<>(FIFO_SIZE);
@@ -84,7 +84,7 @@ private boolean rememberHistory(History history) {
8484
*
8585
* @param history the history to notify
8686
*/
87-
public void newEvent(History history) {
87+
public void newEvent(ExtendedHistory history) {
8888
if (!isEnabled()) {
8989
log.debug("Aspect {} not enabled", ASPECT);
9090
return;

logicaldoc-core/src/main/java/com/logicaldoc/core/communication/EventListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.logicaldoc.core.communication;
22

3-
import com.logicaldoc.core.history.History;
3+
import com.logicaldoc.core.history.ExtendedHistory;
44

55
/**
66
* A listener for the event emitted by the collector
@@ -15,5 +15,5 @@ public interface EventListener {
1515
*
1616
* @param event the event to process
1717
*/
18-
public void newEvent(History event);
18+
public void newEvent(ExtendedHistory event);
1919
}

logicaldoc-core/src/main/java/com/logicaldoc/core/document/DocumentHistory.java

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import javax.persistence.Column;
55
import javax.persistence.Entity;
66
import javax.persistence.Table;
7+
import javax.persistence.Transient;
78

89
import org.hibernate.annotations.Cache;
910
import org.hibernate.annotations.CacheConcurrencyStrategy;
@@ -26,7 +27,32 @@ public class DocumentHistory extends AbstractDocumentHistory {
2627

2728
@Column(name = "ld_color", length = 255)
2829
protected String color;
30+
31+
@Column(name = "ld_new")
32+
private int isNew = 1;
33+
34+
@Transient
35+
private String file = null;
36+
37+
public DocumentHistory() {
38+
super();
39+
}
40+
41+
public DocumentHistory(DocumentHistory source) {
42+
copyAttributesFrom(source);
43+
this.color = source.color;
44+
setFile(source.getFile());
45+
setIsNew(source.getIsNew());
46+
}
2947

48+
public String getFile() {
49+
return file;
50+
}
51+
52+
public void setFile(String file) {
53+
this.file = file;
54+
}
55+
3056
public String getColor() {
3157
return color;
3258
}
@@ -35,13 +61,12 @@ public void setColor(String color) {
3561
this.color = color;
3662
}
3763

38-
public DocumentHistory() {
39-
super();
64+
public int getIsNew() {
65+
return isNew;
4066
}
4167

42-
public DocumentHistory(DocumentHistory source) {
43-
copyAttributesFrom(source);
44-
this.color=source.color;
68+
public void setIsNew(int isNew) {
69+
this.isNew = isNew;
4570
}
4671

4772
@Override

logicaldoc-core/src/main/java/com/logicaldoc/core/document/DocumentManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import com.logicaldoc.core.folder.FolderDAO;
3939
import com.logicaldoc.core.folder.FolderEvent;
4040
import com.logicaldoc.core.folder.FolderHistory;
41-
import com.logicaldoc.core.history.History;
41+
import com.logicaldoc.core.history.ExtendedHistory;
4242
import com.logicaldoc.core.metadata.Attribute;
4343
import com.logicaldoc.core.metadata.Template;
4444
import com.logicaldoc.core.metadata.TemplateDAO;
@@ -226,7 +226,7 @@ public DocumentFuture replaceFile(long docId, String fileVersion, File newFile,
226226
}
227227
}
228228

229-
private void validateTransaction(History transaction) {
229+
private void validateTransaction(ExtendedHistory transaction) {
230230
if (transaction == null)
231231
throw new IllegalArgumentException(TRANSACTION_CANNOT_BE_NULL);
232232
if (transaction.getUser() == null)

logicaldoc-core/src/main/java/com/logicaldoc/core/history/AbstractDocumentHistory.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* @since 9.2
1717
*/
1818
@MappedSuperclass
19-
public abstract class AbstractDocumentHistory extends History {
19+
public abstract class AbstractDocumentHistory extends ExtendedHistory {
2020

2121
private static final long serialVersionUID = 1L;
2222

@@ -43,9 +43,6 @@ public abstract class AbstractDocumentHistory extends History {
4343

4444
@Column(name = "ld_filesize")
4545
private Long fileSize = null;
46-
47-
@Column(name = "ld_new")
48-
private int isNew = 1;
4946

5047
/**
5148
* Something to better qualify the event
@@ -129,14 +126,6 @@ public String getFilenameOld() {
129126
public void setFilenameOld(String filenameOld) {
130127
this.filenameOld = filenameOld;
131128
}
132-
133-
public int getIsNew() {
134-
return isNew;
135-
}
136-
137-
public void setIsNew(int isNew) {
138-
this.isNew = isNew;
139-
}
140129

141130
public String getReason() {
142131
return reason;
@@ -187,7 +176,6 @@ protected void copyAttributesFrom(AbstractDocumentHistory source) {
187176
setDocId(source.getDocId());
188177
setFolderId(source.getFolderId());
189178
setReason(source.getReason());
190-
setIsNew(source.getIsNew());
191179
setFilename(source.getFilename());
192180
setFileSize(source.getFileSize());
193181
}

0 commit comments

Comments
 (0)