Search in sources :

Example 6 with FileStoreURIPortObject

use of com.genericworkflownodes.knime.base.data.port.FileStoreURIPortObject in project GenericKnimeNodes by genericworkflownodes.

the class Image2FilePortNodeModel method writeImageFile.

private FileStoreURIPortObject writeImageFile(ImageContent content, final ExecutionContext exec) throws IOException {
    FileStoreURIPortObject fsPortObject = new FileStoreURIPortObject(exec.createFileStore("Image2FilePort"));
    File outFile = fsPortObject.registerFile(Image2FilePortNodeModel.class.getSimpleName() + "." + IMAGE_FILE_EXTENSION);
    logger.debug("Created output file " + outFile.getAbsolutePath());
    final FileOutputStream out = new FileOutputStream(outFile);
    try {
        content.save(out);
    } finally {
        out.close();
    }
    return fsPortObject;
}
Also used : FileStoreURIPortObject(com.genericworkflownodes.knime.base.data.port.FileStoreURIPortObject) FileOutputStream(java.io.FileOutputStream) File(java.io.File)

Example 7 with FileStoreURIPortObject

use of com.genericworkflownodes.knime.base.data.port.FileStoreURIPortObject in project GenericKnimeNodes by genericworkflownodes.

the class ManglerNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
    // translate portobject to table
    BufferedDataTable table = (BufferedDataTable) inData[0];
    // create a file where we can write to
    FileStoreURIPortObject fsupo;
    fsupo = new FileStoreURIPortObject(exec.createFileStore("ManglerNodeModel"));
    // File file = fileStash.getFile(demangler.getMIMEType(), "mime");
    File file = fsupo.registerFile("mangled_file." + demangler.getMIMEType());
    // translate the filename to a URIContent
    URIContent outputURI = new URIContent(file.toURI(), demangler.getMIMEType());
    // write file
    demangler.mangle(table, outputURI.getURI());
    // create list
    List<URIContent> uriList = new ArrayList<URIContent>();
    uriList.add(outputURI);
    return new FileStoreURIPortObject[] { fsupo };
}
Also used : FileStoreURIPortObject(com.genericworkflownodes.knime.base.data.port.FileStoreURIPortObject) BufferedDataTable(org.knime.core.node.BufferedDataTable) ArrayList(java.util.ArrayList) File(java.io.File) URIContent(org.knime.core.data.uri.URIContent)

Aggregations

FileStoreURIPortObject (com.genericworkflownodes.knime.base.data.port.FileStoreURIPortObject)7 File (java.io.File)5 IURIPortObject (org.knime.core.data.uri.IURIPortObject)5 PortObject (org.knime.core.node.port.PortObject)5 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)4 ArrayList (java.util.ArrayList)3 BufferedDataTable (org.knime.core.node.BufferedDataTable)3 FileStorePrefixURIPortObject (com.genericworkflownodes.knime.base.data.port.FileStorePrefixURIPortObject)2 IPrefixURIPortObject (com.genericworkflownodes.knime.base.data.port.IPrefixURIPortObject)2 PortObjectHandlerCell (com.genericworkflownodes.knime.base.data.port.PortObjectHandlerCell)2 NoBinaryAvailableException (com.genericworkflownodes.knime.custom.config.NoBinaryAvailableException)2 UnknownCommandGeneratorException (com.genericworkflownodes.knime.execution.UnknownCommandGeneratorException)2 UnknownToolExecutorException (com.genericworkflownodes.knime.execution.UnknownToolExecutorException)2 FileListParameter (com.genericworkflownodes.knime.parameter.FileListParameter)2 FileParameter (com.genericworkflownodes.knime.parameter.FileParameter)2 IFileParameter (com.genericworkflownodes.knime.parameter.IFileParameter)2 InvalidParameterValueException (com.genericworkflownodes.knime.parameter.InvalidParameterValueException)2 Port (com.genericworkflownodes.knime.port.Port)2 IOException (java.io.IOException)2 ExecutionException (java.util.concurrent.ExecutionException)2