diff --git a/inception/inception-pdf-editor2/src/main/java/de/tudarmstadt/ukp/inception/pdfeditor2/view/pdfjs/PdfJsViewerPage.java b/inception/inception-pdf-editor2/src/main/java/de/tudarmstadt/ukp/inception/pdfeditor2/view/pdfjs/PdfJsViewerPage.java index 8fef4d2ddb0..a9fd0a9c39e 100644 --- a/inception/inception-pdf-editor2/src/main/java/de/tudarmstadt/ukp/inception/pdfeditor2/view/pdfjs/PdfJsViewerPage.java +++ b/inception/inception-pdf-editor2/src/main/java/de/tudarmstadt/ukp/inception/pdfeditor2/view/pdfjs/PdfJsViewerPage.java @@ -59,6 +59,7 @@ public void renderHead(IHeaderResponse aResponse) aResponse.render(JavaScriptHeaderItem.forReference(PdfJsViewerJavaScriptReference.get())); var script = String.join("\n", // "window.addEventListener('DOMContentLoaded', function() {", // + " PDFViewerApplicationOptions.set('annotationMode', 0);", // " PDFViewerApplicationOptions.set('defaultUrl', null);", // " PDFViewerApplicationOptions.set('disablePreferences', true);", // " PDFViewerApplicationOptions.set('workerSrc', 'pdf.worker.min.js');", // diff --git a/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/SearchServiceImpl.java b/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/SearchServiceImpl.java index bb4a3912986..18a60a36aa4 100644 --- a/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/SearchServiceImpl.java +++ b/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/SearchServiceImpl.java @@ -336,7 +336,7 @@ private boolean isBeingDeleted(long aProjectId) private PooledIndex acquireIndex(long aProjectId) { synchronized (indexes) { - PooledIndex pooledIndex = indexes.get(aProjectId); + var pooledIndex = indexes.get(aProjectId); if (pooledIndex != null && pooledIndex.isTombstone()) { throw new IllegalStateException("Project [" + aProjectId @@ -364,7 +364,7 @@ private PooledIndex acquireIndex(long aProjectId) } if (pooledIndex == null) { - Index index = loadIndex(aProjectId); + var index = loadIndex(aProjectId); pooledIndex = new PooledIndex(index); indexes.put(aProjectId, pooledIndex); } @@ -443,9 +443,10 @@ public void onLayerConfigurationChanged(LayerConfigurationChangedEvent aEvent) } @Override + @Transactional public void indexDocument(SourceDocument aSourceDocument, byte[] aBinaryCas) { - try (PooledIndex pooledIndex = acquireIndex(aSourceDocument.getProject().getId())) { + try (var pooledIndex = acquireIndex(aSourceDocument.getProject().getId())) { indexDocument(pooledIndex, aSourceDocument, aBinaryCas); } } @@ -453,11 +454,11 @@ public void indexDocument(SourceDocument aSourceDocument, byte[] aBinaryCas) private void indexDocument(PooledIndex aPooledIndex, SourceDocument aSourceDocument, byte[] aBinaryCas) { - Project project = aSourceDocument.getProject(); + var project = aSourceDocument.getProject(); log.debug("Request to index source document {} in project {}", aSourceDocument, project); - Index index = aPooledIndex.get(); + var index = aPooledIndex.get(); // Index already initialized? If not, schedule full re-indexing job. This will also // index the given document, so we can stop here after scheduling the re-indexing. if (!index.getPhysicalIndex().isCreated()) { @@ -736,7 +737,7 @@ public boolean isIndexValid(Project aProject) return false; } - return !pooledIndex.get().getInvalid(); + return !pooledIndex.get().isInvalid(); } } @@ -803,7 +804,7 @@ private void ensureIndexIsCreatedAndValid(Project aProject, Index aIndex) } // Is the index valid? - if (aIndex.getInvalid()) { + if (aIndex.isInvalid()) { if (getIndexProgress(aProject).isEmpty()) { // Index is invalid, schedule a new index rebuild enqueueReindexTask(aProject, "ensureIndexIsCreatedAndValid[invalid]"); @@ -830,8 +831,11 @@ private void ensureIndexIsCreatedAndValid(Project aProject, Index aIndex) private void invalidateIndexAndForceIndexRebuild(Project aProject, Index aIndex, String aReason) { - aIndex.setInvalid(true); - entityManager.merge(aIndex); + if (!aIndex.isInvalid()) { + // Only update flag and DB if necessary + aIndex.setInvalid(true); + entityManager.merge(aIndex); + } enqueueReindexTask(aProject, "ensureIndexIsCreatedAndValid[doesNotExist]"); } diff --git a/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/model/Index.java b/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/model/Index.java index 6260d7e2e75..78691507e97 100644 --- a/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/model/Index.java +++ b/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/model/Index.java @@ -54,7 +54,7 @@ public class Index @JoinColumn(name = "project") private Project project; - private Boolean invalid; + private boolean invalid; @Temporal(TemporalType.TIMESTAMP) @Column(nullable = true) @@ -85,14 +85,14 @@ public void setProject(Project project) this.project = project; } - public Boolean getInvalid() + public boolean isInvalid() { return invalid; } - public void setInvalid(Boolean state) + public void setInvalid(Boolean aState) { - this.invalid = state; + invalid = aState; } public Date getCreationDate() diff --git a/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/scheduling/tasks/IndexSourceDocumentTask.java b/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/scheduling/tasks/IndexSourceDocumentTask.java index 89ff71ca169..7d2d3aa435a 100644 --- a/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/scheduling/tasks/IndexSourceDocumentTask.java +++ b/inception/inception-search-core/src/main/java/de/tudarmstadt/ukp/inception/search/scheduling/tasks/IndexSourceDocumentTask.java @@ -75,7 +75,7 @@ public String getTitle() @Override public void execute() { - try (CasStorageSession session = CasStorageSession.open()) { + try (var session = CasStorageSession.open()) { var cas = documentService.createOrReadInitialCas(getSourceDocument(), AUTO_CAS_UPGRADE, SHARED_READ_ONLY_ACCESS); searchService.indexDocument(getSourceDocument(), WebAnnoCasUtil.casToByteArray(cas)); diff --git a/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/documents/ImportDocumentsPanel.java b/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/documents/ImportDocumentsPanel.java index 52488a8636c..471c9d05a13 100644 --- a/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/documents/ImportDocumentsPanel.java +++ b/inception/inception-ui-project/src/main/java/de/tudarmstadt/ukp/clarin/webanno/ui/project/documents/ImportDocumentsPanel.java @@ -24,7 +24,6 @@ import static org.apache.commons.lang3.exception.ExceptionUtils.getRootCauseMessage; import static org.apache.wicket.event.Broadcast.BUBBLE; -import java.io.InputStream; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -168,13 +167,13 @@ private void actionImport(AjaxRequestTarget aTarget, Form aForm) } try { - SourceDocument document = new SourceDocument(); + var document = new SourceDocument(); document.setName(fileName); document.setProject(project); document.setFormat( importExportService.getFormatByName(format.getObject()).get().getId()); - try (InputStream is = documentToUpload.getInputStream()) { + try (var is = documentToUpload.getInputStream()) { documentService.uploadSourceDocument(is, document, fullProjectTypeSystem); }