Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://www.knime.org/2008/09/XMLConfig" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.knime.org/2008/09/XMLConfig http://www.knime.org/XMLConfig_2008_09.xsd" key="settings.xml">
<entry key="node_file" type="xstring" value="settings.xml"/>
<config key="flow_stack"/>
<config key="internal_node_subsettings">
<entry key="memory_policy" type="xstring" value="CacheSmallInMemory"/>
</config>
<config key="model">
<entry key="columnselection" type="xstring" value="Image"/>
<entry key="replace" type="xstring" value="Append"/>
<entry key="columnname" type="xstring" value="PNG"/>
</config>
<config key="variables"/>
<entry key="customDescription" type="xstring" isnull="true" value=""/>
<entry key="state" type="xstring" value="CONFIGURED"/>
<entry key="factory" type="xstring" value="org.knime.base.filehandling.binaryobjectstopngs.BinaryObjectsToPNGsNodeFactory"/>
<entry key="node-name" type="xstring" value="Binary Objects to PNGs"/>
<entry key="node-bundle-name" type="xstring" value="KNIME File Handling Nodes"/>
<entry key="node-bundle-symbolic-name" type="xstring" value="org.knime.base.filehandling"/>
<entry key="node-bundle-vendor" type="xstring" value="KNIME AG, Zurich, Switzerland"/>
<entry key="node-bundle-version" type="xstring" value="5.11.0.qualifier"/>
<entry key="node-feature-name" type="xstring" isnull="true" value=""/>
<entry key="node-feature-symbolic-name" type="xstring" isnull="true" value=""/>
<entry key="node-feature-vendor" type="xstring" isnull="true" value=""/>
<entry key="node-feature-version" type="xstring" value="0.0.0"/>
<config key="factory_settings"/>
<entry key="name" type="xstring" value="Binary Objects to PNGs"/>
<entry key="hasContent" type="xboolean" value="false"/>
<entry key="isInactive" type="xboolean" value="false"/>
<config key="ports">
<config key="port_1">
<entry key="index" type="xint" value="1"/>
<entry key="port_dir_location" type="xstring" isnull="true" value=""/>
</config>
</config>
<config key="filestores">
<entry key="file_store_location" type="xstring" isnull="true" value=""/>
<entry key="file_store_id" type="xstring" isnull="true" value=""/>
</config>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"data" : {
"model" : {
"columnSelection" : "",
"outputMode" : "REPLACE",
"newColumnName" : "PNG"
}
},
"schema" : {
"type" : "object",
"properties" : {
"model" : {
"type" : "object",
"properties" : {
"columnSelection" : {
"type" : "string",
"title" : "Column selection",
"description" : "Column containing the binary objects that will be converted to PNG images.",
"default" : ""
},
"newColumnName" : {
"type" : "string",
"title" : "New column name",
"description" : "Name of the appended column. Only applicable when \"Append\" is selected.",
"default" : "PNG"
},
"outputMode" : {
"oneOf" : [ {
"const" : "REPLACE",
"title" : "Replace"
}, {
"const" : "APPEND",
"title" : "Append"
} ],
"title" : "Output handling",
"description" : "Determines whether to append a new PNG column or to replace the selected binary object column.\n<ul>\n<li><b>Replace</b>: Replaces the selected binary object column with the PNG column.</li>\n<li><b>Append</b>: Appends a new PNG column to the table.</li>\n</ul>",
"default" : "REPLACE"
}
}
}
}
},
"ui_schema" : {
"elements" : [ {
"type" : "Control",
"scope" : "#/properties/model/properties/columnSelection",
"options" : {
"format" : "dropDown"
},
"providedOptions" : [ "possibleValues" ]
}, {
"type" : "Control",
"scope" : "#/properties/model/properties/outputMode",
"options" : {
"format" : "valueSwitch"
}
}, {
"type" : "Control",
"scope" : "#/properties/model/properties/newColumnName",
"rule" : {
"effect" : "SHOW",
"condition" : {
"scope" : "#/properties/model/properties/outputMode",
"schema" : {
"oneOf" : [ {
"const" : "APPEND"
} ]
}
}
}
} ]
},
"persist" : {
"type" : "object",
"properties" : {
"model" : {
"type" : "object",
"properties" : {
"columnSelection" : {
"configKey" : "columnselection"
},
"outputMode" : {
"configPaths" : [ [ "replace" ] ]
},
"newColumnName" : {
"configKey" : "columnname"
}
}
}
}
},
"initialUpdates" : [ {
"scope" : "#/properties/model/properties/columnSelection",
"providedOptionName" : "possibleValues",
"values" : [ {
"indices" : [ ],
"value" : [ {
"id" : "foo",
"text" : "foo",
"type" : {
"id" : "org.knime.core.data.blob.BinaryObjectDataValue",
"text" : "Binary Object"
}
} ]
} ]
} ]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://www.knime.org/2008/09/XMLConfig" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.knime.org/2008/09/XMLConfig http://www.knime.org/XMLConfig_2008_09.xsd" key="test">
<entry key="columnselection" type="xstring" value="Image"/>
<entry key="replace" type="xstring" value="Append"/>
<entry key="columnname" type="xstring" value="PNG"/>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"data" : {
"model" : {
"columnSelection" : "Image",
"outputMode" : "APPEND",
"newColumnName" : "PNG"
}
},
"schema" : {
"type" : "object",
"properties" : {
"model" : {
"type" : "object",
"properties" : {
"columnSelection" : {
"type" : "string",
"title" : "Column selection",
"description" : "Column containing the binary objects that will be converted to PNG images.",
"default" : ""
},
"newColumnName" : {
"type" : "string",
"title" : "New column name",
"description" : "Name of the appended column. Only applicable when \"Append\" is selected.",
"default" : "PNG"
},
"outputMode" : {
"oneOf" : [ {
"const" : "REPLACE",
"title" : "Replace"
}, {
"const" : "APPEND",
"title" : "Append"
} ],
"title" : "Output handling",
"description" : "Determines whether to append a new PNG column or to replace the selected binary object column.\n<ul>\n<li><b>Replace</b>: Replaces the selected binary object column with the PNG column.</li>\n<li><b>Append</b>: Appends a new PNG column to the table.</li>\n</ul>",
"default" : "REPLACE"
}
}
}
}
},
"ui_schema" : {
"elements" : [ {
"type" : "Control",
"scope" : "#/properties/model/properties/columnSelection",
"options" : {
"format" : "dropDown"
},
"providedOptions" : [ "possibleValues" ]
}, {
"type" : "Control",
"scope" : "#/properties/model/properties/outputMode",
"options" : {
"format" : "valueSwitch"
}
}, {
"type" : "Control",
"scope" : "#/properties/model/properties/newColumnName",
"rule" : {
"effect" : "SHOW",
"condition" : {
"scope" : "#/properties/model/properties/outputMode",
"schema" : {
"oneOf" : [ {
"const" : "APPEND"
} ]
}
}
}
} ]
},
"persist" : {
"type" : "object",
"properties" : {
"model" : {
"type" : "object",
"properties" : {
"columnSelection" : {
"configKey" : "columnselection"
},
"outputMode" : {
"configPaths" : [ [ "replace" ] ]
},
"newColumnName" : {
"configKey" : "columnname"
}
}
}
}
},
"initialUpdates" : [ {
"scope" : "#/properties/model/properties/columnSelection",
"providedOptionName" : "possibleValues",
"values" : [ {
"indices" : [ ],
"value" : [ {
"id" : "foo",
"text" : "foo",
"type" : {
"id" : "org.knime.core.data.blob.BinaryObjectDataValue",
"text" : "Binary Object"
}
} ]
} ]
} ]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* ------------------------------------------------------------------------
*
* Copyright by KNIME AG, Zurich, Switzerland
* Website: http://www.knime.com; Email: contact@knime.com
*
Expand Down Expand Up @@ -41,61 +42,64 @@
* may freely choose the license terms applicable to such Node, including
* when such Node is propagated with or for interoperation with KNIME.
* ------------------------------------------------------------------------
*
* History
* Oct 30, 2012 (Patrick Winter): created
*/
package org.knime.base.filehandling.binaryobjectstopngs;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.io.FileInputStream;
import java.io.IOException;

