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 #ifndef _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_
28 #include "adabas/BIndexColumns.hxx"
29 #endif
30 #include "connectivity/sdbcx/VIndexColumn.hxx"
31 #include <com/sun/star/sdbc/XRow.hpp>
32 #include <com/sun/star/sdbc/XResultSet.hpp>
33 #include <com/sun/star/sdbc/DataType.hpp>
34 #include <com/sun/star/sdbc/ColumnValue.hpp>
35 #include "adabas/BTable.hxx"
36 #include "adabas/BCatalog.hxx"
37 #include <comphelper/types.hxx>
38 #include <comphelper/property.hxx>
39
40 using namespace connectivity::adabas;
41 using namespace connectivity::sdbcx;
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::beans;
44 // using namespace ::com::sun::star::sdbcx;
45 using namespace ::com::sun::star::sdbc;
46 using namespace ::com::sun::star::container;
47 using namespace ::com::sun::star::lang;
48 // -------------------------------------------------------------------------
createObject(const::rtl::OUString & _rName)49 ObjectType OIndexColumns::createObject(const ::rtl::OUString& _rName)
50 {
51
52 Reference< XResultSet > xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getIndexInfo(Any(),
53 m_pIndex->getTable()->getSchema(),m_pIndex->getTable()->getTableName(),sal_False,sal_False);
54
55 sal_Bool bAsc = sal_True;
56 if(xResult.is())
57 {
58 Reference< XRow > xRow(xResult,UNO_QUERY);
59 ::rtl::OUString aD(::rtl::OUString::createFromAscii("D"));
60 while(xResult->next())
61 {
62 if(xRow->getString(9) == _rName)
63 bAsc = xRow->getString(10) != aD;
64 }
65 ::comphelper::disposeComponent(xResult);
66 }
67
68 xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getColumns(Any(),
69 m_pIndex->getTable()->getSchema(),m_pIndex->getTable()->getTableName(),_rName);
70
71 ObjectType xRet = NULL;
72 if(xResult.is())
73 {
74 Reference< XRow > xRow(xResult,UNO_QUERY);
75 while(xResult->next())
76 {
77 if(xRow->getString(4) == _rName)
78 {
79 sal_Int32 nType = xRow->getInt(5);
80 ::rtl::OUString sTypeName = xRow->getString(6);
81 sal_Int32 nPrec = xRow->getInt(7);
82 OAdabasCatalog::correctColumnProperties(nPrec,nType,sTypeName);
83
84 OIndexColumn* pRet = new OIndexColumn(bAsc,
85 _rName,
86 sTypeName,
87 xRow->getString(13),
88 xRow->getInt(11),
89 nPrec,
90 xRow->getInt(9),
91 nType,
92 sal_False,sal_False,sal_False,sal_True);
93 xRet = pRet;
94 break;
95 }
96 }
97 ::comphelper::disposeComponent(xResult);
98 }
99
100 return xRet;
101 }
102 // -------------------------------------------------------------------------
createDescriptor()103 Reference< XPropertySet > OIndexColumns::createDescriptor()
104 {
105 return new OIndexColumn(sal_True);
106 }
107 // -----------------------------------------------------------------------------
impl_refresh()108 void OIndexColumns::impl_refresh() throw(::com::sun::star::uno::RuntimeException)
109 {
110 m_pIndex->refreshColumns();
111 }
112 // -----------------------------------------------------------------------------
appendObject(const::rtl::OUString &,const Reference<XPropertySet> & descriptor)113 ObjectType OIndexColumns::appendObject( const ::rtl::OUString& /*_rForName*/, const Reference< XPropertySet >& descriptor )
114 {
115 return cloneDescriptor( descriptor );
116 }
117 // -----------------------------------------------------------------------------
118
119
120
121