1*9b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9b5730f6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9b5730f6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9b5730f6SAndrew Rist  * distributed with this work for additional information
6*9b5730f6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9b5730f6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9b5730f6SAndrew Rist  * "License"); you may not use this file except in compliance
9*9b5730f6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9b5730f6SAndrew Rist  *
11*9b5730f6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9b5730f6SAndrew Rist  *
13*9b5730f6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9b5730f6SAndrew Rist  * software distributed under the License is distributed on an
15*9b5730f6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9b5730f6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9b5730f6SAndrew Rist  * specific language governing permissions and limitations
18*9b5730f6SAndrew Rist  * under the License.
19*9b5730f6SAndrew Rist  *
20*9b5730f6SAndrew Rist  *************************************************************/
21*9b5730f6SAndrew Rist 
22*9b5730f6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _CONNECTIVITY_ADABAS_BDATABASEMETADATA_HXX_
28cdf0e10cSrcweir #include "adabas/BDatabaseMetaData.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include "FDatabaseMetaDataResultSet.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir using namespace connectivity::adabas;
33cdf0e10cSrcweir using namespace ::com::sun::star::uno;
34cdf0e10cSrcweir using namespace ::com::sun::star::beans;
35cdf0e10cSrcweir //	using namespace ::com::sun::star::sdbcx;
36cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
37cdf0e10cSrcweir using namespace ::com::sun::star::container;
38cdf0e10cSrcweir using namespace ::com::sun::star::lang;
39cdf0e10cSrcweir 
getURL()40cdf0e10cSrcweir ::rtl::OUString SAL_CALL OAdabasDatabaseMetaData::getURL(  ) throw(SQLException, RuntimeException)
41cdf0e10cSrcweir {
42cdf0e10cSrcweir     ::rtl::OUString aValue(RTL_CONSTASCII_USTRINGPARAM("sdbc:adabas:"));
43cdf0e10cSrcweir 	aValue += OAdabasDatabaseMetaData_BASE::getURLImpl();
44cdf0e10cSrcweir 	return aValue;
45cdf0e10cSrcweir }
46cdf0e10cSrcweir // -----------------------------------------------------------------------------
supportsIntegrityEnhancementFacility()47cdf0e10cSrcweir sal_Bool SAL_CALL OAdabasDatabaseMetaData::supportsIntegrityEnhancementFacility(  ) throw(SQLException, RuntimeException)
48cdf0e10cSrcweir {
49cdf0e10cSrcweir 	return sal_True;
50cdf0e10cSrcweir }
51cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_getTypeInfo_throw()52cdf0e10cSrcweir Reference< XResultSet > OAdabasDatabaseMetaData::impl_getTypeInfo_throw(  )
53cdf0e10cSrcweir {
54cdf0e10cSrcweir 	::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
55cdf0e10cSrcweir     Reference< XResultSet > xNewRes = pResult;
56cdf0e10cSrcweir 	static ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
57cdf0e10cSrcweir 	if(aRows.empty())
58cdf0e10cSrcweir 	{
59cdf0e10cSrcweir 		aRows.reserve(19);
60cdf0e10cSrcweir 		Reference< XResultSet > xRes = OAdabasDatabaseMetaData_BASE::impl_getTypeInfo_throw();
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 		if(xRes.is())
63cdf0e10cSrcweir 		{
64cdf0e10cSrcweir 			::connectivity::ODatabaseMetaDataResultSet::ORow aRow(19);
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 			Reference< XRow> xRow(xRes,UNO_QUERY);
67cdf0e10cSrcweir 			while(xRes->next())
68cdf0e10cSrcweir 			{
69cdf0e10cSrcweir 				sal_Int32 nPos = 1;
70cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString	(1));
71cdf0e10cSrcweir 				if(xRow->wasNull())
72cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
73cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt		(2));
74cdf0e10cSrcweir 				if(xRow->wasNull())
75cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
76cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt		(3));
77cdf0e10cSrcweir 				if(xRow->wasNull())
78cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
79cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString	(4));
80cdf0e10cSrcweir 				if(xRow->wasNull())
81cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
82cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString	(5));
83cdf0e10cSrcweir 				if(xRow->wasNull())
84cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
85cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString	(6));
86cdf0e10cSrcweir 				if(xRow->wasNull())
87cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
88cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt		(7));
89cdf0e10cSrcweir 				if(xRow->wasNull())
90cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
91cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getBoolean	(8));
92cdf0e10cSrcweir 				if(xRow->wasNull())
93cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
94cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getShort		(9));
95cdf0e10cSrcweir 				if(xRow->wasNull())
96cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
97cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getBoolean	(10));
98cdf0e10cSrcweir 				if(xRow->wasNull())
99cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
100cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt		(11));
101cdf0e10cSrcweir 				if(xRow->wasNull())
102cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
103cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getBoolean	(12));
104cdf0e10cSrcweir 				if(xRow->wasNull())
105cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
106cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString	(13));
107cdf0e10cSrcweir 				if(xRow->wasNull())
108cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
109cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getShort		(14));
110cdf0e10cSrcweir 				if(xRow->wasNull())
111cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
112cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getShort		(15));
113cdf0e10cSrcweir 				if(xRow->wasNull())
114cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
115cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt		(16));
116cdf0e10cSrcweir 				if(xRow->wasNull())
117cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
118cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt		(17));
119cdf0e10cSrcweir 				if(xRow->wasNull())
120cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
121cdf0e10cSrcweir 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator((sal_Int16)xRow->getInt(18));
122cdf0e10cSrcweir 				if(xRow->wasNull())
123cdf0e10cSrcweir 					aRow[nPos-1]->setNull();
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 				// we have to fix some incorrect entries
126cdf0e10cSrcweir 				if(!aRow[2]->getValue().isNull())
127cdf0e10cSrcweir 				{
128cdf0e10cSrcweir 					switch((sal_Int32)aRow[2]->getValue())
129cdf0e10cSrcweir 					{
130cdf0e10cSrcweir 						case DataType::FLOAT:
131cdf0e10cSrcweir //							aRow[3] = sal_Int32(15);
132cdf0e10cSrcweir //							break;
133cdf0e10cSrcweir 						case DataType::REAL:
134cdf0e10cSrcweir //							aRow[3] = sal_Int32(16);
135cdf0e10cSrcweir //							break;
136cdf0e10cSrcweir 						case DataType::DOUBLE:
137cdf0e10cSrcweir 							aRow[2]->setValue(DataType::DOUBLE);
138cdf0e10cSrcweir 							aRow[3]->setValue(sal_Int32(18));
139cdf0e10cSrcweir 							break;
140cdf0e10cSrcweir 						case DataType::TIMESTAMP:
141cdf0e10cSrcweir 							aRow[3]->setValue(sal_Int32(27));
142cdf0e10cSrcweir 							break;
143cdf0e10cSrcweir 						default:
144cdf0e10cSrcweir 							break;
145cdf0e10cSrcweir 					}
146cdf0e10cSrcweir 				}
147cdf0e10cSrcweir 				aRows.push_back(aRow);
148cdf0e10cSrcweir 			}
149cdf0e10cSrcweir 		}
150cdf0e10cSrcweir 	}
151cdf0e10cSrcweir 	pResult->setRows(aRows);
152cdf0e10cSrcweir     return xNewRes;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir // -----------------------------------------------------------------------------
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 
158