Search in sources :

Example 66 with ValueMetaDate

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

the class KettleDatabaseRepository method insertLogEntry.

// ///////////////////////////////////////////////////////////////////////////////////
// INSERT VALUES
// ///////////////////////////////////////////////////////////////////////////////////
public synchronized ObjectId insertLogEntry(String description) throws KettleException {
    ObjectId id = connectionDelegate.getNextLogID();
    RowMetaAndData table = new RowMetaAndData();
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_REPOSITORY_LOG_ID_REPOSITORY_LOG), id);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_REPOSITORY_LOG_REP_VERSION), getVersion());
    table.addValue(new ValueMetaDate(KettleDatabaseRepository.FIELD_REPOSITORY_LOG_LOG_DATE), new Date());
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_REPOSITORY_LOG_LOG_USER), getUserInfo() != null ? getUserInfo().getLogin() : "admin");
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_REPOSITORY_LOG_OPERATION_DESC), description);
    connectionDelegate.insertTableRow(KettleDatabaseRepository.TABLE_R_REPOSITORY_LOG, table);
    return id;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Date(java.util.Date) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate)

Example 67 with ValueMetaDate

use of org.pentaho.di.core.row.value.ValueMetaDate 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)

Example 68 with ValueMetaDate

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

the class CacheDatabaseMetaTest method testSQLStatements.

