Package ke.go.moh.oec.oecsm.data

Examples of ke.go.moh.oec.oecsm.data.Table


        statement.close();
        return column;
    }

    private Table findTable(int id) throws SQLException, InaccessibleConfigurationFileException, DriverNotFoundException {
        Table table = null;
        Statement statement = connection.createStatement();
        ResultSet rs = statement.executeQuery("SELECT `table`.`ID`, `table`.`NAME`, `table`.`PRIMARY_KEYS`, `table`.`DATABASE_ID` FROM `table` WHERE `table`.`ID` = " + id + "");
        if (rs.next()) {
            table = new Table(rs.getInt("ID"), rs.getString("NAME"), rs.getString("PRIMARY_KEYS"));
            table.setDatabase(findDatabase(rs.getInt("DATABASE_ID")));
        }
        rs.close();
        statement.close();
        return table;
    }
View Full Code Here


            tableRs.close();
        }
    }

    private void setupTable(Database database, String tableName, String tableType) throws SQLException {
        Table ts = new Table(tableName);
        String pks;
        if (url.contains("odbc")) {
            pks = extractAccessPrimaryKeys(ts);
        } else {
            pks = extractPrimaryKeys(ts);
        }

        // If it's a table, insist that it has a primary key.
        // If it's a view, we will assume the first column is the primary key.
        if (!pks.equals("") || tableType.equals("VIEW")) {
            ts.setPk(pks);
            ts.setDatabase(database);
            populateColumnList(ts);
            database.getTableList().add(ts);
        }
    }
View Full Code Here

                if (!shadowDatabase.getTableList().contains(table)) {
                    table.setDatabase(shadowDatabase);
                    schemaTransactionList.add(new SchemaTransaction(table, TransactionType.INSERT));
                    schemaTransactionList.addAll(generateColumnTransactions(table, null));
                } else {
                    Table shadowTable = shadowDatabase.getTableList().get(shadowDatabase.getTableList().indexOf(table));
                    if (!table.getPk().equals(shadowTable.getPk())) {
                        table.setId(shadowTable.getId());
                        schemaTransactionList.add(new SchemaTransaction(table, TransactionType.UPDATE));
                    }
                    schemaTransactionList.addAll(generateColumnTransactions(table, shadowTable));
                }
            }
View Full Code Here

                if (schemaTransaction.getType() == TransactionType.INSERT) {
                    if (schemaTransaction.getTarget().getClass() == Database.class) {
                        Database database = (Database) schemaTransaction.getTarget();
                        sql = "INSERT INTO `database` (`database`.`NAME`) VALUES ('" + TransactionConverter.escapeSQL(database.getName()) + "');";
                    } else if (schemaTransaction.getTarget().getClass() == Table.class) {
                        Table table = (Table) schemaTransaction.getTarget();
                        sql = "INSERT INTO `table` (`table`.`NAME`, `table`.`PRIMARY_KEYS`, `table`.`DATABASE_ID`) VALUES ('" + TransactionConverter.escapeSQL(table.getName()) + "', '" + TransactionConverter.escapeSQL(table.getPk()) + "', " + table.getDatabase().getId() + ");";
                    } else if (schemaTransaction.getTarget().getClass() == Column.class) {
                        Column cs = (Column) schemaTransaction.getTarget();
                        sql = "INSERT INTO `column` (`column`.`NAME`, `column`.`ORDINAL_POSITION`, `column`.`DATA_TYPE`, `column`.`SIZE`, `column`.`REPLICABLE`, `column`.`TABLE_ID`) VALUES('" + TransactionConverter.escapeSQL(cs.getName()) + "', " + cs.getOrdinalPosition() + ", '" + TransactionConverter.escapeSQL(cs.getDataType()) + "', " + cs.getSize() + ", " + cs.isReplicable() + ", " + cs.getTable().getId() + ");";
                    }
                } else if (schemaTransaction.getType() == TransactionType.UPDATE) {
                    if (schemaTransaction.getTarget().getClass() == Table.class) {
                        Table table = (Table) schemaTransaction.getTarget();
                        sql = "UPDATE `table` SET `table`.`PRIMARY_KEYS` = '" + table.getPk() + "' WHERE `table`.`ID` = " + table.getId() + ";";
                    } else if (schemaTransaction.getTarget().getClass() == Column.class) {
                        Column column = (Column) schemaTransaction.getTarget();
                        sql = "UPDATE `column` SET `column`.`ORDINAL_POSITION` = " + column.getOrdinalPosition() + ", `column`.`DATA_TYPE` = '" + column.getDataType() + "', `column`.`SIZE` = " + column.getSize() + " WHERE `column`.`ID` = " + column.getId() + ";";
                    }
                } else if (schemaTransaction.getType() == TransactionType.DELETE) {
                    if (schemaTransaction.getTarget().getClass() == Database.class) {
                        Database database = (Database) schemaTransaction.getTarget();
                        sql = "DELETE FROM `database` WHERE `database`.`ID` = " + database.getId() + ";";
                    } else if (schemaTransaction.getTarget().getClass() == Table.class) {
                        Table table = (Table) schemaTransaction.getTarget();
                        sql = "DELETE FROM `table` WHERE `table`.`ID` = " + table.getId() + ";";
                    } else if (schemaTransaction.getTarget().getClass() == Column.class) {
                        Column column = (Column) schemaTransaction.getTarget();
                        sql = "DELETE FROM `column` WHERE `column`.`ID` = " + column.getId() + ";";
                    }
                }
View Full Code Here

        Statement statement = connection.createStatement();
        String sql = "SELECT `table`.`ID`, `table`.`NAME`, `PRIMARY_KEYS` FROM `table` WHERE `table`.`DATABASE_ID` = " + db.getId() + "";
        Mediator.getLogger(ShadowSchemaMiner.class.getName()).log(Level.FINEST, sql);
        ResultSet rs = statement.executeQuery(sql);
        while (rs.next()) {
            Table table = new Table(rs.getInt("ID"), rs.getString("NAME"), rs.getString("PRIMARY_KEYS"));
            table.setDatabase(db);
            if (replicable) {
                populateColumnList(table);
            } else {
                populateReplicableColumnList(table);
            }
View Full Code Here

TOP

Related Classes of ke.go.moh.oec.oecsm.data.Table

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.