Skip to content

Commit 1070d4f

Browse files
committed
UIEXT-3484: WebUI-Migration Find MIME-Type
UIEXT-3484 (WebUI-Migration Find MIME-Type)
1 parent 1fa1f98 commit 1070d4f

File tree

9 files changed

+439
-82
lines changed

9 files changed

+439
-82
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
<config key="columnselection_Internals">
10+
<entry key="SettingsModelID" type="xstring" value="SMID_string"/>
11+
<entry key="EnabledStatus" type="xboolean" value="true"/>
12+
</config>
13+
<entry key="columnselection" type="xstring" value=""/>
14+
</config>
15+
<entry key="customDescription" type="xstring" isnull="true" value=""/>
16+
<entry key="state" type="xstring" value="IDLE"/>
17+
<config key="nodecontainer_message">
18+
<entry key="type" type="xstring" value="WARNING"/>
19+
<entry key="message" type="xstring" value="URI column not set"/>
20+
</config>
21+
<entry key="factory" type="xstring" value="org.knime.base.filehandling.findmimetype.FindMIMETypeNodeFactory"/>
22+
<entry key="node-name" type="xstring" value="Find MIME-Type"/>
23+
<entry key="node-bundle-name" type="xstring" value="KNIME File Handling Nodes"/>
24+
<entry key="node-bundle-symbolic-name" type="xstring" value="org.knime.base.filehandling"/>
25+
<entry key="node-bundle-vendor" type="xstring" value="KNIME AG, Zurich, Switzerland"/>
26+
<entry key="node-bundle-version" type="xstring" value="5.11.0.v202603201205"/>
27+
<entry key="node-feature-name" type="xstring" isnull="true" value=""/>
28+
<entry key="node-feature-symbolic-name" type="xstring" isnull="true" value=""/>
29+
<entry key="node-feature-vendor" type="xstring" isnull="true" value=""/>
30+
<entry key="node-feature-version" type="xstring" value="0.0.0"/>
31+
<config key="factory_settings"/>
32+
<entry key="name" type="xstring" value="Find MIME-Type"/>
33+
<entry key="hasContent" type="xboolean" value="false"/>
34+
<entry key="isInactive" type="xboolean" value="false"/>
35+
<config key="ports">
36+
<config key="port_1">
37+
<entry key="index" type="xint" value="1"/>
38+
<entry key="port_dir_location" type="xstring" isnull="true" value=""/>
39+
</config>
40+
</config>
41+
<config key="filestores">
42+
<entry key="file_store_location" type="xstring" isnull="true" value=""/>
43+
<entry key="file_store_id" type="xstring" isnull="true" value=""/>
44+
</config>
45+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"data" : {
3+
"model" : { }
4+
},
5+
"schema" : {
6+
"type" : "object",
7+
"properties" : {
8+
"model" : {
9+
"type" : "object",
10+
"properties" : {
11+
"columnSelection" : {
12+
"type" : "string",
13+
"title" : "Column selection",
14+
"description" : "Column that contains the URIs."
15+
}
16+
}
17+
}
18+
}
19+
},
20+
"ui_schema" : {
21+
"elements" : [ {
22+
"type" : "Control",
23+
"scope" : "#/properties/model/properties/columnSelection",
24+
"options" : {
25+
"format" : "dropDown"
26+
},
27+
"providedOptions" : [ "possibleValues" ]
28+
} ]
29+
},
30+
"persist" : {
31+
"type" : "object",
32+
"properties" : {
33+
"model" : {
34+
"type" : "object",
35+
"properties" : {
36+
"columnSelection" : {
37+
"configKey" : "columnselection"
38+
}
39+
}
40+
}
41+
}
42+
},
43+
"initialUpdates" : [ {
44+
"scope" : "#/properties/model/properties/columnSelection",
45+
"providedOptionName" : "possibleValues",
46+
"values" : [ {
47+
"indices" : [ ],
48+
"value" : [ {
49+
"id" : "URI",
50+
"text" : "URI",
51+
"type" : {
52+
"id" : "org.knime.core.data.uri.URIDataValue",
53+
"text" : "URI"
54+
}
55+
}, {
56+
"id" : "Another_URI",
57+
"text" : "Another_URI",
58+
"type" : {
59+
"id" : "org.knime.core.data.uri.URIDataValue",
60+
"text" : "URI"
61+
}
62+
} ]
63+
} ]
64+
} ],
65+
"globalUpdates" : [ {
66+
"trigger" : {
67+
"id" : "after-open-dialog"
68+
},
69+
"triggerInitially" : true,
70+
"dependencies" : [ "#/properties/model/properties/columnSelection" ]
71+
} ]
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
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=""/>
4+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"data" : {
3+
"model" : {
4+
"columnSelection" : ""
5+
}
6+
},
7+
"schema" : {
8+
"type" : "object",
9+
"properties" : {
10+
"model" : {
11+
"type" : "object",
12+
"properties" : {
13+
"columnSelection" : {
14+
"type" : "string",
15+
"title" : "Column selection",
16+
"description" : "Column that contains the URIs."
17+
}
18+
}
19+
}
20+
}
21+
},
22+
"ui_schema" : {
23+
"elements" : [ {
24+
"type" : "Control",
25+
"scope" : "#/properties/model/properties/columnSelection",
26+
"options" : {
27+
"format" : "dropDown"
28+
},
29+
"providedOptions" : [ "possibleValues" ]
30+
} ]
31+
},
32+
"persist" : {
33+
"type" : "object",
34+
"properties" : {
35+
"model" : {
36+
"type" : "object",
37+
"properties" : {
38+
"columnSelection" : {
39+
"configKey" : "columnselection"
40+
}
41+
}
42+
}
43+
}
44+
},
45+
"initialUpdates" : [ {
46+
"scope" : "#/properties/model/properties/columnSelection",
47+
"providedOptionName" : "possibleValues",
48+
"values" : [ {
49+
"indices" : [ ],
50+
"value" : [ {
51+
"id" : "URI",
52+
"text" : "URI",
53+
"type" : {
54+
"id" : "org.knime.core.data.uri.URIDataValue",
55+
"text" : "URI"
56+
}
57+
}, {
58+
"id" : "Another_URI",
59+
"text" : "Another_URI",
60+
"type" : {
61+
"id" : "org.knime.core.data.uri.URIDataValue",
62+
"text" : "URI"
63+
}
64+
} ]
65+
} ]
66+
} ],
67+
"globalUpdates" : [ {
68+
"trigger" : {
69+
"id" : "after-open-dialog"
70+
},
71+
"triggerInitially" : true,
72+
"dependencies" : [ "#/properties/model/properties/columnSelection" ]
73+
} ]
74+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* ------------------------------------------------------------------------
3+
*
4+
* Copyright by KNIME AG, Zurich, Switzerland
5+
* Website: http://www.knime.com; Email: contact@knime.com
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License, Version 3, as
9+
* published by the Free Software Foundation.
10+
*
11+
* This program is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, see <http://www.gnu.org/licenses>.
18+
*
19+
* Additional permission under GNU GPL version 3 section 7:
20+
*
21+
* KNIME interoperates with ECLIPSE solely via ECLIPSE's plug-in APIs.
22+
* Hence, KNIME and ECLIPSE are both independent programs and are not
23+
* derived from each other. Should, however, the interpretation of the
24+
* GNU GPL Version 3 ("License") under any applicable laws result in
25+
* KNIME and ECLIPSE being a combined program, KNIME AG herewith grants
26+
* you the additional permission to use and propagate KNIME together with
27+
* ECLIPSE with only the license terms in place for ECLIPSE applying to
28+
* ECLIPSE and the GNU GPL Version 3 applying for KNIME, provided the
29+
* license terms of ECLIPSE themselves allow for the respective use and
30+
* propagation of ECLIPSE together with KNIME.
31+
*
32+
* Additional permission relating to nodes for KNIME that extend the Node
33+
* Extension (and in particular that are based on subclasses of NodeModel,
34+
* NodeDialog, and NodeView) and that only interoperate with KNIME through
35+
* standard APIs ("Nodes"):
36+
* Nodes are deemed to be separate and independent programs and to not be
37+
* covered works. Notwithstanding anything to the contrary in the
38+
* License, the License does not apply to Nodes, you are not required to
39+
* license Nodes under the License, and you are granted a license to
40+
* prepare and propagate Nodes, in each case even if such Nodes are
41+
* propagated with or for interoperation with KNIME. The owner of a Node
42+
* may freely choose the license terms applicable to such Node, including
43+
* when such Node is propagated with or for interoperation with KNIME.
44+
* ------------------------------------------------------------------------
45+
*/
46+
package org.knime.base.filehandling.findmimetype;
47+
48+
import java.io.FileInputStream;
49+
import java.io.IOException;
50+
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;
62+
63+
/**
64+
* Snapshot test for {@link FindMIMETypeNodeParameters}.
65+
*/
66+
@SuppressWarnings("restriction")
67+
final class FindMIMETypeNodeParametersTest extends DefaultNodeSettingsSnapshotTest {
68+
69+
FindMIMETypeNodeParametersTest() {
70+
super(getConfig());
71+
}
72+
73+
private static SnapshotTestConfiguration getConfig() {
74+
return SnapshotTestConfiguration.builder() //
75+
.withInputPortObjectSpecs(createInputPortSpecs()) //
76+
.testJsonFormsForModel(FindMIMETypeNodeParameters.class) //
77+
.testJsonFormsWithInstance(SettingsType.MODEL, () -> readSettings()) //
78+
.testNodeSettingsStructure(() -> readSettings()) //
79+
.build();
80+
}
81+
82+
private static FindMIMETypeNodeParameters readSettings() {
83+
try {
84+
var path = getSnapshotPath(FindMIMETypeNodeParameters.class).getParent().resolve("node_settings")
85+
.resolve("FindMIMETypeNodeParameters.xml");
86+
try (var fis = new FileInputStream(path.toFile())) {
87+
var nodeSettings = NodeSettings.loadFromXML(fis);
88+
return NodeParametersUtil.loadSettings(nodeSettings.getNodeSettings(SettingsType.MODEL.getConfigKey()),
89+
FindMIMETypeNodeParameters.class);
90+
}
91+
} catch (IOException | InvalidSettingsException e) {
92+
throw new IllegalStateException(e);
93+
}
94+
}
95+
96+
private static PortObjectSpec[] createInputPortSpecs() {
97+
return new PortObjectSpec[]{createDefaultTestTableSpec()};
98+
}
99+
100+
private static DataTableSpec createDefaultTestTableSpec() {
101+
return new DataTableSpec(
102+
new String[]{"URI", "String_Column", "Another_URI"},
103+
new DataType[]{
104+
URIDataCell.TYPE,
105+
DataType.getType(StringCell.class),
106+
URIDataCell.TYPE
107+
}
108+
);
109+
}
110+
}

0 commit comments

Comments
 (0)