Examples of ShadowResultSet


Examples of ke.go.moh.oec.oecsm.sync.data.resultsets.ShadowResultSet

        shadowDataMiner.start();
        Database shadowDb = new ShadowSchemaMiner().mine(true);

        for (Table table : shadowDb.getTableList()) {
            SourceResultSet sourceRs = sourceDataMiner.mine(table);
            ShadowResultSet shadowRs = shadowDataMiner.mine(table);

            sourceRsHasRecords = sourceRs.next();
            shadowRsHasRecords = shadowRs.next();

            String tempSourcePk = null;
            boolean sourceRsMovedNext = true;
            while (sourceRsHasRecords || shadowRsHasRecords) {
                if (sourceRsHasRecords && !shadowRsHasRecords) {
                    String sourcePk = sourceRs.getString("PK");
                    insert(table, sourcePk, sourceRs);
                } else if (!sourceRsHasRecords && shadowRsHasRecords) {
                    delete(table, shadowRs);
                } else if (sourceRsHasRecords && shadowRsHasRecords) {
                    String sourcePk;
                    if (!sourceRsMovedNext) {
                        sourcePk = tempSourcePk;
                    } else {
                        sourcePk = sourceRs.getString("PK");
                    }
                    tempSourcePk = sourcePk;

                    String shadowPk = shadowRs.getCell("PK").getData();
                    if (sourcePk.compareTo(shadowPk) < 0) {
                        insert(table, sourcePk, sourceRs);
                        sourceRsMovedNext = true;
                    } else if (sourcePk.compareTo(shadowPk) > 0) {
                        delete(table, shadowRs);
                        sourceRsMovedNext = false;
                    } else if (sourcePk.compareTo(shadowPk) == 0) {
                        update(table, sourcePk, sourceRs, shadowRs);
                        sourceRsMovedNext = true;
                    }
                }
            }
            sourceRs.close();
            shadowRs.close();
        }
        sourceDataMiner.finish();
        shadowDataMiner.finish();
    }
View Full Code Here

Examples of ke.go.moh.oec.oecsm.sync.data.resultsets.ShadowResultSet

        // is being stored in MySQL.
        statement.setFetchSize(Integer.MIN_VALUE);
    }

    public ShadowResultSet mine(Table table) throws InaccessibleConfigurationFileException, SQLException, DriverNotFoundException {
        ShadowResultSet srs = null;
        try {
            String sql = "SELECT `cell`.`ID`, `cell`.`PRIMARY_KEY_VALUE`, `cell`.`DATA`, `cell`.`COLUMN_ID` FROM `cell` WHERE `COLUMN_ID` IN (";
            for (Column c : table.getColumnList()) {
                sql += c.getId() + ", "; // Add anyway, but the final one will be stripped.
            }
            sql = sql.substring(0, sql.length() - 2); // Strip the final ", ".
            sql += ") ORDER BY ASCII(`cell`.`PRIMARY_KEY_VALUE`), `cell`.`PRIMARY_KEY_VALUE` ASC";
            Mediator.getLogger(ShadowDataMiner.class.getName()).log(Level.FINEST, sql);
            ResultSet rs = statement.executeQuery(sql);
            srs = new ShadowResultSet(rs);
        } finally {
        }
        return srs;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.