From 2fa9ba09d404f164f84426aa1a806f783f5f9865 Mon Sep 17 00:00:00 2001 From: Ralph Soika Date: Tue, 1 Aug 2023 17:37:01 +0200 Subject: [PATCH] impl Issue #190 --- .../documents/DocumentSplitAdapter.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/imixs-archive-documents/src/main/java/org/imixs/archive/documents/DocumentSplitAdapter.java b/imixs-archive-documents/src/main/java/org/imixs/archive/documents/DocumentSplitAdapter.java index ffefe0e..410e714 100644 --- a/imixs-archive-documents/src/main/java/org/imixs/archive/documents/DocumentSplitAdapter.java +++ b/imixs-archive-documents/src/main/java/org/imixs/archive/documents/DocumentSplitAdapter.java @@ -12,6 +12,7 @@ import javax.inject.Inject; import org.imixs.archive.core.SnapshotService; +import org.imixs.workflow.FileData; import org.imixs.workflow.ItemCollection; import org.imixs.workflow.SignalAdapter; import org.imixs.workflow.WorkflowKernel; @@ -175,7 +176,7 @@ protected void createSubprocesses(final List subProcessDefinitions, fina if (debug) { logger.info("....split filename " + fileName); } - processSubWorktitem(processData,originWorkitem, fileName); + processSubWorkitem(processData,originWorkitem, fileName); } if (count==0) { throw new PluginException(DOCUMENTSPLIT, FILE_ERROR, "DocumentSplitAdapter - no file found matching the given filepattern, please check workflow model!"); @@ -198,7 +199,7 @@ protected void createSubprocesses(final List subProcessDefinitions, fina * @throws PluginException * @throws ModelException */ - private void processSubWorktitem( ItemCollection processData, ItemCollection originWorkitem, String filename) throws AccessDeniedException, ProcessingErrorException, PluginException, ModelException { + private void processSubWorkitem( ItemCollection processData, ItemCollection originWorkitem, String filename) throws AccessDeniedException, ProcessingErrorException, PluginException, ModelException { boolean debug = logger.isLoggable(Level.FINE); // create new process instance ItemCollection workitemSubProcess = new ItemCollection(); @@ -211,16 +212,15 @@ private void processSubWorktitem( ItemCollection processData, ItemCollection ori workitemSubProcess.removeItem("$eventlog"); workitemSubProcess.removeItem("txtworkflowhistory"); - // now remove all filesdata object not equal to the current filename. - List fileNames=originWorkitem.getFileNames(); - for (String _fileName : fileNames) { - if (!_fileName.equals(filename)) { - if (debug) { - logger.info("....remove filename " + _fileName); - } - workitemSubProcess.removeFile(_fileName); - } - } + // now remove all filesdata objects.... + workitemSubProcess.removeItem("$file"); + // ... and copy the content form the origin snapshot! + FileData snapshotFileData = snapshotService.getWorkItemFile(originWorkitem.getUniqueID(), filename); + if (snapshotFileData==null) { + throw new PluginException(DOCUMENTSPLIT, FILE_ERROR, "DocumentSplitAdapter - no snapshot filedata object found!"); + } + workitemSubProcess.addFileData(snapshotFileData); + // check model version String sModelVersion = processData.getItemValueString("modelversion"); if (sModelVersion.isEmpty()) {