Package org.pentaho.di.connections
Class ConnectionManager
java.lang.Object
org.pentaho.di.connections.ConnectionManager
A class from managing named connections in PDI
Created by bmorrise on 2/3/19.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
Represents the key/value of the name provider type -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConnectionProvider
(String key, ConnectionProvider<? extends ConnectionDetails> connectionProvider) Add a connection provider with a specific keyvoid
addLookupFilter
(LookupFilter lookupFilter) Add a key lookup filtervoid
clear
(org.pentaho.metastore.api.IMetaStore metaStore) Delete all named connections stored in a meta storevoid
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 storecreateConnectionDetails
(String scheme) Get a new connection details object by scheme/keyvoid
Delete a connection by name from the defaultvoid
Delete a connection by name from a specified meta storeboolean
Find out if a named connection existsgetBowl()
Gets the bowl of the connection manager.getConnectionDetails
(String name) Get the named connection from a specified meta storegetConnectionDetails
(String key, String name) Get the named connection from the default meta storegetConnectionDetails
(org.pentaho.metastore.api.IMetaStore metaStore, String name) Get the named connection from a specified meta storegetConnectionDetails
(org.pentaho.metastore.api.IMetaStore metaStore, String key, String name) Get the named connection from a specified meta storeList<? extends ConnectionDetails>
getConnectionDetailsByScheme
(String scheme) Get all named connections by key/schemeConnectionProvider<? extends ConnectionDetails>
Get a connection provider from the key<T extends ConnectionDetails>
TgetDetails
(String name) Gets a connection given its name, casting it to the type parameter.<T extends ConnectionDetails>
TgetExistingDetails
(String name) Gets the details of a connection, given its name, casting it to the type parameter, and throwing if it does not exist.static ConnectionManager
This getter should not generally be used because it is limited to the global scope.static ConnectionManager
getInstance
(Supplier<org.pentaho.metastore.api.IMetaStore> metaStoreSupplier, Bowl bowl) Construct a new instance of a ConnectionManager associated with a given meta-store and bowl.getItems()
Get a list of value/label pairs of named connection types<T extends ConnectionProvider<?>>
List<ConnectionManager.Type>getItemsByType
(Class<T> providerClass) Get a list of value/label pairs of named connection types, optionally filtered to be of a given provider class.protected String
getLookupKey
(String value) Get the lookup key for a providergetNames()
Get the names of named connections by provider from the default meta storegetNames
(boolean clearCache) Get the names of named connections by provider from the default meta storegetNames
(org.pentaho.metastore.api.IMetaStore metaStore) Get the names of named connections by provider from specified meta storegetNamesByKey
(String key) Get the names of named connections by connection type key<T extends ConnectionProvider<?>>
List<String>getNamesByType
(Class<T> providerClass) Get the names of named connection by connection provider typeList<ConnectionProvider<? extends ConnectionDetails>>
Get a list of connection providersList<ConnectionProvider<? extends ConnectionDetails>>
getProvidersByType
(Class<? extends ConnectionProvider> providerClass) Get a list of connection providers by typevoid
reset()
Resets the in-memory storage.<T extends ConnectionDetails>
booleansave
(org.pentaho.metastore.api.IMetaStore metaStore, T connectionDetails) Save a named connection to a specific meta store<T extends ConnectionDetails>
booleansave
(org.pentaho.metastore.api.IMetaStore metaStore, T connectionDetails, boolean prepare) Save a named connection to a specific meta store<T extends ConnectionDetails>
booleansave
(T connectionDetails) Save a named connection to the default meta storevoid
setMetastoreSupplier
(Supplier<org.pentaho.metastore.api.IMetaStore> metaStoreSupplier) Set the default meta store supplier for the Connection Manager<T extends ConnectionDetails>
booleantest
(T details) Tests if a connection is valid, given its details, with default testing options.
-
Method Details
-
reset
public void reset()Resets the in-memory storage. The next call that needs it will refresh the connection information from the metastore. -
getInstance
This getter should not generally be used because it is limited to the global scope. It would be better to have almost all callers use Bowl.getConnectionManager().This instance may still be used to register ConnectionProviders and Lookup Filters.
- Returns:
- ConnectionManager
-
getInstance
@NonNull public static ConnectionManager getInstance(@NonNull Supplier<org.pentaho.metastore.api.IMetaStore> metaStoreSupplier, @NonNull Bowl bowl) Construct a new instance of a ConnectionManager associated with a given meta-store and bowl.Instances returned by this will not share in-memory state with any other instances. If you need the ConnectionManager for a Bowl, use Bowl.getConnectionManager() instead.
- Parameters:
metaStoreSupplier
- The meta-store supplier.bowl
- The bowl.- Returns:
- ConnectionManager
-
setMetastoreSupplier
public void setMetastoreSupplier(@NonNull Supplier<org.pentaho.metastore.api.IMetaStore> metaStoreSupplier) Set the default meta store supplier for the Connection Manager- Parameters:
metaStoreSupplier
- A meta store supplier
-
getBowl
Gets the bowl of the connection manager.- Returns:
- A bowl.
-
addLookupFilter
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 providerconnectionProvider
- The connection provider
-
getConnectionProvider
Get a connection provider from the key- Parameters:
key
- The connection provider key- Returns:
- The connection provider
-
getLookupKey
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 storeconnectionDetails
- 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 storeconnectionDetails
- The named connection details to saveprepare
- Prepare the named connection- Returns:
- A boolean signifying the success of the save operation
-
save
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
Tests if a connection is valid, given its details, with default testing options.If the given connection details is a VFS connection, this method delegates to
VFSConnectionManagerHelper.test(ConnectionManager, VFSConnectionDetails, VFSConnectionTestOptions)
. Otherwise, this method delegates directly toConnectionProvider.test(ConnectionDetails)
.- Parameters:
details
- The details of the connection to test.- Returns:
true
if the connection is valid;false
otherwise.- Throws:
KettleException
-
delete
Delete a connection by name from the default- Parameters:
name
- The name of the named connection
-
delete
Delete a connection by name from a specified meta store- Parameters:
metaStore
- A meta storename
- The name of the named connection
-
getProviders
Get a list of connection providers- Returns:
- A list of connection providers
-
getProvidersByType
public List<ConnectionProvider<? extends ConnectionDetails>> getProvidersByType(Class<? extends ConnectionProvider> providerClass) Get a list of connection providers by type- Parameters:
providerClass
- The type of provider to filter by- Returns:
- A list of connection providers
-
getNames
Get the names of named connections by provider from the default meta store- Parameters:
clearCache
- - Whether or not to clear cache (unused)- Returns:
- A list of named connection names
-
getNames
Get the names of named connections by provider from the default meta store- Returns:
- A list of named connection names
-
getNames
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
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
Get the names of named connection by connection provider type- Parameters:
providerClass
- The connection provider type- Returns:
- A list of named connection names
-
getNamesByKey
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 storekey
- The provider keyname
- The connection name- Returns:
- The named connection details
-
getConnectionDetails
Get the named connection from the default meta store- Parameters:
key
- The provider keyname
- The connection name- Returns:
- The named connection details
-
getConnectionDetails
Get the named connection from a specified meta store- Parameters:
name
- The connection name- Returns:
- The named connection details
-
getDetails
Gets a connection given its name, casting it to the type parameter.- Parameters:
name
- The connection name- Returns:
- The named connection details
-
getExistingDetails
@NonNull public <T extends ConnectionDetails> T getExistingDetails(@Nullable String name) throws KettleException Gets the details of a connection, given its name, casting it to the type parameter, and throwing if it does not exist.- Parameters:
name
- The connection name- Returns:
- The named connection details
- Throws:
KettleException
- When a connection with the given name is not defined.
-
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 storename
- The connection name- Returns:
- The named connection details
-
createConnectionDetails
Get a new connection details object by scheme/key- Parameters:
scheme
- The scheme/key- Returns:
- A empty named connection
-
getConnectionDetailsByScheme
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 fromdestinationMetaStore
- The meta store to copy to
-
getItems
Get a list of value/label pairs of named connection types- Returns:
- A list of value/label pairs of named connection types
-
getItemsByType
public <T extends ConnectionProvider<?>> List<ConnectionManager.Type> getItemsByType(@Nullable Class<T> providerClass) Get a list of value/label pairs of named connection types, optionally filtered to be of a given provider class.- Parameters:
providerClass
- The provider class; whennull
, all providers are returned.- Returns:
- A list of value/label pairs of named connection types.
-