Search in sources :

Example 6 with NodeAndBundleInformationPersistor

use of org.knime.core.node.NodeAndBundleInformationPersistor in project knime-core by knime.

the class Bug5207_BundleVersionInWorkflow method testBundleVersionAfterReexecute.

@Test
public void testBundleVersionAfterReexecute() throws Exception {
    reset(m_tableCreator1);
    // table creator is executed and must have version as from execution time (which was faked but still...)
    NativeNodeContainer tableCreatorNC = (NativeNodeContainer) getManager().getNodeContainer(m_tableCreator1);
    NodeAndBundleInformationPersistor tableBundleInfo = tableCreatorNC.getNodeAndBundleInformation();
    Bundle tableBundle = FrameworkUtil.getBundle(tableCreatorNC.getNodeModel().getClass());
    assertEquals(tableBundle.getVersion().toString(), tableBundleInfo.getBundleVersion().get().toString());
    assertEquals(tableBundle.getSymbolicName(), tableBundleInfo.getBundleSymbolicName().get());
    executeAndWait(m_tableCreator1);
    tableBundleInfo = tableCreatorNC.getNodeAndBundleInformation();
    assertEquals(tableBundle.getVersion().toString(), tableBundleInfo.getBundleVersion().get().toString());
}
Also used : Bundle(org.osgi.framework.Bundle) NodeAndBundleInformationPersistor(org.knime.core.node.NodeAndBundleInformationPersistor) Test(org.junit.Test)

Example 7 with NodeAndBundleInformationPersistor

use of org.knime.core.node.NodeAndBundleInformationPersistor in project knime-core by knime.

the class FileNativeNodeContainerPersistor method preLoadNodeContainer.

/**
 * {@inheritDoc}
 */
@Override
public void preLoadNodeContainer(final WorkflowPersistor parentPersistor, final NodeSettingsRO parentSettings, final LoadResult result) throws InvalidSettingsException, IOException {
    super.preLoadNodeContainer(parentPersistor, parentSettings, result);
    m_parentPersistor = parentPersistor;
    NodeSettingsRO settings = getNodeSettings();
    String error;
    NodeAndBundleInformationPersistor nodeInfo;
    try {
        nodeInfo = loadNodeFactoryInfo(parentSettings, settings);
    } catch (InvalidSettingsException e) {
        setDirtyAfterLoad();
        throw e;
    }
    NodeSettingsRO additionalFactorySettings;
    try {
        additionalFactorySettings = loadAdditionalFactorySettings(settings);
    } catch (Exception e) {
        error = "Unable to load additional factory settings for \"" + nodeInfo + "\"";
        setDirtyAfterLoad();
        throw new InvalidSettingsException(error, e);
    }
    NodeFactory<NodeModel> nodeFactory;
    try {
        nodeFactory = loadNodeFactory(nodeInfo.getFactoryClassNotNull());
    } catch (Exception e) {
        // setDirtyAfterLoad(); // don't set dirty, missing node placeholder will be used instead
        throw new NodeFactoryUnknownException(nodeInfo, additionalFactorySettings, e);
    }
    try {
        if (additionalFactorySettings != null) {
            nodeFactory.loadAdditionalFactorySettings(additionalFactorySettings);
        }
    } catch (Exception e) {
        error = "Unable to load additional factory settings into node factory (node \"" + nodeInfo + "\")";
        getLogger().error(error);
        throw new NodeFactoryUnknownException(error, nodeInfo, additionalFactorySettings, e);
    }
    m_nodeAndBundleInformation = nodeInfo;
    m_node = new Node(nodeFactory, loadCreationConfig(settings, nodeFactory).orElse(null));
}
Also used : NodeModel(org.knime.core.node.NodeModel) NodeFactoryUnknownException(org.knime.core.node.workflow.WorkflowPersistor.NodeFactoryUnknownException) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) Node(org.knime.core.node.Node) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) NodeAndBundleInformationPersistor(org.knime.core.node.NodeAndBundleInformationPersistor) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) InvalidNodeFactoryExtensionException(org.knime.core.node.extension.InvalidNodeFactoryExtensionException) NodeFactoryUnknownException(org.knime.core.node.workflow.WorkflowPersistor.NodeFactoryUnknownException) IOException(java.io.IOException)

Aggregations

NodeAndBundleInformationPersistor (org.knime.core.node.NodeAndBundleInformationPersistor)7 Test (org.junit.Test)3 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)3 Bundle (org.osgi.framework.Bundle)3 IOException (java.io.IOException)2 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)2 Node (org.knime.core.node.Node)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 NoSuchElementException (java.util.NoSuchElementException)1 TreeMap (java.util.TreeMap)1 ReferencedFile (org.knime.core.internal.ReferencedFile)1 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)1 DynamicNodeFactory (org.knime.core.node.DynamicNodeFactory)1