Beispiel #1
0
void MSObservableTree<Element>::removeSubtree(const MSTabularTreeCursor<Element>& cursor_)
{
  MSTabularTreeCursor<Element> cursor2(cursor_);
  unsigned long pos=this->position(cursor2);
  cursor2.setToParent();
  MSTabularTree<Element>::removeSubtree(cursor_);
  if (cursor2.isValid()) changed(cursor2,pos,MSObservableTreeDelete);
  else changed();
}
Beispiel #2
0
void MSObservableTree<Element>::attachSubtreeAsRoot(MSObservableTree<Element>& tree_,
                                                    const MSTabularTreeCursor<Element>& cursor_)
{
  MSTabularTreeCursor<Element> cursor2(cursor_);
  unsigned long p=tree_.position(cursor2);
  cursor2.setToParent();
  
  MSTabularTree<Element>::attachSubtreeAsRoot(tree_,cursor_);
  changed();
  
  if (cursor2.isValid()) tree_.changed(cursor2,p,MSObservableTreeDelete);
  else tree_.changed(); // whole tree is deleted
}
Beispiel #3
0
void MSObservableTree<Element>::attachSubtreeAsChild(const MSTabularTreeCursor<Element> &cursorTo_,
                                                     unsigned long pos_,
                                                     MSObservableTree<Element>& tree_,
                                                     MSTabularTreeCursor<Element> const& cursorFrom_)
{
  MSTabularTreeCursor<Element> cursor2(cursorFrom_);
  unsigned long pos2=tree_.position(cursor2);
  cursor2.setToParent();
  
  MSTabularTree<Element>::attachSubtreeAsChild(cursorTo_,pos_,tree_,cursorFrom_);
  changed(cursorTo_,pos_,MSObservableTreeInsert);
  if (cursor2.isValid()) tree_.changed(cursor2,pos2,MSObservableTreeDelete);
  else tree_.changed();  // whole tree is deleted
}
//   path-absolute = "/" [ segment-nz *( "/" segment ) ]
TextCursor parse_path_absolute(TextCursor cursor)
{
    char c = get_char(cursor);
    if (c != '/')
        throw ParseError();
    else
    {
        try
        {
            TextCursor cursor2(parse_segment_nz(cursor));
            REPEAT_IGNORING(parse_slash_segment, cursor2);
        }
        catch(ParseError)
        {
            return cursor;
        }
    }
}
Beispiel #5
0
	/// Merge the plain text from \a source together with the rich text formatting in \a destTemplate and return the resulting HTML
	QString mergeTextItem(const QString &destTemplate, const QString &source)
	{
		QTextDocument doc;
		textToDocument(doc, destTemplate);
		QTextCursor cursor(&doc);
		cursor.select(QTextCursor::Document);
		
		QTextCharFormat charFormat = cursor.charFormat();
		QTextBlockFormat blockFormat = cursor.blockFormat();
		QTextCharFormat blockCharFormat = cursor.blockCharFormat();
		
		QTextDocument doc2;
		textToDocument(doc2, source);
		QTextCursor cursor2(&doc2);
		cursor2.select(QTextCursor::Document);
		
		cursor2.mergeBlockCharFormat(blockCharFormat);
		cursor2.mergeBlockFormat(blockFormat);
		cursor2.mergeCharFormat(charFormat);
		
		return doc2.toHtml();
	}
