Search in sources :

Example 51 with ValueMetaNumber

use of org.pentaho.di.core.row.value.ValueMetaNumber in project pentaho-kettle by pentaho.

the class BaseStep method getLogFields.

/**
 * Gets the log fields.
 *
 * @param comm the comm
 * @return the log fields
 */
public static final RowMetaInterface getLogFields(String comm) {
    RowMetaInterface r = new RowMeta();
    ValueMetaInterface sname = new ValueMetaString(BaseMessages.getString(PKG, "BaseStep.ColumnName.Stepname"));
    sname.setLength(256);
    r.addValueMeta(sname);
    r.addValueMeta(new ValueMetaNumber(BaseMessages.getString(PKG, "BaseStep.ColumnName.Copy")));
    r.addValueMeta(new ValueMetaNumber(BaseMessages.getString(PKG, "BaseStep.ColumnName.LinesReaded")));
    r.addValueMeta(new ValueMetaNumber(BaseMessages.getString(PKG, "BaseStep.ColumnName.LinesWritten")));
    r.addValueMeta(new ValueMetaNumber(BaseMessages.getString(PKG, "BaseStep.ColumnName.LinesUpdated")));
    r.addValueMeta(new ValueMetaNumber(BaseMessages.getString(PKG, "BaseStep.ColumnName.LinesSkipped")));
    r.addValueMeta(new ValueMetaNumber(BaseMessages.getString(PKG, "BaseStep.ColumnName.Errors")));
    r.addValueMeta(new ValueMetaDate(BaseMessages.getString(PKG, "BaseStep.ColumnName.StartDate")));
    r.addValueMeta(new ValueMetaDate(BaseMessages.getString(PKG, "BaseStep.ColumnName.EndDate")));
    for (int i = 0; i < r.size(); i++) {
        r.getValueMeta(i).setOrigin(comm);
    }
    return r;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 52 with ValueMetaNumber

use of org.pentaho.di.core.row.value.ValueMetaNumber in project pentaho-kettle by pentaho.

the class Database method getParameterMetaData.

// Get the fields back from an SQL query
public RowMetaInterface getParameterMetaData(String sql, RowMetaInterface inform, Object[] data) {
    // The database couldn't handle it: try manually!
    int q = countParameters(sql);
    RowMetaInterface par = new RowMeta();
    if (inform != null && q == inform.size()) {
        for (int i = 0; i < q; i++) {
            ValueMetaInterface inf = inform.getValueMeta(i);
            ValueMetaInterface v = inf.clone();
            par.addValueMeta(v);
        }
    } else {
        for (int i = 0; i < q; i++) {
            ValueMetaInterface v = new ValueMetaNumber("name" + i);
            par.addValueMeta(v);
        }
    }
    return par;
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) Savepoint(java.sql.Savepoint) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 53 with ValueMetaNumber

use of org.pentaho.di.core.row.value.ValueMetaNumber in project pentaho-kettle by pentaho.

the class Database method getQueryFieldsFromDatabaseMetaData.

public RowMetaInterface getQueryFieldsFromDatabaseMetaData() throws Exception {
    ResultSet columns = connection.getMetaData().getColumns("", "", databaseMeta.getName(), "");
    RowMetaInterface rowMeta = new RowMeta();
    while (columns.next()) {
        ValueMetaInterface valueMeta = null;
        String name = columns.getString("COLUMN_NAME");
        String type = columns.getString("SOURCE_DATA_TYPE");
        int size = columns.getInt("COLUMN_SIZE");
        if (type.equals("Integer") || type.equals("Long")) {
            valueMeta = new ValueMetaInteger();
        } else if (type.equals("BigDecimal") || type.equals("BigNumber")) {
            valueMeta = new ValueMetaBigNumber();
        } else if (type.equals("Double") || type.equals("Number")) {
            valueMeta = new ValueMetaNumber();
        } else if (type.equals("String")) {
            valueMeta = new ValueMetaString();
        } else if (type.equals("Date")) {
            valueMeta = new ValueMetaDate();
        } else if (type.equals("Boolean")) {
            valueMeta = new ValueMetaBoolean();
        } else if (type.equals("Binary")) {
            valueMeta = new ValueMetaBinary();
        } else if (type.equals("Timestamp")) {
            valueMeta = new ValueMetaTimestamp();
        } else if (type.equals("Internet Address")) {
            valueMeta = new ValueMetaInternetAddress();
        }
        if (valueMeta != null) {
            valueMeta.setName(name);
            valueMeta.setComments(name);
            valueMeta.setLength(size);
            valueMeta.setOriginalColumnTypeName(type);
            valueMeta.setConversionMask(columns.getString("SOURCE_MASK"));
            valueMeta.setDecimalSymbol(columns.getString("SOURCE_DECIMAL_SYMBOL"));
            valueMeta.setGroupingSymbol(columns.getString("SOURCE_GROUPING_SYMBOL"));
            valueMeta.setCurrencySymbol(columns.getString("SOURCE_CURRENCY_SYMBOL"));
            rowMeta.addValueMeta(valueMeta);
        } else {
            log.logBasic("Database.getQueryFields() ValueMetaInterface mapping not resolved for the column " + name);
            rowMeta = null;
            break;
        }
    }
    if (rowMeta != null && !rowMeta.isEmpty()) {
        return rowMeta;
    } else {
        throw new Exception("Error in Database.getQueryFields()");
    }
}
Also used : ValueMetaTimestamp(org.pentaho.di.core.row.value.ValueMetaTimestamp) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaInternetAddress(org.pentaho.di.core.row.value.ValueMetaInternetAddress) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) Savepoint(java.sql.Savepoint) KettleValueException(org.pentaho.di.core.exception.KettleValueException) BatchUpdateException(java.sql.BatchUpdateException) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) SQLException(java.sql.SQLException) KettleDatabaseBatchException(org.pentaho.di.core.exception.KettleDatabaseBatchException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) ResultSet(java.sql.ResultSet) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate)

Example 54 with ValueMetaNumber

use of org.pentaho.di.core.row.value.ValueMetaNumber in project pentaho-kettle by pentaho.

the class Database method getParameterMetaData.

