Skip to content

Commit d5102a2

Browse files
committed
UIEXT-3490: WebUI-Migration Model to Binary Object
UIEXT-3490 (WebUI-Migration Model to Binary Object)
1 parent 1fa1f98 commit d5102a2

8 files changed

+294
-55
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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="columnname_Internals">
10+
<entry key="SettingsModelID" type="xstring" value="SMID_string"/>
11+
<entry key="EnabledStatus" type="xboolean" value="true"/>
12+
</config>
13+
<entry key="columnname" type="xstring" value="model"/>
14+
</config>
15+
<entry key="customDescription" type="xstring" isnull="true" value=""/>
16+
<entry key="state" type="xstring" value="IDLE"/>
17+
<entry key="factory" type="xstring" value="org.knime.base.filehandling.binaryobjects.model.to.port.ModelToBinaryObjectNodeFactory"/>
18+
<entry key="node-name" type="xstring" value="Model to Binary Object"/>
19+
<entry key="node-bundle-name" type="xstring" value="KNIME File Handling Nodes"/>
20+
<entry key="node-bundle-symbolic-name" type="xstring" value="org.knime.base.filehandling"/>
21+
<entry key="node-bundle-vendor" type="xstring" value="KNIME AG, Zurich, Switzerland"/>
22+
<entry key="node-bundle-version" type="xstring" value="5.11.0.v202603201205"/>
23+
<entry key="node-feature-name" type="xstring" isnull="true" value=""/>
24+
<entry key="node-feature-symbolic-name" type="xstring" isnull="true" value=""/>
25+
<entry key="node-feature-vendor" type="xstring" isnull="true" value=""/>
26+
<entry key="node-feature-version" type="xstring" value="0.0.0"/>
27+
<config key="factory_settings"/>
28+
<entry key="name" type="xstring" value="Model to Binary Object"/>
29+
<entry key="hasContent" type="xboolean" value="false"/>
30+
<entry key="isInactive" type="xboolean" value="false"/>
31+
<config key="ports">
32+
<config key="port_1">
33+
<entry key="index" type="xint" value="1"/>
34+
<entry key="port_dir_location" type="xstring" isnull="true" value=""/>
35+
</config>
36+
</config>
37+
<config key="filestores">
38+
<entry key="file_store_location" type="xstring" isnull="true" value=""/>
39+
<entry key="file_store_id" type="xstring" isnull="true" value=""/>
40+
</config>
41+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"data" : {
3+
"model" : {
4+
"columnName" : ""
5+
}
6+
},
7+
"schema" : {
8+
"type" : "object",
9+
"properties" : {
10+
"model" : {
11+
"type" : "object",
12+
"properties" : {
13+
"columnName" : {
14+
"type" : "string",
15+
"title" : "New column name",
16+
"description" : "Name of the new column.",
17+
"default" : ""
18+
}
19+
}
20+
}
21+
}
22+
},
23+
"ui_schema" : {
24+
"elements" : [ {
25+
"type" : "Control",
26+
"scope" : "#/properties/model/properties/columnName"
27+
} ]
28+
},
29+
"persist" : {
30+
"type" : "object",
31+
"properties" : {
32+
"model" : {
33+
"type" : "object",
34+
"properties" : {
35+
"columnName" : {
36+
"configKey" : "columnname"
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
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="columnname" type="xstring" value="model"/>
4+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"data" : {
3+
"model" : {
4+
"columnName" : "model"
5+
}
6+
},
7+
"schema" : {
8+
"type" : "object",
9+
"properties" : {
10+
"model" : {
11+
"type" : "object",
12+
"properties" : {
13+
"columnName" : {
14+
"type" : "string",
15+
"title" : "New column name",
16+
"description" : "Name of the new column.",
17+
"default" : ""
18+
}
19+
}
20+
}
21+
}
22+
},
23+
"ui_schema" : {
24+
"elements" : [ {
25+
"type" : "Control",
26+
"scope" : "#/properties/model/properties/columnName"
27+
} ]
28+
},
29+
"persist" : {
30+
"type" : "object",
31+
"properties" : {
32+
"model" : {
33+
"type" : "object",
34+
"properties" : {
35+
"columnName" : {
36+
"configKey" : "columnname"
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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+
47+
package org.knime.base.filehandling.binaryobjects.model.to.port;
48+
49+
import java.io.FileInputStream;
50+
import java.io.IOException;
51+
52+
import org.knime.core.node.InvalidSettingsException;
53+
import org.knime.core.node.NodeSettings;
54+
import org.knime.core.webui.node.dialog.SettingsType;
55+
import org.knime.core.webui.node.dialog.defaultdialog.NodeParametersUtil;
56+
import org.knime.testing.node.dialog.DefaultNodeSettingsSnapshotTest;
57+
import org.knime.testing.node.dialog.SnapshotTestConfiguration;
58+
59+
/**
60+
* Snapshot test for {@link ModelToBinaryObjectNodeParameters}.
61+
*
62+
* @author Tim Crundall, TNG Technology Consulting GmbH
63+
*/
64+
@SuppressWarnings({"restriction", "javadoc"})
65+
final class ModelToBinaryObjectNodeParametersTest extends DefaultNodeSettingsSnapshotTest {
66+
67+
ModelToBinaryObjectNodeParametersTest() {
68+
super(getConfig());
69+
}
70+
71+
private static SnapshotTestConfiguration getConfig() {
72+
return SnapshotTestConfiguration.builder() //
73+
.testJsonFormsForModel(ModelToBinaryObjectNodeParameters.class) //
74+
.testJsonFormsWithInstance(SettingsType.MODEL, () -> readSettings()) //
75+
.testNodeSettingsStructure(() -> readSettings()) //
76+
.build();
77+
}
78+
79+
private static ModelToBinaryObjectNodeParameters readSettings() {
80+
try {
81+
var path = getSnapshotPath(ModelToBinaryObjectNodeParameters.class).getParent().resolve("node_settings")
82+
.resolve("ModelToBinaryObjectNodeParameters.xml");
83+
try (var fis = new FileInputStream(path.toFile())) {
84+
var nodeSettings = NodeSettings.loadFromXML(fis);
85+
return NodeParametersUtil.loadSettings(nodeSettings.getNodeSettings(SettingsType.MODEL.getConfigKey()),
86+
ModelToBinaryObjectNodeParameters.class);
87+
}
88+
} catch (IOException | InvalidSettingsException e) {
89+
throw new IllegalStateException(e);
90+
}
91+
}
92+
}

org.knime.base.filehandling/src/org/knime/base/filehandling/binaryobjects/model/to/port/ModelToBinaryObjectNodeFactory.java

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,32 @@
5050
import org.knime.core.node.NodeDialogPane;
5151
import org.knime.core.node.NodeFactory;
5252
import org.knime.core.node.NodeView;
53+
import org.knime.core.webui.node.dialog.NodeDialog;
54+
import org.knime.core.webui.node.dialog.NodeDialogFactory;
55+
import org.knime.core.webui.node.dialog.NodeDialogManager;
56+
import org.knime.core.webui.node.dialog.SettingsType;
57+
import org.knime.core.webui.node.dialog.defaultdialog.DefaultNodeDialog;
58+
import org.knime.core.webui.node.dialog.defaultdialog.DefaultKaiNodeInterface;
59+
import org.knime.core.webui.node.dialog.kai.KaiNodeInterface;
60+
import org.knime.core.webui.node.dialog.kai.KaiNodeInterfaceFactory;
61+
import org.knime.core.node.NodeDescription;
62+
import org.knime.node.impl.description.DefaultNodeDescriptionUtil;
63+
import java.util.Map;
64+
import org.knime.node.impl.description.PortDescription;
65+
import java.util.List;
66+
import static org.knime.node.impl.description.PortDescription.fixedPort;
5367

5468
/**
5569
* <code>NodeFactory</code> for node.
5670
*
5771
*
5872
* @author Eric Axt, KNIME GmbH, Konstanz, Germany
73+
* @author Tim Crundall, TNG Technology Consulting GmbH
74+
* @author AI Migration Pipeline v1.2
5975
*/
60-
public final class ModelToBinaryObjectNodeFactory extends NodeFactory<ModelToBinaryObjectNodeModel> {
76+
@SuppressWarnings("restriction")
77+
public final class ModelToBinaryObjectNodeFactory extends NodeFactory<ModelToBinaryObjectNodeModel>
78+
implements NodeDialogFactory, KaiNodeInterfaceFactory {
6179

6280
@Override
6381
public ModelToBinaryObjectNodeModel createNodeModel() {
@@ -79,10 +97,49 @@ public NodeView<ModelToBinaryObjectNodeModel> createNodeView(final int viewIndex
7997
public boolean hasDialog() {
8098
return true;
8199
}
100+
private static final String NODE_NAME = "Model to Binary Object";
101+
private static final String NODE_ICON = "./modeltobinaryobjects16x16.png";
102+
private static final String SHORT_DESCRIPTION = "Converts a model to a binary object cell.";
103+
private static final String FULL_DESCRIPTION = "Converts a model to a binary object cell.";
104+
private static final List<PortDescription> INPUT_PORTS = List.of(
105+
fixedPort("Input model", "Model that will be converted.")
106+
);
107+
private static final List<PortDescription> OUTPUT_PORTS = List.of(
108+
fixedPort("Output table", "Model turned into binary objects.")
109+
);
82110

83111
@Override
84112
public NodeDialogPane createNodeDialogPane() {
85-
return new ModelToBinaryObjectNodeDialog();
113+
return NodeDialogManager.createLegacyFlowVariableNodeDialog(createNodeDialog());
86114
}
87115

116+
@Override
117+
public NodeDialog createNodeDialog() {
118+
return new DefaultNodeDialog(SettingsType.MODEL, ModelToBinaryObjectNodeParameters.class);
119+
}
120+
121+
@Override
122+
public NodeDescription createNodeDescription() {
123+
return DefaultNodeDescriptionUtil.createNodeDescription( //
124+
NODE_NAME, //
125+
NODE_ICON, //
126+
INPUT_PORTS, //
127+
OUTPUT_PORTS, //
128+
SHORT_DESCRIPTION, //
129+
FULL_DESCRIPTION, //
130+
List.of(), //
131+
ModelToBinaryObjectNodeParameters.class, //
132+
null, //
133+
NodeType.Manipulator, //
134+
List.of(), //
135+
null //
136+
);
137+
}
138+
139+
@Override
140+
public KaiNodeInterface createKaiNodeInterface() {
141+
return new DefaultKaiNodeInterface(Map.of(SettingsType.MODEL, ModelToBinaryObjectNodeParameters.class));
142+
}
143+
144+
88145
}

org.knime.base.filehandling/src/org/knime/base/filehandling/binaryobjects/model/to/port/ModelToBinaryObjectNodeFactory.xml

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)