import org.knime.core.data.blob.BinaryObjectDataValue;
import org.knime.core.node.defaultnodesettings.DefaultNodeSettingsPane;
import org.knime.core.node.defaultnodesettings.DialogComponentButtonGroup;
import org.knime.core.node.defaultnodesettings.DialogComponentColumnNameSelection;
import org.knime.core.node.defaultnodesettings.DialogComponentString;
import org.knime.core.node.defaultnodesettings.SettingsModelString;
import org.knime.core.data.DataTableSpec;
import org.knime.core.data.DataType;
import org.knime.core.data.blob.BinaryObjectDataCell;
import org.knime.core.node.InvalidSettingsException;
import org.knime.core.node.NodeSettings;
import org.knime.core.node.port.PortObjectSpec;
import org.knime.core.webui.node.dialog.SettingsType;
import org.knime.core.webui.node.dialog.defaultdialog.NodeParametersUtil;
import org.knime.testing.node.dialog.DefaultNodeSettingsSnapshotTest;
import org.knime.testing.node.dialog.SnapshotTestConfiguration;

/**
* <code>NodeDialog</code> for the node.
*
*
* @author Patrick Winter, KNIME AG, Zurich, Switzerland
* Snapshot test for {@link BinaryObjectsToPNGsNodeParameters}.
*
* @author Tim Crundall, TNG Technology Consulting GmbH
*/
public class BinaryObjectsToPNGsNodeDialog extends DefaultNodeSettingsPane {
@SuppressWarnings("restriction")
final class BinaryObjectsToPNGsNodeParametersTest extends DefaultNodeSettingsSnapshotTest {

private SettingsModelString m_columnselection;

private SettingsModelString m_columnname;
BinaryObjectsToPNGsNodeParametersTest() {
super(getConfig());
}

private SettingsModelString m_replace;
private static SnapshotTestConfiguration getConfig() {
return SnapshotTestConfiguration.builder() //
.withInputPortObjectSpecs(createInputPortSpecs()) //
.testJsonFormsForModel(BinaryObjectsToPNGsNodeParameters.class) //
.testJsonFormsWithInstance(SettingsType.MODEL, () -> readSettings()) //
.testNodeSettingsStructure(() -> readSettings()) //
.build();
}

/**
* New pane for configuring the node dialog.
*/
@SuppressWarnings("unchecked")
protected BinaryObjectsToPNGsNodeDialog() {
super();
m_columnselection = SettingsFactory.createColumnSelectionSettings();
m_replace = SettingsFactory.createReplacePolicySettings();
m_columnname = SettingsFactory.createColumnNameSettings(m_replace);
m_replace.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
boolean append = m_replace.getStringValue().equals(ReplacePolicy.APPEND.getName());
m_columnname.setEnabled(append);
private static BinaryObjectsToPNGsNodeParameters readSettings() {
try {
var path = getSnapshotPath(BinaryObjectsToPNGsNodeParameters.class).getParent().resolve("node_settings")
.resolve("BinaryObjectsToPNGsNodeParameters.xml");
try (var fis = new FileInputStream(path.toFile())) {
var nodeSettings = NodeSettings.loadFromXML(fis);
return NodeParametersUtil.loadSettings(nodeSettings.getNodeSettings(SettingsType.MODEL.getConfigKey()),
BinaryObjectsToPNGsNodeParameters.class);
}
});
// Column selection
addDialogComponent(new DialogComponentColumnNameSelection(m_columnselection, "Column selection", 0,
BinaryObjectDataValue.class));
createNewGroup("New column...");
// Replace
addDialogComponent(new DialogComponentButtonGroup(m_replace, false, "", ReplacePolicy.getAllSettings()));
// Column name
addDialogComponent(new DialogComponentString(m_columnname, "Name", true, 20));
closeCurrentGroup();
} catch (IOException | InvalidSettingsException e) {
throw new IllegalStateException(e);
}
}

private static PortObjectSpec[] createInputPortSpecs() {
return new PortObjectSpec[]{createDefaultTestTableSpec()};
}

private static DataTableSpec createDefaultTestTableSpec() {
return new DataTableSpec(new String[]{"foo"},
new DataType[]{DataType.getType(BinaryObjectDataCell.class), });
}
}
Loading