Example usage for javax.sql.rowset.spi SyncResolver UPDATE_ROW_CONFLICT

List of usage examples for javax.sql.rowset.spi SyncResolver UPDATE_ROW_CONFLICT

Introduction

In this page you can find the example usage for javax.sql.rowset.spi SyncResolver UPDATE_ROW_CONFLICT.

Prototype

int UPDATE_ROW_CONFLICT

To view the source code for javax.sql.rowset.spi SyncResolver UPDATE_ROW_CONFLICT.

Click Source Link

Document

Indicates that a conflict occurred while the RowSet object was attempting to update a row in the data source.

Usage

From source file:com.egt.core.db.util.DBUtils.java

public static String getTransactionLabel(int status) {
    String value;//from ww  w  . ja v  a 2s  .com
    switch (status) {
    case SyncResolver.INSERT_ROW_CONFLICT:
        value = DBC.COMANDO_INSERT;
        break;
    case SyncResolver.UPDATE_ROW_CONFLICT:
        value = DBC.COMANDO_UPDATE;
        break;
    case SyncResolver.DELETE_ROW_CONFLICT:
        value = DBC.COMANDO_DELETE;
        break;
    default:
        value = DBC.COMANDO_COMMIT;
        break;
    }
    return value;
}

From source file:ips1ap101.lib.core.db.util.DBUtils.java

public static String getTransactionLabel(int status) {
    String value;//ww  w  .  j a v a2s . c  o  m
    switch (status) {
    case SyncResolver.INSERT_ROW_CONFLICT:
        value = BundleWebui.getString("database.insert.command");
        break;
    case SyncResolver.UPDATE_ROW_CONFLICT:
        value = BundleWebui.getString("database.update.command");
        break;
    case SyncResolver.DELETE_ROW_CONFLICT:
        value = BundleWebui.getString("database.delete.command");
        break;
    default:
        value = BundleWebui.getString("database.commit.command");
        break;
    }
    return value;
}

From source file:com.egt.core.db.xdp.RecursoCachedRowSetDataProvider.java

private boolean esFilaValida(RowKey rowKey, boolean cursor) throws ExcepcionAplicacion {
    Bitacora.trace(this.getClass(), "esFilaValida", rowKey, String.valueOf(cursor));
    try {//from   w  w w .  ja  va2 s  . c o  m
        long funcion = -1L;
        int status = SyncResolver.NO_ROW_CONFLICT;
        int tipoError = 3; /* OJO con la constante, 3 -> fila con uno o mas errores, todos conocidos */
        boolean ejecutada = false;
        boolean autorizada = false;
        String comando;
        String mensaje;
        if (cursor) {
            this.setCursorRow(rowKey); /* throws TableCursorVetoException */
        }
        if (this.getCachedRowSet().rowInserted()) { /* throws SQLException */
            funcion = this.getFuncionInsert();
            status = SyncResolver.INSERT_ROW_CONFLICT;
            ejecutada = true; /* this.isFuncionInsertEjecutada(); */
            autorizada = this.isFuncionInsertAutorizada();
        } else {
            if (this.getCachedRowSet().rowUpdated()) { /* throws SQLException */
                funcion = this.getFuncionUpdate();
                status = SyncResolver.UPDATE_ROW_CONFLICT;
                ejecutada = true; /* this.isFuncionUpdateEjecutada(); */
                autorizada = this.isFuncionUpdateAutorizada();
            }
        }
        boolean es = true;
        if (ejecutada) {
            this.filasProcesadasPorConfirmar++;
            if (autorizada) {
                es = this.esFilaValida(rowKey, funcion); /* check */
                if (es) {
                    Bitacora.trace(CBM2.CHECK_CHANGES_1, this.getEtiquetaRecurso(rowKey));
                } else {
                    comando = DBUtils.getTransactionLabel(status);
                    mensaje = tipoError + TLC.getBitacora().error(CBM2.CHECK_CHANGES_EXCEPTION_2, comando,
                            this.getEtiquetaRecurso(rowKey));
                    this.getFilasConflictivas().put(rowKey.getRowId(), mensaje);
                }
            } else {
                comando = DBUtils.getTransactionLabel(status);
                mensaje = tipoError + TLC.getBitacora().error(CBM2.CHECK_CHANGES_EXCEPTION_2, comando,
                        this.getEtiquetaRecurso(rowKey));
                this.getFilasConflictivas().put(rowKey.getRowId(), mensaje);
            }
        } else {
            Bitacora.trace(CBM2.CHECK_CHANGES_2, this.getEtiquetaRecurso(rowKey));
        }
        return es;
    } catch (IllegalArgumentException | SQLException | DataProviderException ex) {
        TLC.getBitacora().fatal(ex);
        throw new ExcepcionAplicacion(ex);
    }
}

From source file:ips1ap101.lib.core.db.xdp.RecursoCachedRowSetDataProvider.java

private boolean esFilaValida(RowKey rowKey, boolean cursor) throws ExcepcionAplicacion {
    Bitacora.trace(getClass(), "esFilaValida", rowKey, String.valueOf(cursor));
    if (isNotRowAvailable(rowKey)) {
        return false;
    }/*from   w  w w .ja  v a 2 s . co  m*/
    try {
        long funcion = -1L;
        int status = SyncResolver.NO_ROW_CONFLICT;
        int tipoError = 3; /* OJO con la constante, 3 -> fila con uno o mas errores, todos conocidos */
        boolean ejecutada = false;
        boolean autorizada = false;
        String comando;
        String mensaje;
        if (cursor) {
            setCursorRow(rowKey); /* throws TableCursorVetoException */
        }
        if (getCachedRowSet().rowInserted()) { /* throws SQLException */
            funcion = getFuncionInsert();
            status = SyncResolver.INSERT_ROW_CONFLICT;
            ejecutada = true; /* isFuncionInsertEjecutada(); */
            autorizada = isFuncionInsertAutorizada();
        } else {
            if (getCachedRowSet().rowUpdated()) { /* throws SQLException */
                funcion = getFuncionUpdate();
                status = SyncResolver.UPDATE_ROW_CONFLICT;
                ejecutada = true; /* isFuncionUpdateEjecutada(); */
                autorizada = isFuncionUpdateAutorizada();
            }
        }
        boolean es = true;
        if (ejecutada) {
            filasProcesadasPorConfirmar++;
            if (autorizada) {
                es = esFilaValida(rowKey, funcion); /* check */
                if (es) {
                    Bitacora.trace(CBM.CHECK_CHANGES_1, getEtiquetaRecurso(rowKey));
                } else {
                    comando = DBUtils.getTransactionLabel(status);
                    mensaje = tipoError + TLC.getBitacora().error(CBM.CHECK_CHANGES_EXCEPTION_2, comando,
                            getEtiquetaRecurso(rowKey));
                    getFilasConflictivas().put(rowKey.getRowId(), mensaje);
                }
            } else {
                comando = DBUtils.getTransactionLabel(status);
                mensaje = tipoError + TLC.getBitacora().error(CBM.CHECK_CHANGES_EXCEPTION_2, comando,
                        getEtiquetaRecurso(rowKey));
                getFilasConflictivas().put(rowKey.getRowId(), mensaje);
            }
        } else {
            Bitacora.trace(CBM.CHECK_CHANGES_2, getEtiquetaRecurso(rowKey));
        }
        return es;
    } catch (IllegalArgumentException | SQLException | DataProviderException ex) {
        TLC.getBitacora().fatal(ex);
        throw new ExcepcionAplicacion(ex);
    }
}