예제 #1
0
void IndexWriter::updateDocument(const DocumentPtr& pDocument)
{
    m_pDocConsumer->consume(pDocument);

    ++m_nOpCountSinceLastCommit;
    if (autoCommit())
    {
        // Perform commit automatically
        commit();
    }
}
예제 #2
0
QoreHashNode* Datasource::describe(const QoreString* query_str, const QoreListNode* args, ExceptionSink* xsink) {
   QoreHashNode* rv = qore_dbi_private::get(*priv->dsl)->describe(this, query_str, args, xsink);
   autoCommit(xsink);

   // set active_transaction flag if in a transaction and the active_transaction flag
   // has not yet been set and no exception was raised
   if (priv->in_transaction && !priv->active_transaction && !*xsink)
      priv->active_transaction = true;

   return rv;
}
예제 #3
0
void IndexWriter::addDocument(const DocumentPtr& pDocument)
{
    FX_DEBUG("Add one document");
    pDocument->setAction(Document::AT_ADD);
    m_pDocConsumer->consume(pDocument);
    ++m_nOpCountSinceLastCommit;

    if (autoCommit())
    {
        // Perform commit automatically
        commit();
    }
}
예제 #4
0
void IndexWriter::deleteDocument(const std::string& sPrimkey)
{
    DocumentPtr pDoc(new Document(m_pKeeper->getDocSchema()));
    pDoc->setPrimaryKey(sPrimkey);
    pDoc->setAction(Document::AT_DELETE);
    m_pDocConsumer->consume(pDoc);
    ++m_nOpCountSinceLastCommit;

    if (autoCommit())
    {
        // Perform commit automatically
        commit();
    }
}
예제 #5
0
void TransMode::updateTransMode(TransMode * trans_mode)
{
  if (trans_mode->isolationLevel() != TransMode::IL_NOT_SPECIFIED_)
    isolationLevel() = trans_mode->isolationLevel();

  if (trans_mode->accessMode() != TransMode::AM_NOT_SPECIFIED_)
    accessMode() = trans_mode->accessMode();

  if (trans_mode->autoCommit() != TransMode::AC_NOT_SPECIFIED_)
    autoCommit() = trans_mode->autoCommit();
  
   if (trans_mode->rollbackMode() != TransMode::ROLLBACK_MODE_NOT_SPECIFIED_)
    rollbackMode() = trans_mode->rollbackMode();
  
 if (trans_mode->diagAreaSize() >= 0)
    diagAreaSize() = trans_mode->diagAreaSize();

 if (trans_mode->autoAbortIntervalInSeconds() >= -3)
    autoAbortIntervalInSeconds() = trans_mode->getAutoAbortIntervalInSeconds();

 if (trans_mode->multiCommit() != multiCommit())
   {
     multiCommit() = trans_mode->multiCommit();
     multiCommitSize() = trans_mode->getMultiCommitSize();
   }
 

  // sets either one of these flag bits to on to indicate whether auto begin
  // is turned on or off.  Only sets it if the user explicitly issues an
  // on or off setting eg. (set transaction autobegin on|off).
  if (trans_mode->getAutoBeginOn() != 0)  // 0 means it has not been set for 
                                          // changing by the user.
     {
     setAutoBeginOff(FALSE); // to clear AUTO_BEGIN_OFF_ bit
     setAutoBeginOn(trans_mode->getAutoBeginOn());
     }
  else
  if (trans_mode->getAutoBeginOff() != 0)
     {
     setAutoBeginOn(FALSE); // to clear AUTO_BEGIN_ON_ bit
     setAutoBeginOff(trans_mode->getAutoBeginOff());
     }

}
예제 #6
0
void FLFormRecordDB::setMainWidget( QWidget * w ) {
    if ( !cursor_ || !w )
        return ;

    if ( !cursor_->metadata() )
        return ;

    if ( showed ) {
        if ( mainWidget_ && mainWidget_ != w )
            initMainWidget( w );
    } else
        w->hide();

    if ( pushButtonAcceptContinue )
        pushButtonAcceptContinue->hide();

    if ( pushButtonAccept )
        pushButtonAccept->hide();

    if ( pushButtonCancel )
        pushButtonCancel->hide();

    if ( pushButtonFirst )
        pushButtonFirst->hide();

    if ( pushButtonPrevious )
        pushButtonPrevious->hide();

    if ( pushButtonNext )
        pushButtonNext->hide();

    if ( pushButtonLast )
        pushButtonLast->hide();

    if ( layoutButtons )
        delete layoutButtons;

    if ( layout )
        delete layout;

    w->setFont( qApp->font() );
    layout = new QVBoxLayout( this, 2, 3, "vlay" + name_ );

    layout->add( w );

    layoutButtons = new QHBoxLayout( layout, 3, "hlay" + name_ ) ;
    QSpacerItem *spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding,
            QSizePolicy::Minimum );

    QSize pbSize( 26, 26 );

