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

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


    private List<LoggableTransactionDatum> generateLoggableTransactionDatumList(LoggableTransaction loggableTransaction) throws InaccessibleConfigurationFileException, DriverNotFoundException, SQLException {
        List<LoggableTransactionDatum> loggableTransactionDatumList = new ArrayList<LoggableTransactionDatum>();
        Statement statement = connection.createStatement();
        ResultSet rs = statement.executeQuery("SELECT `transaction_data`.`ID`, `transaction_data`.`DATA`, `transaction_data`.`COLUMN_ID`, `transaction_data`.`TRANSACTION_ID` FROM `transaction_data` WHERE `transaction_data`.`TRANSACTION_ID` = " + loggableTransaction.getId() + ";");
        while (rs.next()) {
            Cell cell = new Cell(rs.getInt("ID"), rs.getString("DATA"));
            cell.setColumn(findColumn(rs.getInt("COLUMN_ID")));
            LoggableTransactionDatum loggableTransactionDatum = new LoggableTransactionDatum(cell, loggableTransaction);
            loggableTransactionDatumList.add(loggableTransactionDatum);
        }
        return loggableTransactionDatumList;
    }
View Full Code Here


        String pk = null;
        for (Column column : table.getColumnList()) {
//            if (pk == null) {
//                pk = sourceRs.getString("PK");
//            }
            Cell cell = new Cell(sourcePk, sourceRs.getString(column));
            cell.setColumn(column);
            transactionList.add(new DataTransaction(cell, TransactionType.INSERT));
            loggableTransactionDatumList.add(new LoggableTransactionDatum(cell, loggableTransaction));
        }
        loggableTransaction.setLoggableTransactionDatumList(loggableTransactionDatumList);
        transactionList.add(loggableTransaction);
View Full Code Here

    private void delete(Table table, ShadowResultSet shadowRs) throws SQLException {
        List<Transaction> transactionList = new ArrayList<Transaction>();
        LoggableTransaction loggableTransaction = new LoggableTransaction(table, TransactionType.DELETE);
        List<LoggableTransactionDatum> loggableTransactionDatumList = new ArrayList<LoggableTransactionDatum>();
        for (Column column : table.getColumnList()) {
            Cell cell = shadowRs.getCell(column);
            cell.setColumn(column);
            transactionList.add(new DataTransaction(cell, TransactionType.DELETE));
            loggableTransactionDatumList.add(new LoggableTransactionDatum(cell, loggableTransaction));
        }
        loggableTransaction.setLoggableTransactionDatumList(loggableTransactionDatumList);
        transactionList.add(loggableTransaction);
View Full Code Here

             * Ensure cells associated with new columns are created
             */
//            if (pk == null) {
//                pk = sourceRs.getString("PK");              
//            }
            Cell shadowCell = shadowRs.getCell(column);
            String sourceColumnValue = sourceRs.getString(column);
            if (shadowCell == null) {
                Cell cell = new Cell(shadowRs.getCell("PK").getData(), sourceColumnValue);
                cell.setColumn(column);
                transactionList.add(new DataTransaction(cell, TransactionType.INSERT));
                loggableTransactionDatumList.add(new LoggableTransactionDatum(cell, loggableTransaction));
                continue;
            }
            /*
             * Judge which columns we need to compare
             */
            String shadowColumnValue = shadowRs.getCell(column).getData();
            boolean pkColumn = table.getPk().contains(column.getName() + ",");
            boolean compare = (shadowColumnValue != null && sourceColumnValue != null)//compare only if both values are not null and this column is not (part of) the primary key
                    && !pkColumn;
            boolean ignore = (shadowColumnValue == null && sourceColumnValue == null);//if both values are null, no update has taken place
            boolean update = false;
            if (compare) {
                update = !shadowColumnValue.equals(sourceColumnValue);//if both values are not equal then an update has taken place
            } else {
                if (!pkColumn) {
                    update = !ignore;//if only one value is null then an update has taken place
                }
            }
            if (update) {
                Cell cell = shadowRs.getCell(column);
                cell.setData(sourceColumnValue);
                cell.setColumn(column);
                transactionList.add(new DataTransaction(cell, TransactionType.UPDATE));
                loggableTransactionDatumList.add(new LoggableTransactionDatum(cell, loggableTransaction));
            }
        }
        if (!loggableTransactionDatumList.isEmpty()) {
            // String pk = null;
            Cell cell = shadowRs.getCell("PK");
//            cell.setData(sourceRs.getString("PK"));
            cell.setData(sourcePk);

            //TODO: Accommodate cases where the pk is not the first column of the table
            cell.setColumn(table.getColumnList().get(0));
            loggableTransactionDatumList.add(new LoggableTransactionDatum(cell, loggableTransaction));

            loggableTransaction.setLoggableTransactionDatumList(loggableTransactionDatumList);
            transactionList.add(loggableTransaction);
        }
View Full Code Here

        if (!hasNext) {
            return false;
        } else {
            valueMap.clear();
            String pkValue = rs.getString("PRIMARY_KEY_VALUE");
            valueMap.put("PK", new Cell(rs.getInt("ID"), pkValue, pkValue));
            do {
                valueMap.put("C" + rs.getInt("COLUMN_ID"), new Cell(rs.getInt("ID"),
                        pkValue, rs.getString("DATA")));
                hasNext = rs.next();
            } while (hasNext && rs.getString("PRIMARY_KEY_VALUE").equals(pkValue));
        }
        return true;
View Full Code Here

TOP

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

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.