From f609294ba49064121a22697abe0e595a0149b9d1 Mon Sep 17 00:00:00 2001 From: Ocke Janssen Date: Thu, 29 Mar 2001 06:07:13 +0000 Subject: views impl --- connectivity/source/drivers/adabas/BCatalog.cxx | 34 +++++++++---------- connectivity/source/drivers/adabas/BTables.cxx | 43 +++---------------------- connectivity/source/drivers/adabas/makefile.mk | 5 +-- connectivity/source/inc/adabas/BTables.hxx | 5 ++- connectivity/source/sdbcx/VView.cxx | 6 ++-- 5 files changed, 30 insertions(+), 63 deletions(-) (limited to 'connectivity') diff --git a/connectivity/source/drivers/adabas/BCatalog.cxx b/connectivity/source/drivers/adabas/BCatalog.cxx index b9c73fdc4aa3..e36977b7f916 100644 --- a/connectivity/source/drivers/adabas/BCatalog.cxx +++ b/connectivity/source/drivers/adabas/BCatalog.cxx @@ -2,9 +2,9 @@ * * $RCSfile: BCatalog.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * last change: $Author: oj $ $Date: 2001-03-29 07:02:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,6 +74,9 @@ #ifndef _CONNECTIVITY_ADABAS_TABLES_HXX_ #include "adabas/BTables.hxx" #endif +#ifndef _CONNECTIVITY_ADABAS_VIEWS_HXX_ +#include "adabas/BViews.hxx" +#endif #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ #include #endif @@ -115,16 +118,13 @@ void OAdabasCatalog::refreshTables() if(xResult.is()) { Reference< XRow > xRow(xResult,UNO_QUERY); - ::rtl::OUString aName,aDot = ::rtl::OUString::createFromAscii("."),aView = ::rtl::OUString::createFromAscii("VIEW"); + ::rtl::OUString aName,aDot = ::rtl::OUString::createFromAscii("."); while(xResult->next()) { - if(xRow->getString(4) != aView) - { - aName = xRow->getString(2); - aName += aDot; - aName += xRow->getString(3); - aVector.push_back(aName); - } + aName = xRow->getString(2); + aName += aDot; + aName += xRow->getString(3); + aVector.push_back(aName); } } if(m_pTables) @@ -135,10 +135,10 @@ void OAdabasCatalog::refreshTables() void OAdabasCatalog::refreshViews() { ::std::vector< ::rtl::OUString> aVector; - Sequence< ::rtl::OUString > aTypes(1); - aTypes[0] = ::rtl::OUString::createFromAscii("VIEW"); - Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), - ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes); + + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + Reference< XResultSet > xResult = xStmt->executeQuery( + ::rtl::OUString::createFromAscii("SELECT DISTINCT DOMAIN.VIEWDEFS.OWNER, DOMAIN.VIEWDEFS.VIEWNAME FROM DOMAIN.VIEWDEFS")); if(xResult.is()) { @@ -146,15 +146,15 @@ void OAdabasCatalog::refreshViews() ::rtl::OUString aName,aDot = ::rtl::OUString::createFromAscii("."); while(xResult->next()) { - aName = xRow->getString(2); + aName = xRow->getString(1); aName += aDot; - aName += xRow->getString(3); + aName += xRow->getString(2); aVector.push_back(aName); } } if(m_pViews) delete m_pViews; - m_pViews = new OTables(m_xMetaData,*this,m_aMutex,aVector); + m_pViews = new OViews(m_xMetaData,*this,m_aMutex,aVector); } // ------------------------------------------------------------------------- void OAdabasCatalog::refreshGroups() diff --git a/connectivity/source/drivers/adabas/BTables.cxx b/connectivity/source/drivers/adabas/BTables.cxx index 5eba1a656fd4..d727d8e1a463 100644 --- a/connectivity/source/drivers/adabas/BTables.cxx +++ b/connectivity/source/drivers/adabas/BTables.cxx @@ -2,9 +2,9 @@ * * $RCSfile: BTables.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: oj $ $Date: 2001-03-28 11:48:02 $ + * last change: $Author: oj $ $Date: 2001-03-29 07:02:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -171,10 +171,7 @@ void SAL_CALL OTables::appendByDescriptor( const Reference< XPropertySet >& desc if(!aName.getLength()) ::dbtools::FunctionSequenceException(*this); - if(descriptor->getPropertySetInfo()->hasPropertyByName(PROPERTY_COMMAND)) // here we have a view - createView(descriptor); - else - createTable(descriptor); + createTable(descriptor); OCollection_TYPE::appendByDescriptor(descriptor); } @@ -253,7 +250,7 @@ void SAL_CALL OTables::dropByName( const ::rtl::OUString& elementName ) throw(SQ aName = elementName.copy(nLen+1); ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP "); Reference xProp(xTunnel,UNO_QUERY); - if(xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_COMMAND)) // here we have a view + if(xProp.is() && ::comphelper::getString(xProp->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString::createFromAscii("VIEW")) // here we have a view aSql += ::rtl::OUString::createFromAscii("VIEW "); else aSql += ::rtl::OUString::createFromAscii("TABLE "); @@ -465,38 +462,6 @@ void OTables::createTable( const Reference< XPropertySet >& descriptor ) setComments(descriptor); } // ----------------------------------------------------------------------------- -void OTables::createView( const Reference< XPropertySet >& descriptor ) -{ - ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE VIEW "); - ::rtl::OUString aQuote = static_cast(m_rParent).getConnection()->getMetaData()->getIdentifierQuoteString( ); - ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."),sSchema,sCommand; - - descriptor->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema; - if(sSchema.getLength()) - aSql += ::dbtools::quoteName(aQuote, sSchema) + aDot; - else - descriptor->setPropertyValue(PROPERTY_SCHEMANAME,makeAny(static_cast(m_rParent).getConnection()->getMetaData()->getUserName())); - - aSql += ::dbtools::quoteName(aQuote, getString(descriptor->getPropertyValue(PROPERTY_NAME))) - + ::rtl::OUString::createFromAscii(" AS "); - descriptor->getPropertyValue(PROPERTY_SCHEMANAME) >>= sCommand; - aSql += sCommand; - - OAdabasConnection* pConnection = static_cast(m_rParent).getConnection(); - Reference< XStatement > xStmt = pConnection->createStatement( ); - xStmt->execute(aSql); - - // insert the new view also in the tables collection - OTables* pTables = static_cast(static_cast(m_rParent).getPrivateTables()); - if(pTables) - { - ::rtl::OUString sName = sSchema; - sName += aDot; - sName += getString(descriptor->getPropertyValue(PROPERTY_NAME)); - pTables->appendNew(sName); - } -} -// ----------------------------------------------------------------------------- void OTables::appendNew(const ::rtl::OUString& _rsNewTable) { m_aElements.push_back(m_aNameMap.insert(m_aNameMap.begin(), ObjectMap::value_type(_rsNewTable,WeakReference< XNamed >()))); diff --git a/connectivity/source/drivers/adabas/makefile.mk b/connectivity/source/drivers/adabas/makefile.mk index 0bc075316797..fbc8e524c2b2 100644 --- a/connectivity/source/drivers/adabas/makefile.mk +++ b/connectivity/source/drivers/adabas/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.13 $ +# $Revision: 1.14 $ # -# last change: $Author: oj $ $Date: 2001-03-19 09:35:27 $ +# last change: $Author: oj $ $Date: 2001-03-29 07:02:32 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -95,6 +95,7 @@ SLOFILES=\ $(SLO)$/BIndexes.obj \ $(SLO)$/BTable.obj \ $(SLO)$/BTables.obj \ + $(SLO)$/BViews.obj \ $(SLO)$/Bservices.obj \ $(SLO)$/BDatabaseMetaData.obj \ $(SLO)$/BPreparedStatement.obj \ diff --git a/connectivity/source/inc/adabas/BTables.hxx b/connectivity/source/inc/adabas/BTables.hxx index ba4d9c5b1ac0..229d3260ad04 100644 --- a/connectivity/source/inc/adabas/BTables.hxx +++ b/connectivity/source/inc/adabas/BTables.hxx @@ -2,9 +2,9 @@ * * $RCSfile: BTables.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: oj $ $Date: 2001-03-28 11:29:53 $ + * last change: $Author: oj $ $Date: 2001-03-29 07:03:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -81,7 +81,6 @@ namespace connectivity virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); void setComments(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); void createTable( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ); - void createView( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ); public: OTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, const ::std::vector< ::rtl::OUString> &_rVector) : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector) diff --git a/connectivity/source/sdbcx/VView.cxx b/connectivity/source/sdbcx/VView.cxx index 3e6293b9d185..332b35cd419c 100644 --- a/connectivity/source/sdbcx/VView.cxx +++ b/connectivity/source/sdbcx/VView.cxx @@ -2,9 +2,9 @@ * * $RCSfile: VView.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: mh $ $Date: 2000-11-29 12:28:04 $ + * last change: $Author: oj $ $Date: 2001-03-29 07:05:00 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -99,10 +99,12 @@ OView::OView(sal_Bool _bCase, { m_Name = _Name; + construct(); } // ------------------------------------------------------------------------- OView::OView(sal_Bool _bCase): ODescriptor(OViewHelper::rBHelper,_bCase,sal_True) { + construct(); } // ------------------------------------------------------------------------- OView::~OView() -- cgit