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 "adabas/BIndex.hxx" 27 #ifndef _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_ 28 #include "adabas/BIndexColumns.hxx" 29 #endif 30 #include <com/sun/star/sdbc/XRow.hpp> 31 #include <com/sun/star/sdbc/XResultSet.hpp> 32 #include "adabas/BTable.hxx" 33 #include <comphelper/types.hxx> 34 35 using namespace connectivity::adabas; 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 // ------------------------------------------------------------------------- 43 OAdabasIndex::OAdabasIndex( OAdabasTable* _pTable, 44 const ::rtl::OUString& _Name, 45 const ::rtl::OUString& _Catalog, 46 sal_Bool _isUnique, 47 sal_Bool _isPrimaryKeyIndex, 48 sal_Bool _isClustered 49 ) : connectivity::sdbcx::OIndex(_Name, 50 _Catalog, 51 _isUnique, 52 _isPrimaryKeyIndex, 53 _isClustered,sal_True) 54 ,m_pTable(_pTable) 55 { 56 construct(); 57 refreshColumns(); 58 } 59 // ------------------------------------------------------------------------- 60 OAdabasIndex::OAdabasIndex(OAdabasTable* _pTable) 61 : connectivity::sdbcx::OIndex(sal_True) 62 ,m_pTable(_pTable) 63 { 64 construct(); 65 } 66 // ----------------------------------------------------------------------------- 67 68 void OAdabasIndex::refreshColumns() 69 { 70 if(!m_pTable) 71 return; 72 73 TStringVector aVector; 74 if(!isNew()) 75 { 76 Reference< XResultSet > xResult = m_pTable->getMetaData()->getIndexInfo(Any(), 77 m_pTable->getSchema(),m_pTable->getTableName(),sal_False,sal_False); 78 79 if(xResult.is()) 80 { 81 Reference< XRow > xRow(xResult,UNO_QUERY); 82 ::rtl::OUString aColName; 83 while(xResult->next()) 84 { 85 if(xRow->getString(6) == m_Name) 86 { 87 aColName = xRow->getString(9); 88 if(!xRow->wasNull()) 89 aVector.push_back(aColName); 90 } 91 } 92 ::comphelper::disposeComponent(xResult); 93 } 94 } 95 if(m_pColumns) 96 m_pColumns->reFill(aVector); 97 else 98 m_pColumns = new OIndexColumns(this,m_aMutex,aVector); 99 } 100 // ----------------------------------------------------------------------------- 101 102 103