diff options
author | Oliver Bolte <obo@openoffice.org> | 2006-07-10 13:18:48 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2006-07-10 13:18:48 +0000 |
commit | 2f3be886b46b3ea6b09d6ea545fa629dc1e8bb69 (patch) | |
tree | ed65c458c741aed6f5c69c00d3d2d574dc1429e9 /connectivity/source/commontools/TColumnsHelper.cxx | |
parent | b1a6cb0e8cbc33de1d3d13ea870dd41d8034d287 (diff) |
INTEGRATION: CWS qiq (1.6.104); FILE MERGED
2006/06/27 13:55:30 fs 1.6.104.3: RESYNC: (1.6-1.7); FILE MERGED
2006/06/16 11:32:28 fs 1.6.104.2: during #i51143#:
refactored VCollection:
- createEmptyObject now named createDescriptor
- cloneObject removed
- appendObject now returns the newly created object
(previously done via a subsequent call to cloneObject)
2006/05/23 13:24:20 fs 1.6.104.1: some refactoring of compose/quoteTableName and friends, in preparation of #i51143#
Diffstat (limited to 'connectivity/source/commontools/TColumnsHelper.cxx')
-rw-r--r-- | connectivity/source/commontools/TColumnsHelper.cxx | 59 |
1 files changed, 24 insertions, 35 deletions
diff --git a/connectivity/source/commontools/TColumnsHelper.cxx b/connectivity/source/commontools/TColumnsHelper.cxx index f44c7de411..cc3e737cfa 100644 --- a/connectivity/source/commontools/TColumnsHelper.cxx +++ b/connectivity/source/commontools/TColumnsHelper.cxx @@ -4,9 +4,9 @@ * * $RCSfile: TColumnsHelper.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: hr $ $Date: 2006-06-20 01:03:29 $ + * last change: $Author: obo $ $Date: 2006-07-10 14:18:48 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -130,10 +130,7 @@ sdbcx::ObjectType OColumnsHelper::createObject(const ::rtl::OUString& _rName) ColumnInformationMap::iterator aFind = m_pImpl->m_aColumnInfo.find(_rName); if ( aFind == m_pImpl->m_aColumnInfo.end() ) // we have to fill it { - Reference<XDatabaseMetaData> xMetaData = xConnection->getMetaData(); - sal_Bool bUseCatalogInSelect = isDataSourcePropertyEnabled(xConnection,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseCatalogInSelect")),sal_True); - sal_Bool bUseSchemaInSelect = isDataSourcePropertyEnabled(xConnection,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseSchemaInSelect")),sal_True); - ::rtl::OUString sComposedName = ::dbtools::composeTableName(xMetaData,m_pTable,sal_True,::dbtools::eInDataManipulation,bUseCatalogInSelect,bUseSchemaInSelect); + ::rtl::OUString sComposedName = ::dbtools::composeTableNameForSelect( xConnection, m_pTable ); collectColumnInformation(xConnection,sComposedName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*")) ,m_pImpl->m_aColumnInfo); aFind = m_pImpl->m_aColumnInfo.find(_rName); } @@ -144,7 +141,7 @@ sdbcx::ObjectType OColumnsHelper::createObject(const ::rtl::OUString& _rName) bIsCurrency = aFind->second.first.second; nDataType = aFind->second.second; } - + sdbcx::ObjectType xRet(::dbtools::createSDBCXColumn( m_pTable, xConnection, @@ -162,47 +159,39 @@ void OColumnsHelper::impl_refresh() throw(RuntimeException) { if ( m_pTable ) { - m_pImpl->m_aColumnInfo.clear(); + m_pImpl->m_aColumnInfo.clear(); m_pTable->refreshColumns(); } } // ------------------------------------------------------------------------- -Reference< XPropertySet > OColumnsHelper::createEmptyObject() +Reference< XPropertySet > OColumnsHelper::createDescriptor() { return new OColumn(sal_True); } // ----------------------------------------------------------------------------- -sdbcx::ObjectType OColumnsHelper::cloneObject(const Reference< XPropertySet >& _xDescriptor) -{ - Reference<XPropertySet> xProp = createEmptyObject(); - ::comphelper::copyProperties(_xDescriptor,xProp); - return xProp; -} -// ----------------------------------------------------------------------------- // XAppend -void OColumnsHelper::appendObject( const Reference< XPropertySet >& descriptor ) +sdbcx::ObjectType OColumnsHelper::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor ) { ::osl::MutexGuard aGuard(m_rMutex); OSL_ENSURE(m_pTable,"OColumnsHelper::appendByDescriptor: Table is null!"); - OSL_ENSURE(descriptor.is(),"OColumnsHelper::appendByDescriptor: descriptor is null!"); - - if ( descriptor.is() && m_pTable && !m_pTable->isNew() ) + if ( !m_pTable || m_pTable->isNew() ) + return cloneDescriptor( descriptor ); + + Reference<XDatabaseMetaData> xMetaData = m_pTable->getConnection()->getMetaData(); + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE "); + ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString( ); + + aSql += ::dbtools::composeTableName( xMetaData, m_pTable, ::dbtools::eInTableDefinitions, false, false, true ); + aSql += ::rtl::OUString::createFromAscii(" ADD "); + aSql += ::dbtools::createStandardColumnPart(descriptor,m_pTable->getConnection()); + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + if ( xStmt.is() ) { - Reference<XDatabaseMetaData> xMetaData = m_pTable->getConnection()->getMetaData(); - ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE "); - ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString( ); - - aSql += ::dbtools::composeTableName(xMetaData,m_pTable,sal_True,::dbtools::eInTableDefinitions); - aSql += ::rtl::OUString::createFromAscii(" ADD "); - aSql += ::dbtools::createStandardColumnPart(descriptor,m_pTable->getConnection()); - - Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); - if ( xStmt.is() ) - { - xStmt->execute(aSql); - ::comphelper::disposeComponent(xStmt); - } + xStmt->execute(aSql); + ::comphelper::disposeComponent(xStmt); } + return createObject( _rForName ); } // ------------------------------------------------------------------------- // XDrop @@ -215,7 +204,7 @@ void OColumnsHelper::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElem Reference<XDatabaseMetaData> xMetaData = m_pTable->getConnection()->getMetaData(); ::rtl::OUString aQuote = xMetaData->getIdentifierQuoteString( ); - aSql += ::dbtools::composeTableName(xMetaData,m_pTable,sal_True,::dbtools::eInTableDefinitions); + aSql += ::dbtools::composeTableName( xMetaData, m_pTable, ::dbtools::eInTableDefinitions, false, false, true ); aSql += ::rtl::OUString::createFromAscii(" DROP "); aSql += ::dbtools::quoteName( aQuote,_sElementName); |