use of org.knime.workbench.repository.model.IContainerObject in project knime-core by knime.
the class RepositoryManager method readMetanodes.
private void readMetanodes(final IProgressMonitor monitor) {
// iterate over the meta node config elements
// and create meta node templates
IExtension[] metanodeExtensions = getExtensions(ID_META_NODE);
for (IExtension mnExt : metanodeExtensions) {
IConfigurationElement[] mnConfigElems = mnExt.getConfigurationElements();
for (IConfigurationElement mnConfig : mnConfigElems) {
if (monitor.isCanceled()) {
return;
}
try {
MetaNodeTemplate metaNode = RepositoryFactory.createMetaNode(mnConfig);
LOGGER.debug("Found meta node definition '" + metaNode.getID() + "': " + metaNode.getName());
for (Listener l : m_loadListeners) {
l.newMetanode(m_root, metaNode);
}
IContainerObject parentContainer = m_root.findContainer(metaNode.getCategoryPath());
// append the node to the repository root.
if (parentContainer == null) {
LOGGER.warn("Invalid category-path for node " + "contribution: '" + metaNode.getCategoryPath() + "' - adding to root instead");
m_root.addChild(metaNode);
} else {
// everything is fine, add the node to its parent
// category
parentContainer.addChild(metaNode);
}
} catch (Throwable t) {
String message = "MetaNode " + mnConfig.getAttribute("id") + "' from plugin '" + mnConfig.getNamespaceIdentifier() + "' could not be created: " + t.getMessage();
Bundle bundle = Platform.getBundle(mnConfig.getNamespaceIdentifier());
if ((bundle == null) || (bundle.getState() != Bundle.ACTIVE)) {
// if the plugin is null, the plugin could not
// be activated maybe due to a not
// activateable plugin
// (plugin class cannot be found)
message = message + " The corresponding plugin " + "bundle could not be activated!";
}
LOGGER.error(message, t);
}
}
}
}
use of org.knime.workbench.repository.model.IContainerObject in project knime-core by knime.
the class RepositoryManager method readNodes.
/**
* @param isInExpertMode
*/
private void readNodes(final IProgressMonitor monitor) {
//
// Second, process the contributed nodes
//
IContainerObject uncategorized = m_root.findContainer("/uncategorized");
if (uncategorized == null) {
// this should never happen, but who knows...
uncategorized = m_root;
}
Iterator<IConfigurationElement> it = Stream.of(RepositoryManager.getExtensions(ID_NODE)).flatMap(ext -> Stream.of(ext.getConfigurationElements())).filter(elem -> !"true".equalsIgnoreCase(elem.getAttribute("deprecated"))).iterator();
while (it.hasNext()) {
IConfigurationElement elem = it.next();
if (monitor.isCanceled()) {
return;
}
try {
NodeTemplate node = RepositoryFactory.createNode(elem);
LOGGER.debug("Found node extension '" + node.getID() + "': " + node.getName());
for (Listener l : m_loadListeners) {
l.newNode(m_root, node);
}
m_nodesById.put(node.getID(), node);
String nodeName = node.getID();
nodeName = nodeName.substring(nodeName.lastIndexOf('.') + 1);
// Ask the root to lookup the category-container located at
// the given path
IContainerObject parentContainer = m_root.findContainer(node.getCategoryPath());
// the node to the repository root.
if (parentContainer == null) {
LOGGER.coding("Unknown category for node " + node.getID() + " (plugin: " + node.getContributingPlugin() + "): " + node.getCategoryPath() + ". Node will be added to 'Uncategorized' instead");
uncategorized.addChild(node);
} else {
String nodePluginId = elem.getNamespaceIdentifier();
String categoryPluginId = parentContainer.getContributingPlugin();
if (categoryPluginId == null) {
categoryPluginId = "";
}
int secondDotIndex = nodePluginId.indexOf('.', nodePluginId.indexOf('.') + 1);
if (secondDotIndex == -1) {
secondDotIndex = 0;
}
if (!parentContainer.isLocked() || nodePluginId.equals(categoryPluginId) || nodePluginId.startsWith("org.knime.") || nodePluginId.startsWith("com.knime.") || nodePluginId.regionMatches(0, categoryPluginId, 0, secondDotIndex)) {
// container not locked, or node and category from same plug-in
// or the vendor is the same (comparing the first two parts of the plug-in ids)
parentContainer.addChild(node);
} else {
LOGGER.coding("Locked category for node " + node.getID() + ": " + node.getCategoryPath() + ". Node will be added to 'Uncategorized' instead");
uncategorized.addChild(node);
}
}
} catch (Throwable t) {
String message = "Node " + elem.getAttribute("factory-class") + "' from plugin '" + elem.getNamespaceIdentifier() + "' could not be created: " + t.getMessage();
Bundle bundle = Platform.getBundle(elem.getNamespaceIdentifier());
if ((bundle == null) || (bundle.getState() != Bundle.ACTIVE)) {
// if the plugin is null, the plugin could not
// be activated maybe due to a not
// activateable plugin (plugin class cannot be found)
message += " The corresponding plugin " + "bundle could not be activated!";
}
LOGGER.error(message, t);
}
}
// for configuration elements
}
use of org.knime.workbench.repository.model.IContainerObject in project knime-core by knime.
the class RepositoryManager method readNodeSets.
/**
* @param isInExpertMode
*/
private void readNodeSets(final IProgressMonitor monitor) {
//
// Process the contributed node sets
//
Iterator<IConfigurationElement> it = Stream.of(RepositoryManager.getExtensions(ID_NODE_SET)).flatMap(ext -> Stream.of(ext.getConfigurationElements())).filter(elem -> !"true".equalsIgnoreCase(elem.getAttribute("deprecated"))).iterator();
while (it.hasNext()) {
IConfigurationElement elem = it.next();
try {
Collection<DynamicNodeTemplate> dynamicNodeTemplates = RepositoryFactory.createNodeSet(m_root, elem);
for (DynamicNodeTemplate node : dynamicNodeTemplates) {
if (monitor.isCanceled()) {
return;
}
for (Listener l : m_loadListeners) {
l.newNode(m_root, node);
}
m_nodesById.put(node.getID(), node);
String nodeName = node.getID();
nodeName = nodeName.substring(nodeName.lastIndexOf('.') + 1);
// Ask the root to lookup the category-container located
// at
// the given path
IContainerObject parentContainer = m_root.findContainer(node.getCategoryPath());
// the node to the repository root.
if (parentContainer == null) {
LOGGER.warn("Invalid category-path for node " + "contribution: '" + node.getCategoryPath() + "' - adding to root instead");
m_root.addChild(node);
} else {
// everything is fine, add the node to its parent
// category
parentContainer.addChild(node);
}
}
} catch (Throwable t) {
String message = "Node " + elem.getAttribute("factory-class") + "' from plugin '" + elem.getNamespaceIdentifier() + "' could not be created.";
Bundle bundle = Platform.getBundle(elem.getNamespaceIdentifier());
if ((bundle == null) || (bundle.getState() != Bundle.ACTIVE)) {
// if the plugin is null, the plugin could not
// be activated maybe due to a not
// activateable plugin (plugin class cannot be found)
message += " The corresponding plugin " + "bundle could not be activated!";
}
LOGGER.error(message, t);
}
}
}
use of org.knime.workbench.repository.model.IContainerObject in project knime-core by knime.
the class RepositoryStyledLabelProvider method getCategoryString.
private static String getCategoryString(final IRepositoryObject obj) {
StringBuilder builder = new StringBuilder();
IContainerObject curr = obj.getParent();
while (curr != null && curr.getParent() != null) {
builder.insert(0, "/" + curr.getName());
curr = curr.getParent();
}
return builder.toString();
}
use of org.knime.workbench.repository.model.IContainerObject in project knime-core by knime.
the class NodeDocuGenerator method getCategoryIdentifier.
/*
* Helper to compose the category names/identifier of the super-categories
* and the current one
*/
private static String getCategoryIdentifier(final Category cat) {
IContainerObject parent = cat.getParent();
String identifier = cat.getID();
while (!(parent instanceof Root)) {
identifier = parent.getID() + "." + identifier;
parent = parent.getParent();
}
return identifier;
}
Aggregations