Package org.knime.core.ui.workflowcoach
Class NodeRecommendationManager
java.lang.Object
org.knime.core.ui.workflowcoach.NodeRecommendationManager
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface for a listener that gets notified when the recommendations are updated (vialoadRecommendations().static classObject representing one node recommendation, including the node template itself and a frequency as a measure of a certainty for the given recommendation. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener that is notified when the recommendations are updated (vialoadRecommendations().static NodeRecommendationManagerReturns the singleton instance for this class.Determines lists of node recommendation based on the given nodes (e.g.static List<NodeTripleProviderFactory>Returns all availableNodeTripleProviderFactorys.static List<NodeTripleProvider>Returns all availableNodeTripleProviders.static intReturns the number of registered and enabledNodeTripleProviders.booleaninitialize(Function<String, org.knime.core.node.NodeFactory.NodeType> getNodeType) Initializes the node recommendation manager.static booleanChecks whether node recommendations can be considered enabled or not.joinRecommendationsWithoutDuplications(List<NodeRecommendationManager.NodeRecommendation>[] recommendations) Joins the recommendations from multiple sources and removes duplicationsvoid(Re-)Loads the recommendations for the node recommendation engine from the currently active node triple providers.voidRemoves an update listener.
-
Method Details
-
getInstance
Returns the singleton instance for this class.- Returns:
- a singleton instance
-
initialize
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 returnnullif there is no node for the id- Returns:
- true if
loadRecommendations()recommendations were loaded, false otherwise
-
addUpdateListener
Adds a listener that is notified when the recommendations are updated (vialoadRecommendations().- Parameters:
listener- a listener
-
removeUpdateListener
Removes an update listener.- Parameters:
listener- a listener
-
loadRecommendations
(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). TheNodeRecommendationManager.NodeRecommendations are determined based on the statistics ofNodeTriples (i.e. predecessor, node, successor, count -> (p,n,s,c)) that are provided byNodeTripleProviders. 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 returnnullif something went wrong with loading the node statistics!
-
getNumLoadedProviders
public static int getNumLoadedProviders()Returns the number of registered and enabledNodeTripleProviders.- 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
Returns all availableNodeTripleProviderFactorys. Node triple provider factories can be added via the respective extension point.- Returns:
- a list of available node triple provider factories
-
getNodeTripleProviders
Returns all availableNodeTripleProviders. Node triple providers are created from their respectiveNodeTripleProviderFactorythat 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
-