Search in sources :

Example 1 with DefaultWebTemplate

use of org.knime.core.node.web.DefaultWebTemplate in project knime-core by knime.

the class WebResourceController method getWebTemplateFromJSObjectID.

/**
 * @param jsObjectID The JavaScript object ID used for locating the extension point.
 * @return A template object, being used to assamble views.
 */
public static WebTemplate getWebTemplateFromJSObjectID(final String jsObjectID) {
    LinkedHashSet<WebResourceLocator> webResList = new LinkedHashSet<WebResourceLocator>();
    IConfigurationElement jsComponentExtension = getConfigurationFromID(ID_JS_COMP, ATTR_JS_ID, jsObjectID);
    if (jsComponentExtension == null) {
        return getEmptyWebTemplate();
    }
    String bundleID = jsComponentExtension.getAttribute(ID_IMPL_BUNDLE);
    IConfigurationElement implementationExtension = getConfigurationFromID(ID_WEB_RES, ATTR_RES_BUNDLE_ID, bundleID);
    if (implementationExtension == null) {
        return getEmptyWebTemplate();
    }
    Set<WebResourceLocator> implementationRes = getResourcesFromExtension(implementationExtension);
    webResList.addAll(DEFAULT_RES);
    for (IConfigurationElement dependencyConf : jsComponentExtension.getChildren(ID_DEPENDENCY)) {
        String dependencyID = dependencyConf.getAttribute(ATTR_RES_BUNDLE_ID);
        IConfigurationElement dependencyExtension = getConfigurationFromID(ID_WEB_RES, ATTR_RES_BUNDLE_ID, dependencyID);
        if (dependencyExtension == null) {
            LOGGER.error("Web ressource dependency could not be found: " + dependencyID + ". This is most likely an implementation error.");
            continue;
        }
        Set<WebResourceLocator> dependencyRes = getResourcesFromExtension(dependencyExtension);
        webResList.addAll(dependencyRes);
    }
    webResList.addAll(implementationRes);
    String namespace = jsComponentExtension.getAttribute(ATTR_NAMESPACE);
    String initMethodName = jsComponentExtension.getAttribute(ATTR_INIT_METHOD_NAME);
    String validateMethodName = jsComponentExtension.getAttribute(ATTR_VALIDATE_METHOD_NAME);
    String valueMethodName = jsComponentExtension.getAttribute(ATTR_GETCOMPONENTVALUE_METHOD_NAME);
    String setValidationErrorMethodName = jsComponentExtension.getAttribute(ATTR_SETVALIDATIONERROR_METHOD_NAME);
    return new DefaultWebTemplate(webResList.toArray(new WebResourceLocator[0]), namespace, initMethodName, validateMethodName, valueMethodName, setValidationErrorMethodName);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) WebResourceLocator(org.knime.core.node.web.WebResourceLocator) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) DefaultWebTemplate(org.knime.core.node.web.DefaultWebTemplate)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 DefaultWebTemplate (org.knime.core.node.web.DefaultWebTemplate)1 WebResourceLocator (org.knime.core.node.web.WebResourceLocator)1