Class NodeRecommendationManager

java.lang.Object
org.knime.core.ui.workflowcoach.NodeRecommendationManager

public final class NodeRecommendationManager extends Object
Class that manages the node recommendations. It represents the node recommendations in memory for quick retrieval and provides them accordingly. The loadRecommendations()-method updates the statistics, the getNodeRecommendationFor(NativeNodeContainerUI...) gives the actual recommendations.
Author:
Martin Horn, University of Konstanz, Kai Franze, KNIME GmbH
  • Method Details

    • getInstance

      public static NodeRecommendationManager getInstance()
      Returns the singleton instance for this class.
      Returns:
      a singleton instance
    • initialize

      public boolean initialize(Function<String,org.knime.core.node.NodeFactory.NodeType> getNodeType)
      Initializes the node recommendation manager. I.e. loads the recommendations (if that haven't been loaded, yet) using the 'getNodeType' callback to check for node-presence and determine the node type.
      Parameters:
      getNodeType - gets the node type for the given node-factory-id; will return null if there is no node for the id
      Returns:
      true if loadRecommendations() recommendations were loaded, false otherwise
    • addUpdateListener

      public void addUpdateListener(NodeRecommendationManager.IUpdateListener listener)
      Adds a listener that is notified when the recommendations are updated (via loadRecommendations().
      Parameters:
      listener - a listener
    • removeUpdateListener

      public void removeUpdateListener(NodeRecommendationManager.IUpdateListener listener)
      Removes an update listener.
      Parameters:
      listener - a listener
    • loadRecommendations

      public void loadRecommendations() throws IOException
      (Re-)Loads the recommendations for the node recommendation engine from the currently active node triple providers.
      Throws:
      IOException - if something went wrong while loading the statistics (e.g. a corrupt file)
      See Also:
    • getNodeRecommendationFor

      public List<NodeRecommendationManager.NodeRecommendation>[] getNodeRecommendationFor(NativeNodeContainerUI... nnc)
      Determines lists of node recommendation based on the given nodes (e.g. that are selected in the workflow editor). The NodeRecommendationManager.NodeRecommendations are determined based on the statistics of NodeTriples (i.e. predecessor, node, successor, count -> (p,n,s,c)) that are provided by NodeTripleProviders. Given the list's of node triples, {(predecessor, node, successor, count/frequency)} = {(p,n,s,c)} and given a selected node 'sn', the recommendations are determined for each node-triple-list as follows: (1) find all node triples (p,n,s,c) where n==sn and add them to the result list; in that case the predecessor is essentially ignored and recommendation are determined only based on n. The recommendation is the successor 's' given by each found triple. Since there will be multiple triples for the same 'n' and therewith successor duplicates (i.e. recommendations), those will be joined by taking the mean of the respective frequencies 'c' (2) determine all current predecessors ('sp') of the selected node 'sn' and find all node triples that match the given predecessor-node pairs ('sp','sn') (i.e. 'sp'='p' and 'sn'='n'). The recommended nodes are the successor nodes 's' given by the found triples. Those are added to the same list as the recommendations of (1). (3) Post-processing: duplicate recommendations are resolved by removing the recommendations with a smaller counts/frequencies If the array of given nodes is empty, all potential source nodes are recommended, i.e. all nodes 'n' in the node triples list that don't have a predecessor 'p'.
      Parameters:
      nnc - if it's an empty array, source nodes only will be recommended, if more than one node is given, the node recommendations for different nodes will end up in the same list
      Returns:
      an array of lists of node recommendations, i.e. a list of node recommendations for each used node NodeTripleProvider. It will return null if something went wrong with loading the node statistics!
    • getNumLoadedProviders

      public static int getNumLoadedProviders()
      Returns the number of registered and enabled NodeTripleProviders.
      Returns:
      the number of loaded providers
    • isEnabled

      public static boolean isEnabled()
      Checks whether node recommendations can be considered enabled or not.
      Returns:
      True if there are cached recommendations from at least one triple provider loaded, false otherwise.
    • getNodeTripleProviderFactories

      public static List<NodeTripleProviderFactory> getNodeTripleProviderFactories()
      Returns all available NodeTripleProviderFactorys. Node triple provider factories can be added via the respective extension point.
      Returns:
      a list of available node triple provider factories
    • getNodeTripleProviders

      public static List<NodeTripleProvider> getNodeTripleProviders()
      Returns all available NodeTripleProviders. Node triple providers are created from their respective NodeTripleProviderFactory that can be added via the respective extension point. Note that a provider must be enabled to be used in the workflow coach view.
      Returns:
      a list of all available node triple providers
    • joinRecommendationsWithoutDuplications

      public static List<NodeRecommendationManager.NodeRecommendation[]> joinRecommendationsWithoutDuplications(List<NodeRecommendationManager.NodeRecommendation>[] recommendations)
      Joins the recommendations from multiple sources and removes duplications
      Parameters:
      recommendations - The original recommendations
      Returns:
      The joined list without recommendations