Implement Tables::createObject. (firebird-sdbc)

Change-Id: I9a4d301a0edf27af2dc3c571156592406c5019f9
This commit is contained in:
Andrzej J.R. Hunt
2013-08-10 11:06:48 +01:00
parent 73341eddbf
commit f496a1cb39
4 changed files with 129 additions and 29 deletions

View File

@@ -9,4 +9,53 @@
#include "Table.hxx"
using namespace ::connectivity;
using namespace ::connectivity::firebird;
using namespace ::connectivity::sdbcx;
using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::sdbc;
Table::Table(Tables* pTables,
const uno::Reference< XConnection >& rConnection,
const OUString& rName,
const OUString& rType,
const OUString& rDescription,
sal_Int32 nPrivileges):
OTableHelper(pTables,
rConnection,
sal_True,
rName,
rType,
rDescription,
"",
"")
{
(void) nPrivileges;
}
//----- OTableHelper ---------------------------------------------------------
OCollection* Table::createColumns(const TStringVector& rNames)
{
(void) rNames;
// TODO: IMPLEMENT ME
return 0;
}
OCollection* Table::createKeys(const TStringVector& rNames)
{
(void) rNames;
// TODO: IMPLEMENT ME
return 0;
}
OCollection* Table::createIndexes(const TStringVector& rNames)
{
(void) rNames;
// TODO: IMPLEMENT ME
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -10,6 +10,8 @@
#ifndef CONNECTIVITY_FIREBIRD_TABLE_HXX
#define CONNECTIVITY_FIREBIRD_TABLE_HXX
#include "Tables.hxx"
#include <connectivity/TTableHelper.hxx>
namespace connectivity
@@ -19,6 +21,22 @@ namespace connectivity
class Table: public OTableHelper
{
public:
Table(Tables* pTables,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
const OUString& rName,
const OUString& rType,
const OUString& rDescription,
sal_Int32 _nPrivileges);
// OTableHelper
virtual ::connectivity::sdbcx::OCollection* createColumns(
const ::connectivity::TStringVector& rNames);
virtual ::connectivity::sdbcx::OCollection* createKeys(
const ::connectivity::TStringVector& rNames);
virtual ::connectivity::sdbcx::OCollection* createIndexes(
const ::connectivity::TStringVector& rNames);
};
} // namespace firebird

View File

@@ -7,8 +7,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "Table.hxx"
#include "Tables.hxx"
#include <com/sun/star/sdbc/XRow.hpp>
using namespace ::connectivity::firebird;
using namespace ::connectivity::sdbcx;
using namespace ::cppu;
@@ -20,10 +23,12 @@ using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::uno;
Tables::Tables(::cppu::OWeakObject& rParent,
Tables::Tables(ODatabaseMetaData& xMetaData,
::cppu::OWeakObject& rParent,
::osl::Mutex& rMutex,
const TStringVector& rVector) :
OCollection(rParent, sal_True, rMutex, rVector)
OCollection(rParent, sal_True, rMutex, rVector),
m_xMetaData(xMetaData)
{
}
@@ -36,23 +41,46 @@ void Tables::impl_refresh()
ObjectType Tables::createObject(const OUString& rName)
{
(void) rName;
// TODO: IMPLEMENT ME
return ObjectType();
// TODO: parse the name.
// TODO: use table types
uno::Reference< XResultSet > xTables = m_xMetaData.getTables(Any(),
OUString(),
rName,
uno::Sequence< OUString >());
if (!xTables.is())
throw RuntimeException();
uno::Reference< XRow > xRow(xTables,UNO_QUERY);
if (!xRow.is() || !xTables->next())
throw RuntimeException();
ObjectType xRet(new Table(this,
m_xMetaData.getConnection(),
rName,
"", // TODO: Type
"", // TODO: Description
0)); // TODO: privileges
if (xTables->next())
throw RuntimeException(); // Only one table should be returned
return xRet;
}
//----- XDrop ----------------------------------------------------------------
void SAL_CALL Tables::dropByName(const OUString& rName)
throw (SQLException, NoSuchElementException, RuntimeException)
{
(void) rName;
// TODO: IMPLEMENT ME
}
void SAL_CALL Tables::dropByIndex(const sal_Int32 nIndex)
throw (SQLException, IndexOutOfBoundsException, RuntimeException)
{
(void) nIndex;
// TODO: IMPLEMENT ME
}
// //----- XDrop ----------------------------------------------------------------
// void SAL_CALL Tables::dropByName(const OUString& rName)
// throw (SQLException, NoSuchElementException, RuntimeException)
// {
// (void) rName;
// // TODO: IMPLEMENT ME
// }
//
// void SAL_CALL Tables::dropByIndex(const sal_Int32 nIndex)
// throw (SQLException, IndexOutOfBoundsException, RuntimeException)
// {
// (void) nIndex;
// // TODO: IMPLEMENT ME
// }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -10,6 +10,8 @@
#ifndef CONNECTIVITY_FIREBIRD_TABLES_HXX
#define CONNECTIVITY_FIREBIRD_TABLES_HXX
#include "DatabaseMetaData.hxx"
#include <connectivity/sdbcx/VCollection.hxx>
namespace connectivity
@@ -30,23 +32,26 @@ namespace connectivity
virtual ::connectivity::sdbcx::ObjectType createObject(
const ::rtl::OUString& rName);
ODatabaseMetaData& m_xMetaData;
public:
Tables(::cppu::OWeakObject& rParent,
Tables(ODatabaseMetaData& xMetaData,
::cppu::OWeakObject& rParent,
::osl::Mutex& rMutex,
const TStringVector& rVector);
// TODO: we should also implement XDataDescriptorFactory, XRefreshable,
// XAppend, etc., but all are optional.
// XDrop
virtual void SAL_CALL dropByName(const ::rtl::OUString& rName)
throw (::com::sun::star::sdbc::SQLException,
::com::sun::star::container::NoSuchElementException,
::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL dropByIndex(const sal_Int32 nIndex)
throw (::com::sun::star::sdbc::SQLException,
com::sun::star::lang::IndexOutOfBoundsException,
::com::sun::star::uno::RuntimeException);
// // XDrop
// virtual void SAL_CALL dropByName(const ::rtl::OUString& rName)
// throw (::com::sun::star::sdbc::SQLException,
// ::com::sun::star::container::NoSuchElementException,
// ::com::sun::star::uno::RuntimeException);
// virtual void SAL_CALL dropByIndex(const sal_Int32 nIndex)
// throw (::com::sun::star::sdbc::SQLException,
// com::sun::star::lang::IndexOutOfBoundsException,
// ::com::sun::star::uno::RuntimeException);
};
} // namespace firebird