Example #1
0
  /**
   * Abort current transaction and rollback operations.
   *
   * @param fireEvent
   */
  public void abort(boolean fireEvent) {
    if (!aborted && active) {
      if (transaction != null) {
        transaction.executeSQL(
            "invalid sql statement",
            null,
            null,
            new SQLTransaction.SQLStatementErrorCallback() {
              @Override
              public boolean onError(SQLTransaction tx, SQLError error) {
                return true; // tell web sql to rollback transaction
              }
            });

        transaction = null;
      }
      aborted = true;
      active = false;
      requestProcessor.stop();
      if (fireEvent) {
        if (LogConfiguration.loggingIsEnabled()) {
          logger.log(Level.INFO, db.messages.databaseTransactionAborted(db.getName()));
        }
        if (transactionCallback != null) {
          try {
            transactionCallback.onAbort();
          } catch (Exception e) {
            String message = db.messages.databaseTransactionError(db.getName(), e.getMessage());
            reportError(transactionCallback, message, e);
          }
        }
      }
    }
  }
Example #2
0
 public void onError(String errorMessage) {
   String message = db.messages.databaseTransactionError(db.getName(), errorMessage);
   active = false;
   requestProcessor.stop();
   if (LogConfiguration.loggingIsEnabled()) {
     logger.log(Level.SEVERE, message);
   }
   if (transactionCallback != null) {
     transactionCallback.onError(message);
   }
 }
Example #3
0
 public void onSuccess() {
   if (LogConfiguration.loggingIsEnabled()) {
     logger.log(Level.INFO, db.messages.databaseTransactionCompleted(db.getName()));
   }
   active = false;
   requestProcessor.stop();
   if (transactionCallback != null) {
     try {
       transactionCallback.onComplete();
     } catch (Exception e) {
       String message = db.messages.databaseTransactionError(db.getName(), e.getMessage());
       reportError(transactionCallback, message, e);
     }
   }
 }