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