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 "KTable.hxx"
28 #include "KTables.hxx"
29 #include "KColumns.hxx"
30 #include "KCatalog.hxx"
31 
32 using namespace connectivity::kab;
33 using namespace connectivity;
34 using namespace ::comphelper;
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::beans;
37 using namespace ::com::sun::star::sdbcx;
38 using namespace ::com::sun::star::sdbc;
39 using namespace ::com::sun::star::container;
40 using namespace ::com::sun::star::lang;
41 
42 // -------------------------------------------------------------------------
KabTable(sdbcx::OCollection * _pTables,KabConnection * _pConnection)43 KabTable::KabTable( sdbcx::OCollection* _pTables, KabConnection* _pConnection)
44 	: KabTable_TYPEDEF(_pTables, sal_True),
45 	m_pConnection(_pConnection)
46 {
47 	construct();
48 }
49 // -------------------------------------------------------------------------
KabTable(sdbcx::OCollection * _pTables,KabConnection * _pConnection,const::rtl::OUString & _Name,const::rtl::OUString & _Type,const::rtl::OUString & _Description,const::rtl::OUString & _SchemaName,const::rtl::OUString & _CatalogName)50 KabTable::KabTable( sdbcx::OCollection* _pTables,
51 	            KabConnection* _pConnection,
52 	            const ::rtl::OUString& _Name,
53 	            const ::rtl::OUString& _Type,
54 	            const ::rtl::OUString& _Description ,
55 	            const ::rtl::OUString& _SchemaName,
56 	            const ::rtl::OUString& _CatalogName
57 	            ) : KabTable_TYPEDEF(_pTables,sal_True,
58 	                              _Name,
59 	                              _Type,
60 	                              _Description,
61 	                              _SchemaName,
62 	                              _CatalogName),
63 	                m_pConnection(_pConnection)
64 {
65 	construct();
66 }
67 // -------------------------------------------------------------------------
refreshColumns()68 void KabTable::refreshColumns()
69 {
70 	TStringVector aVector;
71 
72 	if (!isNew())
73 	{
74 	    Reference< XResultSet > xResult = m_pConnection->getMetaData()->getColumns(
75 				Any(),
76 				m_SchemaName,
77 				m_Name,
78 				::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")));
79 
80 	    if (xResult.is())
81 	    {
82 		Reference< XRow > xRow(xResult, UNO_QUERY);
83 		while (xResult->next())
84 				aVector.push_back(xRow->getString(4));
85 	    }
86 	}
87 
88 	if (m_pColumns)
89 	    m_pColumns->reFill(aVector);
90 	else
91 	    m_pColumns  = new KabColumns(this,m_aMutex,aVector);
92 }
93