Beispiel #6
0
BOOL IJA_llQueryTableTransaction (
    CaQueryTransactionInfo* pQueryInfo,
    CTypedPtrList<CObList, CaColumn*>* pListColumn,
    CTypedPtrList < CObList, CaTableTransactionItemData* >& listTransaction)
{
	CString strDatabase;
	CString strDatabaseOwner;
	CString strTable;
	CString strTableOwner;
	CString strStatement;

	pQueryInfo->GetDatabase (strDatabase, strDatabaseOwner);
	pQueryInfo->GetTable (strTable, strTableOwner);

	//
	// Open the session:
	CaTemporarySession session (pQueryInfo->GetNode(), strDatabase);
	if (!session.IsConnected())
	{
		//
		// Failedto get Session.
		CString strMsg;
		strMsg.LoadString (IDS_FAIL_TO_GETSESSION);
		AfxMessageBox (strMsg);
		return FALSE;
	}

	CString strTempTable = _T("");
	CString csGranteeList = _T(""); /* no grantee list required here */
	BOOL bOK = IJA_TableAuditdbOutput (pQueryInfo, &session, strTempTable, pListColumn, csGranteeList);
	if (!bOK) {
		session.Release(SESSION_ROLLBACK);
		return FALSE;
	}
	BOOL bOnLocal = session.IsLocalNode();
	//
	// STEP 1: Select row that are INSERT, DELETE, REPOLD, REPNEW
	// Select the rows (table transactions) from the newly created Table:
	CString strSessionPrefix = _T("");
	if (bOnLocal)
		strSessionPrefix = _T("session.");

	strStatement.Format (
		_T("select * from %s%s where operation  in ('repold', 'repnew', 'append', 'insert', 'delete')"),
		(LPCTSTR)strSessionPrefix,
		(LPCTSTR)strTempTable);
	CaIjaCursor cursor(1, strStatement);
	if (cursor.Open())
	{
		int nCount = 0;
		CStringList listData;
		CString strItem1;
		CString strItem2;

		while (cursor.Fetch(listData, nCount))
		{
			CaTableTransactionItemData* pTran = new CaTableTransactionItemData();

			POSITION pos = listData.GetHeadPosition();
			ASSERT (listData.GetCount() >= 10); // At least 10 columns;
			if (listData.GetCount() < 10)
			{
				delete pTran;
				return FALSE;
			}
			pTran->SetTable (strTable);
			pTran->SetTableOwner (strTableOwner);

			if (pos != NULL)
			{
				// LSN:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
				pTran->SetLsn (_ttoul(strItem1), _ttoul(strItem2));
				// TID:
				strItem1 = listData.GetNext (pos); 
				pTran->SetTid(_ttol(strItem1));
				// Date:
				strItem1 = listData.GetNext (pos);
				pTran->SetDate(strItem1);
				// User Name:
				strItem1 = listData.GetNext (pos);
				pTran->SetUser (strItem1);
				// Operation:
				strItem1 = listData.GetNext (pos);
				if (strItem1.CompareNoCase (_T("insert")) == 0 || strItem1.CompareNoCase (_T("append")) == 0)
					pTran->SetOperation (T_INSERT);
				else
				if (strItem1.CompareNoCase (_T("delete")) == 0)
					pTran->SetOperation (T_DELETE);
				else
				if (strItem1.CompareNoCase (_T("repold")) == 0)
					pTran->SetOperation (T_BEFOREUPDATE);
				else
				if (strItem1.CompareNoCase (_T("repnew")) == 0)
					pTran->SetOperation (T_AFTERUPDATE);
				else
				{
					ASSERT (FALSE);
					pTran->SetOperation (T_UNKNOWN);
				}
				// Transaction:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
				pTran->SetTransactionID (_ttoul(strItem1), _ttoul(strItem2));
				// Ignore:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
			}
			pTran->SetCommit  (TRUE);
			pTran->SetJournal (TRUE);

			CStringList& listAuditedData = pTran->GetListData();
			while (pos != NULL)
			{
				strItem1 = listData.GetNext (pos);
				listAuditedData.AddTail(strItem1);
			}

			listTransaction.AddTail (pTran);
			listData.RemoveAll();
		}

		cursor.Close();
	}

	//
	// STEP 2: Select rows that are COMMIT, ABORT, COMMITNJ, ABORTNJ
	//         to update the previous select result if the rows are commit, abort, ...
	// Select the rows (table transactions) from the newly created Table:
	strStatement.Format (
		_T("select * from %s%s where operation  in ('commit', 'abort', 'commitnj', 'abortnj')"),
		(LPCTSTR)strSessionPrefix,
		(LPCTSTR)strTempTable);

	CaIjaCursor cursor2(2, strStatement);
	if (cursor2.Open())
	{
		CaTableTransactionItemData* pFound = NULL;
		int nCount = 0;
		CStringList listData;
		CString strItem1;
		CString strItem2;
		CString strOperation;

		while (cursor2.Fetch(listData, nCount))
		{
			POSITION pos = listData.GetHeadPosition();
			ASSERT (listData.GetCount() >= 10); // At least 10 columns;
			if (listData.GetCount() < 10)
				return FALSE;

			if (pos != NULL)
			{
				// LSN:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
				// Ignore:
				strItem1 = listData.GetNext (pos); 
				// Date:
				strItem1 = listData.GetNext (pos);
				// User Name:
				strItem1 = listData.GetNext (pos);
				// Operation:
				strOperation = listData.GetNext (pos);

				// Transaction:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
				TRANSACTION_ChangeState (_ttoul(strItem1), _ttoul(strItem2), strOperation, listTransaction);
				// Ignore:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
			}
			listData.RemoveAll();
		}

		cursor2.Close();
	}

	//
	// Make sure that the temporary table has been destroyed:
	if (!bOnLocal && bOK && !strTempTable.IsEmpty()) 
	{
		strStatement.Format ( _T("drop table %s"), (LPCTSTR)strTempTable);
		CaLowlevelAddAlterDrop param (pQueryInfo->GetNode(), strDatabase, strStatement);
		param.NeedSession(FALSE); // Use the current open session.
		param.SetStatement(strStatement);
		if (!param.ExecuteStatement(NULL))
		{
			CString strMsg;
			strMsg.LoadString(IDS_FAIL_DROP_TEMP_TABLE);
			AfxMessageBox(strMsg);
		}
	}

	session.Release(); // Release session and commit.
	return TRUE;
}
//   path-rootless = segment-nz *( "/" segment )
TextCursor parse_path_rootless(TextCursor cursor)
{
    TextCursor cursor2(parse_segment_nz(cursor));
    REPEAT_IGNORING(parse_slash_segment, cursor2);
}
//   path-noscheme = segment-nz-nc *( "/" segment )
TextCursor parse_path_noscheme(TextCursor cursor)
{
    TextCursor cursor2(parse_segment_nz_nc(cursor));
    REPEAT_IGNORING(parse_slash_segment, cursor2);
}