public RowMetaInterface getParameterMetaData(PreparedStatement ps) {
    RowMetaInterface par = new RowMeta();
    try {
        ParameterMetaData pmd = ps.getParameterMetaData();
        for (int i = 1; i <= pmd.getParameterCount(); i++) {
            String name = "par" + i;
            int sqltype = pmd.getParameterType(i);
            int length = pmd.getPrecision(i);
            int precision = pmd.getScale(i);
            ValueMetaInterface val;
            switch(sqltype) {
                case java.sql.Types.CHAR:
                case java.sql.Types.VARCHAR:
                    val = new ValueMetaString(name);
                    break;
                case java.sql.Types.BIGINT:
                case java.sql.Types.INTEGER:
                case java.sql.Types.NUMERIC:
                case java.sql.Types.SMALLINT:
                case java.sql.Types.TINYINT:
                    val = new ValueMetaInteger(name);
                    break;
                case java.sql.Types.DECIMAL:
                case java.sql.Types.DOUBLE:
                case java.sql.Types.FLOAT:
                case java.sql.Types.REAL:
                    val = new ValueMetaNumber(name);
                    break;
                case java.sql.Types.DATE:
                case java.sql.Types.TIME:
                case java.sql.Types.TIMESTAMP:
                    val = new ValueMetaDate(name);
                    break;
                case java.sql.Types.BOOLEAN:
                case java.sql.Types.BIT:
                    val = new ValueMetaBoolean(name);
                    break;
                default:
                    val = new ValueMetaNone(name);
                    break;
            }
            if (val.isNumeric() && (length > 18 || precision > 18)) {
                val = new ValueMetaBigNumber(name);
            }
            par.addValueMeta(val);
        }
    } catch (AbstractMethodError e) {
        // Oops: probably the database or JDBC doesn't support it.
        return null;
    } catch (SQLException e) {
        return null;
    } catch (Exception e) {
        return null;
    }
    return par;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) SQLException(java.sql.SQLException) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) Savepoint(java.sql.Savepoint) KettleValueException(org.pentaho.di.core.exception.KettleValueException) BatchUpdateException(java.sql.BatchUpdateException) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) SQLException(java.sql.SQLException) KettleDatabaseBatchException(org.pentaho.di.core.exception.KettleDatabaseBatchException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) ValueMetaNone(org.pentaho.di.core.row.value.ValueMetaNone) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) ParameterMetaData(java.sql.ParameterMetaData)

Example 55 with ValueMetaNumber

use of org.pentaho.di.core.row.value.ValueMetaNumber in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryCreationHelper method createRepositorySchema.

/**
 * Create or upgrade repository tables & fields, populate lookup tables, ...
 *
 * @param monitor
 *          The progress monitor to use, or null if no monitor is present.
 * @param upgrade
 *          True if you want to upgrade the repository, false if you want to create it.
 * @param statements
 *          the list of statements to populate
 * @param dryrun
 *          true if we don't actually execute the statements
 *
 * @throws KettleException
 *           in case something goes wrong!
 */
