xref: /AOO41X/main/connectivity/source/drivers/evoab2/NTables.cxx (revision 9b5730f6ddef7eb82608ca4d31dc0d7678e652cf)
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 "NTables.hxx"
27 #include <com/sun/star/sdbc/XRow.hpp>
28 #include <com/sun/star/sdbc/XResultSet.hpp>
29 #include <com/sun/star/sdbc/ColumnValue.hpp>
30 #include <com/sun/star/sdbc/KeyRule.hpp>
31 #include <com/sun/star/sdbcx/KeyType.hpp>
32 #include <connectivity/sdbcx/VTable.hxx>
33 #include "NCatalog.hxx"
34 #ifndef _CONNECTIVITY_EVOAB_BCONNECTION_HXX_
35 #include "NConnection.hxx"
36 #endif
37 #include <comphelper/extract.hxx>
38 #include "connectivity/dbtools.hxx"
39 #include "connectivity/dbexception.hxx"
40 #include <cppuhelper/interfacecontainer.h>
41 #include <comphelper/types.hxx>
42 #include "NDebug.hxx"
43 #include "NTable.hxx"
44 using namespace ::comphelper;
45 
46 using namespace ::cppu;
47 using namespace connectivity::evoab;
48 using namespace connectivity::sdbcx;
49 using namespace ::com::sun::star::uno;
50 using namespace ::com::sun::star::beans;
51 using namespace ::com::sun::star::sdbcx;
52 using namespace ::com::sun::star::sdbc;
53 using namespace ::com::sun::star::container;
54 using namespace ::com::sun::star::lang;
55 using namespace dbtools;
56 typedef connectivity::sdbcx::OCollection OCollection_TYPE;
57 
createObject(const::rtl::OUString & aName)58 ObjectType OEvoabTables::createObject(const ::rtl::OUString& aName)
59 {
60     ::rtl::OUString aSchema = ::rtl::OUString::createFromAscii("%");
61 
62     Sequence< ::rtl::OUString > aTypes(1);
63     aTypes[0] = ::rtl::OUString::createFromAscii("TABLE");
64     ::rtl::OUString sEmpty;
65 
66     Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),aSchema,aName,aTypes);
67 
68     ObjectType xRet = NULL;
69     if(xResult.is())
70     {
71         Reference< XRow > xRow(xResult,UNO_QUERY);
72         if(xResult->next()) // there can be only one table with this name
73         {
74             OEvoabTable* pRet = new OEvoabTable(
75                     this,
76                     (OEvoabConnection *)static_cast<OEvoabCatalog&>(m_rParent).getConnection(),
77                     aName,
78                     xRow->getString(4),
79                     xRow->getString(5),
80                     sEmpty);
81                     xRet = pRet;
82         }
83     }
84 
85     ::comphelper::disposeComponent(xResult);
86 
87     return xRet;
88 }
89 // -------------------------------------------------------------------------
impl_refresh()90 void OEvoabTables::impl_refresh(  ) throw(RuntimeException)
91 {
92     static_cast<OEvoabCatalog&>(m_rParent).refreshTables();
93 }
94 // -------------------------------------------------------------------------
disposing(void)95 void OEvoabTables::disposing(void)
96 {
97 m_xMetaData.clear();
98     OCollection::disposing();
99 }
100 // -----------------------------------------------------------------------------
101 
102