Skip to content

Commit 6417edf

Browse files
committed
UIEXT-3487: WebUI-Migration Binary Objects to PNGs
UIEXT-3487 (WebUI-Migration Binary Objects to PNGs)
1 parent 1fa1f98 commit 6417edf

9 files changed

+562
-110
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<entry key="node_file" type="xstring" value="settings.xml"/>
4+
<config key="flow_stack"/>
5+
<config key="internal_node_subsettings">
6+
<entry key="memory_policy" type="xstring" value="CacheSmallInMemory"/>
7+
</config>
8+
<config key="model">
9+
<entry key="columnselection" type="xstring" value="Image"/>
10+
<entry key="replace" type="xstring" value="Append"/>
11+
<entry key="columnname" type="xstring" value="PNG"/>
12+
</config>
13+
<config key="variables"/>
14+
<entry key="customDescription" type="xstring" isnull="true" value=""/>
15+
<entry key="state" type="xstring" value="CONFIGURED"/>
16+
<entry key="factory" type="xstring" value="org.knime.base.filehandling.binaryobjectstopngs.BinaryObjectsToPNGsNodeFactory"/>
17+
<entry key="node-name" type="xstring" value="Binary Objects to PNGs"/>
18+
<entry key="node-bundle-name" type="xstring" value="KNIME File Handling Nodes"/>
19+
<entry key="node-bundle-symbolic-name" type="xstring" value="org.knime.base.filehandling"/>
20+
<entry key="node-bundle-vendor" type="xstring" value="KNIME AG, Zurich, Switzerland"/>
21+
<entry key="node-bundle-version" type="xstring" value="5.11.0.qualifier"/>
22+
<entry key="node-feature-name" type="xstring" isnull="true" value=""/>
23+
<entry key="node-feature-symbolic-name" type="xstring" isnull="true" value=""/>
24+
<entry key="node-feature-vendor" type="xstring" isnull="true" value=""/>
25+
<entry key="node-feature-version" type="xstring" value="0.0.0"/>
26+
<config key="factory_settings"/>
27+
<entry key="name" type="xstring" value="Binary Objects to PNGs"/>
28+
<entry key="hasContent" type="xboolean" value="false"/>
29+
<entry key="isInactive" type="xboolean" value="false"/>
30+
<config key="ports">
31+
<config key="port_1">
32+
<entry key="index" type="xint" value="1"/>
33+
<entry key="port_dir_location" type="xstring" isnull="true" value=""/>
34+
</config>
35+
</config>
36+
<config key="filestores">
37+
<entry key="file_store_location" type="xstring" isnull="true" value=""/>
38+
<entry key="file_store_id" type="xstring" isnull="true" value=""/>
39+
</config>
40+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"data" : {
3+
"model" : {
4+
"outputMode" : "REPLACE",
5+
"newColumnName" : "PNG"
6+
}
7+
},
8+
"schema" : {
9+
"type" : "object",
10+
"properties" : {
11+
"model" : {
12+
"type" : "object",
13+
"properties" : {
14+
"columnSelection" : {
15+
"type" : "string",
16+
"title" : "Column selection",
17+
"description" : "Column containing the binary objects that will be converted to PNG images."
18+
},
19+
"newColumnName" : {
20+
"type" : "string",
21+
"title" : "New column name",
22+
"description" : "Name of the appended column. Only applicable when \"Append\" is selected.",
23+
"default" : "PNG"
24+
},
25+
"outputMode" : {
26+
"oneOf" : [ {
27+
"const" : "REPLACE",
28+
"title" : "Replace"
29+
}, {
30+
"const" : "APPEND",
31+
"title" : "Append"
32+
} ],
33+
"title" : "Output handling",
34+
"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>",
35+
"default" : "REPLACE"
36+
}
37+
}
38+
}
39+
}
40+
},
41+
"ui_schema" : {
42+
"elements" : [ {
43+
"type" : "Control",
44+
"scope" : "#/properties/model/properties/columnSelection",
45+
"options" : {
46+
"format" : "dropDown"
47+
},
48+
"providedOptions" : [ "possibleValues" ]
49+
}, {
50+
"type" : "Control",
51+
"scope" : "#/properties/model/properties/outputMode",
52+
"options" : {
53+
"format" : "valueSwitch"
54+
}
55+
}, {
56+
"type" : "Control",
57+
"scope" : "#/properties/model/properties/newColumnName",
58+
"rule" : {
59+
"effect" : "SHOW",
60+
"condition" : {
61+
"scope" : "#/properties/model/properties/outputMode",
62+
"schema" : {
63+
"oneOf" : [ {
64+
"const" : "APPEND"
65+
} ]
66+
}
67+
}
68+
}
69+
} ]
70+
},
71+
"persist" : {
72+
"type" : "object",
73+
"properties" : {
74+
"model" : {
75+
"type" : "object",
76+
"properties" : {
77+
"columnSelection" : {
78+
"configKey" : "columnselection"
79+
},
80+
"outputMode" : {
81+
"configPaths" : [ [ "replace" ] ]
82+
},
83+
"newColumnName" : {
84+
"configKey" : "columnname"
85+
}
86+
}
87+
}
88+
}
89+
},
90+
"initialUpdates" : [ {
91+
"scope" : "#/properties/model/properties/columnSelection",
92+
"providedOptionName" : "possibleValues",
93+
"values" : [ {
94+
"indices" : [ ],
95+
"value" : [ {
96+
"id" : "foo",
97+
"text" : "foo",
98+
"type" : {
99+
"id" : "org.knime.core.data.blob.BinaryObjectDataValue",
100+
"text" : "Binary Object"
101+
}
102+
} ]
103+
} ]
104+
} ]
105+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<entry key="columnselection" type="xstring" value="Image"/>
4+
<entry key="replace" type="xstring" value="Append"/>
5+
<entry key="columnname" type="xstring" value="PNG"/>
6+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"data" : {
3+
"model" : {
4+
"columnSelection" : "Image",
5+
"outputMode" : "APPEND",
6+
"newColumnName" : "PNG"
7+
}
8+
},
9+
"schema" : {
10+
"type" : "object",
11+
"properties" : {
12+
"model" : {
13+
"type" : "object",
14+
"properties" : {
15+
"columnSelection" : {
16+
"type" : "string",
17+
"title" : "Column selection",
18+
"description" : "Column containing the binary objects that will be converted to PNG images."
19+
},
20+
"newColumnName" : {
21+
"type" : "string",
22+
"title" : "New column name",
23+
"description" : "Name of the appended column. Only applicable when \"Append\" is selected.",
24+
"default" : "PNG"
25+
},
26+
"outputMode" : {
27+
"oneOf" : [ {
28+
"const" : "REPLACE",
29+
"title" : "Replace"
30+
}, {
31+
"const" : "APPEND",
32+
"title" : "Append"
33+
} ],
34+
"title" : "Output handling",
35+
"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>",
36+
"default" : "REPLACE"
37+
}
38+
}
39+
}
40+
}
41+
},
42+
"ui_schema" : {
43+
"elements" : [ {
44+
"type" : "Control",
45+
"scope" : "#/properties/model/properties/columnSelection",
46+
"options" : {
47+
"format" : "dropDown"
48+
},
49+
"providedOptions" : [ "possibleValues" ]
50+
}, {
51+
"type" : "Control",
52+
"scope" : "#/properties/model/properties/outputMode",
53+
"options" : {
54+
"format" : "valueSwitch"
55+
}
56+
}, {
57+
"type" : "Control",
58+
"scope" : "#/properties/model/properties/newColumnName",
59+
"rule" : {
60+
"effect" : "SHOW",
61+
"condition" : {
62+
"scope" : "#/properties/model/properties/outputMode",
63+
"schema" : {
64+
"oneOf" : [ {
65+
"const" : "APPEND"
66+
} ]
67+
}
68+
}
69+
}
70+
} ]
71+
},
72+
"persist" : {
73+
"type" : "object",
74+
"properties" : {
75+
"model" : {
76+
"type" : "object",
77+
"properties" : {
78+
"columnSelection" : {
79+
"configKey" : "columnselection"
80+
},
81+
"outputMode" : {
82+
"configPaths" : [ [ "replace" ] ]
83+
},
84+
"newColumnName" : {
85+
"configKey" : "columnname"
86+
}
87+
}
88+
}
89+
}
90+
},
91+
"initialUpdates" : [ {
92+
"scope" : "#/properties/model/properties/columnSelection",
93+
"providedOptionName" : "possibleValues",
94+
"values" : [ {
95+
"indices" : [ ],
96+
"value" : [ {
97+
"id" : "foo",
98+
"text" : "foo",
99+
"type" : {
100+
"id" : "org.knime.core.data.blob.BinaryObjectDataValue",
101+
"text" : "Binary Object"
102+
}
103+
} ]
104+
} ]
105+
} ]
106+
}

