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_BDATABASEMETADATA_HXX_
28 #include "adabas/BDatabaseMetaData.hxx"
29 #endif
30 #include "FDatabaseMetaDataResultSet.hxx"
31 
32 using namespace connectivity::adabas;
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::beans;
35 //	using namespace ::com::sun::star::sdbcx;
36 using namespace ::com::sun::star::sdbc;
37 using namespace ::com::sun::star::container;
38 using namespace ::com::sun::star::lang;
39 
getURL()40 ::rtl::OUString SAL_CALL OAdabasDatabaseMetaData::getURL(  ) throw(SQLException, RuntimeException)
41 {
42     ::rtl::OUString aValue(RTL_CONSTASCII_USTRINGPARAM("sdbc:adabas:"));
43 	aValue += OAdabasDatabaseMetaData_BASE::getURLImpl();
44 	return aValue;
45 }
46 // -----------------------------------------------------------------------------
supportsIntegrityEnhancementFacility()47 sal_Bool SAL_CALL OAdabasDatabaseMetaData::supportsIntegrityEnhancementFacility(  ) throw(SQLException, RuntimeException)
48 {
49 	return sal_True;
50 }
51 // -----------------------------------------------------------------------------
impl_getTypeInfo_throw()52 Reference< XResultSet > OAdabasDatabaseMetaData::impl_getTypeInfo_throw(  )
53 {
54 	::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
55     Reference< XResultSet > xNewRes = pResult;
56 	static ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
57 	if(aRows.empty())
58 	{
59 		aRows.reserve(19);
60 		Reference< XResultSet > xRes = OAdabasDatabaseMetaData_BASE::impl_getTypeInfo_throw();
61 
62 		if(xRes.is())
63 		{
64 			::connectivity::ODatabaseMetaDataResultSet::ORow aRow(19);
65 
66 			Reference< XRow> xRow(xRes,UNO_QUERY);
67 			while(xRes->next())
68 			{
69 				sal_Int32 nPos = 1;
70 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString	(1));
71 				if(xRow->wasNull())
72 					aRow[nPos-1]->setNull();
73 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt		(2));
74 				if(xRow->wasNull())
75 					aRow[nPos-1]->setNull();
76 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt		(3));
77 				if(xRow->wasNull())
78 					aRow[nPos-1]->setNull();
79 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString	(4));
80 				if(xRow->wasNull())
81 					aRow[nPos-1]->setNull();
82 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString	(5));
83 				if(xRow->wasNull())
84 					aRow[nPos-1]->setNull();
85 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString	(6));
86 				if(xRow->wasNull())
87 					aRow[nPos-1]->setNull();
88 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt		(7));
89 				if(xRow->wasNull())
90 					aRow[nPos-1]->setNull();
91 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getBoolean	(8));
92 				if(xRow->wasNull())
93 					aRow[nPos-1]->setNull();
94 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getShort		(9));
95 				if(xRow->wasNull())
96 					aRow[nPos-1]->setNull();
97 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getBoolean	(10));
98 				if(xRow->wasNull())
99 					aRow[nPos-1]->setNull();
100 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt		(11));
101 				if(xRow->wasNull())
102 					aRow[nPos-1]->setNull();
103 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getBoolean	(12));
104 				if(xRow->wasNull())
105 					aRow[nPos-1]->setNull();
106 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString	(13));
107 				if(xRow->wasNull())
108 					aRow[nPos-1]->setNull();
109 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getShort		(14));
110 				if(xRow->wasNull())
111 					aRow[nPos-1]->setNull();
112 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getShort		(15));
113 				if(xRow->wasNull())
114 					aRow[nPos-1]->setNull();
115 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt		(16));
116 				if(xRow->wasNull())
117 					aRow[nPos-1]->setNull();
118 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt		(17));
119 				if(xRow->wasNull())
120 					aRow[nPos-1]->setNull();
121 				aRow[nPos++] = new ::connectivity::ORowSetValueDecorator((sal_Int16)xRow->getInt(18));
122 				if(xRow->wasNull())
123 					aRow[nPos-1]->setNull();
124 
125 				// we have to fix some incorrect entries
126 				if(!aRow[2]->getValue().isNull())
127 				{
128 					switch((sal_Int32)aRow[2]->getValue())
129 					{
130 						case DataType::FLOAT:
131 //							aRow[3] = sal_Int32(15);
132 //							break;
133 						case DataType::REAL:
134 //							aRow[3] = sal_Int32(16);
135 //							break;
136 						case DataType::DOUBLE:
137 							aRow[2]->setValue(DataType::DOUBLE);
138 							aRow[3]->setValue(sal_Int32(18));
139 							break;
140 						case DataType::TIMESTAMP:
141 							aRow[3]->setValue(sal_Int32(27));
142 							break;
143 						default:
144 							break;
145 					}
146 				}
147 				aRows.push_back(aRow);
148 			}
149 		}
150 	}
151 	pResult->setRows(aRows);
152     return xNewRes;
153 }
154 // -----------------------------------------------------------------------------
155 
156 
157 
158