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 #ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_
25 #define _CONNECTIVITY_ADABAS_TABLE_HXX_
26 
27 #include "connectivity/sdbcx/VTable.hxx"
28 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
29 #include "adabas/BConnection.hxx"
30 #include "connectivity/TTableHelper.hxx"
31 
32 namespace connectivity
33 {
34 	namespace adabas
35 	{
36 		typedef connectivity::OTableHelper OTable_TYPEDEF;
37 
38         ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp);
39 
40 		class OAdabasTable : public OTableHelper
41 		{
42 			OAdabasConnection* m_pConnection;
43 		protected:
44 			/** creates the column collection for the table
45 				@param	_rNames
46 					The column names.
47 			*/
48 			virtual sdbcx::OCollection* createColumns(const TStringVector& _rNames);
49 
50 			/** creates the key collection for the table
51 				@param	_rNames
52 					The key names.
53 			*/
54 			virtual sdbcx::OCollection* createKeys(const TStringVector& _rNames);
55 
56 			/** creates the index collection for the table
57 				@param	_rNames
58 					The index names.
59 			*/
60 			virtual sdbcx::OCollection* createIndexes(const TStringVector& _rNames);
61 
62 		public:
63 			OAdabasTable(	sdbcx::OCollection* _pTables,
64 							OAdabasConnection* _pConnection);
65 			OAdabasTable(	sdbcx::OCollection* _pTables,
66 							OAdabasConnection* _pConnection,
67 					const ::rtl::OUString& _Name,
68 					const ::rtl::OUString& _Type,
69 					const ::rtl::OUString& _Description = ::rtl::OUString(),
70 					const ::rtl::OUString& _SchemaName = ::rtl::OUString(),
71 					const ::rtl::OUString& _CatalogName = ::rtl::OUString()
72 				);
73 
getTableName() const74 			::rtl::OUString getTableName() const { return m_Name; }
getSchema() const75 			::rtl::OUString getSchema() const { return m_SchemaName; }
76 
77 			// com::sun::star::lang::XUnoTunnel
78             virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
79             static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
80 
81 			// XAlterTable
82             virtual void SAL_CALL alterColumnByName( const ::rtl::OUString& colName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
83 			// XNamed
84 			virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
85 			/**
86 				returns the ALTER TABLE XXX COLUMN statement
87 			*/
88 			::rtl::OUString getAlterTableColumnPart(const ::rtl::OUString& _rsColumnName );
89 
90 			// starts a sql transaaction
91 			void beginTransAction();
92 			// rolls back a sql transaaction
93 			void rollbackTransAction();
94 			// ends a sql transaaction
95 			void endTransAction();
96 			// some methods to alter table structures
97 			void alterColumnType(const ::rtl::OUString& _rColName,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDescriptor);
98 			void alterNotNullValue(sal_Int32 _nNewNullable,const ::rtl::OUString& _rColName);
99 			void alterDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName);
100 			void dropDefaultValue(const ::rtl::OUString& _sNewDefault);
101 			void addDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName);
102 		};
103 	}
104 }
105 #endif // _CONNECTIVITY_ADABAS_TABLE_HXX_
106 
107