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

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


        sourceDataMiner.start();
        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


     * @param table
     * @return
     * @throws SQLException
     */
    public SourceResultSet mine(Table table) throws SQLException {
        SourceResultSet srs = null;
        try {
            String compositePK = getQueryCustomizer().buildCompositePrimaryKey(table);
            String asciiCompositePK = getQueryCustomizer().buildAsciiCompositePrimaryKey(compositePK);
            String sql = "SELECT " + asciiCompositePK + " AS ASCII_ID, " + compositePK + " AS PK";
            String prefix = getQueryCustomizer().getOpenningSafetyPad();
            String suffix = getQueryCustomizer().getClosingSafetyPad();
            for (Column column : table.getColumnList()) {
                sql += ", " + prefix + column.getName() + suffix + " AS C" + column.getId();
            }
            sql += " FROM " + prefix + table.getName() + suffix + " ORDER BY 1 ASC, " + compositePK + " ASC";
            Mediator.getLogger(SourceDataMiner.class.getName()).log(Level.FINEST, sql);
            ResultSet rs = statement.executeQuery(sql);
            srs = new SourceResultSet(rs);
        } finally {
        }
        return srs;
    }
View Full Code Here

TOP

Related Classes of ke.go.moh.oec.oecsm.sync.data.resultsets.SourceResultSet

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.