Search in sources :

Example 1 with FileParameter

use of com.genericworkflownodes.knime.parameter.FileParameter in project GenericKnimeNodes by genericworkflownodes.

the class CTDConfigurationReaderTest method testReadTMTAnalyzer.

@Test
public void testReadTMTAnalyzer() throws Exception {
    CTDConfigurationReader reader = new CTDConfigurationReader();
    assertNotNull(reader);
    INodeConfiguration config = reader.read(TestDataSource.class.getResourceAsStream("TMTAnalyzer.ctd"));
    assertEquals("Quantitation", config.getCategory());
    assertEquals("1.11.0", config.getVersion());
    assertNotNull(config.getParameter("TMTAnalyzer.1.in"));
    assertTrue(config.getParameter("TMTAnalyzer.1.in") instanceof FileParameter);
    assertTrue(config.getParameter("TMTAnalyzer.1.algorithm.Extraction.channel_active") instanceof StringListParameter);
    StringListParameter slp = (StringListParameter) config.getParameter("TMTAnalyzer.1.algorithm.Extraction.channel_active");
    assertEquals(2, slp.getValue().size());
    assertEquals("126:liver", slp.getValue().get(0));
    assertEquals("131:lung", slp.getValue().get(1));
    assertTrue(config.getParameter("TMTAnalyzer.1.algorithm.Quantification.isotope_correction.tmt-6plex").isAdvanced());
    assertTrue(config.getParameter("TMTAnalyzer.1.algorithm.Quantification.isotope_correction.tmt-6plex").isOptional());
    assertFalse(config.getParameter("TMTAnalyzer.1.in").isAdvanced());
    assertFalse(config.getParameter("TMTAnalyzer.1.in").isOptional());
}
Also used : StringListParameter(com.genericworkflownodes.knime.parameter.StringListParameter) TestDataSource(com.genericworkflownodes.knime.test.data.TestDataSource) INodeConfiguration(com.genericworkflownodes.knime.config.INodeConfiguration) FileParameter(com.genericworkflownodes.knime.parameter.FileParameter) Test(org.junit.Test)

Example 2 with FileParameter

use of com.genericworkflownodes.knime.parameter.FileParameter in project GenericKnimeNodes by genericworkflownodes.

the class CTDConfigurationReaderTest method testGKNIgnoreTag.

@Test
public void testGKNIgnoreTag() throws Exception {
    CTDConfigurationReader reader = new CTDConfigurationReader();
    assertNotNull(reader);
    INodeConfiguration config = reader.read(TestDataSource.class.getResourceAsStream("test_app.ctd"));
    assertEquals("SeqAn/Testing", config.getCategory());
    assertEquals("http://www.seqan.de", config.getDocUrl());
    FileParameter fp = (FileParameter) config.getParameter("test_app.out");
    assertNotNull(fp);
    assertEquals("set an output file", fp.getDescription());
    // the parameter following parameters were tagged with gkn-ignore and
    // hence should not be parsed
    assertNull(config.getParameter("test_app.write-ctd-file-ext"));
    assertNull(config.getParameter("test_app.in-file-ext"));
    assertNull(config.getParameter("test_app.out-file-ext"));
}
Also used : TestDataSource(com.genericworkflownodes.knime.test.data.TestDataSource) INodeConfiguration(com.genericworkflownodes.knime.config.INodeConfiguration) FileParameter(com.genericworkflownodes.knime.parameter.FileParameter) Test(org.junit.Test)

Example 3 with FileParameter

use of com.genericworkflownodes.knime.parameter.FileParameter in project GenericKnimeNodes by genericworkflownodes.

the class CTDConfigurationReaderTest method testReadFileFilter.

@Test
public void testReadFileFilter() throws Exception {
    CTDConfigurationReader reader = new CTDConfigurationReader();
    assertNotNull(reader);
    INodeConfiguration config = reader.read(TestDataSource.class.getResourceAsStream("FileFilter.ctd"));
    assertEquals("File Handling", config.getCategory());
    assertNotNull(config.getParameter("FileFilter.1.in"));
    assertTrue(config.getParameter("FileFilter.1.in") instanceof FileParameter);
    assertNotNull(config.getInputPortByName("FileFilter.1.in"));
    assertEquals("1.11.0", config.getVersion());
    FileParameter fp = (FileParameter) config.getParameter("FileFilter.1.in");
    assertEquals("temp", fp.getValue());
    // get list restrictions
    assertNotNull(config.getParameter("FileFilter.1.peak_options.level"));
    assertTrue(config.getParameter("FileFilter.1.peak_options.level") instanceof IntegerListParameter);
    IntegerListParameter ilp = (IntegerListParameter) config.getParameter("FileFilter.1.peak_options.level");
    assertEquals(Integer.valueOf(1), ilp.getLowerBound());
}
Also used : TestDataSource(com.genericworkflownodes.knime.test.data.TestDataSource) INodeConfiguration(com.genericworkflownodes.knime.config.INodeConfiguration) IntegerListParameter(com.genericworkflownodes.knime.parameter.IntegerListParameter) FileParameter(com.genericworkflownodes.knime.parameter.FileParameter) Test(org.junit.Test)

Example 4 with FileParameter

use of com.genericworkflownodes.knime.parameter.FileParameter in project GenericKnimeNodes by genericworkflownodes.

the class ParamHandler method createPort.

