summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2013-08-10 11:06:48 +0100
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2013-08-11 16:05:10 +0100
commitf496a1cb39b33e3dff1b3f0475dc00c904a2c5f4 (patch)
treeed9823e9943d57f15308e83204b0f62793ec4744 /connectivity
parent73341eddbf3e42a121d80cada4d1252af80f5396 (diff)
Implement Tables::createObject. (firebird-sdbc)
Change-Id: I9a4d301a0edf27af2dc3c571156592406c5019f9
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/firebird/Table.cxx49
-rw-r--r--connectivity/source/drivers/firebird/Table.hxx18
-rw-r--r--connectivity/source/drivers/firebird/Tables.cxx64
-rw-r--r--connectivity/source/drivers/firebird/Tables.hxx25
4 files changed, 128 insertions, 28 deletions
diff --git a/connectivity/source/drivers/firebird/Table.cxx b/connectivity/source/drivers/firebird/Table.cxx
index c5576007b0db..f53d2290b901 100644
--- a/connectivity/source/drivers/firebird/Table.cxx
+++ b/connectivity/source/drivers/firebird/Table.cxx
@@ -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: */ \ No newline at end of file
diff --git a/connectivity/source/drivers/firebird/Table.hxx b/connectivity/source/drivers/firebird/Table.hxx
index b97a9fd88a1d..426f9064ef67 100644
--- a/connectivity/source/drivers/firebird/Table.hxx
+++ b/connectivity/source/drivers/firebird/Table.hxx
@@ -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
diff --git a/connectivity/source/drivers/firebird/Tables.cxx b/connectivity/source/drivers/firebird/Tables.cxx
index 52b15127a2ee..e44e952d47d2 100644
--- a/connectivity/source/drivers/firebird/Tables.cxx
+++ b/connectivity/source/drivers/firebird/Tables.cxx
@@ -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 >());
-//----- XDrop ----------------------------------------------------------------
-void SAL_CALL Tables::dropByName(const OUString& rName)
- throw (SQLException, NoSuchElementException, RuntimeException)
-{
- (void) rName;
- // TODO: IMPLEMENT ME
-}
+ if (!xTables.is())
+ throw RuntimeException();
-void SAL_CALL Tables::dropByIndex(const sal_Int32 nIndex)
- throw (SQLException, IndexOutOfBoundsException, RuntimeException)
-{
- (void) nIndex;
- // TODO: IMPLEMENT ME
+ 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
+// }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/connectivity/source/drivers/firebird/Tables.hxx b/connectivity/source/drivers/firebird/Tables.hxx
index 89f188d269b0..2b3453c13e6b 100644
--- a/connectivity/source/drivers/firebird/Tables.hxx
+++ b/connectivity/source/drivers/firebird/Tables.hxx
@@ -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