Search in sources :

Example 6 with PartitionDatabaseMeta

use of org.pentaho.di.core.database.PartitionDatabaseMeta in project pentaho-kettle by pentaho.

the class DatabaseDialogHarness method setMessage.

private static String setMessage(DatabaseMeta database) {
    String message = "";
    if (database != null) {
        String carriageReturn = System.getProperty("line.separator");
        try {
            message = "Name: ".concat(database.getName()).concat(carriageReturn).concat("Database Name: ").concat(database.getDatabaseName()).concat(carriageReturn).concat("Host Name: ").concat(database.getHostname()).concat(carriageReturn).concat("Port Number: ").concat(database.getDatabasePortNumberString()).concat(carriageReturn).concat("User Name: ").concat(database.getUsername()).concat(carriageReturn).concat("Password: ").concat(database.getPassword()).concat(carriageReturn).concat("Driver Class: ").concat(database.getDriverClass()).concat(carriageReturn).concat("URL: ").concat(database.getURL()).concat(carriageReturn);
            Iterator<String> keys = database.getExtraOptions().keySet().iterator();
            message = message.concat(carriageReturn).concat("Option Parameters:").concat(carriageReturn);
            while (keys.hasNext()) {
                String parameter = keys.next();
                String value = database.getExtraOptions().get(parameter);
                message = message.concat(carriageReturn).concat(parameter).concat(": ").concat(value).concat(carriageReturn);
            }
            message = message.concat(carriageReturn).concat("SQL: ").concat(database.getConnectSQL() != null ? database.getConnectSQL() : "").concat(carriageReturn).concat("Quote Identifiers: ").concat(Boolean.toString(database.isQuoteAllFields())).concat(carriageReturn).concat("Upper Case Identifiers: ").concat(Boolean.toString(database.isForcingIdentifiersToUpperCase())).concat(carriageReturn).concat("Lower Case Identifiers: ").concat(Boolean.toString(database.isForcingIdentifiersToLowerCase())).concat(carriageReturn);
            message = message.concat(carriageReturn).concat("Is Partitioned: ").concat(Boolean.toString(database.isPartitioned())).concat(carriageReturn);
            if (database.isPartitioned()) {
                PartitionDatabaseMeta[] partitions = database.getPartitioningInformation();
                if (partitions != null) {
                    for (int i = 0; i < partitions.length; i++) {
                        PartitionDatabaseMeta pdm = partitions[i];
                        message = message.concat(carriageReturn).concat(Integer.toString(i)).concat(". ID: ").concat(pdm.getPartitionId()).concat(", Host: ").concat(pdm.getHostname()).concat(", Db: ").concat(pdm.getDatabaseName()).concat(", Port: ").concat(pdm.getPort()).concat(", User: ").concat(pdm.getUsername()).concat(", Pass: ").concat(pdm.getPassword()).concat(carriageReturn);
                    }
                }
            }
            Iterator<Object> poolKeys = database.getConnectionPoolingProperties().keySet().iterator();
            message = message.concat(carriageReturn).concat("Pooling Parameters:").concat(carriageReturn);
            while (poolKeys.hasNext()) {
                String parameter = (String) poolKeys.next();
                String value = database.getConnectionPoolingProperties().getProperty(parameter);
                message = message.concat(carriageReturn).concat(parameter).concat(": ").concat(value).concat(carriageReturn);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return message;
}
Also used : PartitionDatabaseMeta(org.pentaho.di.core.database.PartitionDatabaseMeta) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException)

Aggregations

PartitionDatabaseMeta (org.pentaho.di.core.database.PartitionDatabaseMeta)6 ArrayList (java.util.ArrayList)2 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2 Properties (java.util.Properties)1 MessageBox (org.eclipse.swt.widgets.MessageBox)1 Database (org.pentaho.di.core.database.Database)1 DatabaseInterface (org.pentaho.di.core.database.DatabaseInterface)1 OracleDatabaseMeta (org.pentaho.di.core.database.OracleDatabaseMeta)1 SqlScriptStatement (org.pentaho.di.core.database.SqlScriptStatement)1 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)1 KettleException (org.pentaho.di.core.exception.KettleException)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 EnterSelectionDialog (org.pentaho.di.ui.core.dialog.EnterSelectionDialog)1 EnterTextDialog (org.pentaho.di.ui.core.dialog.EnterTextDialog)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1 PreviewRowsDialog (org.pentaho.di.ui.core.dialog.PreviewRowsDialog)1 XulException (org.pentaho.ui.xul.XulException)1 XulTreeRow (org.pentaho.ui.xul.containers.XulTreeRow)1