Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable first step as automatic task #4853

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ public String createNewProcess() {
}
try {
createProcessHierarchy();
ImportService.runAutomaticTasks(getMainProcess());
if (Objects.nonNull(PrimeFaces.current()) && Objects.nonNull(FacesContext.getCurrentInstance())) {
PrimeFaces.current().executeScript("PF('sticky-notifications').renderMessage({'summary':'"
+ Helper.getTranslation("processSaving") + "','detail':'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@
import org.kitodo.production.helper.Helper;
import org.kitodo.production.helper.TempProcess;
import org.kitodo.production.helper.XMLUtils;
import org.kitodo.production.helper.tasks.TaskManager;
import org.kitodo.production.process.ProcessGenerator;
import org.kitodo.production.services.ServiceManager;
import org.kitodo.production.thread.TaskScriptThread;
import org.kitodo.production.workflow.KitodoNamespaceContext;
import org.kitodo.serviceloader.KitodoServiceLoader;
import org.w3c.dom.Document;
Expand Down Expand Up @@ -1065,6 +1067,7 @@ public static void processProcessChildren(Process mainProcess, LinkedList<TempPr
Process childProcess = tempProcess.getProcess();
ServiceManager.getProcessService().save(childProcess, true);
ProcessService.setParentRelations(mainProcess, childProcess);
runAutomaticTasks(childProcess);
}
}

Expand Down Expand Up @@ -1140,6 +1143,21 @@ public static void updateTasks(Process process) {
}
}

/**
* Run pending automatic tasks for a given Process 'process'.
*
* @param process Process whose pending automatic tasks should be executed
*/
public static void runAutomaticTasks(Process process) {
Task currentTask = ServiceManager.getProcessService().getCurrentTask(process);
if (Objects.nonNull(currentTask) && currentTask.isTypeAutomatic()) {
currentTask.setProcessingStatus(TaskStatus.INWORK);
currentTask.setProcessingBegin(new Date());
TaskScriptThread thread = new TaskScriptThread(currentTask);
TaskManager.addTask(thread);
}
}

/**
* Process given TempProcess 'tempProcess' by creating the metadata, doc type and properties for the process and
* updating the process' tasks.
Expand Down Expand Up @@ -1196,6 +1214,7 @@ public Process importProcess(String ppn, int projectId, int templateId, String s
.write(ServiceManager.getProcessService().getMetadataFileUri(tempProcess.getProcess()));
tempProcess.getWorkpiece().setId(tempProcess.getProcess().getId().toString());
ServiceManager.getMetsService().save(tempProcess.getWorkpiece(), out);
runAutomaticTasks(tempProcess.getProcess());
} catch (DAOException | IOException | ProcessGenerationException | XPathExpressionException
| ParserConfigurationException | NoRecordFoundException | UnsupportedFormatException
| URISyntaxException | SAXException | InvalidMetadataValueException | NoSuchMetadataFieldException
Expand Down