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

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


                        Column column = (Column) schemaTransaction.getTarget();
                        sql = "DELETE FROM `column` WHERE `column`.`ID` = " + column.getId() + ";";
                    }
                }
            } else if (transaction.getClass() == DataTransaction.class) {
                DataTransaction dataTransaction = (DataTransaction) transaction;
                String data = dataTransaction.getCell().getData();
                if (dataTransaction.getType() == TransactionType.INSERT) {
                    if (data != null) {
                        sql = "INSERT INTO `cell`(`cell`.`PRIMARY_KEY_VALUE`, `cell`.`DATA`, `cell`.`COLUMN_ID`) VALUES('" + TransactionConverter.escapeSQL(dataTransaction.getCell().getPrimaryKeyValue()) + "', '" + TransactionConverter.escapeSQL(dataTransaction.getCell().getData()) + "', " + dataTransaction.getCell().getColumn().getId() + ");";
                    } else {
                        sql = "INSERT INTO `cell`(`cell`.`PRIMARY_KEY_VALUE`, `cell`.`DATA`, `cell`.`COLUMN_ID`) VALUES('" + TransactionConverter.escapeSQL(dataTransaction.getCell().getPrimaryKeyValue()) + "', NULL, " + dataTransaction.getCell().getColumn().getId() + ");";
                    }
                } else if (dataTransaction.getType() == TransactionType.UPDATE) {
                    if (data != null) {
                        sql = "UPDATE `cell` SET `cell`.`DATA` = '" + TransactionConverter.escapeSQL(data) + "' WHERE `cell`.`ID` = " + dataTransaction.getCell().getId() + ";";
                    } else {
                        sql = "UPDATE `cell` SET `cell`.`DATA` = NULL WHERE `cell`.`ID` = " + dataTransaction.getCell().getId() + ";";
                    }
                } else if (dataTransaction.getType() == TransactionType.DELETE) {
                    sql = "DELETE FROM `cell` WHERE `cell`.`ID` = " + dataTransaction.getCell().getId() + ";";
                }
            } else if (transaction.getClass() == LoggableTransaction.class) {
                LoggableTransaction loggableTransaction = (LoggableTransaction) transaction;
                sql = "INSERT INTO `transaction`(`transaction`.`TYPE`, `transaction`.`TABLE_ID`, `transaction`.`CREATED_DATETIME`) VALUES('" + loggableTransaction.getType() + "', " + loggableTransaction.getTable().getId() + ", NOW());";
            } else if (transaction.getClass() == LoggableTransactionDatum.class) {
View Full Code Here


//            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);
        processTransactions(transactionList);
View Full Code Here

        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);
        processTransactions(transactionList);
View Full Code Here

            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;
View Full Code Here

TOP

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

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.