Skip to content

Commit 33e0520

Browse files
committed
Refactored IndexingStatus
1 parent 96c0837 commit 33e0520

File tree

26 files changed

+132
-129
lines changed

26 files changed

+132
-129
lines changed

logicaldoc-core/src/main/java/com/logicaldoc/core/automation/DocTool.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import com.logicaldoc.core.document.DocumentDAO;
1919
import com.logicaldoc.core.document.DocumentHistory;
2020
import com.logicaldoc.core.document.DocumentHistoryDAO;
21-
import com.logicaldoc.core.document.DocumentIndexed;
21+
import com.logicaldoc.core.document.IndexingStatus;
2222
import com.logicaldoc.core.document.DocumentLink;
2323
import com.logicaldoc.core.document.DocumentLinkDAO;
2424
import com.logicaldoc.core.document.DocumentManager;
@@ -1002,7 +1002,7 @@ public String parse(Document document, String fileVersion) {
10021002
public String getText(Document document) {
10031003
String text = null;
10041004

1005-
if (document.getIndexed() == DocumentIndexed.INDEXED) {
1005+
if (document.getIndexed() == IndexingStatus.INDEXED) {
10061006
SearchEngine indexer = Context.get(SearchEngine.class);
10071007
Hit hit = indexer.getHit(document.getId());
10081008
if (hit != null)

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public abstract class AbstractDocument extends ExtensibleObject implements Trans
119119

120120
@Column(name = "ld_indexed", nullable = false)
121121
@Enumerated(EnumType.ORDINAL)
122-
private DocumentIndexed indexed = DocumentIndexed.TO_INDEX;
122+
private IndexingStatus indexingStatus = IndexingStatus.TO_INDEX;
123123

124124
@Column(name = "ld_type", length = 255)
125125
private String type;
@@ -291,16 +291,16 @@ public void setStatus(int status) {
291291
this.status = DocumentStatus.values()[status];
292292
}
293293

294-
public DocumentIndexed getIndexed() {
295-
return indexed;
294+
public IndexingStatus getIndexed() {
295+
return indexingStatus;
296296
}
297297

298-
public void setIndexed(DocumentIndexed indexed) {
299-
this.indexed = indexed;
298+
public void setIndexingStatus(IndexingStatus indexingStatus) {
299+
this.indexingStatus = indexingStatus;
300300
}
301301

302-
public void setIndexed(int indexed) {
303-
this.indexed = DocumentIndexed.values()[indexed];
302+
public void setIndexingStatus(int indexingStatus) {
303+
this.indexingStatus = IndexingStatus.values()[indexingStatus];
304304
}
305305

306306
/**
@@ -614,7 +614,7 @@ public void setExportId(Long exportId) {
614614
}
615615

616616
public boolean isToIndex() {
617-
return indexed == DocumentIndexed.TO_INDEX;
617+
return indexingStatus == IndexingStatus.TO_INDEX;
618618
}
619619

620620
public int getBarcoded() {
@@ -900,7 +900,7 @@ public void copyAttributes(AbstractDocument docVO) {
900900
setLanguage(docVO.getLanguage());
901901
setFileName(docVO.getFileName());
902902
setFileSize(docVO.getFileSize());
903-
setIndexed(docVO.getIndexed());
903+
setIndexingStatus(docVO.getIndexed());
904904
setBarcoded(docVO.getBarcoded());
905905
setSigned(docVO.getSigned());
906906
setStamped(docVO.getStamped());

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ public Document(AbstractDocument source) {
9898
setTemplateId(source.getTemplateId());
9999
setTemplateName(source.getTemplateName());
100100

101-
if (source.getIndexed() != DocumentIndexed.INDEXED)
102-
setIndexed(source.getIndexed());
101+
if (source.getIndexed() != IndexingStatus.INDEXED)
102+
setIndexingStatus(source.getIndexed());
103103
setCustomId(null);
104104

105105
try {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,14 @@ public List<Document> findByFileNameAndParentFolderId(Long folderId, String file
296296
public long count(Long tenantId, boolean computeDeleted, boolean computeArchived) throws PersistenceException;
297297

298298
/**
299-
* Finds all documents by the indexed state. Order by ascending lastModifed
299+
* Finds all documents by the indexing status. Order by ascending lastModifed
300300
*
301-
* @param indexed the indexed property
301+
* @param indexingStatus the indexed property
302302
* @return Collection of all documents
303303
*
304304
* @throws PersistenceException error at data layer
305305
*/
306-
public List<Document> findByIndexed(int indexed) throws PersistenceException;
306+
public List<Document> findByIndexingStatus(IndexingStatus indexingStatus) throws PersistenceException;
307307

308308
/**
309309
* Counts the number of documents in a given indexation status(@see

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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ public DocumentFuture replaceFile(long docId, String fileVersion, File newFile,
198198
// Update the document's gridRecord
199199
documentDAO.initialize(document);
200200
document.setFileSize(fileSize);
201-
if (document.getIndexed() != DocumentIndexed.SKIP)
202-
document.setIndexed(DocumentIndexed.TO_INDEX);
201+
if (document.getIndexed() != IndexingStatus.SKIP)
202+
document.setIndexingStatus(IndexingStatus.TO_INDEX);
203203
document.setOcrd(0);
204204
document.setBarcoded(0);
205205
document.setSigned(0);
@@ -346,8 +346,8 @@ public DocumentFuture checkin(long docId, File file, String filename, boolean re
346346
document.setOcrd(0);
347347
document.setBarcoded(0);
348348

349-
if (document.getIndexed() != DocumentIndexed.SKIP)
350-
document.setIndexed(DocumentIndexed.TO_INDEX);
349+
if (document.getIndexed() != IndexingStatus.SKIP)
350+
document.setIndexingStatus(IndexingStatus.TO_INDEX);
351351

352352
documentDAO.store(document);
353353

@@ -386,7 +386,7 @@ public DocumentFuture checkin(long docId, File file, String filename, boolean re
386386
document.setOcrTemplateId(oldDocument.getOcrTemplateId());
387387
document.setBarcoded(oldDocument.getBarcoded());
388388
document.setBarcodeTemplateId(oldDocument.getBarcodeTemplateId());
389-
document.setIndexed(oldDocument.getIndexed());
389+
document.setIndexingStatus(oldDocument.getIndexed());
390390
document.setCustomId(oldDocument.getCustomId());
391391
document.setStatus(oldDocument.getStatus());
392392
document.setStamped(oldDocument.getStamped());
@@ -502,7 +502,7 @@ public void deleteFromIndex(Document doc) {
502502
// Physically remove the document from full-text index
503503
indexer.deleteHit(docId);
504504

505-
doc.setIndexed(DocumentIndexed.TO_INDEX);
505+
doc.setIndexingStatus(IndexingStatus.TO_INDEX);
506506
documentDAO.store(doc);
507507

508508
markAliasesToIndex(doc.getId());
@@ -597,8 +597,8 @@ public long index(long docId, String content, DocumentHistory transaction)
597597
// We are indexing an alias, so index the real document first
598598
Document realDoc = documentDAO.findById(doc.getDocRef());
599599
if (realDoc != null) {
600-
if (realDoc.getIndexed() == DocumentIndexed.TO_INDEX
601-
|| realDoc.getIndexed() == DocumentIndexed.TO_INDEX_METADATA)
600+
if (realDoc.getIndexed() == IndexingStatus.TO_INDEX
601+
|| realDoc.getIndexed() == IndexingStatus.TO_INDEX_METADATA)
602602
parsingTime = index(realDoc.getId(), content, new DocumentHistory(transaction));
603603

604604
// Take the content from the real document to avoid double
@@ -609,12 +609,12 @@ public long index(long docId, String content, DocumentHistory transaction)
609609
log.debug("Alias {} cannot be indexed because it references an unexisting document {}", doc,
610610
doc.getDocRef());
611611
documentDAO.jdbcUpdate(
612-
UPDATE_LD_DOCUMENT_SET_LD_INDEXED + DocumentIndexed.SKIP + " where ld_id=" + doc.getId());
612+
UPDATE_LD_DOCUMENT_SET_LD_INDEXED + IndexingStatus.SKIP + " where ld_id=" + doc.getId());
613613
return 0;
614614
}
615615
}
616616

617-
if (StringUtils.isEmpty(cont) && doc.getIndexed() != DocumentIndexed.TO_INDEX_METADATA) {
617+
if (StringUtils.isEmpty(cont) && doc.getIndexed() != IndexingStatus.TO_INDEX_METADATA) {
618618
// Extracts the content from the file. This may take very long
619619
// time.
620620
Date beforeParsing = new Date();
@@ -632,7 +632,7 @@ public long index(long docId, String content, DocumentHistory transaction)
632632
}
633633

634634
// For additional safety update the DB directly
635-
doc.setIndexed(DocumentIndexed.INDEXED);
635+
doc.setIndexingStatus(IndexingStatus.INDEXED);
636636
documentDAO.jdbcUpdate(UPDATE_LD_DOCUMENT_SET_LD_INDEXED + doc.getIndexed().ordinal() + " where ld_id=" + doc.getId());
637637

638638
// Save the event
@@ -671,7 +671,7 @@ private void recordIndexingError(DocumentHistory transaction, Document document,
671671
if (Context.get().getProperties().getBoolean(tenant + ".index.skiponerror", false)) {
672672
DocumentDAO dDao = Context.get(DocumentDAO.class);
673673
dDao.initialize(document);
674-
document.setIndexed(DocumentIndexed.SKIP);
674+
document.setIndexingStatus(IndexingStatus.SKIP);
675675
dDao.store(document);
676676
}
677677
}
@@ -693,7 +693,7 @@ private void addHit(Document doc, String cont) throws ParsingException {
693693
}
694694

695695
private void markAliasesToIndex(long referencedDocId) throws PersistenceException {
696-
documentDAO.jdbcUpdate(UPDATE_LD_DOCUMENT_SET_LD_INDEXED + DocumentIndexed.TO_INDEX.ordinal() + " where ld_docref="
696+
documentDAO.jdbcUpdate(UPDATE_LD_DOCUMENT_SET_LD_INDEXED + IndexingStatus.TO_INDEX.ordinal() + " where ld_docref="
697697
+ referencedDocId + " and not ld_id = " + referencedDocId);
698698
}
699699

@@ -740,7 +740,7 @@ private synchronized void synchronizedUpdate(Document document, Document docVO,
740740
checkCustomIdUniquenesOnUpdate(document, docVO);
741741

742742
// The document must be re-indexed
743-
document.setIndexed(DocumentIndexed.TO_INDEX);
743+
document.setIndexingStatus(IndexingStatus.TO_INDEX);
744744

745745
document.setWorkflowStatus(docVO.getWorkflowStatus());
746746
document.setColor(docVO.getColor());
@@ -894,12 +894,12 @@ public DocumentFuture moveToFolder(Document doc, Folder folder, DocumentHistory
894894
doc.setFolder(folder);
895895

896896
// The document needs to be reindexed
897-
if (doc.getIndexed() == DocumentIndexed.INDEXED) {
898-
doc.setIndexed(DocumentIndexed.TO_INDEX);
897+
if (doc.getIndexed() == IndexingStatus.INDEXED) {
898+
doc.setIndexingStatus(IndexingStatus.TO_INDEX);
899899
indexer.deleteHit(doc.getId());
900900

901901
// The same thing should be done on each shortcut
902-
documentDAO.jdbcUpdate(UPDATE_LD_DOCUMENT_SET_LD_INDEXED + DocumentIndexed.TO_INDEX.ordinal()
902+
documentDAO.jdbcUpdate(UPDATE_LD_DOCUMENT_SET_LD_INDEXED + IndexingStatus.TO_INDEX.ordinal()
903903
+ " where ld_docref=" + doc.getId());
904904
}
905905

@@ -1177,8 +1177,8 @@ public DocumentFuture copyToFolder(Document doc, Folder folder, DocumentHistory
11771177
cloned.setFolder(folder);
11781178
cloned.setLastModified(null);
11791179
cloned.setDate(null);
1180-
if (cloned.getIndexed() == DocumentIndexed.INDEXED)
1181-
cloned.setIndexed(DocumentIndexed.TO_INDEX);
1180+
if (cloned.getIndexed() == IndexingStatus.INDEXED)
1181+
cloned.setIndexingStatus(IndexingStatus.TO_INDEX);
11821182
cloned.setStamped(0);
11831183
cloned.setSigned(0);
11841184
cloned.setLinks(0);
@@ -1351,7 +1351,7 @@ public DocumentFuture rename(long docId, String newName, DocumentHistory transac
13511351
document.setType(UNKNOWN);
13521352
}
13531353

1354-
document.setIndexed(DocumentIndexed.TO_INDEX);
1354+
document.setIndexingStatus(IndexingStatus.TO_INDEX);
13551355

13561356
Version version = Version.create(document, transaction.getUser(), transaction.getComment(),
13571357
DocumentEvent.RENAMED.toString(), false);
@@ -1504,18 +1504,18 @@ public Document createAlias(Document doc, Folder folder, String aliasType, Docum
15041504
* @param doc The document for which will be changed the indexer status.
15051505
* @param status The new document indexer status.
15061506
*/
1507-
public void changeIndexingStatus(Document doc, DocumentIndexed status) {
1508-
if (status == DocumentIndexed.SKIP && doc.getIndexed() == DocumentIndexed.SKIP)
1507+
public void changeIndexingStatus(Document doc, IndexingStatus status) {
1508+
if (status == IndexingStatus.SKIP && doc.getIndexed() == IndexingStatus.SKIP)
15091509
return;
1510-
if (status == DocumentIndexed.TO_INDEX && doc.getIndexed() == DocumentIndexed.TO_INDEX)
1510+
if (status == IndexingStatus.TO_INDEX && doc.getIndexed() == IndexingStatus.TO_INDEX)
15111511
return;
1512-
if (status == DocumentIndexed.TO_INDEX_METADATA && doc.getIndexed() == DocumentIndexed.TO_INDEX_METADATA)
1512+
if (status == IndexingStatus.TO_INDEX_METADATA && doc.getIndexed() == IndexingStatus.TO_INDEX_METADATA)
15131513
return;
15141514

15151515
documentDAO.initialize(doc);
1516-
if (doc.getIndexed() == DocumentIndexed.INDEXED)
1516+
if (doc.getIndexed() == IndexingStatus.INDEXED)
15171517
deleteFromIndex(doc);
1518-
doc.setIndexed(status);
1518+
doc.setIndexingStatus(status);
15191519
try {
15201520
documentDAO.store(doc);
15211521
} catch (PersistenceException e) {

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ private HibernateDocumentDAO() {
112112
public void archive(long docId, DocumentHistory transaction) throws PersistenceException {
113113
Document doc = findById(docId);
114114
doc.setStatus(DocumentStatus.ARCHIVED);
115-
if (doc.getIndexed() != DocumentIndexed.SKIP)
116-
doc.setIndexed(DocumentIndexed.TO_INDEX);
115+
if (doc.getIndexed() != IndexingStatus.SKIP)
116+
doc.setIndexingStatus(IndexingStatus.TO_INDEX);
117117
doc.setLockUserId(transaction.getUserId());
118118
transaction.setEvent(DocumentEvent.ARCHIVED.toString());
119119
store(doc, transaction);
@@ -494,17 +494,17 @@ private void setTags(Document doc) {
494494
}
495495

496496
private void setIndexed(Document doc, Tenant tenant) {
497-
if (doc.getIndexed() == DocumentIndexed.TO_INDEX || doc.getIndexed() == DocumentIndexed.TO_INDEX_METADATA) {
497+
if (doc.getIndexed() == IndexingStatus.TO_INDEX || doc.getIndexed() == IndexingStatus.TO_INDEX_METADATA) {
498498
// Check if the document must be indexed
499499
if (!FileUtil.matches(doc.getFileName(), config.getProperty(tenant.getName() + ".index.includes", ""),
500500
config.getProperty(tenant.getName() + ".index.excludes", "")))
501-
doc.setIndexed(DocumentIndexed.SKIP);
501+
doc.setIndexingStatus(IndexingStatus.SKIP);
502502

503503
// Check if the document must be indexed
504-
if (doc.getIndexed() == DocumentIndexed.SKIP && FileUtil.matches(doc.getFileName(),
504+
if (doc.getIndexed() == IndexingStatus.SKIP && FileUtil.matches(doc.getFileName(),
505505
config.getProperty(tenant.getName() + ".index.includes.metadata", ""),
506506
config.getProperty(tenant.getName() + ".index.excludes.metadata", "")))
507-
doc.setIndexed(DocumentIndexed.TO_INDEX_METADATA);
507+
doc.setIndexingStatus(IndexingStatus.TO_INDEX_METADATA);
508508
}
509509
}
510510

@@ -900,8 +900,8 @@ public long count(Long tenantId, boolean computeDeleted, boolean computeArchived
900900
}
901901

902902
@Override
903-
public List<Document> findByIndexed(int indexed) throws PersistenceException {
904-
return findByWhere(ENTITY + ".docRef is null and " + ENTITY + ".indexed=" + indexed,
903+
public List<Document> findByIndexingStatus(IndexingStatus indexingStatus) throws PersistenceException {
904+
return findByWhere(ENTITY + ".docRef is null and " + ENTITY + ".indexingStatus = " + indexingStatus.ordinal(),
905905
ENTITY + ".lastModified asc", null);
906906
}
907907

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ private void updateLastNote(Document document, DocumentNote note) {
6767
.orElse(note.getMessage());
6868

6969
doc.setLastNote(HTMLSanitizer.sanitizeSimpleText(lastNoteMessage));
70-
if (document.getIndexed() == DocumentIndexed.INDEXED)
71-
document.setIndexed(DocumentIndexed.TO_INDEX);
70+
if (document.getIndexed() == IndexingStatus.INDEXED)
71+
document.setIndexingStatus(IndexingStatus.TO_INDEX);
7272
dao.store(doc);
7373
} catch (PersistenceException e) {
7474
log.error(e.getMessage(), e);
@@ -151,10 +151,10 @@ public void delete(long id, int code) throws PersistenceException {
151151
super.delete(id, code);
152152
DocumentDAO documentDao = Context.get(DocumentDAO.class);
153153
Document document = documentDao.findById(note.getDocId());
154-
if (document != null && document.getIndexed() == DocumentIndexed.INDEXED) {
154+
if (document != null && document.getIndexed() == IndexingStatus.INDEXED) {
155155
// Mark to index
156156
documentDao.initialize(document);
157-
document.setIndexed(DocumentIndexed.TO_INDEX);
157+
document.setIndexingStatus(IndexingStatus.TO_INDEX);
158158
documentDao.store(document);
159159
updateLastNote(document, note);
160160
}

logicaldoc-core/src/main/java/com/logicaldoc/core/document/DocumentIndexed.java renamed to logicaldoc-core/src/main/java/com/logicaldoc/core/document/IndexingStatus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.logicaldoc.core.document;
22

3-
public enum DocumentIndexed {
3+
public enum IndexingStatus {
44
TO_INDEX,
55
INDEXED,
66
SKIP,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public Version(Version source) {
8787
copyAttributes(source);
8888
setId(source.getId());
8989
setFolderId(source.getFolderId());
90-
if (source.getIndexed() != DocumentIndexed.INDEXED)
91-
setIndexed(source.getIndexed());
90+
if (source.getIndexed() != IndexingStatus.INDEXED)
91+
setIndexingStatus(source.getIndexed());
9292
setCustomId(null);
9393
}
9494

logicaldoc-core/src/main/java/com/logicaldoc/core/folder/HibernateFolderDAO.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import com.logicaldoc.core.document.DocumentDAO;
3434
import com.logicaldoc.core.document.DocumentEvent;
3535
import com.logicaldoc.core.document.DocumentHistory;
36-
import com.logicaldoc.core.document.DocumentIndexed;
36+
import com.logicaldoc.core.document.IndexingStatus;
3737
import com.logicaldoc.core.document.DocumentManager;
3838
import com.logicaldoc.core.document.DocumentStatus;
3939
import com.logicaldoc.core.document.FolderAccessControlEntry;
@@ -1599,7 +1599,7 @@ private Folder internalCopy(Folder source, Folder target, String newName, boolea
15991599
newDoc.setVersion(null);
16001600
newDoc.setFileVersion(null);
16011601
newDoc.setFolder(newFolder);
1602-
newDoc.setIndexed(DocumentIndexed.TO_INDEX);
1602+
newDoc.setIndexingStatus(IndexingStatus.TO_INDEX);
16031603
newDoc.setStatus(DocumentStatus.UNLOCKED);
16041604
newDoc.setImmutable(0);
16051605
newDoc.setBarcoded(0);

0 commit comments

Comments
 (0)