1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26 #include "NCatalog.hxx"
27 #include "NConnection.hxx"
28 #include "NTables.hxx"
29 #include <com/sun/star/sdbc/XRow.hpp>
30 #include <com/sun/star/sdbc/XResultSet.hpp>
31 #include "NDebug.hxx"
32 
33 
34 // -------------------------------------------------------------------------
35 using namespace connectivity::evoab;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::beans;
38 using namespace ::com::sun::star::sdbcx;
39 using namespace ::com::sun::star::sdbc;
40 using namespace ::com::sun::star::container;
41 using namespace ::com::sun::star::lang;
42 // -------------------------------------------------------------------------
OEvoabCatalog(OEvoabConnection * _pCon)43 OEvoabCatalog::OEvoabCatalog(OEvoabConnection* _pCon) :
44 	connectivity::sdbcx::OCatalog(_pCon)
45 	,m_pConnection(_pCon)
46 	,m_xMetaData(m_pConnection->getMetaData())
47 {
48 }
refreshTables()49 void OEvoabCatalog::refreshTables()
50 {
51 	TStringVector aVector;
52 	Sequence< ::rtl::OUString > aTypes(1);
53 	aTypes[0] = ::rtl::OUString::createFromAscii("TABLE");
54 	Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
55 		::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes);
56 
57 	if(xResult.is())
58 	{
59 		Reference< XRow > xRow(xResult,UNO_QUERY);
60 		::rtl::OUString aName;
61 
62 		while(xResult->next())
63 		{
64 			aName = xRow->getString(3);
65 			aVector.push_back(aName);
66 		}
67 	}
68 	if(m_pTables)
69 		m_pTables->reFill(aVector);
70 	else
71 		m_pTables = new OEvoabTables(m_xMetaData,*this,m_aMutex,aVector);
72 }
73 // XTablesSupplier
getTables()74 Reference< XNameAccess > SAL_CALL  OEvoabCatalog::getTables(  ) throw(RuntimeException)
75 {
76         ::osl::MutexGuard aGuard(m_aMutex);
77 
78         try
79         {
80                 if (!m_pTables) {
81                         refreshTables();
82                         }
83         }
84         catch( const RuntimeException& )
85         {
86                 // allowed to leave this method
87                 throw;
88         }
89         catch( const Exception& )
90         {
91                 // allowed
92         }
93 
94         return m_pTables;
95 }
96 
97