Package org.pentaho.di.core.util
Class AsyncDatabaseAction
java.lang.Object
org.pentaho.di.core.util.AsyncDatabaseAction
Static methods for asynchronous execution of actions on a , which defines what
action to take on the Database.
The .executeSql / .getTables / .getSchemas / etc. methods are convenience
methods which leverage .executeAction() to retrieve specific info.
These methods can be used wherever Database info needs to be retrieved
without blocking the calling thread, for example with setting UI elements:
AsyncDatabaseAction.getTables( dbMeta, schemaName,
tables -> display.asyncExec(() -> combo.setItems(tables))
Note that the action of setting the items still needs to happen on
the SWT display thread, hence the need for display.asyncExec(). So with
the above two lines,
AsyncDatabaseAction thread retrieves the table array from the database,
When retrieved, `combo.setItems(tables)` is put on the display thread's queue.
Database,
with a set timeout for the async thread.
The .executeAction() method takes a Consumer-
Method Summary
Modifier and TypeMethodDescriptionstatic voidexecuteAction(org.pentaho.di.core.database.DatabaseMeta databaseMeta, Consumer<org.pentaho.di.core.database.Database> dbAction) static voidexecuteSql(org.pentaho.di.core.database.DatabaseMeta databaseMeta, String sql, Consumer<List<Object[]>> rowConsumer) static voidgetFields(org.pentaho.di.core.database.DatabaseMeta databaseMeta, String tablename, Consumer<org.pentaho.di.core.row.RowMetaInterface> fieldsConsumer) static voidgetSchemas(org.pentaho.di.core.database.DatabaseMeta databaseMeta, Consumer<String[]> schemasConsumer) static voidgetTables(org.pentaho.di.core.database.DatabaseMeta databaseMeta, String schema, Consumer<String[]> tablesConsumer)
-
Method Details
-
executeAction
public static void executeAction(org.pentaho.di.core.database.DatabaseMeta databaseMeta, Consumer<org.pentaho.di.core.database.Database> dbAction) -
executeSql
-
getTables
-
getSchemas
-
getFields
-