#ifdef FL_DEBUGGER
    if ( !pushButtonIDE ) {
        pushButtonIDE = new QPushButton( this, "pushButtonIDE" );
        connect( pushButtonIDE, SIGNAL( clicked() ), this, SLOT( openIde() ) );
    }
    pushButtonIDE->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                                  pushButtonIDE->sizePolicy().hasHeightForWidth() ) );
    pushButtonIDE->setMinimumSize( pbSize );
    pushButtonIDE->setMaximumSize( pbSize );
    QPixmap qsa( QPixmap::fromMimeSource( "bug.png" ) );
    pushButtonIDE->setIconSet( qsa );
    pushButtonIDE->setAccel( QKeySequence( Qt::Key_F3 ) );
    QToolTip::add( pushButtonIDE, tr( "Abrir Depurador (F3)" ) );
    QWhatsThis::add( pushButtonIDE, tr( "Abrir Depurador (F3)" ) );
    pushButtonIDE->setFocusPolicy( QWidget::NoFocus );
    layoutButtons->addWidget( pushButtonIDE );
    connect( pushButtonIDE, SIGNAL( clicked() ), this, SLOT( openIde() ) );
#endif

    layoutButtons->addItem( spacer_2 );

    if ( cursor_->modeAccess() == FLSqlCursor::EDIT ||
            cursor_->modeAccess() == FLSqlCursor::BROWSE ) {
        if ( !pushButtonFirst ) {
            pushButtonFirst = new QPushButton( this, "pushButtonFirst" );
            connect( pushButtonFirst, SIGNAL( clicked() ), this, SLOT( firstRecord() ) );
        }
        pushButtonFirst->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                                        pushButtonFirst->sizePolicy().hasHeightForWidth() ) );
        pushButtonFirst->setMinimumSize( pbSize );
        pushButtonFirst->setMaximumSize( pbSize );
        QPixmap rld( QPixmap::fromMimeSource( "first.png" ) );
        pushButtonFirst->setIconSet( rld );
        pushButtonFirst->setAccel( QKeySequence( Qt::Key_F5 ) );
        QToolTip::add( pushButtonFirst, tr( "Aceptar los cambios e ir al primer registro (F5)" ) );
        QWhatsThis::add( pushButtonFirst, tr( "Aceptar los cambios e ir al primer registro (F5)" ) );
        pushButtonFirst->setFocusPolicy( QWidget::NoFocus );
        layoutButtons->addWidget( pushButtonFirst );
        pushButtonFirst->show();

        if ( !pushButtonPrevious ) {
            pushButtonPrevious = new QPushButton( this, "pushButtonPrevious" );
            connect( pushButtonPrevious, SIGNAL( clicked() ), this, SLOT( previousRecord() ) );
        }
        pushButtonPrevious->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                                           pushButtonPrevious->sizePolicy().hasHeightForWidth() ) );
        pushButtonPrevious->setMinimumSize( pbSize );
        pushButtonPrevious->setMaximumSize( pbSize );
        QPixmap rld2( QPixmap::fromMimeSource( "previous.png" ) );
        pushButtonPrevious->setIconSet( rld2 );
        pushButtonPrevious->setAccel( QKeySequence( Qt::Key_F6 ) );
        QToolTip::add( pushButtonPrevious, tr( "Aceptar los cambios e ir al registro anterior (F6)" ) );
        QWhatsThis::add( pushButtonPrevious, tr( "Aceptar los cambios e ir al registro anterior (F6)" ) );
        pushButtonPrevious->setFocusPolicy( QWidget::NoFocus );
        layoutButtons->addWidget( pushButtonPrevious );
        pushButtonPrevious->show();

        if ( !pushButtonNext ) {
            pushButtonNext = new QPushButton( this, "pushButtonNext" );
            connect( pushButtonNext, SIGNAL( clicked() ), this, SLOT( nextRecord() ) );
        }
        pushButtonNext->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                                       pushButtonNext->sizePolicy().hasHeightForWidth() ) );
        pushButtonNext->setMinimumSize( pbSize );
        pushButtonNext->setMaximumSize( pbSize );
        QPixmap rld3( QPixmap::fromMimeSource( "next.png" ) );
        pushButtonNext->setIconSet( rld3 );
        pushButtonNext->setAccel( QKeySequence( Qt::Key_F7 ) );
        QToolTip::add( pushButtonNext, tr( "Aceptar los cambios e ir al registro siguiente (F7)" ) );
        QWhatsThis::add( pushButtonNext, tr( "Aceptar los cambios e ir al registro siguiente (F7)" ) );
        pushButtonNext->setFocusPolicy( QWidget::NoFocus );
        layoutButtons->addWidget( pushButtonNext );
        pushButtonNext->show();

        if ( !pushButtonLast ) {
            pushButtonLast = new QPushButton( this, "pushButtonLast" );
            connect( pushButtonLast, SIGNAL( clicked() ), this, SLOT( lastRecord() ) );
        }
        pushButtonLast->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                                       pushButtonLast->sizePolicy().hasHeightForWidth() ) );
        pushButtonLast->setMinimumSize( pbSize );
        pushButtonLast->setMaximumSize( pbSize );
        QPixmap rld4( QPixmap::fromMimeSource( "last.png" ) );
        pushButtonLast->setIconSet( rld4 );
        pushButtonLast->setAccel( QKeySequence( Qt::Key_F8 ) );
        QToolTip::add( pushButtonLast, tr( "Aceptar los cambios e ir al último registro (F8)" ) );
        QWhatsThis::add( pushButtonLast, tr( "Aceptar los cambios e ir al último registro (F8)" ) );
        pushButtonLast->setFocusPolicy( QWidget::NoFocus );
        layoutButtons->addWidget( pushButtonLast );
        pushButtonLast->show();
    }

    if ( cursor_->modeAccess() != FLSqlCursor::BROWSE ) {
        if ( showAcceptContinue_ ) {
            if ( !pushButtonAcceptContinue ) {
                pushButtonAcceptContinue = new QPushButton( this, "pushButtonAcceptContinue" );
                connect( pushButtonAcceptContinue, SIGNAL( clicked() ), this, SLOT( acceptContinue() ) );
            }
            pushButtonAcceptContinue->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                    pushButtonAcceptContinue->sizePolicy().hasHeightForWidth() ) );
            pushButtonAcceptContinue->setMinimumSize( pbSize );
            pushButtonAcceptContinue->setMaximumSize( pbSize );
            QPixmap rld( QPixmap::fromMimeSource( "reload.png" ) );
            pushButtonAcceptContinue->setIconSet( rld );
            pushButtonAcceptContinue->setFocusPolicy( QWidget::NoFocus );
            pushButtonAcceptContinue->setAccel( QKeySequence( Qt::Key_F9 ) );
            QToolTip::add( pushButtonAcceptContinue, tr( "Aceptar los cambios y continuar con la edición de un nuevo registro (F9)" ) );
            QWhatsThis::add( pushButtonAcceptContinue, tr( "Aceptar los cambios y continuar con la edición de un nuevo registro (F9)" ) );
            layoutButtons->addWidget( pushButtonAcceptContinue );
            pushButtonAcceptContinue->show();
        }

        if ( !pushButtonAccept ) {
            pushButtonAccept = new QPushButton( this, "pushButtonAccept" );
            connect( pushButtonAccept, SIGNAL( clicked() ), this, SLOT( accept() ) );
        }
        pushButtonAccept->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                                         pushButtonAccept->sizePolicy().hasHeightForWidth() ) );
        pushButtonAccept->setMinimumSize( pbSize );
        pushButtonAccept->setMaximumSize( pbSize );
        QPixmap ok( QPixmap::fromMimeSource( "button_ok.png" ) );
        pushButtonAccept->setIconSet( ok );
        pushButtonAccept->setFocusPolicy( QWidget::NoFocus );
        pushButtonAccept->setAccel( QKeySequence( Qt::Key_F10 ) );
        QToolTip::add( pushButtonAccept, tr( "Aceptar los cambios y cerrar formulario (F10)" ) );
        QWhatsThis::add( pushButtonAccept, tr( "Aceptar los cambios y cerrar formulario (F10)" ) );
        layoutButtons->addWidget( pushButtonAccept );
        pushButtonAccept->show();
    }

    if ( !pushButtonCancel ) {
        pushButtonCancel = new QPushButton( this, "pushButtonCancel" );
        connect( cursor_, SIGNAL( autoCommit() ), this, SLOT( disablePushButtonCancel() ) );
        connect( pushButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
    }
    pushButtonCancel->setSizePolicy( QSizePolicy(( QSizePolicy::SizeType ) 0, ( QSizePolicy::SizeType ) 0, 0, 0,
                                     pushButtonCancel->sizePolicy().hasHeightForWidth() ) );
    pushButtonCancel->setMinimumSize( pbSize );
    pushButtonCancel->setMaximumSize( pbSize );
    QPixmap cancel( QPixmap::fromMimeSource( "button_cancel.png" ) );
    pushButtonCancel->setIconSet( cancel );
    if ( cursor_->modeAccess() != FLSqlCursor::BROWSE ) {
        pushButtonCancel->setFocusPolicy( QWidget::NoFocus );
        pushButtonCancel->setAccel( 4096 );
        QToolTip::add( pushButtonCancel, tr( "Cancelar los cambios y cerrar formulario (Esc)" ) );
        QWhatsThis::add( pushButtonCancel, tr( "Cancelar los cambios y cerrar formulario (Esc)" ) );
    } else {
        QPixmap ok( QPixmap::fromMimeSource( "button_cancel.png" ) );
        pushButtonCancel->setIconSet( ok );
        pushButtonCancel->setFocusPolicy( QWidget::StrongFocus );
        pushButtonCancel->setFocus();
        pushButtonCancel->setAccel( 4096 );
        QToolTip::add( pushButtonCancel, tr( "Aceptar y cerrar formulario (Esc)" ) );
        QWhatsThis::add( pushButtonCancel, tr( "Aceptar y cerrar formulario (Esc)" ) );
    }
    pushButtonCancel->setDefault( true );
    layoutButtons->addWidget( pushButtonCancel );
    pushButtonCancel->show();

    mainWidget_ = w;
    mainWidget_->setFocusPolicy( QWidget::NoFocus );
    int mWidth = mainWidget_->width();
    int mHeight = mainWidget_->height();
    QWidget * actWin = qApp->activeWindow();
    QRect screen = ( actWin ? actWin->geometry() : qApp->mainWidget()->geometry() );
    QRect desk = QApplication::desktop()->geometry();
    QPoint p = screen.center() - QPoint( mWidth / 2, mHeight / 2 );
    if ( p.x() + mWidth > desk.width() )
        p.setX( desk.width() - mWidth );
    if ( p.y() + mHeight > desk.height() )
        p.setY( desk.height() - mHeight );
    if ( p.x() < 0 )
        p.setX( 0 );
    if ( p.y() < 0 )
        p.setY( 0 );
    move( p );
}
예제 #7
0
void SessionImpl::open(const std::string& connect)
{
	if (connect != connectionString())
	{
		if (isConnected())
			throw InvalidAccessException("Session already connected");

		if (!connect.empty())
			setConnectionString(connect);
	}

	poco_assert_dbg (!connectionString().empty());

	SQLULEN tout = static_cast<SQLULEN>(getLoginTimeout());
	if (Utility::isError(SQLSetConnectAttr(_db, SQL_ATTR_LOGIN_TIMEOUT, (SQLPOINTER) tout, 0)))
	{
		if (Utility::isError(SQLGetConnectAttr(_db, SQL_ATTR_LOGIN_TIMEOUT, &tout, 0, 0)) ||
				getLoginTimeout() != tout)
		{
			ConnectionError e(_db);
			throw ConnectionFailedException(e.toString());
		}
	}

	SQLCHAR connectOutput[512] = {0};
	SQLSMALLINT result;

	if (Utility::isError(Poco::Data::ODBC::SQLDriverConnect(_db
		, NULL
		,(SQLCHAR*) connectionString().c_str()
		,(SQLSMALLINT) SQL_NTS
		, connectOutput
		, sizeof(connectOutput)
		, &result
		, SQL_DRIVER_NOPROMPT)))
	{
		ConnectionError err(_db);
		std::string errStr = err.toString();
		close();
		throw ConnectionFailedException(errStr);
	}

	_dataTypes.fillTypeInfo(_db);
		addProperty("dataTypeInfo",
		&SessionImpl::setDataTypeInfo,
		&SessionImpl::dataTypeInfo);

	addFeature("autoCommit",
		&SessionImpl::autoCommit,
		&SessionImpl::isAutoCommit);

	addFeature("autoBind",
		&SessionImpl::autoBind,
		&SessionImpl::isAutoBind);

	addFeature("autoExtract",
		&SessionImpl::autoExtract,
		&SessionImpl::isAutoExtract);

	addProperty("maxFieldSize",
		&SessionImpl::setMaxFieldSize,
		&SessionImpl::getMaxFieldSize);

	addProperty("queryTimeout",
		&SessionImpl::setQueryTimeout,
		&SessionImpl::getQueryTimeout);

	Poco::Data::ODBC::SQLSetConnectAttr(_db, SQL_ATTR_QUIET_MODE, 0, 0);

	if (!canTransact()) autoCommit("", true);
}