1*9b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*9b5730f6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*9b5730f6SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*9b5730f6SAndrew Rist * distributed with this work for additional information
6*9b5730f6SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*9b5730f6SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*9b5730f6SAndrew Rist * "License"); you may not use this file except in compliance
9*9b5730f6SAndrew Rist * with the License. You may obtain a copy of the License at
10*9b5730f6SAndrew Rist *
11*9b5730f6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*9b5730f6SAndrew Rist *
13*9b5730f6SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*9b5730f6SAndrew Rist * software distributed under the License is distributed on an
15*9b5730f6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9b5730f6SAndrew Rist * KIND, either express or implied. See the License for the
17*9b5730f6SAndrew Rist * specific language governing permissions and limitations
18*9b5730f6SAndrew Rist * under the License.
19*9b5730f6SAndrew Rist *
20*9b5730f6SAndrew Rist *************************************************************/
21*9b5730f6SAndrew Rist
22*9b5730f6SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir #include "ado/ACatalog.hxx"
27cdf0e10cSrcweir #ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_
28cdf0e10cSrcweir #include "ado/AConnection.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include "ado/AGroups.hxx"
31cdf0e10cSrcweir #include "ado/AUsers.hxx"
32cdf0e10cSrcweir #include "ado/ATables.hxx"
33cdf0e10cSrcweir #include "ado/AViews.hxx"
34cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
35cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp>
36cdf0e10cSrcweir
37cdf0e10cSrcweir
38cdf0e10cSrcweir // -------------------------------------------------------------------------
39cdf0e10cSrcweir using namespace connectivity;
40cdf0e10cSrcweir using namespace connectivity::ado;
41cdf0e10cSrcweir // -------------------------------------------------------------------------
OCatalog(_ADOCatalog * _pCatalog,OConnection * _pCon)42cdf0e10cSrcweir OCatalog::OCatalog(_ADOCatalog* _pCatalog,OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon)
43cdf0e10cSrcweir ,m_pConnection(_pCon)
44cdf0e10cSrcweir ,m_aCatalog(_pCatalog)
45cdf0e10cSrcweir {
46cdf0e10cSrcweir }
47cdf0e10cSrcweir // -----------------------------------------------------------------------------
~OCatalog()48cdf0e10cSrcweir OCatalog::~OCatalog()
49cdf0e10cSrcweir {
50cdf0e10cSrcweir if(m_aCatalog.IsValid())
51cdf0e10cSrcweir m_aCatalog.putref_ActiveConnection(NULL);
52cdf0e10cSrcweir m_aCatalog.clear();
53cdf0e10cSrcweir }
54cdf0e10cSrcweir // -----------------------------------------------------------------------------
refreshTables()55cdf0e10cSrcweir void OCatalog::refreshTables()
56cdf0e10cSrcweir {
57cdf0e10cSrcweir TStringVector aVector;
58cdf0e10cSrcweir
59cdf0e10cSrcweir WpADOTables aTables(m_aCatalog.get_Tables());
60cdf0e10cSrcweir if ( aTables.IsValid() )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir aTables.Refresh();
63cdf0e10cSrcweir sal_Int32 nCount = aTables.GetItemCount();
64cdf0e10cSrcweir aVector.reserve(nCount);
65cdf0e10cSrcweir for(sal_Int32 i=0;i< nCount;++i)
66cdf0e10cSrcweir {
67cdf0e10cSrcweir WpADOTable aElement = aTables.GetItem(i);
68cdf0e10cSrcweir if ( aElement.IsValid() )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir ::rtl::OUString sTypeName = aElement.get_Type();
71cdf0e10cSrcweir if ( !sTypeName.equalsIgnoreAsciiCaseAscii("SYSTEM TABLE") && !sTypeName.equalsIgnoreAsciiCaseAscii("ACCESS TABLE") )
72cdf0e10cSrcweir aVector.push_back(aElement.get_Name());
73cdf0e10cSrcweir }
74cdf0e10cSrcweir }
75cdf0e10cSrcweir }
76cdf0e10cSrcweir
77cdf0e10cSrcweir if(m_pTables)
78cdf0e10cSrcweir m_pTables->reFill(aVector);
79cdf0e10cSrcweir else
80cdf0e10cSrcweir m_pTables = new OTables(this,m_aMutex,aVector,aTables,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers());
81cdf0e10cSrcweir }
82cdf0e10cSrcweir // -------------------------------------------------------------------------
refreshViews()83cdf0e10cSrcweir void OCatalog::refreshViews()
84cdf0e10cSrcweir {
85cdf0e10cSrcweir TStringVector aVector;
86cdf0e10cSrcweir
87cdf0e10cSrcweir WpADOViews aViews = m_aCatalog.get_Views();
88cdf0e10cSrcweir aViews.fillElementNames(aVector);
89cdf0e10cSrcweir
90cdf0e10cSrcweir if(m_pViews)
91cdf0e10cSrcweir m_pViews->reFill(aVector);
92cdf0e10cSrcweir else
93cdf0e10cSrcweir m_pViews = new OViews(this,m_aMutex,aVector,aViews,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers());
94cdf0e10cSrcweir }
95cdf0e10cSrcweir // -------------------------------------------------------------------------
refreshGroups()96cdf0e10cSrcweir void OCatalog::refreshGroups()
97cdf0e10cSrcweir {
98cdf0e10cSrcweir TStringVector aVector;
99cdf0e10cSrcweir
100cdf0e10cSrcweir WpADOGroups aGroups = m_aCatalog.get_Groups();
101cdf0e10cSrcweir aGroups.fillElementNames(aVector);
102cdf0e10cSrcweir
103cdf0e10cSrcweir if(m_pGroups)
104cdf0e10cSrcweir m_pGroups->reFill(aVector);
105cdf0e10cSrcweir else
106cdf0e10cSrcweir m_pGroups = new OGroups(this,m_aMutex,aVector,aGroups,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers());
107cdf0e10cSrcweir }
108cdf0e10cSrcweir // -------------------------------------------------------------------------
refreshUsers()109cdf0e10cSrcweir void OCatalog::refreshUsers()
110cdf0e10cSrcweir {
111cdf0e10cSrcweir TStringVector aVector;
112cdf0e10cSrcweir
113cdf0e10cSrcweir WpADOUsers aUsers = m_aCatalog.get_Users();
114cdf0e10cSrcweir aUsers.fillElementNames(aVector);
115cdf0e10cSrcweir
116cdf0e10cSrcweir if(m_pUsers)
117cdf0e10cSrcweir m_pUsers->reFill(aVector);
118cdf0e10cSrcweir else
119cdf0e10cSrcweir m_pUsers = new OUsers(this,m_aMutex,aVector,aUsers,m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers());
120cdf0e10cSrcweir }
121cdf0e10cSrcweir // -------------------------------------------------------------------------
122cdf0e10cSrcweir
123cdf0e10cSrcweir
124