Skip to content

Commit 39f09cf

Browse files
tom-miPaulBrnrther
authored andcommitted
UIEXT-3486: Migrate node
UIEXT-3486 (WebUI-Migration Files To Binary Objects)
1 parent 731c57a commit 39f09cf

16 files changed

+628
-125
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="uricolumn" type="xstring" value="URI"/>
10+
<entry key="replace" type="xstring" value="Append"/>
11+
<entry key="binaryobjectcolumnname" type="xstring" value="BinaryObject"/>
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.filestobinaryobjects.FilesToBinaryObjectsNodeFactory"/>
17+
<entry key="node-name" type="xstring" value="Files to Binary Objects"/>
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="Files to Binary Objects"/>
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,111 @@
1+
{
2+
"data" : {
3+
"model" : {
4+
"uriColumn" : "",
5+
"appendOrReplace" : "APPEND",
6+
"binaryObjectColumnName" : "BinaryObject"
7+
}
8+
},
9+
"schema" : {
10+
"type" : "object",
11+
"properties" : {
12+
"model" : {
13+
"type" : "object",
14+
"properties" : {
15+
"appendOrReplace" : {
16+
"oneOf" : [ {
17+
"const" : "APPEND",
18+
"title" : "Append"
19+
}, {
20+
"const" : "REPLACE",
21+
"title" : "Replace"
22+
} ],
23+
"title" : "Append or replace",
24+
"description" : "Determines whether the binary object column is appended to the table or replaces the URI column.",
25+
"default" : "APPEND"
26+
},
27+
"binaryObjectColumnName" : {
28+
"type" : "string",
29+
"title" : "New column name",
30+
"description" : "The name for the newly appended binary object column. Only relevant when \"Append\" is selected.",
31+
"default" : "BinaryObject"
32+
},
33+
"uriColumn" : {
34+
"type" : "string",
35+
"title" : "URI column",
36+
"description" : "The column containing the paths to the files that should be loaded as binary objects.",
37+
"default" : ""
38+
}
39+
}
40+
}
41+
}
42+
},
43+
"ui_schema" : {
44+
"elements" : [ {
45+
"type" : "Control",
46+
"scope" : "#/properties/model/properties/uriColumn",
47+
"options" : {
48+
"format" : "dropDown"
49+
},
50+
"providedOptions" : [ "possibleValues" ]
51+
}, {
52+
"label" : "Output Column",
53+
"type" : "Section",
54+
"elements" : [ {
55+
"type" : "Control",
56+
"scope" : "#/properties/model/properties/appendOrReplace",
57+
"options" : {
58+
"format" : "valueSwitch"
59+
}
60+
}, {
61+
"type" : "Control",
62+
"scope" : "#/properties/model/properties/binaryObjectColumnName",
63+
"rule" : {
64+
"effect" : "SHOW",
65+
"condition" : {
66+
"scope" : "#/properties/model/properties/appendOrReplace",
67+
"schema" : {
68+
"oneOf" : [ {
69+
"const" : "APPEND"
70+
} ]
71+
}
72+
}
73+
}
74+
} ]
75+
} ]
76+
},
77+
"persist" : {
78+
"type" : "object",
79+
"properties" : {
80+
"model" : {
81+
"type" : "object",
82+
"properties" : {
83+
"uriColumn" : {
84+
"configKey" : "uricolumn"
85+
},
86+
"appendOrReplace" : {
87+
"configPaths" : [ [ "replace" ] ]
88+
},
89+
"binaryObjectColumnName" : {
90+
"configKey" : "binaryobjectcolumnname"
91+
}
92+
}
93+
}
94+
}
95+
},
96+
"initialUpdates" : [ {
97+
"scope" : "#/properties/model/properties/uriColumn",
98+
"providedOptionName" : "possibleValues",
99+
"values" : [ {
100+
"indices" : [ ],
101+
"value" : [ {
102+
"id" : "URI",
103+
"text" : "URI",
104+
"type" : {
105+
"id" : "org.knime.core.data.uri.URIDataValue",
106+
"text" : "URI"
107+
}
108+
} ]
109+
} ]
110+
} ]
111+
}
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="uricolumn" type="xstring" value="URI"/>
4+
<entry key="replace" type="xstring" value="Append"/>
5+
<entry key="binaryobjectcolumnname" type="xstring" value="BinaryObject"/>
6+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"data" : {
3+
"model" : {
4+
"uriColumn" : "URI",
5+
"appendOrReplace" : "APPEND",
6+
"binaryObjectColumnName" : "BinaryObject"
7+
}
8+
},
9+
"schema" : {
10+
"type" : "object",
11+
"properties" : {
12+
"model" : {
13+
"type" : "object",
14+
"properties" : {
15+
"appendOrReplace" : {
16+
"oneOf" : [ {
17+
"const" : "APPEND",
18+
"title" : "Append"
19+
}, {
20+
"const" : "REPLACE",
21+
"title" : "Replace"
22+
} ],
23+
"title" : "Append or replace",
24+
"description" : "Determines whether the binary object column is appended to the table or replaces the URI column.",
25+
"default" : "APPEND"
26+
},
27+
"binaryObjectColumnName" : {
28+
"type" : "string",
29+
"title" : "New column name",
30+
"description" : "The name for the newly appended binary object column. Only relevant when \"Append\" is selected.",
31+
"default" : "BinaryObject"
32+
},
33+
"uriColumn" : {
34+
"type" : "string",
35+
"title" : "URI column",
36+
"description" : "The column containing the paths to the files that should be loaded as binary objects.",
37+
"default" : ""
38+
}
39+
}
40+
}
41+
}
42+
},
43+
"ui_schema" : {
44+
"elements" : [ {
45+
"type" : "Control",
46+
"scope" : "#/properties/model/properties/uriColumn",
47+
"options" : {
48+
"format" : "dropDown"
49+
},
50+
"providedOptions" : [ "possibleValues" ]
51+
}, {
52+
"label" : "Output Column",
53+
"type" : "Section",
54+
"elements" : [ {
55+
"type" : "Control",
56+
"scope" : "#/properties/model/properties/appendOrReplace",
57+
"options" : {
58+
"format" : "valueSwitch"
59+
}
60+
}, {
61+
"type" : "Control",
62+
"scope" : "#/properties/model/properties/binaryObjectColumnName",
63+
"rule" : {
64+
"effect" : "SHOW",
65+
"condition" : {
66+
"scope" : "#/properties/model/properties/appendOrReplace",
67+
"schema" : {
68+
"oneOf" : [ {
69+
"const" : "APPEND"
70+
} ]
71+
}
72+
}
73+
}
74+
} ]
75+
} ]
76+
},
77+
"persist" : {
78+
"type" : "object",
79+
"properties" : {
80+
"model" : {
81+
"type" : "object",
82+
"properties" : {
83+
"uriColumn" : {
84+
"configKey" : "uricolumn"
85+
},
86+
"appendOrReplace" : {
87+
"configPaths" : [ [ "replace" ] ]
88+
},
89+
"binaryObjectColumnName" : {
90+
"configKey" : "binaryobjectcolumnname"
91+
}
92+
}
93+
}
94+
}
95+
},
96+
"initialUpdates" : [ {
97+
"scope" : "#/properties/model/properties/uriColumn",
98+
"providedOptionName" : "possibleValues",
99+
"values" : [ {
100+
"indices" : [ ],
101+
"value" : [ {
102+
"id" : "URI",
103+
"text" : "URI",
104+
"type" : {
105+
"id" : "org.knime.core.data.uri.URIDataValue",
106+
"text" : "URI"
107+
}
108+
} ]
109+
} ]
110+
} ]
111+
}