/**
 * Convert the current element into a Port and the respective
 * IFileParameter.
 *
 * @param paramName
 *            The name of the Parameter.
 * @param attributes
 *            Attributes of the Parameter.
 */
private void createPort(String paramName, Attributes attributes, boolean isList) {
    // check if we want to create this port
    if (BLACKLIST.contains(paramName)) {
        LOG.setLevel(Level.ALL);
        LOG.info("Ignoring port: " + paramName);
        return;
    }
    Port p = new Port();
    p.setName(m_currentPath + paramName);
    p.setMultiFile(isList);
    p.setOptional(isOptional(attributes));
    p.setActive(true);
    List<String> mimetypes = extractMIMETypes(attributes);
    for (String mt : mimetypes) {
        p.addMimeType(mt);
    }
    String attr_type = attributes.getValue(ATTR_TYPE);
    boolean isInputPort = TYPE_INPUT_FILE.equals(attr_type) || getTags(attributes).contains(INPUTFILE_TAG) || TYPE_INPUT_PREFIX.equals(attr_type);
    // to save/load settings.
    if (p.isOptional() && !isInputPort) {
        p.addMimeType("Inactive");
    }
    String description = attributes.getValue(ATTR_DESCRIPTION);
    p.setDescription(description);
    m_currentParameter = null;
    // create port parameter
    if (isList) {
        m_currentParameter = new FileListParameter(paramName, new ArrayList<String>());
        ((FileListParameter) m_currentParameter).setPort(p);
        ((FileListParameter) m_currentParameter).setDescription(p.getDescription());
        ((FileListParameter) m_currentParameter).setIsOptional(p.isOptional());
    // Values will be filled at the end of the ITEMLIST tag.
    } else {
        m_currentParameter = new FileParameter(paramName, "");
        ((FileParameter) m_currentParameter).setPort(p);
        ((FileParameter) m_currentParameter).setDescription(p.getDescription());
        ((FileParameter) m_currentParameter).setIsOptional(p.isOptional());
        // Fills parameter with default value
        ((FileParameter) m_currentParameter).setValue(attributes.getValue(ATTR_VALUE));
    }
    p.setIsPrefix(TYPE_OUTPUT_PREFIX.equals(attr_type) || TYPE_INPUT_PREFIX.equals(attr_type));
    if (isInputPort) {
        m_inputPorts.add(p);
    } else {
        m_outputPorts.add(p);
    }
}
Also used : FileListParameter(com.genericworkflownodes.knime.parameter.FileListParameter) Port(com.genericworkflownodes.knime.port.Port) ArrayList(java.util.ArrayList) FileParameter(com.genericworkflownodes.knime.parameter.FileParameter)

Example 5 with FileParameter

use of com.genericworkflownodes.knime.parameter.FileParameter in project GenericKnimeNodes by genericworkflownodes.

the class CLICommandGenerator method handleNonListParameter.

private void handleNonListParameter(final List<List<? extends CommandLineElement>> extractedParameterValues, final Parameter<?> p) {
    final List<CommandLineElement> l = new ArrayList<CommandLineElement>();
    final CommandLineElement commandLineElement;
    if (p instanceof FileParameter) {
        commandLineElement = new CommandLineFile((FileParameter) p);
    } else {
        commandLineElement = new CommandLineParameter(p);
    }
    l.add(commandLineElement);
    extractedParameterValues.add(l);
}
Also used : CommandLineParameter(com.genericworkflownodes.knime.commandline.impl.CommandLineParameter) ArrayList(java.util.ArrayList) CommandLineFile(com.genericworkflownodes.knime.commandline.impl.CommandLineFile) CommandLineElement(com.genericworkflownodes.knime.commandline.CommandLineElement) FileParameter(com.genericworkflownodes.knime.parameter.FileParameter) IFileParameter(com.genericworkflownodes.knime.parameter.IFileParameter)

Aggregations

FileParameter (com.genericworkflownodes.knime.parameter.FileParameter)14 ArrayList (java.util.ArrayList)9 IFileParameter (com.genericworkflownodes.knime.parameter.IFileParameter)8 FileListParameter (com.genericworkflownodes.knime.parameter.FileListParameter)7 Port (com.genericworkflownodes.knime.port.Port)7 NoBinaryAvailableException (com.genericworkflownodes.knime.custom.config.NoBinaryAvailableException)6 UnknownCommandGeneratorException (com.genericworkflownodes.knime.execution.UnknownCommandGeneratorException)6 UnknownToolExecutorException (com.genericworkflownodes.knime.execution.UnknownToolExecutorException)6 InvalidParameterValueException (com.genericworkflownodes.knime.parameter.InvalidParameterValueException)6 IOException (java.io.IOException)6 ExecutionException (java.util.concurrent.ExecutionException)6 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)6 IPrefixURIPortObject (com.genericworkflownodes.knime.base.data.port.IPrefixURIPortObject)4 INodeConfiguration (com.genericworkflownodes.knime.config.INodeConfiguration)4 TestDataSource (com.genericworkflownodes.knime.test.data.TestDataSource)4 File (java.io.File)4 Test (org.junit.Test)4 IURIPortObject (org.knime.core.data.uri.IURIPortObject)4 CommandLineElement (com.genericworkflownodes.knime.commandline.CommandLineElement)3 CommandLineParameter (com.genericworkflownodes.knime.commandline.impl.CommandLineParameter)3