Skip to content

Commit 45ae2ba

Browse files
authored
Merge pull request #21 from NicoKiaru/master
Creates a scijava task linked to the batch job
2 parents e3bc4e5 + c57f18a commit 45ae2ba

16 files changed

Lines changed: 44 additions & 21 deletions

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.classpath
33
.project
44
.settings/
5+
.idea/

‎.mailmap‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Jan Eglinger <jan.eglinger@fmi.ch> <jan.eglinger@gmail.com>

‎LICENSE.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2017 - 2018, Friedrich Miescher Institute for Biomedical Research, Basel (Switzerland)
1+
Copyright (c) 2017 - 2022, Friedrich Miescher Institute for Biomedical Research, Basel (Switzerland)
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification,

‎pom.xml‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.scijava</groupId>
77
<artifactId>pom-scijava</artifactId>
8-
<version>27.0.1</version>
8+
<version>32.0.0-beta-6</version>
99
<relativePath />
1010
</parent>
1111

@@ -32,7 +32,7 @@
3232
<developer>
3333
<id>imagejan</id>
3434
<name>Jan Eglinger</name>
35-
<url>https://imagej.net/User:Eglinger</url>
35+
<url>https://imagej.net/people/imagejan</url>
3636
<roles>
3737
<role>founder</role>
3838
<role>lead</role>
@@ -47,10 +47,15 @@
4747
<contributors>
4848
<contributor>
4949
<name>Curtis Rueden</name>
50-
<url>https://imagej.net/User:Rueden</url>
50+
<url>https://imagej.net/people/ctrueden</url>
5151
<roles><role>founder</role></roles>
5252
<properties><id>ctrueden</id></properties>
5353
</contributor>
54+
<contributor>
55+
<name>Nicolas Chiaruttini</name>
56+
<url>https://imagej.net/people/NicoKiaru</url>
57+
<properties><id>NicoKiaru</id></properties>
58+
</contributor>
5459
</contributors>
5560

5661
<mailingLists>
@@ -82,9 +87,6 @@
8287
<license.copyrightOwners>Friedrich Miescher Institute for Biomedical Research, Basel (Switzerland)</license.copyrightOwners>
8388
<license.excludes>**/scripts/**</license.excludes>
8489

85-
<!-- NB: Fiji ships with scijava-common-2.80.1.jar currently, so we need to adapt as long as no new pom-scijava is released -->
86-
<scijava-common.version>2.80.1</scijava-common.version>
87-
8890
<!-- NB: Deploy releases to the SciJava Maven repository. -->
8991
<releaseProfiles>sign,deploy-to-scijava</releaseProfiles>
9092
</properties>

‎src/main/java/org/scijava/batch/BatchModuleSearchActionFactory.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* #%L
33
* A Batch Processor for SciJava Modules and Scripts
44
* %%
5-
* Copyright (C) 2017 - 2018 Friedrich Miescher Institute for Biomedical Research, Basel (Switzerland)
5+
* Copyright (C) 2017 - 2022 Friedrich Miescher Institute for Biomedical Research, Basel (Switzerland)
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:

‎src/main/java/org/scijava/batch/BatchService.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* #%L
33
* A Batch Processor for SciJava Modules and Scripts
44
* %%
5-
* Copyright (C) 2017 - 2018 Friedrich Miescher Institute for Biomedical Research, Basel (Switzerland)
5+
* Copyright (C) 2017 - 2022 Friedrich Miescher Institute for Biomedical Research, Basel (Switzerland)
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:

‎src/main/java/org/scijava/batch/FileBatchService.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* #%L
33
* A Batch Processor for SciJava Modules and Scripts
44
* %%
5-
* Copyright (C) 2017 - 2018 Friedrich Miescher Institute for Biomedical Research, Basel (Switzerland)
5+
* Copyright (C) 2017 - 2022 Friedrich Miescher Institute for Biomedical Research, Basel (Switzerland)
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:

‎src/main/java/org/scijava/batch/FileScriptBatchProcessor.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* #%L
33
* A Batch Processor for SciJava Modules and Scripts
44
* %%
5-
* Copyright (C) 2017 - 2018 Friedrich Miescher Institute for Biomedical Research, Basel (Switzerland)
5+
* Copyright (C) 2017 - 2022 Friedrich Miescher Institute for Biomedical Research, Basel (Switzerland)
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:

‎src/main/java/org/scijava/batch/MenuScriptBatchProcessor.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* #%L
33
* A Batch Processor for SciJava Modules and Scripts
44
* %%
5-
* Copyright (C) 2017 - 2018 Friedrich Miescher Institute for Biomedical Research, Basel (Switzerland)
5+
* Copyright (C) 2017 - 2022 Friedrich Miescher Institute for Biomedical Research, Basel (Switzerland)
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:

‎src/main/java/org/scijava/batch/ModuleBatchProcessor.java‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* #%L
33
* A Batch Processor for SciJava Modules and Scripts
44
* %%
5-
* Copyright (C) 2017 - 2018 Friedrich Miescher Institute for Biomedical Research, Basel (Switzerland)
5+
* Copyright (C) 2017 - 2022 Friedrich Miescher Institute for Biomedical Research, Basel (Switzerland)
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:
@@ -50,6 +50,8 @@
5050
import org.scijava.table.Column;
5151
import org.scijava.table.DefaultGenericTable;
5252
import org.scijava.table.Table;
53+
import org.scijava.task.Task;
54+
import org.scijava.task.TaskService;
5355
//import org.scijava.widget.FileWidget;
5456

5557
@Plugin(type = Command.class, label = "Choose batch processing parameters", initializer = "initInputChoice")
@@ -76,6 +78,9 @@ public class ModuleBatchProcessor<T> extends DynamicCommand {
7678
@Parameter(type = ItemIO.OUTPUT)
7779
private Table outputTable;
7880

81+
@Parameter
82+
private TaskService taskService;
83+
7984
// -- Initializer --
8085

8186
protected void initInputChoice() {
@@ -114,13 +119,27 @@ public void run() {
114119
scriptModule.resolveOutput(outputKey);
115120
}
116121

122+
String taskName = "Batch:";
123+
ModuleInfo scriptInfo = scriptModule.getInfo();
124+
if (scriptInfo != null && scriptInfo.getName() != null) {
125+
taskName = scriptInfo.getName();
126+
}
127+
Task batchTask = taskService.createTask(taskName);
128+
batchTask.setProgressMaximum(inputFileList.length);
129+
batchTask.setCancelCallBack(() -> batchTask.setStatusMessage("Cancelling batch task..."));
117130
for (File file : inputFileList) {
118-
if(!processFile(scriptModule, inputModuleItem, file)) {
131+
batchTask.setStatusMessage("process "+file.getName());
132+
if (!(processFile(scriptModule, inputModuleItem, file))) {
119133
log.warn("Terminating batch process.");
120134
break; // end for loop
121135
}
136+
if (batchTask.isCanceled()) {
137+
log.warn("Terminating batch process.");
138+
break; // end for loop
139+
}
140+
batchTask.setProgressValue(batchTask.getProgressValue() + 1);
122141
}
123-
142+
batchTask.finish();
124143
// case File
125144
// feed files into input
126145
// case Image (not needed if conversion works

0 commit comments

Comments
 (0)