org.knime.base.filehandling/src/org/knime/base/filehandling/binaryobjectstopngs/BinaryObjectsToPNGsNodeDialog.java renamed to org.knime.base.filehandling.tests/src/org/knime/base/filehandling/binaryobjectstopngs/BinaryObjectsToPNGsNodeParametersTest.java

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* ------------------------------------------------------------------------
3+
*
34
* Copyright by KNIME AG, Zurich, Switzerland
45
* Website: http://www.knime.com; Email: contact@knime.com
56
*
@@ -41,61 +42,64 @@
4142
* may freely choose the license terms applicable to such Node, including
4243
* when such Node is propagated with or for interoperation with KNIME.
4344
* ------------------------------------------------------------------------
44-
*
45-
* History
46-
* Oct 30, 2012 (Patrick Winter): created
4745
*/
4846
package org.knime.base.filehandling.binaryobjectstopngs;
4947

50-
import javax.swing.event.ChangeEvent;
51-
import javax.swing.event.ChangeListener;
48+
import java.io.FileInputStream;
49+
import java.io.IOException;
5250

53-
import org.knime.core.data.blob.BinaryObjectDataValue;
54-
import org.knime.core.node.defaultnodesettings.DefaultNodeSettingsPane;
55-
import org.knime.core.node.defaultnodesettings.DialogComponentButtonGroup;
56-
import org.knime.core.node.defaultnodesettings.DialogComponentColumnNameSelection;
57-
import org.knime.core.node.defaultnodesettings.DialogComponentString;
58-
import org.knime.core.node.defaultnodesettings.SettingsModelString;
51+
import org.knime.core.data.DataTableSpec;
52+
import org.knime.core.data.DataType;
53+
import org.knime.core.data.blob.BinaryObjectDataCell;
54+
import org.knime.core.node.InvalidSettingsException;
55+
import org.knime.core.node.NodeSettings;
56+
import org.knime.core.node.port.PortObjectSpec;
57+
import org.knime.core.webui.node.dialog.SettingsType;
58+
import org.knime.core.webui.node.dialog.defaultdialog.NodeParametersUtil;
59+
import org.knime.testing.node.dialog.DefaultNodeSettingsSnapshotTest;
60+
import org.knime.testing.node.dialog.SnapshotTestConfiguration;
5961

