Skip to content

Commit

Permalink
[26348] fix omnivore exportToFileSystem with query MAINTAIN_CACHE
Browse files Browse the repository at this point in the history
  • Loading branch information
huthomas committed May 14, 2024
1 parent 02410e4 commit 7afb812
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import ch.elexis.omnivore.Constants;
import ch.elexis.omnivore.model.internal.ModelUtil;
import ch.elexis.omnivore.model.internal.Preferences;
import ch.elexis.omnivore.model.service.OmnivoreModelServiceHolder;

public class DocumentDocHandle extends AbstractIdDeleteModelAdapter<DocHandle>
implements Identifiable, IDocumentHandle {
Expand Down Expand Up @@ -342,6 +343,7 @@ public boolean exportToFileSystem() {
try (OutputStream out = vfsHandle.openOutputStream()) {
out.write(doc);
getEntity().setDoc(null);
OmnivoreModelServiceHolder.get().save(this);
} catch (IOException ios) {
LoggerFactory.getLogger(getClass()).error("Exporting dochandle [" + getId() + "] to filesystem fails."); //$NON-NLS-1$ //$NON-NLS-2$
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package ch.elexis.omnivore.ui.jobs;

import java.lang.reflect.InvocationTargetException;
import java.util.Collections;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.persistence.config.HintValues;
import org.eclipse.persistence.config.QueryHints;
import org.eclipse.swt.widgets.Shell;

import ch.elexis.core.services.IQuery;
Expand All @@ -27,7 +30,8 @@ public Object execute(Shell parentShell) {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IQuery<IDocumentHandle> qDoc = OmnivoreModelServiceHolder.get().getQuery(IDocumentHandle.class);

try (IQueryCursor<IDocumentHandle> docs = qDoc.executeAsCursor()) {
try (IQueryCursor<IDocumentHandle> docs = qDoc
.executeAsCursor(Collections.singletonMap(QueryHints.MAINTAIN_CACHE, HintValues.TRUE))) {
monitor.beginTask("Dateien werden ausgelagert...", docs.size());

while (docs.hasNext()) {
Expand All @@ -39,8 +43,6 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException, Inte
if (!docHandle.exportToFileSystem()) {
SWTHelper.showError(Messages.DocHandle_writeErrorCaption2,
Messages.DocHandle_writeErrorCaption2, "Fehlerdetails siehe Logdatei");
} else {
OmnivoreModelServiceHolder.get().save(docHandle);
}
monitor.worked(1);
}
Expand Down

0 comments on commit 7afb812

Please sign in to comment.