use of org.knime.core.node.NodeModel in project knime-core by knime.
the class SubNodeContainer method setHideNodeFromWizard.
/**
* Sets a flag on a given {@link WizardNode}, whether or not it is hidden from wizard execution
* @param id the node to set the flag on
* @param hide true if the node is supposed to be hidden from WebPortal or wizard execution, false otherwise
* @since 3.5
* @noreference This method is not intended to be referenced by clients.
*/
public void setHideNodeFromWizard(final NodeID id, final boolean hide) {
try (WorkflowLock lock = lock()) {
NativeNodeContainer nnc = m_wfm.getNodeContainer(id, NativeNodeContainer.class, true);
NodeModel model = nnc.getNodeModel();
CheckUtils.checkArgument(model instanceof WizardNode, "Can't set hide in wizard flag on non-wizard nodes.");
WizardNode<?, ?> wn = (WizardNode<?, ?>) model;
if (hide != wn.isHideInWizard()) {
wn.setHideInWizard(hide);
nnc.saveNodeSettingsToDefault();
nnc.setDirty();
}
}
}
use of org.knime.core.node.NodeModel in project knime-core by knime.
the class SubNodeContainer method checkInOutNodesAfterLoad.
/**
* Fixes in- and output nodes after loading (in case they don't exist or have errors).
*/
private void checkInOutNodesAfterLoad(final SubNodeContainerPersistor subNodePersistor, final LoadResult loadResult) {
/* Fix output node */
NodeID virtualOutID = getVirtualOutNodeID();
// non null in case not is not present of of wrong type
String error = null;
// settings of previous node if present or null
NodeSettings outputSettings = null;
// assigned with node insertion, used for node placement
Pair<int[], int[]> minMaxCoordinates;
if (m_wfm.containsNodeContainer(virtualOutID)) {
NodeContainer virtualOutNC = m_wfm.getNodeContainer(virtualOutID);
if (virtualOutNC instanceof NativeNodeContainer) {
NodeModel virtualOutModel = ((NativeNodeContainer) virtualOutNC).getNodeModel();
if (!(virtualOutModel instanceof VirtualSubNodeOutputNodeModel)) {
// this is very likely a missing node (placeholder)
error = String.format("Virtual output node is not of expected type (expected %s, actual %s)", VirtualSubNodeOutputNodeModel.class.getName(), virtualOutModel.getClass().getName());
try {
NodeSettings temp = new NodeSettings("temp");
m_wfm.saveNodeSettings(virtualOutID, temp);
outputSettings = temp;
} catch (InvalidSettingsException ise) {
// silently ignore; this is minor given that the node is not there.
}
}
} else {
error = String.format("Virtual output node with ID %s is not a native node", virtualOutID);
}
} else {
error = String.format("Virtual output node with ID %s does not exist", virtualOutID);
}
if (error != null) {
minMaxCoordinates = getMinMaxCoordinates();
m_virtualOutNodeIDSuffix = addVirtualOutNode(Output.getPortTypesNoFlowVariablePort(m_outputs), minMaxCoordinates).getIndex();
error = error.concat(String.format(" - creating new instance (ID %s)", m_virtualOutNodeIDSuffix));
loadResult.addError(error);
if (outputSettings != null) {
try {
m_wfm.loadNodeSettings(getVirtualOutNodeID(), outputSettings);
} catch (InvalidSettingsException e) {
// again, ignore as the node was missing, which is much more critical
}
}
}
/* Fix input node */
NodeID virtualInID = getVirtualInNodeID();
// non null in case not is not present of of wrong type
error = null;
// settings of previous node if present or null
NodeSettings inputSettings = null;
if (m_wfm.containsNodeContainer(virtualInID)) {
NodeContainer virtualInNC = m_wfm.getNodeContainer(virtualInID);
if (virtualInNC instanceof NativeNodeContainer) {
NodeModel virtualInModel = ((NativeNodeContainer) virtualInNC).getNodeModel();
if (!(virtualInModel instanceof VirtualSubNodeInputNodeModel)) {
// this is very likely a missing node (placeholder)
error = String.format("Virtual input node is not of expected type (expected %s, actual %s)", VirtualSubNodeInputNodeModel.class.getName(), virtualInModel.getClass().getName());
try {
NodeSettings temp = new NodeSettings("temp");
m_wfm.saveNodeSettings(virtualInID, temp);
inputSettings = temp;
} catch (InvalidSettingsException ise) {
// silently ignore; this is minor given that the node is not there.
}
}
} else {
error = String.format("Virtual input node with ID %s is not a native node", virtualInID);
}
} else {
error = String.format("Virtual input node with ID %s does not exist", virtualInID);
}
if (error != null) {
minMaxCoordinates = getMinMaxCoordinates();
// skip flow var port
PortType[] inportTypes = new PortType[getNrInPorts() - 1];
for (int i = 1; i < getNrInPorts(); i++) {
inportTypes[i - 1] = getInPort(i).getPortType();
}
m_virtualInNodeIDSuffix = addVirtualInNode(inportTypes, minMaxCoordinates).getIndex();
error = error.concat(String.format(" - creating new instance (ID %s)", m_virtualInNodeIDSuffix));
loadResult.addError(error);
if (inputSettings != null) {
try {
m_wfm.loadNodeSettings(getVirtualInNodeID(), inputSettings);
} catch (InvalidSettingsException e) {
// again, ignore as the node was missing, which is much more critical
}
}
}
}
use of org.knime.core.node.NodeModel in project knime-core by knime.
the class CovarianceMatrixCalculatorTest method setUp.
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
@SuppressWarnings({ "unchecked", "rawtypes" }) NodeFactory<NodeModel> dummyFactory = (NodeFactory) new VirtualParallelizedChunkPortObjectInNodeFactory(new PortType[0]);
m_exec = new ExecutionContext(new DefaultNodeProgressMonitor(), new Node(dummyFactory), SingleNodeContainer.MemoryPolicy.CacheOnDisc, new HashMap<Integer, ContainerTable>());
}
use of org.knime.core.node.NodeModel in project knime-core by knime.
the class JoinerTest method setUp.
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
NodeFactory<NodeModel> dummyFactory = (NodeFactory) new VirtualParallelizedChunkPortObjectInNodeFactory(new PortType[0]);
m_exec = new ExecutionContext(new DefaultNodeProgressMonitor(), new Node(dummyFactory), SingleNodeContainer.MemoryPolicy.CacheOnDisc, new HashMap<Integer, ContainerTable>());
}
use of org.knime.core.node.NodeModel in project knime-core by knime.
the class LiftChartNodeView method modelChanged.
/**
* {@inheritDoc}
*/
@Override
protected void modelChanged() {
final NodeModel model = getNodeModel();
m_liftChart.setDataProvider((DataProvider) model);
m_gainChart.setDataProvider(new DataProvider() {
public DataArray getDataArray(final int index) {
return ((LiftChartNodeModel) model).getDataArray(1);
}
});
m_liftChart.updatePaintModel();
m_gainChart.updatePaintModel();
}
Aggregations