6062
/**
61-
* <code>NodeDialog</code> for the node.
62-
*
63-
*
64-
* @author Patrick Winter, KNIME AG, Zurich, Switzerland
63+
* Snapshot test for {@link BinaryObjectsToPNGsNodeParameters}.
64+
*
65+
* @author Tim Crundall, TNG Technology Consulting GmbH
6566
*/
66-
public class BinaryObjectsToPNGsNodeDialog extends DefaultNodeSettingsPane {
67+
@SuppressWarnings("restriction")
68+
final class BinaryObjectsToPNGsNodeParametersTest extends DefaultNodeSettingsSnapshotTest {
6769

68-
private SettingsModelString m_columnselection;
69-
70-
private SettingsModelString m_columnname;
70+
BinaryObjectsToPNGsNodeParametersTest() {
71+
super(getConfig());
72+
}
7173

72-
private SettingsModelString m_replace;
74+
private static SnapshotTestConfiguration getConfig() {
75+
return SnapshotTestConfiguration.builder() //
76+
.withInputPortObjectSpecs(createInputPortSpecs()) //
77+
.testJsonFormsForModel(BinaryObjectsToPNGsNodeParameters.class) //
78+
.testJsonFormsWithInstance(SettingsType.MODEL, () -> readSettings()) //
79+
.testNodeSettingsStructure(() -> readSettings()) //
80+
.build();
81+
}
7382

74-
/**
75-
* New pane for configuring the node dialog.
76-
*/
77-
@SuppressWarnings("unchecked")
78-
protected BinaryObjectsToPNGsNodeDialog() {
79-
super();
80-
m_columnselection = SettingsFactory.createColumnSelectionSettings();
81-
m_replace = SettingsFactory.createReplacePolicySettings();
82-
m_columnname = SettingsFactory.createColumnNameSettings(m_replace);
83-
m_replace.addChangeListener(new ChangeListener() {
84-
@Override
85-
public void stateChanged(final ChangeEvent e) {
86-
boolean append = m_replace.getStringValue().equals(ReplacePolicy.APPEND.getName());
87-
m_columnname.setEnabled(append);
83+
private static BinaryObjectsToPNGsNodeParameters readSettings() {
84+
try {
85+
var path = getSnapshotPath(BinaryObjectsToPNGsNodeParameters.class).getParent().resolve("node_settings")
86+
.resolve("BinaryObjectsToPNGsNodeParameters.xml");
87+
try (var fis = new FileInputStream(path.toFile())) {
88+
var nodeSettings = NodeSettings.loadFromXML(fis);
89+
return NodeParametersUtil.loadSettings(nodeSettings.getNodeSettings(SettingsType.MODEL.getConfigKey()),
90+
BinaryObjectsToPNGsNodeParameters.class);
8891
}
89-
});
90-
// Column selection
91-
addDialogComponent(new DialogComponentColumnNameSelection(m_columnselection, "Column selection", 0,
92-
BinaryObjectDataValue.class));
93-
createNewGroup("New column...");
94-
// Replace
95-
addDialogComponent(new DialogComponentButtonGroup(m_replace, false, "", ReplacePolicy.getAllSettings()));
96-
// Column name
97-
addDialogComponent(new DialogComponentString(m_columnname, "Name", true, 20));
98-
closeCurrentGroup();
92+
} catch (IOException | InvalidSettingsException e) {
93+
throw new IllegalStateException(e);
94+
}
95+
}
96+
97+
private static PortObjectSpec[] createInputPortSpecs() {
98+
return new PortObjectSpec[]{createDefaultTestTableSpec()};
9999
}
100100

101+
private static DataTableSpec createDefaultTestTableSpec() {
102+
return new DataTableSpec(new String[]{"foo"},
103+
new DataType[]{DataType.getType(BinaryObjectDataCell.class), });
104+
}
101105
}

0 commit comments

Comments
 (0)