Use correct object
[LibreOffice.git] / connectivity / source / drivers / firebird / Catalog.cxx
blobaba0784662a7b209543cb63fa749216a2db187fa
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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"
13 #include "Views.hxx"
15 #include <com/sun/star/sdbc/XRow.hpp>
17 using namespace ::connectivity::firebird;
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 Sequence< OUString > aTypes {u"TABLE"_ustr, u"VIEW"_ustr};
33 uno::Reference< XResultSet > xTables = m_xMetaData->getTables(Any(),
34 u"%"_ustr,
35 u"%"_ustr,
36 aTypes);
38 if (!xTables.is())
39 return;
41 ::std::vector< OUString> aTableNames;
43 fillNames(xTables, aTableNames);
45 if (!m_pTables)
46 m_pTables.reset( new Tables(m_xConnection->getMetaData(),
47 *this,
48 m_aMutex,
49 aTableNames) );
50 else
51 m_pTables->reFill(aTableNames);
55 void Catalog::refreshViews()
57 css::uno::Reference<css::sdbc::XResultSet> xViews
58 = m_xMetaData->getTables(css::uno::Any(), u"%"_ustr, u"%"_ustr, { u"VIEW"_ustr });
60 if (!xViews.is())
61 return;
63 ::std::vector<OUString> aViewNames;
65 fillNames(xViews, aViewNames);
67 if (!m_pViews)
68 m_pViews.reset(new Views(m_xConnection, *this, m_aMutex, aViewNames));
69 else
70 m_pViews->reFill(aViewNames);
73 //----- IRefreshableGroups ---------------------------------------------------
74 void Catalog::refreshGroups()
76 // TODO: implement me
79 //----- IRefreshableUsers ----------------------------------------------------
80 void Catalog::refreshUsers()
82 Reference<XStatement> xStmt= m_xMetaData->getConnection()->createStatement();
83 uno::Reference< XResultSet > xUsers = xStmt->executeQuery(u"SELECT DISTINCT RDB$USER FROM RDB$USER_PRIVILEGES"_ustr);
85 if (!xUsers.is())
86 return;
88 ::std::vector< OUString> aUserNames;
90 uno::Reference< XRow > xRow(xUsers,UNO_QUERY);
91 while (xUsers->next())
93 aUserNames.push_back(xRow->getString(1));
96 if (!m_pUsers)
97 m_pUsers.reset( new Users(m_xConnection->getMetaData(),
98 *this,
99 m_aMutex,
100 aUserNames) );
101 else
102 m_pUsers->reFill(aUserNames);
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */