xref: /AOO41X/main/connectivity/source/inc/mysql/YTable.hxx (revision caf5cd79edad04a48dcaf209068b3b89eae4622e)
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
10cdf0e10cSrcweir  *
11*caf5cd79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
20*caf5cd79SAndrew Rist  *************************************************************/
21*caf5cd79SAndrew Rist 
22*caf5cd79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef CONNECTIVITY_MYSQL_TABLE_HXX
25cdf0e10cSrcweir #define CONNECTIVITY_MYSQL_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 mysql
34cdf0e10cSrcweir     {
35cdf0e10cSrcweir 
36cdf0e10cSrcweir         ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp);
37cdf0e10cSrcweir 
38cdf0e10cSrcweir         class OMySQLTable;
39cdf0e10cSrcweir         typedef ::comphelper::OIdPropertyArrayUsageHelper< OMySQLTable >    OMySQLTable_PROP;
40cdf0e10cSrcweir         class OMySQLTable : public OTableHelper
41cdf0e10cSrcweir                             ,public OMySQLTable_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             /** Returns always "RENAME TABLE " even for views.
71cdf0e10cSrcweir             *
72cdf0e10cSrcweir             * \return The start of the rename statement.
73cdf0e10cSrcweir             * @see http://dev.mysql.com/doc/refman/5.1/de/rename-table.html
74cdf0e10cSrcweir             */
75cdf0e10cSrcweir             virtual ::rtl::OUString getRenameStart() const;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir             /** used to implement the creation of the array helper which is shared amongst all instances of the class.
78cdf0e10cSrcweir                 This method needs to be implemented in derived classes.
79cdf0e10cSrcweir                 <BR>
80cdf0e10cSrcweir                 The method gets called with s_aMutex acquired.
81cdf0e10cSrcweir                 <BR>
82cdf0e10cSrcweir                 as long as IPropertyArrayHelper has no virtual destructor, the implementation of ~OPropertyArrayUsageHelper
83cdf0e10cSrcweir                 assumes that you created an ::cppu::OPropertyArrayHelper when deleting s_pProps.
84cdf0e10cSrcweir                 @return                         an pointer to the newly created array helper. Must not be NULL.
85cdf0e10cSrcweir             */
86cdf0e10cSrcweir             virtual ::cppu::IPropertyArrayHelper* createArrayHelper(sal_Int32 nId) const;
87cdf0e10cSrcweir             virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
88cdf0e10cSrcweir 
89cdf0e10cSrcweir         public:
90cdf0e10cSrcweir             OMySQLTable(    sdbcx::OCollection* _pTables,
91cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection);
92cdf0e10cSrcweir             OMySQLTable(    sdbcx::OCollection* _pTables,
93cdf0e10cSrcweir                             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
94cdf0e10cSrcweir                             const ::rtl::OUString& _Name,
95cdf0e10cSrcweir                             const ::rtl::OUString& _Type,
96cdf0e10cSrcweir                             const ::rtl::OUString& _Description = ::rtl::OUString(),
97cdf0e10cSrcweir                             const ::rtl::OUString& _SchemaName = ::rtl::OUString(),
98cdf0e10cSrcweir                             const ::rtl::OUString& _CatalogName = ::rtl::OUString(),
99cdf0e10cSrcweir                             sal_Int32 _nPrivileges = 0
100cdf0e10cSrcweir                 );
101cdf0e10cSrcweir 
102cdf0e10cSrcweir             // ODescriptor
103cdf0e10cSrcweir             virtual void construct();
104cdf0e10cSrcweir             // com::sun::star::lang::XUnoTunnel
105cdf0e10cSrcweir             virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
106cdf0e10cSrcweir             static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir             // XAlterTable
109cdf0e10cSrcweir             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);
110cdf0e10cSrcweir             /** returns the ALTER TABLE XXX statement
111cdf0e10cSrcweir             */
112cdf0e10cSrcweir             ::rtl::OUString getAlterTableColumnPart();
113cdf0e10cSrcweir 
114cdf0e10cSrcweir             // some methods to alter table structures
115cdf0e10cSrcweir             void alterColumnType(sal_Int32 nNewType,const ::rtl::OUString& _rColName,const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDescriptor);
116cdf0e10cSrcweir             void alterDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName);
117cdf0e10cSrcweir             void dropDefaultValue(const ::rtl::OUString& _sNewDefault);
118cdf0e10cSrcweir 
119cdf0e10cSrcweir             virtual ::rtl::OUString getTypeCreatePattern() const;
120cdf0e10cSrcweir         };
121cdf0e10cSrcweir     }
122cdf0e10cSrcweir }
123cdf0e10cSrcweir #endif // CONNECTIVITY_MYSQL_TABLE_HXX
124cdf0e10cSrcweir 
125