Class ConnectionManager


  • public class ConnectionManager
    extends Object
    A class from managing named connections in PDI

    Created by bmorrise on 2/3/19.

    • Constructor Detail

      • ConnectionManager

        public ConnectionManager()
    • Method Detail

      • setMetastoreSupplier

        public void setMetastoreSupplier​(Supplier<org.pentaho.metastore.api.IMetaStore> metaStoreSupplier)
        Set the default meta store supplier for the Connection Manager
        Parameters:
        metaStoreSupplier - A meta store supplier
      • addLookupFilter

        public void addLookupFilter​(LookupFilter lookupFilter)
        Add a key lookup filter
        Parameters:
        lookupFilter - The lookup filter to add
      • addConnectionProvider

        public void addConnectionProvider​(String key,
                                          ConnectionProvider<? extends ConnectionDetails> connectionProvider)
        Add a connection provider with a specific key
        Parameters:
        key - The key used to query the connection provider
        connectionProvider - The connection provider
      • getConnectionProvider

        public ConnectionProvider<? extends ConnectionDetails> getConnectionProvider​(String key)
        Get a connection provider from the key
        Parameters:
        key - The connection provider key
        Returns:
        The connection provider
      • getLookupKey

        protected String getLookupKey​(String value)
        Get the lookup key for a provider
        Parameters:
        value - The key to lookup
        Returns:
        the key returned from the lookup
      • save

        public <T extends ConnectionDetails> boolean save​(org.pentaho.metastore.api.IMetaStore metaStore,
                                                          T connectionDetails)
        Save a named connection to a specific meta store
        Parameters:
        metaStore - A meta store
        connectionDetails - The named connection details to save
        Returns:
        A boolean signifying the success of the save operation
      • save

        public <T extends ConnectionDetails> boolean save​(org.pentaho.metastore.api.IMetaStore metaStore,
                                                          T connectionDetails,
                                                          boolean prepare)
        Save a named connection to a specific meta store
        Parameters:
        metaStore - A meta store
        connectionDetails - The named connection details to save
        prepare - Prepare the named connection
        Returns:
        A boolean signifying the success of the save operation
      • save

        public <T extends ConnectionDetails> boolean save​(T connectionDetails)
        Save a named connection to the default meta store
        Parameters:
        connectionDetails - The named connection details to save
        Returns:
        A boolean signifying the success of the save operation
      • test

        public <T extends ConnectionDetails> boolean test​(T connectionDetails)
                                                   throws KettleException
        Run a test operation on the named connection
        Parameters:
        connectionDetails - The named connection details to test
        Returns:
        A boolean signifying the success of the test operation
        Throws:
        KettleException
      • delete

        public void delete​(String name)
        Delete a connection by name from the default
        Parameters:
        name - The name of the named connection
      • delete

        public void delete​(org.pentaho.metastore.api.IMetaStore metaStore,
                           String name)
        Delete a connection by name from a specified meta store
        Parameters:
        metaStore - A meta store
        name - The name of the named connection
      • getNames

        public List<String> getNames​(org.pentaho.metastore.api.IMetaStore metaStore,
                                     boolean clearCache)
        Get the names of named connections by provider from specified meta store
        Parameters:
        metaStore - A meta store
        clearCache - Whether or not to clear cache
        Returns:
        A list of named connection names
      • getNames

        public List<String> getNames​(boolean clearCache)
        Get the names of named connections by provider from the default meta store
        Parameters:
        clearCache - - Whether or not to clear cache
        Returns:
        A list of named connection names
      • getNames

        public List<String> getNames()
        Get the names of named connections by provider from the default meta store
        Returns:
        A list of named connection names
      • getNames

        public List<String> getNames​(org.pentaho.metastore.api.IMetaStore metaStore)
        Get the names of named connections by provider from specified meta store
        Parameters:
        metaStore - A meta store
        Returns:
        A list of named connection names
      • exists

        public boolean exists​(String name)
        Find out if a named connection exists
        Parameters:
        name - The named connection name to check
        Returns:
        A boolean whether or not the connection exists
      • getNamesByType

        public List<String> getNamesByType​(Class<? extends ConnectionProvider> clazz)
        Get the names of named connection by connection provider type
        Parameters:
        clazz - The connection provider type
        Returns:
        A list of named connection names
      • getNamesByKey

        public List<String> getNamesByKey​(String key)
        Get the names of named connections by connection type key
        Parameters:
        key - The connection type key
        Returns:
        A list of named connection names
      • getConnectionDetails

        public ConnectionDetails getConnectionDetails​(org.pentaho.metastore.api.IMetaStore metaStore,
                                                      String key,
                                                      String name)
        Get the named connection from a specified meta store
        Parameters:
        metaStore - A meta store
        key - The provider key
        name - The connection name
        Returns:
        The named connection details
      • getConnectionDetails

        public ConnectionDetails getConnectionDetails​(String key,
                                                      String name)
        Get the named connection from the default meta store
        Parameters:
        key - The provider key
        name - The connection name
        Returns:
        The named connection details
      • getConnectionDetails

        public ConnectionDetails getConnectionDetails​(String name)
        Get the named connection from a specified meta store
        Parameters:
        name - The connection name
        Returns:
        The named connection details
      • getConnectionDetails

        public ConnectionDetails getConnectionDetails​(org.pentaho.metastore.api.IMetaStore metaStore,
                                                      String name)
        Get the named connection from a specified meta store
        Parameters:
        metaStore - A meta store
        name - The connection name
        Returns:
        The named connection details
      • createConnectionDetails

        public ConnectionDetails createConnectionDetails​(String scheme)
        Get a new connection details object by scheme/key
        Parameters:
        scheme - The scheme/key
        Returns:
        A empty named connection
      • getConnectionDetailsByScheme

        public List<? extends ConnectionDetails> getConnectionDetailsByScheme​(String scheme)
        Get all named connections by key/scheme
        Parameters:
        scheme - The scheme/key
        Returns:
        A list of named connections
      • clear

        public void clear​(org.pentaho.metastore.api.IMetaStore metaStore)
        Delete all named connections stored in a meta store
        Parameters:
        metaStore - A meta store
      • copy

        public void copy​(org.pentaho.metastore.api.IMetaStore sourceMetaStore,
                         org.pentaho.metastore.api.IMetaStore destinationMetaStore)
        Copy the named connections stored in one meta store into another meta store
        Parameters:
        sourceMetaStore - The meta store to copy from
        destinationMetaStore - The meta store to copy to
      • getItems

        public List<ConnectionManager.Type> getItems()
        Get a list of value/label pairs of named connection types
        Returns:
        A list of value/label pairs of named connection types