Search in sources :

Example 1 with FileWorkflowPersistor

use of org.knime.core.node.workflow.FileWorkflowPersistor in project knime-core by knime.

the class RepositoryFactory method loadMetaNode.

private static WorkflowManagerUI loadMetaNode(final String pluginId, final String workflowDir) {
    LOGGER.debug("found pre-installed template " + workflowDir);
    Bundle bundle = Platform.getBundle(pluginId);
    URL url = FileLocator.find(bundle, new Path(workflowDir), null);
    if (url != null) {
        try {
            File f = new File(FileLocator.toFileURL(url).getFile());
            LOGGER.debug("meta node template name: " + f.getName());
            WorkflowLoadHelper loadHelper = new WorkflowLoadHelper(true) {

                /**
                 * {@inheritDoc}
                 */
                @Override
                public String getDotKNIMEFileName() {
                    return WorkflowPersistor.WORKFLOW_FILE;
                }
            };
            // don't lock workflow dir
            FileWorkflowPersistor persistor = WorkflowManager.createLoadPersistor(f, loadHelper);
            WorkflowManager metaNode = WorkflowManager.META_NODE_ROOT.load(persistor, new ExecutionMonitor(), false).getWorkflowManager();
            return WorkflowManagerWrapper.wrap(metaNode);
        } catch (CanceledExecutionException cee) {
            LOGGER.error("Unexpected canceled execution exception", cee);
        } catch (Exception e) {
            LOGGER.error("Failed to load meta workflow repository", e);
        }
    }
    return null;
}
Also used : Path(org.eclipse.core.runtime.Path) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) Bundle(org.osgi.framework.Bundle) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) WorkflowLoadHelper(org.knime.core.node.workflow.WorkflowLoadHelper) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) File(java.io.File) URL(java.net.URL) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) FileWorkflowPersistor(org.knime.core.node.workflow.FileWorkflowPersistor)

Aggregations

File (java.io.File)1 URL (java.net.URL)1 Path (org.eclipse.core.runtime.Path)1 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)1 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)1 FileWorkflowPersistor (org.knime.core.node.workflow.FileWorkflowPersistor)1 WorkflowLoadHelper (org.knime.core.node.workflow.WorkflowLoadHelper)1 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)1 Bundle (org.osgi.framework.Bundle)1