org.knime.base.filehandling/src-deprecated/org/knime/base/filehandling/filestobinaryobjects/FilesToBinaryObjectsNodeDialog.java renamed to org.knime.base.filehandling.tests/src/org/knime/base/filehandling/filestobinaryobjects/FilesToBinaryObjectsNodeParametersTest.java

Lines changed: 52 additions & 45 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,62 +42,68 @@
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-
* Sep 5, 2012 (Patrick Winter): created
4745
*/
4846
package org.knime.base.filehandling.filestobinaryobjects;
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.uri.URIDataValue;
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.def.StringCell;
54+
import org.knime.core.data.uri.URIDataCell;
55+
import org.knime.core.node.InvalidSettingsException;
56+
import org.knime.core.node.NodeSettings;
57+
import org.knime.core.node.port.PortObjectSpec;
58+
import org.knime.core.webui.node.dialog.SettingsType;
59+
import org.knime.core.webui.node.dialog.defaultdialog.NodeParametersUtil;
60+
import org.knime.testing.node.dialog.DefaultNodeSettingsSnapshotTest;
61+
import org.knime.testing.node.dialog.SnapshotTestConfiguration;
5962

6063
/**
61-
* <code>NodeDialog</code> for the node.
62-
*
64+
* Snapshot test for {@link FilesToBinaryObjectsNodeParameters}.
6365
*
64-
* @author Patrick Winter, KNIME AG, Zurich, Switzerland
66+
* @author Thomas Reifenberger, TNG Technology Consulting GmbH
6567
*/
66-
@Deprecated
67-
class FilesToBinaryObjectsNodeDialog extends DefaultNodeSettingsPane {
68+
@SuppressWarnings("restriction")
69+
final class FilesToBinaryObjectsNodeParametersTest extends DefaultNodeSettingsSnapshotTest {
6870

69-
private SettingsModelString m_uricolumn;
70-
71-
private SettingsModelString m_bocolumnname;
71+
FilesToBinaryObjectsNodeParametersTest() {
72+
super(getConfig());
73+
}
7274

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

75-
/**
76-
* New pane for configuring the node dialog.
77-
* @deprecated
78-
*/
79-
@Deprecated
80-
@SuppressWarnings("unchecked")
81-
protected FilesToBinaryObjectsNodeDialog() {
82-
super();
83-
m_uricolumn = SettingsFactory.createURIColumnSettings();
84-
m_replace = SettingsFactory.createReplacePolicySettings();
85-
m_bocolumnname = SettingsFactory.createBinaryObjectColumnNameSettings(m_replace);
86-
m_replace.addChangeListener(new ChangeListener() {
87-
@Override
88-
public void stateChanged(final ChangeEvent e) {
89-
boolean append = m_replace.getStringValue().equals(ReplacePolicy.APPEND.getName());
90-
m_bocolumnname.setEnabled(append);
84+
private static FilesToBinaryObjectsNodeParameters readSettings() {
85+
try {
86+
var path = getSnapshotPath(FilesToBinaryObjectsNodeParameters.class).getParent().resolve("node_settings")
87+
.resolve("FilesToBinaryObjectsNodeParameters.xml");
88+
try (var fis = new FileInputStream(path.toFile())) {
89+
var nodeSettings = NodeSettings.loadFromXML(fis);
90+
return NodeParametersUtil.loadSettings(
91+
nodeSettings.getNodeSettings(SettingsType.MODEL.getConfigKey()),
92+
FilesToBinaryObjectsNodeParameters.class);
9193
}
92-
});
93-
// URI column
94-
addDialogComponent(new DialogComponentColumnNameSelection(m_uricolumn, "URI column", 0, URIDataValue.class));
95-
createNewGroup("New column...");
96-
// Replace setting
97-
addDialogComponent(new DialogComponentButtonGroup(m_replace, false, "", ReplacePolicy.getAllSettings()));
98-
// Binary object column name
99-
addDialogComponent(new DialogComponentString(m_bocolumnname, "Name", true, 20));
100-
closeCurrentGroup();
94+
} catch (IOException | InvalidSettingsException e) {
95+
throw new IllegalStateException(e);
96+
}
97+
}
98+
99+
private static PortObjectSpec[] createInputPortSpecs() {
100+
return new PortObjectSpec[]{createDefaultTestTableSpec()};
101+
}
102+
103+
private static DataTableSpec createDefaultTestTableSpec() {
104+
return new DataTableSpec( //
105+
new String[]{"URI", "Other_Column"}, //
106+
new DataType[]{DataType.getType(URIDataCell.class), DataType.getType(StringCell.class)});
101107
}
102108
}
109+

0 commit comments

Comments
 (0)