Package org.pentaho.di.connections
Class ConnectionManager
- java.lang.Object
-
- org.pentaho.di.connections.ConnectionManager
-
public class ConnectionManager extends Object
A class from managing named connections in PDICreated by bmorrise on 2/3/19.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConnectionManager.TypeRepresents the key/value of the name provider type
-
Constructor Summary
Constructors Constructor Description ConnectionManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConnectionProvider(String key, ConnectionProvider<? extends ConnectionDetails> connectionProvider)Add a connection provider with a specific keyvoidaddLookupFilter(LookupFilter lookupFilter)Add a key lookup filtervoidclear(org.pentaho.metastore.api.IMetaStore metaStore)Delete all named connections stored in a meta storevoidcopy(org.pentaho.metastore.api.IMetaStore sourceMetaStore, org.pentaho.metastore.api.IMetaStore destinationMetaStore)Copy the named connections stored in one meta store into another meta storeConnectionDetailscreateConnectionDetails(String scheme)Get a new connection details object by scheme/keyvoiddelete(String name)Delete a connection by name from the defaultvoiddelete(org.pentaho.metastore.api.IMetaStore metaStore, String name)Delete a connection by name from a specified meta storebooleanexists(String name)Find out if a named connection existsConnectionDetailsgetConnectionDetails(String name)Get the named connection from a specified meta storeConnectionDetailsgetConnectionDetails(String key, String name)Get the named connection from the default meta storeConnectionDetailsgetConnectionDetails(org.pentaho.metastore.api.IMetaStore metaStore, String name)Get the named connection from a specified meta storeConnectionDetailsgetConnectionDetails(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>getConnectionProvider(String key)Get a connection provider from the keystatic ConnectionManagergetInstance()List<ConnectionManager.Type>getItems()Get a list of value/label pairs of named connection typesprotected StringgetLookupKey(String value)Get the lookup key for a providerList<String>getNames()Get the names of named connections by provider from the default meta storeList<String>getNames(boolean clearCache)Get the names of named connections by provider from the default meta storeList<String>getNames(org.pentaho.metastore.api.IMetaStore metaStore)Get the names of named connections by provider from specified meta storeList<String>getNames(org.pentaho.metastore.api.IMetaStore metaStore, boolean clearCache)Get the names of named connections by provider from specified meta storeList<String>getNamesByKey(String key)Get the names of named connections by connection type keyList<String>getNamesByType(Class<? extends ConnectionProvider> clazz)Get the names of named connection by connection provider typeList<ConnectionProvider<? extends ConnectionDetails>>getProviders()Get a list of connection providersList<ConnectionProvider<? extends ConnectionDetails>>getProvidersByType(Class<? extends ConnectionProvider> clazz)Get a list of connection providers by type<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 storevoidsetMetastoreSupplier(Supplier<org.pentaho.metastore.api.IMetaStore> metaStoreSupplier)Set the default meta store supplier for the Connection Manager<T extends ConnectionDetails>
booleantest(T connectionDetails)Run a test operation on the named connection
-
-
-
Method Detail
-
getInstance
public static ConnectionManager getInstance()
-
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 providerconnectionProvider- 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 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
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 storename- The name of the named connection
-
getProviders
public List<ConnectionProvider<? extends ConnectionDetails>> getProviders()
Get a list of connection providers- Returns:
- A list of connection providers
-
getProvidersByType
public List<ConnectionProvider<? extends ConnectionDetails>> getProvidersByType(Class<? extends ConnectionProvider> clazz)
Get a list of connection providers by type- Parameters:
clazz- The type of provider to filter by- Returns:
- A list of connection providers
-
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 storeclearCache- 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 storekey- The provider keyname- 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 keyname- 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 storename- 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 fromdestinationMetaStore- 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
-
-