1- package com .logicaldoc .core .history ;
2-
3- import java .util .Objects ;
1+ package com .logicaldoc .core .document ;
42
53import javax .persistence .Column ;
64import javax .persistence .MappedSuperclass ;
75import javax .persistence .Transient ;
86
9- import com .logicaldoc .core .document .AbstractDocument ;
10- import com .logicaldoc .core .document .Document ;
11- import com .logicaldoc .core .document .Version ;
127import com .logicaldoc .core .folder .Folder ;
8+ import com .logicaldoc .core .history .History ;
139
1410/**
15- * Superclass for history entries with more information
11+ * A superclass for those histories tightly related to documents
1612 *
17- * @author Matteo Caruso - LogicalDOC
18- * @since 5.0
13+ * @author Giuseppe Desiato - LogicalDOC
14+ * @since 9.2
1915 */
2016@ MappedSuperclass
21- public abstract class ExtendedHistory extends History {
22-
23- public static final String ASPECT = "saveHistory" ;
17+ public abstract class AbstractDocumentHistory extends History {
2418
2519 private static final long serialVersionUID = 1L ;
26-
27- @ Column (name = "ld_filename" , length = 255 )
28- private String filename = null ;
2920
21+ @ Column (name = "ld_docid" )
22+ private Long docId ;
23+
24+ @ Column (name = "ld_folderid" )
25+ private Long folderId ;
26+
3027 @ Column (name = "ld_filesize" )
3128 private Long fileSize = null ;
3229
33- @ Column (name = "ld_folderid" )
34- private Long folderId ;
35-
30+ @ Column (name = "ld_filename" , length = 255 )
31+ private String filename = null ;
32+
3633 /**
3734 * Something to better qualify the event
3835 */
3936 @ Column (name = "ld_reason" , length = 4000 )
4037 private String reason = null ;
4138
42- // Not persistent
39+ @ Column (name = "ld_version" , length = 10 )
40+ private String version = null ;
41+
42+ @ Column (name = "ld_fileversion" , length = 10 )
43+ private String fileVersion = null ;
44+
45+ @ Column (name = "ld_pathold" , length = 4000 )
46+ private String pathOld = null ;
47+
48+ @ Column (name = "ld_filenameold" , length = 255 )
49+ private String filenameOld = null ;
50+
4351 @ Transient
4452 private AbstractDocument document ;
4553
4654 // Not persistent
4755 @ Transient
4856 private Folder folder ;
4957
58+ public AbstractDocumentHistory () {
59+ super ();
60+ }
61+
62+ public Long getDocId () {
63+ return docId ;
64+ }
65+
66+ public void setDocId (Long docId ) {
67+ this .docId = docId ;
68+ }
69+
5070 public Long getFolderId () {
5171 return folderId ;
5272 }
5373
5474 public void setFolderId (Long folderId ) {
5575 this .folderId = folderId ;
5676 }
57-
58- public String getReason () {
59- return reason ;
77+
78+ public Long getFileSize () {
79+ return fileSize ;
6080 }
6181
62- public void setReason ( String reason ) {
63- this .reason = reason ;
82+ public void setFileSize ( Long fileSize ) {
83+ this .fileSize = fileSize ;
6484 }
65-
85+
6686 public String getFilename () {
6787 return filename ;
6888 }
6989
7090 public void setFilename (String filename ) {
7191 this .filename = filename ;
7292 }
73-
74- public Long getFileSize () {
75- return fileSize ;
76- }
77-
78- public void setFileSize (Long fileSize ) {
79- this .fileSize = fileSize ;
93+
94+ public String getReason () {
95+ return reason ;
8096 }
8197
82- public void setDocument (AbstractDocument document ) {
83- this .document = document ;
84- if (document != null ) {
85- this .setTenantId (document .getTenantId ());
86-
87- this .setFilename (document .getFileName ());
88- this .setFileSize (document .getFileSize ());
89-
90- if (document instanceof Version ver )
91- this .setFolderId (ver .getFolderId ());
92- else if (document instanceof Document doc )
93- this .setFolderId (doc .getFolder ().getId ());
94- }
98+ public void setReason (String reason ) {
99+ this .reason = reason ;
95100 }
96-
101+
97102 public AbstractDocument getDocument () {
98103 return document ;
99104 }
@@ -106,42 +111,66 @@ public void setFolder(Folder folder) {
106111 this .folder = folder ;
107112 }
108113
109- protected void copyAttributesFrom (ExtendedHistory source ) {
110- super .copyAttributesFrom (source );
114+ public String getVersion () {
115+ return version ;
116+ }
111117
112- setFolderId (source .getFolderId ());
113- setReason (source .getReason ());
114- setFilename (source .getFilename ());
115- setFileSize (source .getFileSize ());
118+ public void setVersion (String version ) {
119+ this .version = version ;
120+ }
121+
122+ public String getFileVersion () {
123+ return fileVersion ;
116124 }
117125
118- @ Override
119- public String toString () {
120- return getId () + " - " + getEvent ();
126+ public void setFileVersion (String fileVersion ) {
127+ this .fileVersion = fileVersion ;
121128 }
122129
123- @ Override
124- public int compareTo (History other ) {
125- return getDate ().compareTo (other .getDate ());
130+ public String getPathOld () {
131+ return pathOld ;
126132 }
127133
128- @ Override
129- public int hashCode () {
130- final int prime = 31 ;
131- int result = super .hashCode ();
132- result = prime * result + Objects .hash (folderId );
133- return result ;
134+ public void setPathOld (String pathOld ) {
135+ this .pathOld = pathOld ;
136+ }
137+
138+ public String getFilenameOld () {
139+ return filenameOld ;
140+ }
141+
142+ public void setFilenameOld (String filenameOld ) {
143+ this .filenameOld = filenameOld ;
144+ }
145+
146+ protected void copyAttributesFrom (AbstractDocumentHistory source ) {
147+ super .copyAttributesFrom (source );
148+
149+ setDocId (source .getDocId ());
150+ setFolderId (source .getFolderId ());
151+ setFileSize (source .getFileSize ());
152+ setFilename (source .getFilename ());
153+ setReason (source .getReason ());
154+ setVersion (source .getVersion ());
155+ setFileVersion (source .getFileVersion ());
156+ setPathOld (source .getPathOld ());
157+ setFilenameOld (source .getFilenameOld ());
134158 }
135159
136- @ Override
137- public boolean equals (Object obj ) {
138- if (this == obj )
139- return true ;
140- if (!super .equals (obj ))
141- return false ;
142- if (getClass () != obj .getClass ())
143- return false ;
144- ExtendedHistory other = (ExtendedHistory ) obj ;
145- return Objects .equals (folderId , other .folderId );
160+ public void setDocument (AbstractDocument document ) {
161+ this .document = document ;
162+
163+ if (document != null ) {
164+ this .setFileSize (document .getFileSize ());
165+ this .setFilename (document .getFileName ());
166+
167+ if (document instanceof Version ver ) {
168+ this .setDocId (ver .getDocId ());
169+ this .setFolderId (ver .getFolderId ());
170+ } else if (document instanceof Document doc ) {
171+ this .setDocId (doc .getId ());
172+ this .setFolderId (doc .getFolder ().getId ());
173+ }
174+ }
146175 }
147176}
0 commit comments