LibreOffice Module connectivity (master) 1
Catalog.cxx
Go to the documentation of this file.
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.
4 *
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 */
9
10#include "Catalog.hxx"
11#include "Tables.hxx"
12#include "Users.hxx"
13#include "Views.hxx"
14
15#include <com/sun/star/sdbc/XRow.hpp>
16
17using namespace ::connectivity::firebird;
18using namespace ::com::sun::star;
19using namespace ::com::sun::star::sdbc;
20using namespace ::com::sun::star::uno;
21
22Catalog::Catalog(const uno::Reference< XConnection >& rConnection):
23 OCatalog(rConnection),
24 m_xConnection(rConnection)
25{
26}
27
28//----- OCatalog -------------------------------------------------------------
29void Catalog::refreshTables()
30{
31 Sequence< OUString > aTypes {"TABLE", "VIEW"};
32
33 uno::Reference< XResultSet > xTables = m_xMetaData->getTables(Any(),
34 "%",
35 "%",
36 aTypes);
37
38 if (!xTables.is())
39 return;
40
41 ::std::vector< OUString> aTableNames;
42
43 fillNames(xTables, aTableNames);
44
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);
52
53}
54
55void Catalog::refreshViews()
56{
57 css::uno::Reference<css::sdbc::XResultSet> xViews
58 = m_xMetaData->getTables(css::uno::Any(), "%", "%", { "VIEW" });
59
60 if (!xViews.is())
61 return;
62
63 ::std::vector<OUString> aViewNames;
64
65 fillNames(xViews, aViewNames);
66
67 if (!m_pViews)
68 m_pViews.reset(new Views(m_xConnection, *this, m_aMutex, aViewNames));
69 else
70 m_pViews->reFill(aViewNames);
71}
72
73//----- IRefreshableGroups ---------------------------------------------------
74void Catalog::refreshGroups()
75{
76 // TODO: implement me
77}
78
79//----- IRefreshableUsers ----------------------------------------------------
80void Catalog::refreshUsers()
81{
82 Reference<XStatement> xStmt= m_xMetaData->getConnection()->createStatement();
83 uno::Reference< XResultSet > xUsers = xStmt->executeQuery("SELECT DISTINCT RDB$USER FROM RDB$USER_PRIVILEGES");
84
85 if (!xUsers.is())
86 return;
87
88 ::std::vector< OUString> aUserNames;
89
90 uno::Reference< XRow > xRow(xUsers,UNO_QUERY);
91 while (xUsers->next())
92 {
93 aUserNames.push_back(xRow->getString(1));
94 }
95
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);
103}
104
105/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
Reference< XConnection > m_xConnection
const SvXMLTokenMapEntry aTypes[]