public synchronized void createRepositorySchema(ProgressMonitorListener monitor, boolean upgrade, List<String> statements, boolean dryrun) throws KettleException {
    RowMetaInterface table;
    String sql;
    String tablename;
    String schemaTable;
    String indexname;
    String[] keyfield;
    String[] user, pass, code, desc;
    // integer, no need for bigint!
    int KEY = 9;
    log.logBasic("Starting to create or modify the repository tables...");
    String message = (upgrade ? "Upgrading " : "Creating") + " the Kettle repository...";
    if (monitor != null) {
        monitor.beginTask(message, 31);
    }
    repository.connectionDelegate.setAutoCommit(true);
    // ////////////////////////////////////////////////////////////////////////////////
    // R_LOG
    // 
    // Log the operations we do in the repository.
    // 
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_REPOSITORY_LOG;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_REPOSITORY_LOG_ID_REPOSITORY_LOG, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_REPOSITORY_LOG_REP_VERSION, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaDate(KettleDatabaseRepository.FIELD_REPOSITORY_LOG_LOG_DATE));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_REPOSITORY_LOG_LOG_USER, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_REPOSITORY_LOG_OPERATION_DESC, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_REPOSITORY_LOG_ID_REPOSITORY_LOG, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            try {
                if (log.isDetailed()) {
                    log.logDetailed("executing SQL statements: " + Const.CR + sql);
                }
                database.execStatements(sql);
                if (log.isDetailed()) {
                    log.logDetailed("Created/altered table " + schemaTable);
                }
            } catch (KettleException dbe) {
                throw new KettleException("Unable to create or modify table " + schemaTable, dbe);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (!dryrun) {
        repository.insertLogEntry((upgrade ? "Upgrade" : "Creation") + " of the Kettle repository");
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // R_VERSION
    // 
    // Let's start with the version table
    // 
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_VERSION;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_VERSION_ID_VERSION, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_VERSION_MAJOR_VERSION, 3, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_VERSION_MINOR_VERSION, 3, 0));
    table.addValueMeta(new ValueMetaDate(KettleDatabaseRepository.FIELD_VERSION_UPGRADE_DATE, 0, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_VERSION_IS_UPGRADE, 1, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_VERSION_ID_VERSION, false);
    boolean create = false;
    if (!Utils.isEmpty(sql)) {
        create = sql.toUpperCase().indexOf("CREATE TABLE") >= 0;
        statements.add(sql);
        if (!dryrun) {
            try {
                if (log.isDetailed()) {
                    log.logDetailed("executing SQL statements: " + Const.CR + sql);
                }
                database.execStatements(sql);
                if (log.isDetailed()) {
                    log.logDetailed("Created/altered table " + schemaTable);
                }
            } catch (KettleException dbe) {
                throw new KettleException("Unable to create or modify table " + schemaTable, dbe);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    // 
    try {
        // if the table doesn't exist, don't try to grab an ID from it...
        LongObjectId nextId;
        if (sql.toUpperCase().indexOf("CREATE TABLE") < 0) {
            nextId = repository.connectionDelegate.getNextID(schemaTable, KettleDatabaseRepository.FIELD_VERSION_ID_VERSION);
        } else {
            nextId = new LongObjectId(1L);
        }
        Object[] data = new Object[] { nextId.longValue(), Long.valueOf(KettleDatabaseRepositoryConnectionDelegate.REQUIRED_MAJOR_VERSION), Long.valueOf(KettleDatabaseRepositoryConnectionDelegate.REQUIRED_MINOR_VERSION), new Date(), Boolean.valueOf(upgrade) };
        if (dryrun) {
            sql = database.getSQLOutput(null, KettleDatabaseRepository.TABLE_R_VERSION, table, data, null);
            statements.add(sql);
        } else {
            database.execStatement("INSERT INTO " + databaseMeta.getQuotedSchemaTableCombination(null, KettleDatabaseRepository.TABLE_R_VERSION) + " VALUES(?, ?, ?, ?, ?)", table, data);
        }
    } catch (KettleException e) {
        throw new KettleException("Unable to insert new version log record into " + schemaTable, e);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // R_DATABASE_TYPE
    // 
    // Create table...
    // 
    boolean ok_database_type = true;
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_DATABASE_TYPE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_TYPE_ID_DATABASE_TYPE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_TYPE_CODE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_TYPE_DESCRIPTION, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_DATABASE_TYPE_ID_DATABASE_TYPE, false);
    create = false;
    if (!Utils.isEmpty(sql)) {
        create = sql.toUpperCase().indexOf("CREATE TABLE") >= 0;
        statements.add(sql);
        if (!dryrun) {
            try {
                if (log.isDetailed()) {
                    log.logDetailed("executing SQL statements: " + Const.CR + sql);
                }
                database.execStatements(sql);
                if (log.isDetailed()) {
                    log.logDetailed("Created/altered table " + schemaTable);
                }
            } catch (KettleException dbe) {
                throw new KettleException("Unable to create or modify table " + schemaTable, dbe);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (ok_database_type) {
        // 
        // Populate...
        // 
        updateDatabaseTypes(statements, dryrun, create);
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_DATABASE_CONTYPE
    // 
    // Create table...
    // 
    boolean ok_database_contype = true;
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_DATABASE_CONTYPE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_CONTYPE_ID_DATABASE_CONTYPE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_CONTYPE_CODE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_CONTYPE_DESCRIPTION, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_DATABASE_CONTYPE_ID_DATABASE_CONTYPE, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    // If it's creating the table, go ahead and populate below...
    // 
    ok_database_contype = sql.toUpperCase().contains("CREATE TABLE");
    if (ok_database_contype) {
        // 
        // Populate with data...
        // 
        code = DatabaseMeta.dbAccessTypeCode;
        desc = DatabaseMeta.dbAccessTypeDesc;
        if (!dryrun) {
            database.prepareInsert(table, null, tablename);
        }
        for (int i = 0; i < code.length; i++) {
            RowMetaAndData lookup = null;
            if (upgrade) {
                lookup = database.getOneRow("SELECT " + repository.quote(KettleDatabaseRepository.FIELD_DATABASE_CONTYPE_ID_DATABASE_CONTYPE) + " FROM " + schemaTable + " WHERE " + repository.quote(KettleDatabaseRepository.FIELD_DATABASE_CONTYPE_CODE) + " = '" + code[i] + "'");
            }
            if (lookup == null) {
                ObjectId nextid = new LongObjectId(i + 1);
                if (!create) {
                    nextid = repository.connectionDelegate.getNextDatabaseConnectionTypeID();
                }
                Object[] tableData = new Object[] { new LongObjectId(nextid).longValue(), code[i], desc[i] };
                if (dryrun) {
                    sql = database.getSQLOutput(null, tablename, table, tableData, null);
                    statements.add(sql);
                } else {
                    database.setValuesInsert(table, tableData);
                    database.insertRow();
                }
            }
        }
        try {
            if (!dryrun) {
                database.closeInsert();
            }
            if (log.isDetailed()) {
                log.logDetailed("Populated table " + schemaTable);
            }
        } catch (KettleException dbe) {
            throw new KettleException("Unable to close insert after populating table " + schemaTable, dbe);
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_NOTE
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_NOTE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NOTE_ID_NOTE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_NOTE_VALUE_STR, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NOTE_GUI_LOCATION_X, 6, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NOTE_GUI_LOCATION_Y, 6, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NOTE_GUI_LOCATION_WIDTH, 6, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NOTE_GUI_LOCATION_HEIGHT, 6, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_NOTE_FONT_NAME, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NOTE_FONT_SIZE, 6, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_NOTE_FONT_BOLD, 1, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_NOTE_FONT_ITALIC, 1, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NOTE_COLOR_RED, 6, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NOTE_COLOR_GREEN, 6, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NOTE_COLOR_BLUE, 6, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NOTE_BACK_GROUND_COLOR_RED, 6, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NOTE_BACK_GROUND_COLOR_GREEN, 6, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NOTE_BACK_GROUND_COLOR_BLUE, 6, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NOTE_BORDER_COLOR_RED, 6, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NOTE_BORDER_COLOR_GREEN, 6, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NOTE_BORDER_COLOR_BLUE, 6, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_NOTE_DRAW_SHADOW, 1, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_NOTE_ID_NOTE, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_DATABASE
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_DATABASE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE_TYPE, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE_CONTYPE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_HOST_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_DATABASE_NAME, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_PORT, 7, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_USERNAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_PASSWORD, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_SERVERNAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_DATA_TBS, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_INDEX_TBS, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_DATABASE_ATTRIBUTE
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_DATABASE_ATTRIBUTE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_ID_DATABASE_ATTRIBUTE, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_ID_DATABASE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_CODE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_VALUE_STR, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_ID_DATABASE_ATTRIBUTE, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
        try {
            indexname = KettleDatabaseRepositoryBase.IDX_R_DATABASE_ATTRIBUTE;
            keyfield = new String[] { KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_ID_DATABASE, KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_CODE };
            if (!database.checkIndexExists(schemaTable, keyfield)) {
                sql = database.getCreateIndexStatement(schemaTable, indexname, keyfield, false, true, false, false);
                statements.add(sql);
                if (!dryrun) {
                    if (log.isDetailed()) {
                        log.logDetailed("executing SQL statements: " + Const.CR + sql);
                    }
                    database.execStatements(sql);
                    if (log.isDetailed()) {
                        log.logDetailed("Created lookup index " + indexname + " on " + schemaTable);
                    }
                }
            }
        } catch (KettleException kdbe) {
        // Ignore this one: index is not properly detected, it already exists...
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_DIRECTORY
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_DIRECTORY;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY_PARENT, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DIRECTORY_DIRECTORY_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
        try {
            indexname = KettleDatabaseRepositoryBase.IDX_R_DIRECTORY;
            keyfield = new String[] { KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY_PARENT, KettleDatabaseRepository.FIELD_DIRECTORY_DIRECTORY_NAME };
            if (!database.checkIndexExists(schemaTable, keyfield)) {
                sql = database.getCreateIndexStatement(schemaTable, indexname, keyfield, false, true, false, false);
                statements.add(sql);
                if (!dryrun) {
                    if (log.isDetailed()) {
                        log.logDetailed("executing SQL statements: " + Const.CR + sql);
                    }
                    database.execStatements(sql);
                    if (log.isDetailed()) {
                        log.logDetailed("Created lookup index " + indexname + " on " + schemaTable);
                    }
                }
            }
        } catch (KettleException kdbe) {
        // Ignore this one: index is not properly detected, it already exists...
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_TRANSFORMATION
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_TRANSFORMATION;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_TRANSFORMATION, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_DESCRIPTION, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_EXTENDED_DESCRIPTION, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_TRANS_VERSION, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_TRANS_STATUS, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_READ, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_WRITE, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_INPUT, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_OUTPUT, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_STEP_UPDATE, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DATABASE_LOG, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_TABLE_NAME_LOG, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_TRANSFORMATION_USE_BATCHID, 1, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_TRANSFORMATION_USE_LOGFIELD, 1, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DATABASE_MAXDATE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_TABLE_NAME_MAXDATE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_FIELD_NAME_MAXDATE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaNumber(KettleDatabaseRepository.FIELD_TRANSFORMATION_OFFSET_MAXDATE, 12, 2));
    table.addValueMeta(new ValueMetaNumber(KettleDatabaseRepository.FIELD_TRANSFORMATION_DIFF_MAXDATE, 12, 2));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_CREATED_USER, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaDate(KettleDatabaseRepository.FIELD_TRANSFORMATION_CREATED_DATE, 20, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANSFORMATION_MODIFIED_USER, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaDate(KettleDatabaseRepository.FIELD_TRANSFORMATION_MODIFIED_DATE, 20, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANSFORMATION_SIZE_ROWSET, KEY, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_TRANSFORMATION, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    // 
    if (database.checkTableExists(schemaTable)) {
        sql = "SELECT * FROM " + schemaTable + " WHERE " + repository.quote(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY) + " IS NULL";
        List<Object[]> rows = database.getRows(sql, 1);
        if (rows != null && rows.size() > 0) {
            sql = "UPDATE " + schemaTable + " SET " + repository.quote(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY) + "=0 WHERE " + repository.quote(KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY) + " IS NULL";
            statements.add(sql);
            if (!dryrun) {
                database.execStatement(sql);
            }
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_TRANS_ATTRIBUTE
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_TRANS_ATTRIBUTE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANS_ATTRIBUTE, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_NR, 6, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_CODE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_VALUE_NUM, 18, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_VALUE_STR, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANS_ATTRIBUTE, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
        try {
            indexname = KettleDatabaseRepositoryBase.IDX_TRANS_ATTRIBUTE_LOOKUP;
            keyfield = new String[] { KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION, KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_CODE, KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_NR };
            if (!database.checkIndexExists(schemaTable, keyfield)) {
                sql = database.getCreateIndexStatement(schemaTable, indexname, keyfield, false, true, false, false);
                statements.add(sql);
                if (!dryrun) {
                    if (log.isDetailed()) {
                        log.logDetailed("executing SQL statements: " + Const.CR + sql);
                    }
                    database.execStatements(sql);
                    if (log.isDetailed()) {
                        log.logDetailed("Created lookup index " + indexname + " on " + schemaTable);
                    }
                }
            }
        } catch (KettleException kdbe) {
        // Ignore this one: index is not properly detected, it already exists...
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_JOB_ATTRIBUTE
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_JOB_ATTRIBUTE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_ID_JOB_ATTRIBUTE, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_ID_JOB, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_NR, 6, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_CODE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_VALUE_NUM, 18, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_VALUE_STR, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_ID_JOB_ATTRIBUTE, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
        try {
            // PDI-10237
            indexname = KettleDatabaseRepositoryBase.IDX_JOB_ATTRIBUTE_LOOKUP;
            keyfield = new String[] { KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_ID_JOB, KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_CODE, KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_NR };
            if (!database.checkIndexExists(schemaTable, keyfield)) {
                sql = database.getCreateIndexStatement(schemaTable, indexname, keyfield, false, true, false, false);
                statements.add(sql);
                if (!dryrun) {
                    if (log.isDetailed()) {
                        log.logDetailed("executing SQL statements: " + Const.CR + sql);
                    }
                    database.execStatements(sql);
                    if (log.isDetailed()) {
                        log.logDetailed("Created lookup index " + indexname + " on " + schemaTable);
                    }
                }
            }
        } catch (KettleException kdbe) {
        // Ignore this one: index is not properly detected, it already exists...
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_DEPENDENCY
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_DEPENDENCY;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DEPENDENCY_ID_DEPENDENCY, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DEPENDENCY_ID_TRANSFORMATION, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DEPENDENCY_ID_DATABASE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DEPENDENCY_TABLE_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DEPENDENCY_FIELD_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_DEPENDENCY_ID_DEPENDENCY, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_PARTITION_SCHEMA
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_PARTITION_SCHEMA;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_ID_PARTITION_SCHEMA, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_DYNAMIC_DEFINITION, 1, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_PARTITIONS_PER_SLAVE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_ID_PARTITION_SCHEMA, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_PARTITION
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_PARTITION;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_PARTITION_ID_PARTITION, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_PARTITION_ID_PARTITION_SCHEMA, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_PARTITION_PARTITION_ID, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_PARTITION_ID_PARTITION, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_TRANS_PARTITION_SCHEMA
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_TRANS_PARTITION_SCHEMA;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_PARTITION_SCHEMA_ID_TRANS_PARTITION_SCHEMA, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_PARTITION_SCHEMA_ID_TRANSFORMATION, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_PARTITION_SCHEMA_ID_PARTITION_SCHEMA, KEY, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_TRANS_PARTITION_SCHEMA_ID_TRANS_PARTITION_SCHEMA, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_CLUSTER
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_CLUSTER;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_CLUSTER_ID_CLUSTER, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_CLUSTER_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_CLUSTER_BASE_PORT, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_CLUSTER_SOCKETS_BUFFER_SIZE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_CLUSTER_SOCKETS_FLUSH_INTERVAL, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_CLUSTER_SOCKETS_COMPRESSED, 0, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_CLUSTER_DYNAMIC, 0, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_CLUSTER_ID_CLUSTER, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_SLAVE
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_SLAVE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_SLAVE_ID_SLAVE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_SLAVE_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_SLAVE_HOST_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_SLAVE_PORT, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_SLAVE_WEB_APP_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_SLAVE_USERNAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_SLAVE_PASSWORD, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_SLAVE_PROXY_HOST_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_SLAVE_PROXY_PORT, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_SLAVE_NON_PROXY_HOSTS, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_SLAVE_MASTER));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_SLAVE_ID_SLAVE, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_CLUSTER_SLAVE
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_CLUSTER_SLAVE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_CLUSTER_SLAVE_ID_CLUSTER_SLAVE, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_CLUSTER_SLAVE_ID_CLUSTER, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_CLUSTER_SLAVE_ID_SLAVE, KEY, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_CLUSTER_SLAVE_ID_CLUSTER_SLAVE, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_TRANS_SLAVE
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_TRANS_SLAVE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_SLAVE_ID_TRANS_SLAVE, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_SLAVE_ID_TRANSFORMATION, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_SLAVE_ID_SLAVE, KEY, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_TRANS_SLAVE_ID_TRANS_SLAVE, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_TRANS_CLUSTER
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_TRANS_CLUSTER;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_CLUSTER_ID_TRANS_CLUSTER, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_CLUSTER_ID_TRANSFORMATION, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_CLUSTER_ID_CLUSTER, KEY, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_TRANS_CLUSTER_ID_TRANS_CLUSTER, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // 
    // R_TRANS_HOP
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_TRANS_HOP;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_HOP_ID_TRANS_HOP, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_HOP_ID_TRANSFORMATION, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_HOP_ID_STEP_FROM, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_HOP_ID_STEP_TO, KEY, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_TRANS_HOP_ENABLED, 1, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_TRANS_HOP_ID_TRANS_HOP, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // /////////////////////////////////////////////////////////////////////////////
    // R_TRANS_STEP_CONDITION
    // 
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_TRANS_STEP_CONDITION;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_STEP_CONDITION_ID_TRANSFORMATION, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_STEP_CONDITION_ID_STEP, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_STEP_CONDITION_ID_CONDITION, KEY, 0));
    sql = database.getDDL(schemaTable, table, null, false, null, false);
    if (!Utils.isEmpty(sql)) {
        // Doesn't exists: create the table...
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // /////////////////////////////////////////////////////////////////////////////
    // R_CONDITION
    // 
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_CONDITION;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_CONDITION_ID_CONDITION, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_CONDITION_ID_CONDITION_PARENT, KEY, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_CONDITION_NEGATED, 1, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_CONDITION_OPERATOR, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_CONDITION_LEFT_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_CONDITION_CONDITION_FUNCTION, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_CONDITION_RIGHT_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_CONDITION_ID_VALUE_RIGHT, KEY, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_CONDITION_ID_CONDITION, false);
    if (!Utils.isEmpty(sql)) {
        // Doesn't exist: create the table...
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // /////////////////////////////////////////////////////////////////////////////
    // R_VALUE
    // 
    tablename = KettleDatabaseRepository.TABLE_R_VALUE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table = new RowMeta();
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_VALUE_ID_VALUE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_VALUE_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_VALUE_VALUE_TYPE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_VALUE_VALUE_STR, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_VALUE_IS_NULL, 1, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_VALUE_ID_VALUE, false);
    if (!Utils.isEmpty(sql)) {
        // Doesn't exists: create the table...
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_STEP_TYPE
    // 
    // Create table...
    boolean ok_step_type = true;
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_STEP_TYPE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_TYPE_ID_STEP_TYPE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_STEP_TYPE_CODE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_STEP_TYPE_DESCRIPTION, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_STEP_TYPE_HELPTEXT, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, "ID_STEP_TYPE", false);
    create = false;
    if (!Utils.isEmpty(sql)) {
        // Doesn't exists: create the table...
        create = sql.toUpperCase().indexOf("CREATE TABLE") >= 0;
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (ok_step_type) {
        updateStepTypes(statements, dryrun, create);
        if (log.isDetailed()) {
            log.logDetailed("Populated table " + schemaTable);
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_STEP
    // 
    // Create table
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_STEP;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_ID_STEP, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_ID_TRANSFORMATION, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_STEP_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_STEP_DESCRIPTION, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_ID_STEP_TYPE, KEY, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_STEP_DISTRIBUTE, 1, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_COPIES, 3, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_X, 6, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_Y, 6, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_STEP_GUI_DRAW, 1, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_STEP_COPIES_STRING, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_STEP_ID_STEP, false);
    if (!Utils.isEmpty(sql)) {
        // Doesn't exists: create the table...
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_STEP_ATTRIBUTE
    // 
    // Create table...
    tablename = KettleDatabaseRepository.TABLE_R_STEP_ATTRIBUTE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table = new RowMeta();
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_ID_STEP_ATTRIBUTE, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_ID_TRANSFORMATION, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_ID_STEP, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_NR, 6, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_CODE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_VALUE_NUM, 18, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_VALUE_STR, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_ID_STEP_ATTRIBUTE, false);
    if (!Utils.isEmpty(sql)) {
        // Doesn't exist: create the table...
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
        try {
            indexname = KettleDatabaseRepositoryBase.IDX_R_STEP_ATTRIBUTE;
            keyfield = new String[] { KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_ID_STEP, KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_CODE, KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_NR };
            if (!database.checkIndexExists(schemaTable, keyfield)) {
                sql = database.getCreateIndexStatement(schemaTable, indexname, keyfield, false, true, false, false);
                statements.add(sql);
                if (!dryrun) {
                    if (log.isDetailed()) {
                        log.logDetailed("executing SQL statements: " + Const.CR + sql);
                    }
                    database.execStatements(sql);
                    if (log.isDetailed()) {
                        log.logDetailed("Created lookup index " + indexname + " on " + schemaTable);
                    }
                }
            }
        } catch (KettleException kdbe) {
        // Ignore this one: index is not properly detected, it already exists...
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_STEP_DATABASE
    // 
    // Keeps the links between transformation steps and databases.
    // That way investigating dependencies becomes easier to program.
    // 
    // Create table...
    tablename = KettleDatabaseRepository.TABLE_R_STEP_DATABASE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table = new RowMeta();
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_DATABASE_ID_TRANSFORMATION, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_DATABASE_ID_STEP, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_DATABASE_ID_DATABASE, KEY, 0));
    sql = database.getDDL(schemaTable, table, null, false, null, false);
    if (!Utils.isEmpty(sql)) {
        // Doesn't exist: create the table...
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
        try {
            indexname = KettleDatabaseRepositoryBase.R_STEP_DATABASE_LU1;
            keyfield = new String[] { KettleDatabaseRepository.FIELD_STEP_DATABASE_ID_TRANSFORMATION };
            if (!database.checkIndexExists(schemaTable, keyfield)) {
                sql = database.getCreateIndexStatement(schemaTable, indexname, keyfield, false, false, false, false);
                statements.add(sql);
                if (!dryrun) {
                    if (log.isDetailed()) {
                        log.logDetailed("executing SQL statements: " + Const.CR + sql);
                    }
                    database.execStatements(sql);
                    if (log.isDetailed()) {
                        log.logDetailed("Created lookup index " + indexname + " on " + schemaTable);
                    }
                }
            }
        } catch (KettleException kdbe) {
        // Ignore this one: index is not properly detected, it already exists...
        }
        try {
            indexname = KettleDatabaseRepositoryBase.R_STEP_DATABASE_LU2;
            keyfield = new String[] { KettleDatabaseRepository.FIELD_STEP_DATABASE_ID_DATABASE };
            if (!database.checkIndexExists(schemaTable, keyfield)) {
                sql = database.getCreateIndexStatement(schemaTable, indexname, keyfield, false, false, false, false);
                statements.add(sql);
                if (!dryrun) {
                    if (log.isDetailed()) {
                        log.logDetailed("executing SQL statements: " + Const.CR + sql);
                    }
                    database.execStatements(sql);
                    if (log.isDetailed()) {
                        log.logDetailed("Created lookup index " + indexname + " on " + schemaTable);
                    }
                }
            }
        } catch (KettleException kdbe) {
        // Ignore this one: index is not properly detected, it already exists...
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_TRANS_NOTE
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_TRANS_NOTE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_NOTE_ID_TRANSFORMATION, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_NOTE_ID_NOTE, KEY, 0));
    sql = database.getDDL(schemaTable, table, null, false, null, false);
    if (!Utils.isEmpty(sql)) {
        // Doesn't exist: create the table...
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_LOGLEVEL
    // 
    // Create table...
    boolean ok_loglevel = true;
    tablename = KettleDatabaseRepository.TABLE_R_LOGLEVEL;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table = new RowMeta();
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_LOGLEVEL_ID_LOGLEVEL, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_LOGLEVEL_CODE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_LOGLEVEL_DESCRIPTION, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_LOGLEVEL_ID_LOGLEVEL, false);
    create = false;
    if (!Utils.isEmpty(sql)) {
        // Doesn't exist: create the table...
        create = sql.toUpperCase().indexOf("CREATE TABLE") >= 0;
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (ok_loglevel) {
        // 
        // Populate with data...
        // 
        code = LogLevel.logLogLevelCodes();
        desc = LogLevel.getLogLevelDescriptions();
        if (!dryrun) {
            database.prepareInsert(table, null, tablename);
        }
        for (int i = 1; i < code.length; i++) {
            RowMetaAndData lookup = null;
            if (upgrade) {
                lookup = database.getOneRow("SELECT " + repository.quote(KettleDatabaseRepository.FIELD_LOGLEVEL_ID_LOGLEVEL) + " FROM " + schemaTable + " WHERE " + database.getDatabaseMeta().quoteField("CODE") + " = '" + code[i] + "'");
            }
            if (lookup == null) {
                ObjectId nextid = new LongObjectId(i);
                if (!create) {
                    nextid = repository.connectionDelegate.getNextLoglevelID();
                }
                RowMetaAndData tableData = new RowMetaAndData();
                tableData.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_LOGLEVEL_ID_LOGLEVEL), nextid);
                tableData.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_LOGLEVEL_CODE), code[i]);
                tableData.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_LOGLEVEL_DESCRIPTION), desc[i]);
                if (dryrun) {
                    sql = database.getSQLOutput(null, tablename, tableData.getRowMeta(), tableData.getData(), null);
                    statements.add(sql);
                } else {
                    database.setValuesInsert(tableData.getRowMeta(), tableData.getData());
                    database.insertRow();
                }
            }
        }
        try {
            if (!dryrun) {
                database.closeInsert();
            }
            if (log.isDetailed()) {
                log.logDetailed("Populated table " + schemaTable);
            }
        } catch (KettleException dbe) {
            throw new KettleException("Unable to close insert after populating table " + schemaTable, dbe);
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_LOG
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_LOG;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_LOG_ID_LOG, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_LOG_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_LOG_ID_LOGLEVEL, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_LOG_LOGTYPE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_LOG_FILENAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_LOG_FILEEXTENTION, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_LOG_ADD_DATE, 1, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_LOG_ADD_TIME, 1, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_LOG_ID_DATABASE_LOG, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_LOG_TABLE_NAME_LOG, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_LOG_ID_LOG, false);
    if (!Utils.isEmpty(sql)) {
        // Doesn't exist: create the table...
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_JOB
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_JOB;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ID_JOB, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_DESCRIPTION, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_EXTENDED_DESCRIPTION, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_JOB_VERSION, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_JOB_STATUS, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ID_DATABASE_LOG, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_TABLE_NAME_LOG, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_CREATED_USER, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaDate(KettleDatabaseRepository.FIELD_JOB_CREATED_DATE, 20, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_MODIFIED_USER, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaDate(KettleDatabaseRepository.FIELD_JOB_MODIFIED_DATE, 20, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_JOB_USE_BATCH_ID, 0, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_JOB_PASS_BATCH_ID, 0, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_JOB_USE_LOGFIELD, 0, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_SHARED_FILE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, // 255 max length for now.
    0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_JOB_ID_JOB, false);
    if (!Utils.isEmpty(sql)) {
        // Doesn't exist: create the table...
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_JOBENTRY_DATABASE
    // 
    // Keeps the links between job entries and databases.
    // That way investigating dependencies becomes easier to program.
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_JOBENTRY_DATABASE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_DATABASE_ID_JOB, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_DATABASE_ID_JOBENTRY, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_DATABASE_ID_DATABASE, KEY, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_JOB_ID_JOB, false);
    sql = database.getDDL(schemaTable, table, null, false, null, false);
    if (!Utils.isEmpty(sql)) {
        // Doesn't exist: create the table...
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
        try {
            indexname = KettleDatabaseRepositoryBase.R_JOBENTRY_DATABASE_LU1;
            keyfield = new String[] { KettleDatabaseRepository.FIELD_JOBENTRY_DATABASE_ID_JOB };
            if (!database.checkIndexExists(schemaTable, keyfield)) {
                sql = database.getCreateIndexStatement(schemaTable, indexname, keyfield, false, false, false, false);
                statements.add(sql);
                if (!dryrun) {
                    if (log.isDetailed()) {
                        log.logDetailed("executing SQL statements: " + Const.CR + sql);
                    }
                    database.execStatements(sql);
                    if (log.isDetailed()) {
                        log.logDetailed("Created lookup index " + indexname + " on " + schemaTable);
                    }
                }
            }
        } catch (KettleException kdbe) {
        // Ignore this one: index is not properly detected, it already exists...
        }
        try {
            indexname = KettleDatabaseRepositoryBase.R_JOBENTRY_DATABASE_LU2;
            keyfield = new String[] { KettleDatabaseRepository.FIELD_JOBENTRY_DATABASE_ID_DATABASE };
            if (!database.checkIndexExists(schemaTable, keyfield)) {
                sql = database.getCreateIndexStatement(schemaTable, indexname, keyfield, false, false, false, false);
                statements.add(sql);
                if (!dryrun) {
                    if (log.isDetailed()) {
                        log.logDetailed("executing SQL statements: " + Const.CR + sql);
                    }
                    database.execStatements(sql);
                    if (log.isDetailed()) {
                        log.logDetailed("Created lookup index " + indexname + " on " + schemaTable);
                    }
                }
            }
        } catch (KettleException kdbe) {
        // Ignore this one: index is not properly detected, it already exists...
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_JOBENTRY_TYPE
    // 
    // Create table...
    boolean ok_jobentry_type = true;
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_JOBENTRY_TYPE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_ID_JOBENTRY_TYPE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_CODE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_DESCRIPTION, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_ID_JOBENTRY_TYPE, false);
    create = false;
    if (!Utils.isEmpty(sql)) {
        // Doesn't exist: create the table...
        create = sql.toUpperCase().indexOf("CREATE TABLE") >= 0;
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (ok_jobentry_type) {
        // 
        // Populate with data...
        // 
        updateJobEntryTypes(statements, dryrun, create);
        if (log.isDetailed()) {
            log.logDetailed("Populated table " + schemaTable);
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_JOBENTRY
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_JOBENTRY;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_ID_JOBENTRY, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_ID_JOB, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_ID_JOBENTRY_TYPE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_DESCRIPTION, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_JOBENTRY_ID_JOBENTRY, false);
    if (!Utils.isEmpty(sql)) {
        // Doesn't exist: create the table...
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_JOBENTRY_COPY
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_JOBENTRY_COPY;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY_COPY, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOB, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY_TYPE, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_NR, 4, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_X, 6, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_Y, 6, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_DRAW, 1, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_PARALLEL, 1, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY_COPY, false);
    if (!Utils.isEmpty(sql)) {
        // Doesn't exist: create the table...
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_JOBENTRY_ATTRIBUTE
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_JOBENTRY_ATTRIBUTE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOBENTRY_ATTRIBUTE, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOB, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOBENTRY, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_NR, 6, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_CODE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaNumber(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_VALUE_NUM, 13, 2));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_VALUE_STR, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOBENTRY_ATTRIBUTE, false);
    if (!Utils.isEmpty(sql)) {
        // Doesn't exist: create the table...
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
        try {
            indexname = KettleDatabaseRepositoryBase.R_JOBENTRY_ATTRIBUTE;
            keyfield = new String[] { KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOBENTRY_ATTRIBUTE, KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_CODE, KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_NR };
            if (!database.checkIndexExists(schemaTable, keyfield)) {
                sql = database.getCreateIndexStatement(schemaTable, indexname, keyfield, false, true, false, false);
                statements.add(sql);
                if (!dryrun) {
                    if (log.isDetailed()) {
                        log.logDetailed("executing SQL statements: " + Const.CR + sql);
                    }
                    database.execStatements(sql);
                    if (log.isDetailed()) {
                        log.logDetailed("Created lookup index " + indexname + " on " + schemaTable);
                    }
                }
            }
        } catch (KettleException kdbe) {
        // Ignore this one: index is not properly detected, it already exists...
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_JOB_HOP
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_JOB_HOP;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_HOP_ID_JOB_HOP, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_HOP_ID_JOB, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_HOP_ID_JOBENTRY_COPY_FROM, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_HOP_ID_JOBENTRY_COPY_TO, KEY, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_JOB_HOP_ENABLED, 1, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_JOB_HOP_EVALUATION, 1, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_JOB_HOP_UNCONDITIONAL, 1, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_JOB_HOP_ID_JOB_HOP, false);
    if (!Utils.isEmpty(sql)) {
        // Doesn't exist: create the table...
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_JOB_NOTE
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_JOB_NOTE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_NOTE_ID_JOB, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_NOTE_ID_NOTE, KEY, 0));
    sql = database.getDDL(schemaTable, table, null, false, null, false);
    if (!Utils.isEmpty(sql)) {
        // Doesn't exist: create the table...
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // 
    // R_TRANS_LOCK
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_TRANS_LOCK;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_LOCK_ID_TRANS_LOCK, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_LOCK_ID_TRANSFORMATION, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_LOCK_ID_USER, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANS_LOCK_LOCK_MESSAGE, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    table.addValueMeta(new ValueMetaDate(KettleDatabaseRepository.FIELD_TRANS_LOCK_LOCK_DATE, 0, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_TRANS_LOCK_ID_TRANS_LOCK, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // 
    // R_JOB_LOCK
    // 
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_JOB_LOCK;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_LOCK_ID_JOB_LOCK, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_LOCK_ID_JOB, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_LOCK_ID_USER, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_LOCK_LOCK_MESSAGE, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    table.addValueMeta(new ValueMetaDate(KettleDatabaseRepository.FIELD_JOB_LOCK_LOCK_DATE, 0, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_JOB_LOCK_ID_JOB_LOCK, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // /////////////////////////////////////////////////////////////////////////////////
    // 
    // MetaStore tables...
    // 
    // /////////////////////////////////////////////////////////////////////////////////
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_NAMESPACE
    // 
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_NAMESPACE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_NAMESPACE_ID_NAMESPACE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_NAMESPACE_NAME, (database.getDatabaseMeta().getDatabaseInterface().getMaxVARCHARLength() - 1 > 0 ? database.getDatabaseMeta().getDatabaseInterface().getMaxVARCHARLength() - 1 : KettleDatabaseRepository.REP_ORACLE_STRING_LENGTH), 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_NAMESPACE_ID_NAMESPACE, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_ELEMENT_TYPE
    // 
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_ELEMENT_TYPE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_NAMESPACE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_ELEMENT_TYPE_NAME, getRepoStringLength(), 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_ELEMENT_TYPE_DESCRIPTION, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_ELEMENT
    // 
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_ELEMENT;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_ELEMENT_ID_ELEMENT, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_ELEMENT_ID_ELEMENT_TYPE, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_ELEMENT_NAME, getRepoStringLength(), 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_ELEMENT_ID_ELEMENT, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_ELEMENT_ATTRIBUTE
    // 
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_ELEMENT_ATTRIBUTE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT, KEY, 0));
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE_PARENT, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_KEY, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_VALUE, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE, false);
    if (!Utils.isEmpty(sql)) {
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    // /////////////////////////////////////////////////////////////////////////////////
    // 
    // User tables...
    // 
    // /////////////////////////////////////////////////////////////////////////////////
    // ////////////////////////////////////////////////////////////////////////////////
    // 
    // R_USER
    // 
    // Keep a mapping between the user login and the object id
    // 
    Map<String, ObjectId> users = new Hashtable<String, ObjectId>();
    // Create table...
    // 
    boolean ok_user = true;
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_USER;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
    if (monitor != null) {
        monitor.subTask("Checking table " + schemaTable);
    }
    table.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_USER_ID_USER, KEY, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_USER_LOGIN, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_USER_PASSWORD, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_USER_NAME, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_USER_DESCRIPTION, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
    table.addValueMeta(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_USER_ENABLED, 1, 0));
    sql = database.getDDL(schemaTable, table, null, false, KettleDatabaseRepository.FIELD_USER_ID_USER, false);
    create = false;
    if (!Utils.isEmpty(sql)) {
        // Doesn't exist: create the table...
        create = sql.toUpperCase().indexOf("CREATE TABLE") >= 0;
        statements.add(sql);
        if (!dryrun) {
            if (log.isDetailed()) {
                log.logDetailed("executing SQL statements: " + Const.CR + sql);
            }
            database.execStatements(sql);
            if (log.isDetailed()) {
                log.logDetailed("Created or altered table " + schemaTable);
            }
        }
    } else {
        if (log.isDetailed()) {
            log.logDetailed("Table " + schemaTable + " is OK.");
        }
    }
    if (ok_user) {
        // 
        // Populate with data...
        // 
        user = new String[] { "admin", "guest" };
        pass = new String[] { "admin", "guest" };
        code = new String[] { "Administrator", "Guest account" };
        desc = new String[] { "User manager", "Read-only guest account" };
        if (!dryrun) {
            database.prepareInsert(table, null, tablename);
        }
        for (int i = 0; i < user.length; i++) {
            RowMetaAndData lookup = null;
            if (upgrade) {
                lookup = database.getOneRow("SELECT " + repository.quote(KettleDatabaseRepository.FIELD_USER_ID_USER) + " FROM " + schemaTable + " WHERE " + repository.quote(KettleDatabaseRepository.FIELD_USER_LOGIN) + " = '" + user[i] + "'");
            }
            if (lookup == null) {
                ObjectId nextid = new LongObjectId(i + 1);
                if (!create) {
                    nextid = repository.connectionDelegate.getNextUserID();
                }
                String password = Encr.encryptPassword(pass[i]);
                RowMetaAndData tableData = new RowMetaAndData();
                tableData.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_USER_ID_USER), nextid);
                tableData.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_USER_LOGIN), user[i]);
                tableData.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_USER_PASSWORD), password);
                tableData.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_USER_NAME), code[i]);
                tableData.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_USER_DESCRIPTION), desc[i]);
                tableData.addValue(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_USER_ENABLED), Boolean.TRUE);
                if (dryrun) {
                    sql = database.getSQLOutput(null, tablename, tableData.getRowMeta(), tableData.getData(), null);
                    statements.add(sql);
                } else {
                    database.setValuesInsert(tableData);
                    database.insertRow();
                }
                users.put(user[i], nextid);
            }
        }
        try {
            if (!dryrun) {
                database.closeInsert();
            }
            if (log.isDetailed()) {
                log.logDetailed("Populated table " + schemaTable);
            }
        } catch (KettleException dbe) {
            throw new KettleException("Unable to close insert after populating table " + schemaTable, dbe);
        }
    }
    if (monitor != null) {
        monitor.worked(1);
    }
    if (monitor != null) {
        monitor.done();
    }
    log.logBasic((upgrade ? "Upgraded" : "Created") + " " + KettleDatabaseRepository.repositoryTableNames.length + " repository tables.");
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleException(org.pentaho.di.core.exception.KettleException) RowMeta(org.pentaho.di.core.row.RowMeta) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) Hashtable(java.util.Hashtable) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) LongObjectId(org.pentaho.di.repository.LongObjectId) Date(java.util.Date) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate)

Aggregations

ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)95 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)75 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)52 Test (org.junit.Test)51 RowMeta (org.pentaho.di.core.row.RowMeta)39 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)34 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)34 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)32 ValueMetaBigNumber (org.pentaho.di.core.row.value.ValueMetaBigNumber)30 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)25 ValueMetaBinary (org.pentaho.di.core.row.value.ValueMetaBinary)20 ValueMetaTimestamp (org.pentaho.di.core.row.value.ValueMetaTimestamp)16 ValueMetaInternetAddress (org.pentaho.di.core.row.value.ValueMetaInternetAddress)15 KettleException (org.pentaho.di.core.exception.KettleException)12 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)11 KettleStepException (org.pentaho.di.core.exception.KettleStepException)7 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 RowSet (org.pentaho.di.core.RowSet)6 RowAdapter (org.pentaho.di.trans.step.RowAdapter)6