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 
27 #include "MacabTables.hxx"
28 #include "MacabTable.hxx"
29 #include "MacabCatalog.hxx"
30 #include "MacabConnection.hxx"
31 #include <comphelper/types.hxx>
32 
33 using namespace connectivity::macab;
34 using namespace connectivity;
35 using namespace ::comphelper;
36 using namespace ::cppu;
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::beans;
39 using namespace ::com::sun::star::sdbcx;
40 using namespace ::com::sun::star::sdbc;
41 using namespace ::com::sun::star::container;
42 using namespace ::com::sun::star::lang;
43 
createObject(const::rtl::OUString & _rName)44 sdbcx::ObjectType MacabTables::createObject(const ::rtl::OUString& _rName)
45 {
46 	::rtl::OUString aName,aSchema;
47 	aSchema = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
48 	aName = _rName;
49 
50 	Sequence< ::rtl::OUString > aTypes(1);
51 	aTypes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
52 	::rtl::OUString sEmpty;
53 
54 	Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), aSchema, aName, aTypes);
55 
56 	sdbcx::ObjectType xRet = NULL;
57 	if (xResult.is())
58 	{
59         Reference< XRow > xRow(xResult, UNO_QUERY);
60 		if (xResult->next()) // there can be only one table with this name
61 		{
62 			MacabTable* pRet = new MacabTable(
63 					this,
64 					static_cast<MacabCatalog&>(m_rParent).getConnection(),
65 					aName,
66 					xRow->getString(4),
67 					xRow->getString(5),
68 					sEmpty);
69 			xRet = pRet;
70 		}
71 	}
72 	::comphelper::disposeComponent(xResult);
73 
74 	return xRet;
75 }
76 // -------------------------------------------------------------------------
impl_refresh()77 void MacabTables::impl_refresh(  ) throw(RuntimeException)
78 {
79 	static_cast<MacabCatalog&>(m_rParent).refreshTables();
80 }
81 // -------------------------------------------------------------------------
disposing(void)82 void MacabTables::disposing(void)
83 {
84 m_xMetaData.clear();
85 	OCollection::disposing();
86 }
87