@Test
public void testSQLStatements() {
    assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR VARCHAR(15) ) ", cdm.getAddColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR TIMESTAMP ) ", cdm.getAddColumnStatement("FOO", new ValueMetaDate("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR TIMESTAMP ) ", cdm.getAddColumnStatement("FOO", new ValueMetaTimestamp("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR CHAR(1) ) ", cdm.getAddColumnStatement("FOO", new ValueMetaBoolean("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR INT ) ", cdm.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 0, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR DOUBLE ) ", // I believe this is a bug!
    cdm.getAddColumnStatement("FOO", new ValueMetaInteger("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR DOUBLE ) ", cdm.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 10, -7), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR DOUBLE ) ", cdm.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", -10, 7), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR DECIMAL(5, 7) ) ", cdm.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 5, 7), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD COLUMN ( BAR  UNKNOWN ) ", cdm.getAddColumnStatement("FOO", new ValueMetaInternetAddress("BAR"), "", false, "", false));
    String lineSep = System.getProperty("line.separator");
    assertEquals("ALTER TABLE FOO DROP COLUMN BAR" + lineSep, cdm.getDropColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", true));
    assertEquals("ALTER TABLE FOO ALTER COLUMN BAR VARCHAR(15)", cdm.getModifyColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", true));
}
Also used : ValueMetaTimestamp(org.pentaho.di.core.row.value.ValueMetaTimestamp) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaInternetAddress(org.pentaho.di.core.row.value.ValueMetaInternetAddress) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Test(org.junit.Test)

Example 69 with ValueMetaDate

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

the class Exasol4DatabaseMetaTest method testSQLStatements.

@Test
public void testSQLStatements() {
    assertEquals(" WHERE ROWNUM <= 15", nativeMeta.getLimitClause(15));
    assertEquals("SELECT /*+FIRST_ROWS*/ * FROM FOO WHERE 1=0", nativeMeta.getSQLQueryFields("FOO"));
    assertEquals("SELECT /*+FIRST_ROWS*/ * FROM FOO WHERE 1=0", nativeMeta.getSQLTableExists("FOO"));
    assertEquals("SELECT /*+FIRST_ROWS*/ FOO FROM BAR WHERE 1=0", nativeMeta.getSQLQueryColumnFields("FOO", "BAR"));
    assertEquals("SELECT /*+FIRST_ROWS*/ FOO FROM BAR WHERE 1=0", nativeMeta.getSQLColumnExists("FOO", "BAR"));
    String lineSep = System.getProperty("line.separator");
    assertEquals("ALTER TABLE FOO DROP COLUMN BAR" + lineSep, nativeMeta.getDropColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", true));
    assertEquals("ALTER TABLE FOO ADD ( BAR TIMESTAMP ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaDate("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD ( BAR TIMESTAMP ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaTimestamp("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD ( BAR BOOLEAN ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBoolean("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD ( BAR DECIMAL ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD ( BAR DECIMAL ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD ( BAR DECIMAL(15) ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 15, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD ( BAR DECIMAL(15) ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 15, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD ( BAR DECIMAL(15, 5) ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 15, 5), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD ( BAR DECIMAL(15, 5) ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 15, 5), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD ( BAR INTEGER ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD ( BAR VARCHAR(15) ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD ( BAR VARCHAR(2000000) ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaString("BAR", nativeMeta.getMaxVARCHARLength() + 15, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD ( BAR UNKNOWN ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInternetAddress("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD ( BAR BIGINT NOT NULL PRIMARY KEY ) ", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR"), "BAR", false, "", false));
}
Also used : ValueMetaTimestamp(org.pentaho.di.core.row.value.ValueMetaTimestamp) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) ValueMetaInternetAddress(org.pentaho.di.core.row.value.ValueMetaInternetAddress) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Test(org.junit.Test)

Example 70 with ValueMetaDate

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

the class HypersonicDatabaseMetaTest method testSQLStatements.

@Test
public void testSQLStatements() throws Exception {
    HypersonicDatabaseMeta nativeMeta = new HypersonicDatabaseMeta();
    nativeMeta.setAccessType(DatabaseMeta.TYPE_ACCESS_NATIVE);
    HypersonicDatabaseMeta odbcMeta = new HypersonicDatabaseMeta();
    odbcMeta.setAccessType(DatabaseMeta.TYPE_ACCESS_ODBC);
    assertEquals("TRUNCATE TABLE FOO", nativeMeta.getTruncateTableStatement("FOO"));
    assertEquals("SELECT * FROM FOO", nativeMeta.getSQLQueryFields("FOO"));
    assertEquals("SELECT 1 FROM FOO", nativeMeta.getSQLTableExists("FOO"));
    assertEquals("ALTER TABLE FOO ADD BAR TIMESTAMP", nativeMeta.getAddColumnStatement("FOO", new ValueMetaDate("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR TIMESTAMP", nativeMeta.getAddColumnStatement("FOO", new ValueMetaTimestamp("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR CHAR(1)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBoolean("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 10, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 10, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR", 10, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR DOUBLE PRECISION", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 0, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR INTEGER", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 5, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR NUMERIC(10, 3)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 10, 3), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR NUMERIC(10, 3)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 10, 3), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR NUMERIC(21, 4)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 21, 4), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR LONGVARCHAR", nativeMeta.getAddColumnStatement("FOO", new ValueMetaString("BAR", nativeMeta.getMaxVARCHARLength() + 2, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR VARCHAR(15)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT", // Bug here - invalid SQL
    nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 10, -7), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR NUMERIC(22, 7)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 22, 7), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR DOUBLE PRECISION", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", -10, 7), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR NUMERIC(5, 7)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 5, 7), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR  UNKNOWN", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInternetAddress("BAR"), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0, INCREMENT BY 1) PRIMARY KEY", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR"), "BAR", true, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0, INCREMENT BY 1) PRIMARY KEY", nativeMeta.getAddColumnStatement("FOO", new ValueMetaNumber("BAR", 26, 8), "BAR", true, "", false));
    String lineSep = System.getProperty("line.separator");
    assertEquals("ALTER TABLE FOO DROP BAR" + lineSep, nativeMeta.getDropColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", true));
    assertEquals("ALTER TABLE FOO ALTER COLUMN BAR VARCHAR(15)", nativeMeta.getModifyColumnStatement("FOO", new ValueMetaString("BAR", 15, 0), "", false, "", true));
    assertEquals("ALTER TABLE FOO ALTER COLUMN BAR VARCHAR()", // I think this is a bug ..
    nativeMeta.getModifyColumnStatement("FOO", new ValueMetaString("BAR"), "", false, "", true));
    assertEquals("ALTER TABLE FOO ADD BAR SMALLINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR", 4, 0), "", true, "", false));
    // do a boolean check
    odbcMeta.setSupportsBooleanDataType(true);
    assertEquals("ALTER TABLE FOO ADD BAR BOOLEAN", odbcMeta.getAddColumnStatement("FOO", new ValueMetaBoolean("BAR"), "", false, "", false));
    odbcMeta.setSupportsBooleanDataType(false);
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0, INCREMENT BY 1) PRIMARY KEY", nativeMeta.getAddColumnStatement("FOO", new ValueMetaInteger("BAR"), "BAR", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR BIGINT", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 10, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR NUMERIC(22, 0)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBigNumber("BAR", 22, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR VARCHAR(1)", nativeMeta.getAddColumnStatement("FOO", new ValueMetaString("BAR", 1, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR LONGVARCHAR", nativeMeta.getAddColumnStatement("FOO", new ValueMetaString("BAR", 16777250, 0), "", false, "", false));
    assertEquals("ALTER TABLE FOO ADD BAR  UNKNOWN", nativeMeta.getAddColumnStatement("FOO", new ValueMetaBinary("BAR", 16777250, 0), "", false, "", false));
    assertEquals("insert into FOO(FOOKEY, FOOVERSION) values (0, 1)", nativeMeta.getSQLInsertAutoIncUnknownDimensionRow("FOO", "FOOKEY", "FOOVERSION"));
}
Also used : ValueMetaTimestamp(org.pentaho.di.core.row.value.ValueMetaTimestamp) ValueMetaBinary(org.pentaho.di.core.row.value.ValueMetaBinary) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) ValueMetaInternetAddress(org.pentaho.di.core.row.value.ValueMetaInternetAddress) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Test(org.junit.Test)

Aggregations

ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)104 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)63 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)59 Test (org.junit.Test)50 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)44 RowMeta (org.pentaho.di.core.row.RowMeta)43 ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)34 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)33 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)25 ValueMetaBigNumber (org.pentaho.di.core.row.value.ValueMetaBigNumber)23 ValueMetaTimestamp (org.pentaho.di.core.row.value.ValueMetaTimestamp)21 Calendar (java.util.Calendar)17 Date (java.util.Date)17 KettleException (org.pentaho.di.core.exception.KettleException)15 ValueMetaInternetAddress (org.pentaho.di.core.row.value.ValueMetaInternetAddress)15 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)14 ValueMetaBinary (org.pentaho.di.core.row.value.ValueMetaBinary)13 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)10 KettleStepException (org.pentaho.di.core.exception.KettleStepException)10 SQLException (java.sql.SQLException)8