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_MYSQL_TABLE_HXX 25 #define CONNECTIVITY_MYSQL_TABLE_HXX 26 27 #include "connectivity/TTableHelper.hxx" 28 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> 29 #include <comphelper/IdPropArrayHelper.hxx> 30 31 namespace connectivity 32 { 33 namespace mysql 34 { 35 36 ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp); 37 38 class OMySQLTable; 39 typedef ::comphelper::OIdPropertyArrayUsageHelper< OMySQLTable > OMySQLTable_PROP; 40 class OMySQLTable : public OTableHelper 41 ,public OMySQLTable_PROP 42 { 43 sal_Int32 m_nPrivileges; // we have to set our privileges by our own 44 45 /** executes the statmenmt. 46 @param _rStatement 47 The statement to execute. 48 */ 49 void executeStatement(const ::rtl::OUString& _rStatement ); 50 protected: 51 52 /** creates the column collection for the table 53 @param _rNames 54 The column names. 55 */ 56 virtual sdbcx::OCollection* createColumns(const TStringVector& _rNames); 57 58 /** creates the key collection for the table 59 @param _rNames 60 The key names. 61 */ 62 virtual sdbcx::OCollection* createKeys(const TStringVector& _rNames); 63 64 /** creates the index collection for the table 65 @param _rNames 66 The index names. 67 */ 68 virtual sdbcx::OCollection* createIndexes(const TStringVector& _rNames); 69 70 /** Returns always "RENAME TABLE " even for views. 71 * 72 * \return The start of the rename statement. 73 * @see http://dev.mysql.com/doc/refman/5.1/de/rename-table.html 74 */ 75 virtual ::rtl::OUString getRenameStart() const; 76 77 /** used to implement the creation of the array helper which is shared amongst all instances of the class. 78 This method needs to be implemented in derived classes. 79 <BR> 80 The method gets called with s_aMutex acquired. 81 <BR> 82 as long as IPropertyArrayHelper has no virtual destructor, the implementation of ~OPropertyArrayUsageHelper 83 assumes that you created an ::cppu::OPropertyArrayHelper when deleting s_pProps. 84 @return an pointer to the newly created array helper. Must not be NULL. 85 */ 86 virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const; 87 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); 88 89 public: 90 OMySQLTable( sdbcx::OCollection* _pTables, 91 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection); 92 OMySQLTable( sdbcx::OCollection* _pTables, 93 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection, 94 const ::rtl::OUString& _Name, 95 const ::rtl::OUString& _Type, 96 const ::rtl::OUString& _Description = ::rtl::OUString(), 97 const ::rtl::OUString& _SchemaName = ::rtl::OUString(), 98 const ::rtl::OUString& _CatalogName = ::rtl::OUString(), 99 sal_Int32 _nPrivileges = 0 100 ); 101 102 // ODescriptor 103 virtual void construct(); 104 // com::sun::star::lang::XUnoTunnel 105 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); 106 static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); 107 108 // XAlterTable 109 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); 110 /** returns the ALTER TABLE XXX statement 111 */ 112 ::rtl::OUString getAlterTableColumnPart(); 113 114 // some methods to alter table structures 115 void alterColumnType(sal_Int32 nNewType,const ::rtl::OUString& _rColName,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDescriptor); 116 void alterDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName); 117 void dropDefaultValue(const ::rtl::OUString& _sNewDefault); 118 119 virtual ::rtl::OUString getTypeCreatePattern() const; 120 }; 121 } 122 } 123 #endif // CONNECTIVITY_MYSQL_TABLE_HXX 124 125