Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / firebird / Catalog.cxx
blobdbbfaa33691c84313f7872fc0f90acbbb7b83c41
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "Catalog.hxx"
11 #include "Tables.hxx"
12 #include "Users.hxx"
14 using namespace ::connectivity::firebird;
16 using namespace ::rtl;
18 using namespace ::com::sun::star;
19 using namespace ::com::sun::star::sdbc;
20 using namespace ::com::sun::star::uno;
22 Catalog::Catalog(const uno::Reference< XConnection >& rConnection):
23 OCatalog(rConnection),
24 m_xConnection(rConnection)
28 //----- OCatalog -------------------------------------------------------------
29 void Catalog::refreshTables()
31 // TODO: set type -- currenty we also get system tables...
32 Sequence< OUString > aTypes(2);
33 aTypes[0] = "TABLE";
34 aTypes[1] = "VIEW";
36 uno::Reference< XResultSet > xTables = m_xMetaData->getTables(Any(),
37 "%",
38 "%",
39 aTypes);
41 if (!xTables.is())
42 return;
44 TStringVector aTableNames;
46 fillNames(xTables, aTableNames);
48 if (!m_pTables)
49 m_pTables = new Tables(m_xConnection->getMetaData(),
50 *this,
51 m_aMutex,
52 aTableNames);
53 else
54 m_pTables->reFill(aTableNames);
58 void Catalog::refreshViews()
60 // TODO: implement me.
61 // Sets m_pViews (OCatalog)
64 //----- IRefreshableGroups ---------------------------------------------------
65 void Catalog::refreshGroups()
67 // TODO: implement me
70 //----- IRefreshableUsers ----------------------------------------------------
71 void Catalog::refreshUsers()
73 OUString sSql("SELECT DISTINCT RDB$USER FROM RDB$USER_PRIVILEGES");
75 uno::Reference< XResultSet > xUsers = m_xMetaData->getConnection()
76 ->createStatement()->executeQuery(sSql);
78 if (!xUsers.is())
79 return;
81 TStringVector aUserNames;
83 uno::Reference< XRow > xRow(xUsers,UNO_QUERY);
84 while (xUsers->next())
86 aUserNames.push_back(xRow->getString(1));
89 if (!m_pUsers)
90 m_pUsers = new Users(m_xConnection->getMetaData(),
91 *this,
92 m_aMutex,
93 aUserNames);
94 else
95 m_pUsers->reFill(aUserNames);
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */