diff --git a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/Job.java b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/Job.java index 52b6e7d3859d5e0bfe5cf7d4312663122baa6d2b..11c7654110f6848d990963f330a4e619cef09c21 100644 --- a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/Job.java +++ b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/Job.java @@ -394,6 +394,10 @@ public class Job { synchronization.close(); } + public Path getInputDirectory() { + return inputDirectory; + } + private void storeInputOutputDirectory() { if (inputDirectory == null) { useDemoData = true; diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/BenchmarkJobManager.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/BenchmarkJobManager.java index 51fc01a75cc3a78b5aa363bc0b5cbfb6092d8b56..d74cace55ffbc4b0bd170ea5652ce245ff48a9ba 100644 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/BenchmarkJobManager.java +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/BenchmarkJobManager.java @@ -41,7 +41,6 @@ import cz.it4i.fiji.haas.HaaSOutputHolder; import cz.it4i.fiji.haas.HaaSOutputHolderImpl; import cz.it4i.fiji.haas.Job; import cz.it4i.fiji.haas.JobManager; -import cz.it4i.fiji.haas.UploadingFileFromResource; import cz.it4i.fiji.haas_java_client.JobState; import cz.it4i.fiji.haas_java_client.ProgressNotifier; import cz.it4i.fiji.haas_java_client.Settings; @@ -259,6 +258,14 @@ public class BenchmarkJobManager implements Closeable { public String toString() { return "" + getId(); } + + public void storeDataInWorkdirectory(UploadingFile file) throws IOException { + job.storeDataInWorkdirectory(file); + } + + public Path getInputDirectory() { + return job.getInputDirectory(); + } private ProgressNotifier convertTo(Progress progress) { return progress == null ? null : new P_ProgressNotifierAdapter(progress); @@ -453,6 +460,7 @@ public class BenchmarkJobManager implements Closeable { Stream<BenchmarkError> taskSpecificErrors = tasks.stream().flatMap(s -> s.getErrors().stream()); return Stream.concat(nonTaskSpecificErrors.stream(), taskSpecificErrors).collect(Collectors.toList()); } + } public BenchmarkJobManager(BenchmarkSPIMParameters params) throws IOException { @@ -462,9 +470,6 @@ public class BenchmarkJobManager implements Closeable { public BenchmarkJob createJob(Function<Path, Path> inputDirectoryProvider, Function<Path, Path> outputDirectoryProvider) throws IOException { Job job = jobManager.createJob(inputDirectoryProvider, outputDirectoryProvider); - if (job.isUseDemoData()) { - job.storeDataInWorkdirectory(getConfigYamlFile()); - } return convertJob(job); } @@ -578,10 +583,7 @@ public class BenchmarkJobManager implements Closeable { jobManager.close(); } - private UploadingFile getConfigYamlFile() { - return new UploadingFileFromResource("", Constants.CONFIG_YAML); - } - + private BenchmarkJob convertJob(Job job) { return new BenchmarkJob(job); } diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMController.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMController.java index 3aed3b9a2ca36f6ff7d58e7389a6f6690d8243ad..fd33cca18396606dab930e2ae0e5feaa5a4a94f8 100644 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMController.java +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMController.java @@ -3,6 +3,7 @@ package cz.it4i.fiji.haas_spim_benchmark.ui; import java.awt.Desktop; import java.awt.Window; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.util.EnumSet; import java.util.HashSet; @@ -20,9 +21,11 @@ import java.util.function.Function; import javax.swing.WindowConstants; +import org.apache.commons.lang3.NotImplementedException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import cz.it4i.fiji.haas.UploadingFileFromResource; import cz.it4i.fiji.haas.ui.CloseableControl; import cz.it4i.fiji.haas.ui.DummyProgress; import cz.it4i.fiji.haas.ui.InitiableControl; @@ -31,6 +34,7 @@ import cz.it4i.fiji.haas.ui.ModalDialogs; import cz.it4i.fiji.haas.ui.ProgressDialog; import cz.it4i.fiji.haas.ui.TableViewContextMenu; import cz.it4i.fiji.haas_java_client.JobState; +import cz.it4i.fiji.haas_java_client.UploadingFile; import cz.it4i.fiji.haas_spim_benchmark.core.BenchmarkJobManager; import cz.it4i.fiji.haas_spim_benchmark.core.BenchmarkJobManager.BenchmarkJob; import cz.it4i.fiji.haas_spim_benchmark.core.Constants; @@ -160,15 +164,33 @@ public class BenchmarkSPIMController extends BorderPane implements CloseableCont private void askForCreateJob() { NewJobWindow newJobWindow = new NewJobWindow(null); ModalDialogs.doModal(newJobWindow, WindowConstants.DISPOSE_ON_CLOSE); - newJobWindow.setCreatePressedNotifier(() -> executeWSCallAsync("Creating job", false,p -> doCreateJob(wd -> newJobWindow.getInputDirectory(wd), wd -> newJobWindow.getOutputDirectory(wd)))); + newJobWindow.setCreatePressedNotifier(() -> executeWSCallAsync("Creating job", false, + new P_JobAction() { + @Override + public void doAction(Progress p) throws IOException { + BenchmarkJob job = doCreateJob(wd -> newJobWindow.getInputDirectory(wd), wd -> newJobWindow.getOutputDirectory(wd)); + if (job.isUseDemoData()) { + job.storeDataInWorkdirectory(getConfigYamlFile()); + } else if (Files.exists(job.getInputDirectory().resolve(Constants.CONFIG_YAML))) { + throw new NotImplementedException(""); + } + } + } + )); + } - private void doCreateJob(Function<Path,Path> inputProvider, Function<Path,Path> outputProvider) throws IOException { + private UploadingFile getConfigYamlFile() { + return new UploadingFileFromResource("", Constants.CONFIG_YAML); + } + + private BenchmarkJob doCreateJob(Function<Path,Path> inputProvider, Function<Path,Path> outputProvider) throws IOException { BenchmarkJob bj = manager.createJob(inputProvider, outputProvider); ObservableBenchmarkJob obj = registry.addIfAbsent(bj); addJobToItems(obj); jobs.refresh(); + return bj; } private synchronized void addJobToItems(ObservableBenchmarkJob obj) {