Search in sources :

Example 1 with PreprocessorPlugin

use of org.scijava.module.process.PreprocessorPlugin in project imagej-omero by imagej.

the class ModuleAdapter method getJobInfo.

/**
 * Converts ImageJ module metadata to OMERO job metadata.
 */
public omero.RType getJobInfo() {
    // populate module metadata
    final omero.grid.JobParams params = new omero.grid.JobParams();
    // info.getName();
    params.name = "[ImageJ] " + info.getTitle();
    params.version = getVersion();
    params.description = info.getDescription();
    params.stdoutFormat = "text/plain";
    params.stderrFormat = "text/plain";
    // Instantiate and preprocess the module
    final Module m = moduleService.createModule(info);
    final List<PreprocessorPlugin> pre = pluginService.createInstancesOfType(PreprocessorPlugin.class);
    final ModuleRunner mr = new ModuleRunner(getContext(), m, pre, null);
    mr.preProcess();
    // count module inputs and outputs
    final int inputCount = m.getInputs().size();
    final int outputCount = m.getOutputs().size();
    final int inputDigits = String.valueOf(inputCount).length();
    final int outputDigits = String.valueOf(outputCount).length();
    // convert metadata for each module input
    params.inputs = new HashMap<>();
    int inputIndex = 0;
    for (final ModuleItem<?> item : info.inputs()) {
        if (item.getVisibility() == ItemVisibility.MESSAGE)
            continue;
        if (m.isInputResolved(item.getName()))
            continue;
        final omero.grid.Param param = omeroService.getJobParam(item);
        if (param != null) {
            param.grouping = pad(inputIndex++, inputDigits);
            params.inputs.put(getInputName(item), param);
        }
    }
    // convert metadata for each module output
    params.outputs = new HashMap<>();
    int outputIndex = 0;
    for (final ModuleItem<?> item : info.outputs()) {
        final omero.grid.Param param = omeroService.getJobParam(item);
        if (param != null) {
            param.grouping = pad(outputIndex++, outputDigits);
            params.outputs.put(getOutputName(item), param);
        }
    }
    return omero.rtypes.rinternal(params);
}
Also used : ModuleRunner(org.scijava.module.ModuleRunner) PreprocessorPlugin(org.scijava.module.process.PreprocessorPlugin) Module(org.scijava.module.Module)

Aggregations

Module (org.scijava.module.Module)1 ModuleRunner (org.scijava.module.ModuleRunner)1 PreprocessorPlugin (org.scijava.module.process.PreprocessorPlugin)1