1*caf5cd79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*caf5cd79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*caf5cd79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*caf5cd79SAndrew Rist  * distributed with this work for additional information
6*caf5cd79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*caf5cd79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*caf5cd79SAndrew Rist  * "License"); you may not use this file except in compliance
9*caf5cd79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*caf5cd79SAndrew Rist  *
11*caf5cd79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*caf5cd79SAndrew Rist  *
13*caf5cd79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*caf5cd79SAndrew Rist  * software distributed under the License is distributed on an
15*caf5cd79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*caf5cd79SAndrew Rist  * KIND, either express or implied.  See the License for the
17*caf5cd79SAndrew Rist  * specific language governing permissions and limitations
18*caf5cd79SAndrew Rist  * under the License.
19*caf5cd79SAndrew Rist  *
20*caf5cd79SAndrew Rist  *************************************************************/
21*caf5cd79SAndrew Rist 
22*caf5cd79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef CONNECTIVITY_HSQLDB_TABLE_HXX
25cdf0e10cSrcweir #define CONNECTIVITY_HSQLDB_TABLE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "connectivity/TTableHelper.hxx"
28cdf0e10cSrcweir #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
29cdf0e10cSrcweir #include <comphelper/IdPropArrayHelper.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir namespace connectivity
32cdf0e10cSrcweir {
33cdf0e10cSrcweir 	namespace hsqldb
34cdf0e10cSrcweir 	{
35cdf0e10cSrcweir 
36cdf0e10cSrcweir         ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp);
37cdf0e10cSrcweir 
38cdf0e10cSrcweir 		class OHSQLTable;
39cdf0e10cSrcweir 		typedef ::comphelper::OIdPropertyArrayUsageHelper< OHSQLTable >	OHSQLTable_PROP;
40cdf0e10cSrcweir 		class OHSQLTable :	public OTableHelper
41cdf0e10cSrcweir 							,public OHSQLTable_PROP
42cdf0e10cSrcweir 		{
43cdf0e10cSrcweir 			sal_Int32 m_nPrivileges; // we have to set our privileges by our own
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 			/** executes the statmenmt.
46cdf0e10cSrcweir 				@param	_rStatement
47cdf0e10cSrcweir 					The statement to execute.
48cdf0e10cSrcweir 				*/
49cdf0e10cSrcweir 			void executeStatement(const ::rtl::OUString& _rStatement );
50cdf0e10cSrcweir 		protected:
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 			/** creates the column collection for the table
53cdf0e10cSrcweir 				@param	_rNames
54cdf0e10cSrcweir 					The column names.
55cdf0e10cSrcweir 			*/
56cdf0e10cSrcweir 			virtual sdbcx::OCollection* createColumns(const TStringVector& _rNames);
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 			/** creates the key collection for the table
59cdf0e10cSrcweir 				@param	_rNames
60cdf0e10cSrcweir 					The key names.
61cdf0e10cSrcweir 			*/
62cdf0e10cSrcweir 			virtual sdbcx::OCollection* createKeys(const TStringVector& _rNames);
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 			/** creates the index collection for the table
65cdf0e10cSrcweir 				@param	_rNames
66cdf0e10cSrcweir 					The index names.
67cdf0e10cSrcweir 			*/
68cdf0e10cSrcweir 			virtual sdbcx::OCollection* createIndexes(const TStringVector& _rNames);
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 			/** used to implement the creation of the array helper which is shared amongst all instances of the class.
71cdf0e10cSrcweir 				This method needs to be implemented in derived classes.
72cdf0e10cSrcweir 				<BR>
73cdf0e10cSrcweir 				The method gets called with s_aMutex acquired.
74cdf0e10cSrcweir 				<BR>
75cdf0e10cSrcweir 				as long as IPropertyArrayHelper has no virtual destructor, the implementation of ~OPropertyArrayUsageHelper
76cdf0e10cSrcweir 				assumes that you created an ::cppu::OPropertyArrayHelper when deleting s_pProps.
77cdf0e10cSrcweir 				@return							an pointer to the newly created array helper. Must not be NULL.
78cdf0e10cSrcweir 			*/
79cdf0e10cSrcweir 			virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const;
80cdf0e10cSrcweir 			virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 		public:
83cdf0e10cSrcweir 			OHSQLTable(	sdbcx::OCollection* _pTables,
84cdf0e10cSrcweir 							const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection);
85cdf0e10cSrcweir 			OHSQLTable(	sdbcx::OCollection* _pTables,
86cdf0e10cSrcweir 							const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
87cdf0e10cSrcweir 							const ::rtl::OUString& _Name,
88cdf0e10cSrcweir 							const ::rtl::OUString& _Type,
89cdf0e10cSrcweir 							const ::rtl::OUString& _Description = ::rtl::OUString(),
90cdf0e10cSrcweir 							const ::rtl::OUString& _SchemaName = ::rtl::OUString(),
91cdf0e10cSrcweir 							const ::rtl::OUString& _CatalogName = ::rtl::OUString(),
92cdf0e10cSrcweir 							sal_Int32 _nPrivileges = 0
93cdf0e10cSrcweir 				);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 			// ODescriptor
96cdf0e10cSrcweir 			virtual void construct();
97cdf0e10cSrcweir 			// com::sun::star::lang::XUnoTunnel
98cdf0e10cSrcweir             virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
99cdf0e10cSrcweir             static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 			virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
102cdf0e10cSrcweir 			//XTypeProvider
103cdf0e10cSrcweir 			virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
104cdf0e10cSrcweir 			// XAlterTable
105cdf0e10cSrcweir             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);
106cdf0e10cSrcweir 
107cdf0e10cSrcweir             // XRename
108cdf0e10cSrcweir             virtual void SAL_CALL rename( const ::rtl::OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 			/**
111cdf0e10cSrcweir 				returns the ALTER TABLE XXX COLUMN statement
112cdf0e10cSrcweir 			*/
113cdf0e10cSrcweir 			::rtl::OUString getAlterTableColumnPart();
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 			// some methods to alter table structures
116cdf0e10cSrcweir 			void alterColumnType(sal_Int32 nNewType,const ::rtl::OUString& _rColName,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDescriptor);
117cdf0e10cSrcweir 			void alterDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName);
118cdf0e10cSrcweir 			void dropDefaultValue(const ::rtl::OUString& _sNewDefault);
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 		};
121cdf0e10cSrcweir 	}
122cdf0e10cSrcweir }
123cdf0e10cSrcweir #endif // CONNECTIVITY_HSQLDB_TABLE_HXX
124cdf0e10cSrcweir 
125