diff options
Diffstat (limited to 'connectivity/source/drivers/adabas')
21 files changed, 4165 insertions, 0 deletions
diff --git a/connectivity/source/drivers/adabas/BCatalog.cxx b/connectivity/source/drivers/adabas/BCatalog.cxx new file mode 100644 index 000000000000..b9c73fdc4aa3 --- /dev/null +++ b/connectivity/source/drivers/adabas/BCatalog.cxx @@ -0,0 +1,195 @@ +/************************************************************************* + * + * $RCSfile: BCatalog.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADABAS_CATALOG_HXX_ +#include "adabas/BCatalog.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_BCONNECTION_HXX_ +#include "adabas/BConnection.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_GROUPS_HXX_ +#include "adabas/BGroups.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_USERS_HXX_ +#include "adabas/BUsers.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLES_HXX_ +#include "adabas/BTables.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif + + +// ------------------------------------------------------------------------- +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +// ------------------------------------------------------------------------- +OAdabasCatalog::OAdabasCatalog(SQLHANDLE _aConnectionHdl, OAdabasConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon) + ,m_pConnection(_pCon) + ,m_aConnectionHdl(_aConnectionHdl) + ,m_xMetaData(m_pConnection->getMetaData( )) +{ + osl_incrementInterlockedCount( &m_refCount ); + refreshTables(); + refreshViews(); + refreshGroups(); + refreshUsers(); + osl_decrementInterlockedCount( &m_refCount ); +} +// ------------------------------------------------------------------------- +void OAdabasCatalog::refreshTables() +{ + ::std::vector< ::rtl::OUString> aVector; + Sequence< ::rtl::OUString > aTypes(1); + aTypes[0] = ::rtl::OUString::createFromAscii("%"); + Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), + ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + ::rtl::OUString aName,aDot = ::rtl::OUString::createFromAscii("."),aView = ::rtl::OUString::createFromAscii("VIEW"); + while(xResult->next()) + { + if(xRow->getString(4) != aView) + { + aName = xRow->getString(2); + aName += aDot; + aName += xRow->getString(3); + aVector.push_back(aName); + } + } + } + if(m_pTables) + delete m_pTables; + m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +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); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + ::rtl::OUString aName,aDot = ::rtl::OUString::createFromAscii("."); + while(xResult->next()) + { + aName = xRow->getString(2); + aName += aDot; + aName += xRow->getString(3); + aVector.push_back(aName); + } + } + if(m_pViews) + delete m_pViews; + m_pViews = new OTables(m_xMetaData,*this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +void OAdabasCatalog::refreshGroups() +{ + ::std::vector< ::rtl::OUString> aVector; + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + Reference< XResultSet > xResult = xStmt->executeQuery( + ::rtl::OUString::createFromAscii("SELECT DISTINCT GROUPNAME FROM DOMAIN.USERS WHERE GROUPNAME IS NOT NULL AND GROUPNAME <> ' '")); + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + aVector.push_back(xRow->getString(1)); + } + if(m_pGroups) + delete m_pGroups; + m_pGroups = new OGroups(*this,m_aMutex,aVector,m_pConnection,this); +} +// ------------------------------------------------------------------------- +void OAdabasCatalog::refreshUsers() +{ + ::std::vector< ::rtl::OUString> aVector; + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + Reference< XResultSet > xResult = xStmt->executeQuery( + ::rtl::OUString::createFromAscii("SELECT DISTINCT USERNAME FROM DOMAIN.USERS WHERE USERNAME IS NOT NULL AND USERNAME <> ' ' AND USERNAME <> 'CONTROL'")); + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + aVector.push_back(xRow->getString(1)); + } + if(m_pUsers) + delete m_pUsers; + m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/adabas/BColumns.cxx b/connectivity/source/drivers/adabas/BColumns.cxx new file mode 100644 index 000000000000..cfebf615d6f2 --- /dev/null +++ b/connectivity/source/drivers/adabas/BColumns.cxx @@ -0,0 +1,241 @@ +/************************************************************************* + * + * $RCSfile: BColumns.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADABAS_COLUMNS_HXX_ +#include "adabas/BColumns.hxx" +#endif +#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_ +#include "connectivity/sdbcx/VColumn.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::adabas; +using namespace connectivity::sdbcx; +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OColumns::createObject(const ::rtl::OUString& _rName) +{ + + Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(), + m_pTable->getSchema(),m_pTable->getName(),_rName); + + Reference< XNamed > xRet = NULL; + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + { + if(xRow->getString(4) == _rName) + { + OColumn* pRet = new OColumn(_rName, + xRow->getString(6), + xRow->getString(13), + xRow->getInt(11), + xRow->getInt(7), + xRow->getInt(9), + xRow->getInt(5), + sal_False,sal_False,sal_False,sal_True); + xRet = pRet; + break; + } + } + } + + return xRet; +} + +// ------------------------------------------------------------------------- +void OColumns::impl_refresh() throw(RuntimeException) +{ + m_pTable->refreshColumns(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OColumns::createEmptyObject() +{ + OColumn* pNew = new OColumn(sal_True); + Reference< XPropertySet > xRet = pNew; + return xRet; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OColumns::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if(!m_pTable->isNew()) + { + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE "); + ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql = aSql + aQuote + m_pTable->getSchema() + aQuote + aDot + aQuote + m_pTable->getName() + aQuote; + aSql = aSql + ::rtl::OUString::createFromAscii(" ADD "); + aSql = aSql + aQuote + getString(descriptor->getPropertyValue(PROPERTY_NAME)) + aQuote; + aSql = aSql + ::rtl::OUString::createFromAscii(" "); + + Any aTypeName = descriptor->getPropertyValue(PROPERTY_TYPENAME); + if(aTypeName.hasValue() && getString(aTypeName).getLength()) + aSql = aSql + getString(aTypeName); + else + aSql = aSql + getTypeString(descriptor) + ::rtl::OUString::createFromAscii(" "); + + // aSql = aSql + getString(descriptor->getPropertyValue(PROPERTY_TYPENAME)); + + switch(getINT32(descriptor->getPropertyValue(PROPERTY_TYPE))) + { + case DataType::CHAR: + case DataType::VARCHAR: + aSql = aSql + ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(descriptor->getPropertyValue(PROPERTY_PRECISION))) + + ::rtl::OUString::createFromAscii(")"); + break; + + case DataType::DECIMAL: + case DataType::NUMERIC: + aSql = aSql + ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(descriptor->getPropertyValue(PROPERTY_PRECISION))) + + ::rtl::OUString::createFromAscii(",") + + ::rtl::OUString::valueOf(getINT32(descriptor->getPropertyValue(PROPERTY_SCALE))) + + ::rtl::OUString::createFromAscii(")"); + break; + } + ::rtl::OUString aDefault = getString(descriptor->getPropertyValue(PROPERTY_DEFAULTVALUE)); + if(getINT32(descriptor->getPropertyValue(PROPERTY_ISNULLABLE)) == ColumnValue::NO_NULLS) + { + aSql = aSql + ::rtl::OUString::createFromAscii(" NOT NULL"); + if(aDefault.getLength()) + aSql = aSql + ::rtl::OUString::createFromAscii(" WITH DEFAULT"); + } + else if(aDefault.getLength()) + aSql = aSql + ::rtl::OUString::createFromAscii(" DEFAULT ") + aDefault; + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + xStmt->execute(aSql); + } + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OColumns::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if(!m_pTable->isNew()) + { + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE "); + ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql = aSql + aQuote + m_pTable->getSchema() + aQuote + aDot + aQuote + m_pTable->getName() + aQuote; + aSql = aSql + ::rtl::OUString::createFromAscii(" DROP "); + aSql = aSql + aQuote + elementName + aQuote; + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + xStmt->execute(aSql); + } + + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OColumns::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + if(!m_pTable->isNew()) + { + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE "); + ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql = aSql + aQuote + m_pTable->getSchema() + aQuote + aDot + aQuote + m_pTable->getName() + aQuote; + aSql = aSql + ::rtl::OUString::createFromAscii(" DROP "); + aSql = aSql + aQuote + m_aElements[index]->first + aQuote; + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + xStmt->execute(aSql); + } + OCollection_TYPE::dropByIndex(index); +} + + diff --git a/connectivity/source/drivers/adabas/BConnection.cxx b/connectivity/source/drivers/adabas/BConnection.cxx new file mode 100644 index 000000000000..0b7dbea58955 --- /dev/null +++ b/connectivity/source/drivers/adabas/BConnection.cxx @@ -0,0 +1,233 @@ +/************************************************************************* + * + * $RCSfile: BConnection.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _CONNECTIVITY_ADABAS_BCONNECTION_HXX_ +#include "adabas/BConnection.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_BDRIVER_HXX_ +#include "adabas/BDriver.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_CATALOG_HXX_ +#include "adabas/BCatalog.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_OFUNCTIONS_HXX_ +#include "odbc/OFunctions.hxx" +#endif +#ifndef _CONNECTIVITY_OTOOLS_HXX_ +#include "odbc/OTools.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_ODATABASEMETADATA_HXX_ +#include "adabas/BDatabaseMetaData.hxx" +#endif + +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif + +using namespace connectivity::adabas; +using namespace connectivity; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + + +//------------------------------------------------------------------------------ +namespace starlang = ::com::sun::star::lang; +// -------------------------------------------------------------------------------- +OAdabasConnection::OAdabasConnection(const SQLHANDLE _pDriverHandle, connectivity::odbc::ODBCDriver* _pDriver) + : OConnection_BASE2(_pDriverHandle,_pDriver) +{ +} +//----------------------------------------------------------------------------- +SQLRETURN OAdabasConnection::Construct( const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + osl_incrementInterlockedCount( &m_refCount ); + + m_aConnectionHandle = SQL_NULL_HANDLE; + + // Connection allozieren + N3SQLAllocHandle(SQL_HANDLE_DBC,m_pDriverHandleCopy,&m_aConnectionHandle); + if(m_aConnectionHandle == SQL_NULL_HANDLE) + throw SQLException(); + + const PropertyValue *pBegin = info.getConstArray(); + const PropertyValue *pEnd = pBegin + info.getLength(); + ::rtl::OUString aAdminUid,aAdminPwd; + + sal_Int32 nLen = url.indexOf(':'); + nLen = url.indexOf(':',nLen+1); + ::rtl::OUString aDSN(url.copy(nLen+1)),aUID,aPWD; + sal_Int32 nTimeout = 20; + for(;pBegin != pEnd;++pBegin) + { + if(!pBegin->Name.compareToAscii("CTRLUSER")) + pBegin->Value >>= aAdminUid; + else if(!pBegin->Name.compareToAscii("CTRLPWD")) + pBegin->Value >>= aAdminPwd; + else if(!pBegin->Name.compareToAscii("Timeout")) + pBegin->Value >>= nTimeout; + else if(!pBegin->Name.compareToAscii("user")) + pBegin->Value >>= aUID; + else if(!pBegin->Name.compareToAscii("password")) + pBegin->Value >>= aPWD; + } + + SQLRETURN nSQLRETURN = OpenConnection(aDSN,nTimeout, aUID,aPWD); + + osl_decrementInterlockedCount( &m_refCount ); + return nSQLRETURN; +} +//----------------------------------------------------------------------------- +SQLRETURN OAdabasConnection::OpenConnection(const ::rtl::OUString& aConnectStr,sal_Int32 nTimeOut, const ::rtl::OUString& _uid,const ::rtl::OUString& _pwd) +{ + if (m_aConnectionHandle == SQL_NULL_HANDLE) + return -1; + + SQLRETURN nSQLRETURN = 0; + SDB_ODBC_CHAR szDSN[4096]; + SDB_ODBC_CHAR szUID[20]; + SDB_ODBC_CHAR szPWD[20]; + + memset(szDSN,'\0',4096); + memset(szUID,'\0',20); + memset(szPWD,'\0',20); + + ::rtl::OString aConStr(::rtl::OUStringToOString(aConnectStr,osl_getThreadTextEncoding())); + ::rtl::OString aUID(::rtl::OUStringToOString(_uid,osl_getThreadTextEncoding())); + ::rtl::OString aPWD(::rtl::OUStringToOString(_pwd,osl_getThreadTextEncoding())); + memcpy(szDSN, (SDB_ODBC_CHAR*) aConStr.getStr(), ::std::min<sal_Int32>((sal_Int32)2048,aConStr.getLength())); + memcpy(szUID, (SDB_ODBC_CHAR*) aUID.getStr(), ::std::min<sal_Int32>((sal_Int32)20,aUID.getLength())); + memcpy(szPWD, (SDB_ODBC_CHAR*) aPWD.getStr(), ::std::min<sal_Int32>((sal_Int32)20,aPWD.getLength())); + + + + N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_LOGIN_TIMEOUT,(SQLPOINTER)nTimeOut,SQL_IS_INTEGER); + // Verbindung aufbauen + + nSQLRETURN = N3SQLConnect(m_aConnectionHandle, + szDSN, + (SQLSMALLINT) ::std::min<sal_Int32>((sal_Int32)2048,aConStr.getLength()), + szUID, + (SQLSMALLINT) ::std::min<sal_Int32>((sal_Int32)20,aUID.getLength()), + szPWD, + (SQLSMALLINT) ::std::min<sal_Int32>((sal_Int32)20,aPWD.getLength())); + if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA) + return nSQLRETURN; + +#ifndef MAC + // autocoomit ist immer default + + N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_AUTOCOMMIT,(SQLPOINTER)SQL_AUTOCOMMIT_ON,SQL_IS_INTEGER); +#endif + buildTypeInfo(); + + return nSQLRETURN; +} + +//------------------------------------------------------------------------------ +void OAdabasConnection::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + Reference< XComponent > xComp2(m_xCatalog.get(), UNO_QUERY); + if(xComp2.is()) + xComp2->dispose(); + + m_xCatalog = Reference< XTablesSupplier >(); + + OConnection_BASE2::disposing(); +} +//------------------------------------------------------------------------------ +::com::sun::star::uno::Reference< XTablesSupplier > OAdabasConnection::createCatalog() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + Reference< XTablesSupplier > xTab = m_xCatalog; + if(!m_xCatalog.get().is()) + { + OAdabasCatalog *pCat = new OAdabasCatalog(m_aConnectionHandle,this); + xTab = pCat; + m_xCatalog = xTab; + } + return xTab; +} +// -------------------------------------------------------------------------------- +Reference< XDatabaseMetaData > SAL_CALL OAdabasConnection::getMetaData( ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (OConnection_BASE2::rBHelper.bDisposed) + throw DisposedException(); + + if(!m_xMetaData.is()) + m_xMetaData = new OAdabasDatabaseMetaData(m_aConnectionHandle,this); + + return m_xMetaData; +} +//------------------------------------------------------------------------------ +sal_Bool OAdabasConnection::isStarted() +{ + return sal_True; + +} + diff --git a/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx b/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx new file mode 100644 index 000000000000..00edcb7e9971 --- /dev/null +++ b/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * $RCSfile: BDatabaseMetaData.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADABAS_BDATABASEMETADATA_HXX_ +#include "adabas/BDatabaseMetaData.hxx" +#endif + +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +::rtl::OUString SAL_CALL OAdabasDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aRet = ::rtl::OUString::createFromAscii("sdbc:adabas:") + OAdabasDatabaseMetaData_BASE::getURL(); + return aRet; +} + + diff --git a/connectivity/source/drivers/adabas/BDriver.cxx b/connectivity/source/drivers/adabas/BDriver.cxx new file mode 100644 index 000000000000..3bbf1c42bd83 --- /dev/null +++ b/connectivity/source/drivers/adabas/BDriver.cxx @@ -0,0 +1,252 @@ +/************************************************************************* + * + * $RCSfile: BDriver.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADABAS_BDRIVER_HXX_ +#include "adabas/BDriver.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_BCONNECTION_HXX_ +#include "adabas/BConnection.hxx" +#endif +#ifndef _CONNECTIVITY_ODBC_OFUNCTIONS_HXX_ +#include "odbc/OFunctions.hxx" +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _CONNECTIVITY_OTOOLS_HXX_ +#include "odbc/OTools.hxx" +#endif + +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +// -------------------------------------------------------------------------------- +ODriver::ODriver() +{ +} +//------------------------------------------------------------------------------ +void ODriver::disposing() +{ + ::osl::MutexGuard aGuard(m_aMutex); + ODriver_BASE::disposing(); +} + +// static ServiceInfo +//------------------------------------------------------------------------------ +rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException) +{ + return rtl::OUString::createFromAscii("com.sun.star.sdbc.BDriver"); +} +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString > ODriver::getSupportedServiceNames_Static( ) throw (RuntimeException) +{ + Sequence< ::rtl::OUString > aSNS( 2 ); + aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver"); + aSNS[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Driver"); + return aSNS; +} +//------------------------------------------------------------------ +::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------ +sal_Bool SAL_CALL ODriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) +{ + Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); + const ::rtl::OUString* pSupported = aSupported.getConstArray(); + for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported) + if (pSupported->equals(_rServiceName)) + return sal_True; + + return sal_False; +} +//------------------------------------------------------------------ +Sequence< ::rtl::OUString > SAL_CALL ODriver::getSupportedServiceNames( ) throw(RuntimeException) +{ + return getSupportedServiceNames_Static(); +} +//------------------------------------------------------------------ +Any SAL_CALL ODriver::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType, static_cast<XDataDefinitionSupplier*>(this)); + if(aRet.hasValue()) + return aRet; + return ODriver_BASE::queryInterface(rType); +} +//------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::adabas::ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ) throw( ::com::sun::star::uno::Exception ) +{ + return *(new ODriver()); +} +// -------------------------------------------------------------------------------- +Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException) +{ + if(!m_pDriverHandle) + { + ::rtl::OUString aPath; + if(!EnvironmentHandle(aPath)) + throw SQLException(aPath,*this,::rtl::OUString(),1000,Any()); + } + OAdabasConnection* pCon = new OAdabasConnection(m_pDriverHandle,this); + SQLRETURN nSQLRETURN = pCon->Construct(url,info); + + if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA) + { + connectivity::odbc::OTools::ThrowException(nSQLRETURN,pCon->getConnection(),SQL_HANDLE_DBC,*this); + } + else if(SQL_SUCCESS_WITH_INFO == nSQLRETURN) // this driver does not support odbc3 + { + } + Reference< XConnection > xCon = pCon; + m_xConnections.push_back(WeakReferenceHelper(*pCon)); + + return xCon; +} + +// -------------------------------------------------------------------------------- +sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url ) + throw(SQLException, RuntimeException) +{ + if(!url.compareTo(::rtl::OUString::createFromAscii("sdbc:adabas:"),12)) + { + return sal_True; + } + return sal_False; +} +// -------------------------------------------------------------------------------- +Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& , const Sequence< PropertyValue >& ) throw(SQLException, RuntimeException) +{ + return Sequence< DriverPropertyInfo >(); +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODriver::getMajorVersion( ) throw(RuntimeException) +{ + return 1; +} +// -------------------------------------------------------------------------------- +sal_Int32 SAL_CALL ODriver::getMinorVersion( ) throw(RuntimeException) +{ + return 0; +} +// -------------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// ODBC Environment (gemeinsam fuer alle Connections): +SQLHANDLE ODriver::EnvironmentHandle(::rtl::OUString &_rPath) +{ + // Ist (fuer diese Instanz) bereits ein Environment erzeugt worden? + if (!m_pDriverHandle) + { + SQLHANDLE h = SQL_NULL_HANDLE; + // Environment allozieren + + // ODBC-DLL jetzt laden: + if (! connectivity::LoadLibrary_ADABAS(_rPath)) + return SQL_NULL_HANDLE; + + if (N3SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&h) != SQL_SUCCESS) + return SQL_NULL_HANDLE; + + // In globaler Struktur merken ... + m_pDriverHandle = (void *) h; + SQLRETURN nError = N3SQLSetEnvAttr(h, SQL_ATTR_ODBC_VERSION,(SQLPOINTER) SQL_OV_ODBC3, SQL_IS_INTEGER); + //N3SQLSetEnvAttr(h, SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER); + } + + return m_pDriverHandle; +} +// -------------------------------------------------------------------------------- +// XDataDefinitionSupplier +Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByConnection( const Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if (ODriver_BASE::rBHelper.bDisposed) + throw DisposedException(); + + + OAdabasConnection* pConnection = NULL; + for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i) + { + if ((OAdabasConnection*) Reference< XConnection >::query(i->get().get()).get() == (OAdabasConnection*)connection.get()) + { + pConnection = (OAdabasConnection*)connection.get(); + break; + } + } + + Reference< XTablesSupplier > xTab = NULL; + if(pConnection) + xTab = pConnection->createCatalog(); + return xTab; +} + +// -------------------------------------------------------------------------------- +Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByURL( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, RuntimeException) +{ + return getDataDefinitionByConnection(connect(url,info)); +} + + diff --git a/connectivity/source/drivers/adabas/BGroup.cxx b/connectivity/source/drivers/adabas/BGroup.cxx new file mode 100644 index 000000000000..8423bf7d3384 --- /dev/null +++ b/connectivity/source/drivers/adabas/BGroup.cxx @@ -0,0 +1,131 @@ +/************************************************************************* + * + * $RCSfile: BGroup.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADABAS_GROUP_HXX_ +#include "adabas/BGroup.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_USERS_HXX_ +#include "adabas/BUsers.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CONNECTIVITY_ADABAS_BCONNECTION_HXX_ +#include "adabas/BConnection.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +// ------------------------------------------------------------------------- +OAdabasGroup::OAdabasGroup( OAdabasConnection* _pConnection) : connectivity::sdbcx::OGroup(sal_True) + ,m_pConnection(_pConnection) +{ + construct(); + ::std::vector< ::rtl::OUString> aVector; + m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this); +} +// ------------------------------------------------------------------------- +OAdabasGroup::OAdabasGroup( OAdabasConnection* _pConnection, + const ::rtl::OUString& _Name + ) : connectivity::sdbcx::OGroup(_Name,sal_True) + ,m_pConnection(_pConnection) +{ + construct(); + refreshUsers(); +} +// ------------------------------------------------------------------------- +void OAdabasGroup::refreshUsers() +{ + if(!m_pConnection) + return; + + ::std::vector< ::rtl::OUString> aVector; + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("SELECT DISTINCT USERNAME FROM DOMAIN.USERS WHERE USERNAME IS NOT NULL AND USERNAME <> ' ' AND USERNAME <> 'CONTROL' AND GROUPNAME = '"); + aSql += getName( ); + aSql += ::rtl::OUString::createFromAscii("'"); + + Reference< XResultSet > xResult = xStmt->executeQuery(aSql); + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + aVector.push_back(xRow->getString(1)); + } + if(m_pUsers) + delete m_pUsers; + m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this); +} + + diff --git a/connectivity/source/drivers/adabas/BGroups.cxx b/connectivity/source/drivers/adabas/BGroups.cxx new file mode 100644 index 000000000000..f9a3c6b8adb7 --- /dev/null +++ b/connectivity/source/drivers/adabas/BGroups.cxx @@ -0,0 +1,161 @@ +/************************************************************************* + * + * $RCSfile: BGroups.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADABAS_GROUPS_HXX_ +#include "adabas/BGroups.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_GROUP_HXX_ +#include "adabas/BGroup.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_ +#include "sdbcx/IRefreshable.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +typedef connectivity::sdbcx::OCollection OCollection_TYPE; +// ------------------------------------------------------------------------- +Reference< XNamed > OGroups::createObject(const ::rtl::OUString& _rName) +{ + Reference< XNamed > xRet = NULL; + OAdabasGroup* pRet = new OAdabasGroup(m_pConnection,_rName); + xRet = pRet; + return xRet; +} +// ------------------------------------------------------------------------- +void OGroups::impl_refresh() throw(RuntimeException) +{ + m_pParent->refreshGroups(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OGroups::createEmptyObject() +{ + OAdabasGroup* pNew = new OAdabasGroup(m_pConnection); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OGroups::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME)); + ObjectMap::iterator aIter = m_aNameMap.find(aName); + if( aIter != m_aNameMap.end()) + throw ElementExistException(aName,*this); + + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE USERGROUP "); + ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( ); + + aSql = aSql + aQuote + getString(descriptor->getPropertyValue(PROPERTY_NAME)) + aQuote; + + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + xStmt->execute(aSql); + + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OGroups::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ObjectMap::iterator aIter = m_aNameMap.find(elementName); + if( aIter == m_aNameMap.end()) + throw NoSuchElementException(elementName,*this); + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP USERGROUP "); + ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( ); + + aSql = aSql + aQuote + elementName + aQuote; + + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + xStmt->execute(aSql); + + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OGroups::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + dropByName(m_aElements[index]->first); +} + + diff --git a/connectivity/source/drivers/adabas/BIndex.cxx b/connectivity/source/drivers/adabas/BIndex.cxx new file mode 100644 index 000000000000..6d8276f9b791 --- /dev/null +++ b/connectivity/source/drivers/adabas/BIndex.cxx @@ -0,0 +1,139 @@ +/************************************************************************* + * + * $RCSfile: BIndex.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADABAS_INDEX_HXX_ +#include "adabas/BIndex.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_ +#include "adabas/BIndexColumns.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif + +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +// ------------------------------------------------------------------------- +OAdabasIndex::OAdabasIndex( OAdabasTable* _pTable) : connectivity::sdbcx::OIndex(sal_True) + , m_pTable(_pTable) +{ + construct(); + ::std::vector< ::rtl::OUString> aVector; + m_pColumns = new OIndexColumns(this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +OAdabasIndex::OAdabasIndex( OAdabasTable* _pTable, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _Catalog, + sal_Bool _isUnique, + sal_Bool _isPrimaryKeyIndex, + sal_Bool _isClustered + ) : connectivity::sdbcx::OIndex(_Name, + _Catalog, + _isUnique, + _isPrimaryKeyIndex, + _isClustered,sal_True) + ,m_pTable(_pTable) +{ + construct(); + refreshColumns(); +} +// ------------------------------------------------------------------------- + +void OAdabasIndex::refreshColumns() +{ + if(!m_pTable) + return; + + ::std::vector< ::rtl::OUString> aVector; + Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getIndexInfo(Any(), + m_pTable->getSchema(),m_pTable->getName(),sal_False,sal_False); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + ::rtl::OUString aColName; + while(xResult->next()) + { + if(xRow->getString(9) == m_Name) + { + aColName = xRow->getString(9); + if(!xRow->wasNull()) + aVector.push_back(aColName); + } + } + } + if(m_pColumns) + delete m_pColumns; + m_pColumns = new OIndexColumns(this,m_aMutex,aVector); +} + diff --git a/connectivity/source/drivers/adabas/BIndexColumns.cxx b/connectivity/source/drivers/adabas/BIndexColumns.cxx new file mode 100644 index 000000000000..8f7582a621d2 --- /dev/null +++ b/connectivity/source/drivers/adabas/BIndexColumns.cxx @@ -0,0 +1,146 @@ +/************************************************************************* + * + * $RCSfile: BIndexColumns.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:19 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_ +#include "adabas/BIndexColumns.hxx" +#endif +#ifndef _CONNECTIVITY_SDBCX_INDEXCOLUMN_HXX_ +#include "connectivity/sdbcx/VIndexColumn.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ +#include <com/sun/star/sdbc/DataType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif + +using namespace connectivity::adabas; +using namespace connectivity::sdbcx; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +// ------------------------------------------------------------------------- +Reference< XNamed > OIndexColumns::createObject(const ::rtl::OUString& _rName) +{ + + Reference< XResultSet > xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getIndexInfo(Any(), + m_pIndex->getTable()->getSchema(),m_pIndex->getTable()->getName(),sal_False,sal_False); + + sal_Bool bAsc = sal_True; + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + ::rtl::OUString aD(::rtl::OUString::createFromAscii("D")); + while(xResult->next()) + { + if(xRow->getString(9) == _rName) + bAsc = xRow->getString(10) != aD; + } + } + + xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getColumns(Any(), + m_pIndex->getTable()->getSchema(),m_pIndex->getTable()->getName(),_rName); + + Reference< XNamed > xRet = NULL; + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + { + if(xRow->getString(4) == _rName) + { + OIndexColumn* pRet = new OIndexColumn(bAsc, + _rName, + xRow->getString(6), + xRow->getString(13), + xRow->getInt(11), + xRow->getInt(7), + xRow->getInt(9), + xRow->getInt(5), + sal_False,sal_False,sal_False,sal_True); + xRet = pRet; + break; + } + } + } + + return xRet; +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OIndexColumns::createEmptyObject() +{ + OIndexColumn* pNew = new OIndexColumn(sal_True); + return pNew; +} +// ------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/adabas/BIndexes.cxx b/connectivity/source/drivers/adabas/BIndexes.cxx new file mode 100644 index 000000000000..82361e74977c --- /dev/null +++ b/connectivity/source/drivers/adabas/BIndexes.cxx @@ -0,0 +1,241 @@ +/************************************************************************* + * + * $RCSfile: BIndexes.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _CONNECTIVITY_ADABAS_INDEXES_HXX_ +#include "adabas/BIndexes.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_INDEX_HXX_ +#include "adabas/BIndex.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_INDEXTYPE_HPP_ +#include <com/sun/star/sdbc/IndexType.hpp> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OIndexes::createObject(const ::rtl::OUString& _rName) +{ + ::rtl::OUString aName,aQualifier; + sal_Int32 nLen = _rName.indexOf('.'); + if(nLen != -1) + { + aQualifier = _rName.copy(0,nLen); + aName = _rName.copy(nLen+1); + } + else + aName = _rName; + + + Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getIndexInfo(Any(), + m_pTable->getSchema(),m_pTable->getName(),sal_False,sal_False); + + Reference< XNamed > xRet = NULL; + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + { + if(xRow->getString(6) == aName && (!aQualifier.getLength() || xRow->getString(5) == aQualifier )) + { + OAdabasIndex* pRet = new OAdabasIndex(m_pTable,aName,aQualifier,!xRow->getBoolean(4), + aName == ::rtl::OUString::createFromAscii("SYSPRIMARYKEYINDEX"), + xRow->getShort(7) == IndexType::CLUSTERED); + xRet = pRet; + } + } + } + + return xRet; +} +// ------------------------------------------------------------------------- +void OIndexes::impl_refresh() throw(RuntimeException) +{ + m_pTable->refreshIndexes(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OIndexes::createEmptyObject() +{ + OAdabasIndex* pNew = new OAdabasIndex(m_pTable); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OIndexes::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME)); + ObjectMap::iterator aIter = m_aNameMap.find(aName); + if( aIter != m_aNameMap.end()) + throw ElementExistException(aName,*this); + + if(!m_pTable->isNew()) + { + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE "); + ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + if(getINT32(descriptor->getPropertyValue(PROPERTY_ISUNIQUE))) + aSql = aSql + ::rtl::OUString::createFromAscii("UNIQUE "); + aSql = aSql + ::rtl::OUString::createFromAscii("INDEX "); + + + if(aName.getLength()) + { + aSql = aSql + aQuote + aName + aQuote + + ::rtl::OUString::createFromAscii(" ON ") + + aQuote + m_pTable->getSchema() + aQuote + aDot + + aQuote + m_pTable->getName() + aQuote + + ::rtl::OUString::createFromAscii(" ( "); + + Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY); + Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY); + Reference< XPropertySet > xColProp; + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + xColumns->getByIndex(i) >>= xColProp; + aSql = aSql + aQuote + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote; + aSql = aSql + (getBOOL(xColProp->getPropertyValue(PROPERTY_ISASCENDING)) + ? + ::rtl::OUString::createFromAscii(" ASC") + : + ::rtl::OUString::createFromAscii(" DESC")) + + ::rtl::OUString::createFromAscii(","); + } + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + } + else + { + aSql = aSql + aQuote + m_pTable->getSchema() + aQuote + aDot + aQuote + m_pTable->getName() + aQuote; + + Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY); + Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY); + Reference< XPropertySet > xColProp; + if(xColumns->getCount() != 1) + throw SQLException(); + + xColumns->getByIndex(0) >>= xColProp; + + aSql = aSql + aDot + aQuote + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote; + } + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + xStmt->execute(aSql); + } + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OIndexes::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ObjectMap::iterator aIter = m_aNameMap.find(elementName); + if( aIter == m_aNameMap.end()) + throw NoSuchElementException(elementName,*this); + + if(!m_pTable->isNew()) + { + ::rtl::OUString aName,aSchema; + sal_Int32 nLen = elementName.indexOf('.'); + aSchema = elementName.copy(0,nLen); + aName = elementName.copy(nLen+1); + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP INDEX "); + ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql = aSql + aQuote + aSchema + aQuote + aDot + aQuote + aName + ::rtl::OUString::createFromAscii(" ON ") + + aQuote + m_pTable->getSchema() + aQuote + m_pTable->getName() + aQuote; + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + xStmt->execute(aSql); + } + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OIndexes::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + dropByName(m_aElements[index]->first); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/adabas/BKeys.cxx b/connectivity/source/drivers/adabas/BKeys.cxx new file mode 100644 index 000000000000..e3227f467b0e --- /dev/null +++ b/connectivity/source/drivers/adabas/BKeys.cxx @@ -0,0 +1,285 @@ +/************************************************************************* + * + * $RCSfile: BKeys.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADABAS_KEYS_HXX_ +#include "adabas/BKeys.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_INDEX_HXX_ +#include "adabas/BKey.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ +#include <com/sun/star/sdbcx/KeyType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ +#include <com/sun/star/sdbc/KeyRule.hpp> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Any SAL_CALL OKeys::queryInterface( const Type & rType ) throw(RuntimeException) +{ + if(rType == ::getCppuType(static_cast< Reference<XNameAccess> *>(NULL))) + return Any(); + + return OCollection_TYPE::queryInterface(rType); +} +// ------------------------------------------------------------------------- +Sequence< Type > SAL_CALL OKeys::getTypes( ) throw(RuntimeException) +{ + Sequence< Type > aTypes(OCollection_TYPE::getTypes()); + Type* pBegin = aTypes.getArray(); + Type* pEnd = pBegin + aTypes.getLength(); + + Sequence< Type > aRetType(aTypes.getLength()-1); + sal_Int32 i=0; + for(;pBegin != pEnd; ++pBegin) + { + if(*pBegin != ::getCppuType(static_cast< Reference<XNameAccess> *>(NULL))) + { + aRetType.getArray()[i++] = *pBegin; + } + } + + return aRetType; +} +// ------------------------------------------------------------------------- +Reference< XNamed > OKeys::createObject(const ::rtl::OUString& _rName) +{ + Reference< XNamed > xRet = NULL; + + if(_rName.getLength()) + { + Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getExportedKeys(Any(), + m_pTable->getSchema(),m_pTable->getName()); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + ::rtl::OUString aName,aDot = ::rtl::OUString::createFromAscii("."); + while(xResult->next()) + { + if(xRow->getString(13) == _rName) + { + aName = xRow->getString(6); + if(aName.getLength()) + aName += aDot; + aName += xRow->getString(7); + + OAdabasKey* pRet = new OAdabasKey(m_pTable,_rName,aName,KeyType::FOREIGN,xRow->getInt(10),xRow->getInt(11)); + xRet = pRet; + break; + } + } + } + } + else + { + OAdabasKey* pRet = new OAdabasKey(m_pTable,_rName,::rtl::OUString(),KeyType::PRIMARY,KeyRule::NO_ACTION,KeyRule::NO_ACTION); + xRet = pRet; + } + + return xRet; +} +// ------------------------------------------------------------------------- +void OKeys::impl_refresh() throw(RuntimeException) +{ + m_pTable->refreshKeys(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OKeys::createEmptyObject() +{ + OAdabasKey* pNew = new OAdabasKey(m_pTable); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OKeys::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME)); + ObjectMap::iterator aIter = m_aNameMap.find(aName); + if( aIter != m_aNameMap.end()) + throw ElementExistException(aName,*this); + if(!m_pTable->isNew()) + { + sal_Int32 nKeyType = getINT32(descriptor->getPropertyValue(PROPERTY_TYPE)); + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE "); + ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql = aSql + aQuote + m_pTable->getSchema() + aQuote + aDot + aQuote + m_pTable->getName() + aQuote; + if(nKeyType == KeyType::PRIMARY) + { + aSql = aSql + ::rtl::OUString::createFromAscii(" ALTER PRIMARY KEY ("); + } + else if(nKeyType == KeyType::FOREIGN) + { + aSql = aSql + ::rtl::OUString::createFromAscii(" FOREIGN KEY ("); + } + else + throw SQLException(); + + Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY); + Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY); + Reference< XPropertySet > xColProp; + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + xColumns->getByIndex(i) >>= xColProp; + aSql = aSql + aQuote + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(","); + } + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + + if(nKeyType == KeyType::FOREIGN) + { + sal_Int32 nDeleteRule = getINT32(xColProp->getPropertyValue(PROPERTY_DELETERULE)); + + ::rtl::OUString aName,aSchema,aRefTable = getString(xColProp->getPropertyValue(PROPERTY_REFERENCEDTABLE)); + sal_Int32 nLen = aRefTable.indexOf('.'); + aSchema = aRefTable.copy(0,nLen); + aName = aRefTable.copy(nLen+1); + aSql = aSql + ::rtl::OUString::createFromAscii(" REFERENCES ") + + aQuote + aSchema + aQuote + aDot + aQuote + aName + aQuote; + + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + xColumns->getByIndex(i) >>= xColProp; + aSql = aSql + aQuote + getString(xColProp->getPropertyValue(PROPERTY_REFERENCEDCOLUMN)) + aQuote + + ::rtl::OUString::createFromAscii(","); + } + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + + switch(nDeleteRule) + { + case KeyRule::CASCADE: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE CASCADE "); + break; + case KeyRule::RESTRICT: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE RESTRICT "); + break; + case KeyRule::SET_NULL: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE SET NULL "); + break; + case KeyRule::SET_DEFAULT: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE SET DEFAULT "); + break; + default: + ; + } + } + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + xStmt->execute(aSql); + } + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OKeys::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ObjectMap::iterator aIter = m_aNameMap.find(elementName); + if( aIter == m_aNameMap.end()) + throw NoSuchElementException(elementName,*this); + + if(!m_pTable->isNew()) + { + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE "); + ::rtl::OUString aQuote = m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql = aSql + aQuote + m_pTable->getSchema() + aQuote + m_pTable->getName() + aQuote + + ::rtl::OUString::createFromAscii(" DROP PRIMARY KEY"); + + Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); + xStmt->execute(aSql); + } + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OKeys::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + dropByName(m_aElements[index]->first); +} + diff --git a/connectivity/source/drivers/adabas/BResultSetMetaData.cxx b/connectivity/source/drivers/adabas/BResultSetMetaData.cxx new file mode 100644 index 000000000000..df70ad5de067 --- /dev/null +++ b/connectivity/source/drivers/adabas/BResultSetMetaData.cxx @@ -0,0 +1,249 @@ +/************************************************************************* + * + * $RCSfile: BResultSetMetaData.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADABAS_BRESULTSETMETADATA_HXX_ +#include "adabas/BResultSetMetaData.hxx" +#endif +#ifndef _CONNECTIVITY_OTOOLS_HXX_ +#include "adabas/BTools.hxx" +#endif + +using namespace connectivity::adabas; +// ------------------------------------------------------------------------- +OResultSetMetaData::~OResultSetMetaData() +{ +} +// ------------------------------------------------------------------------- +::rtl::OUString OResultSetMetaData::getCharColAttrib(sal_Int32 _column,sal_Int32 ident) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + sal_Int32 column = _column; + if(_column < m_vMapping.size()) // use mapping + column = m_vMapping[_column]; + + sal_Int32 BUFFER_LEN = 128; + char *pName = new char[BUFFER_LEN]; + SQLSMALLINT nRealLen=0; + OTools::ThrowException(N3SQLColAttribute(m_aStatementHandle, + column, + ident, + (SQLPOINTER)pName, + BUFFER_LEN, + &nRealLen, + NULL + ),m_aStatementHandle,SQL_HANDLE_STMT,*this); + if(nRealLen > BUFFER_LEN) + { + delete pName; + pName = new char[nRealLen]; + OTools::ThrowException(N3SQLColAttribute(m_aStatementHandle, + column, + ident, + (SQLPOINTER)pName, + nRealLen, + &nRealLen, + NULL + ),m_aStatementHandle,SQL_HANDLE_STMT,*this); + } + + return ::rtl::OUString::createFromAscii(pName); +} +// ------------------------------------------------------------------------- +sal_Int32 OResultSetMetaData::getNumColAttrib(sal_Int32 _column,sal_Int32 ident) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + sal_Int32 column = _column; + if(_column < m_vMapping.size()) // use mapping + column = m_vMapping[_column]; + + sal_Int32 nValue; + OTools::ThrowException(N3SQLColAttribute(m_aStatementHandle, + column, + ident, + NULL, + 0, + NULL, + &nValue),m_aStatementHandle,SQL_HANDLE_STMT,*this); + return nValue; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_DISPLAY_SIZE); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return OTools::MapOdbcType2Jdbc(getNumColAttrib(column,SQL_DESC_TYPE)); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + if(m_nColCount != -1) + return m_nColCount; + sal_Int16 nNumResultCols=0; + OTools::ThrowException(N3SQLNumResultCols(m_aStatementHandle,&nNumResultCols),m_aStatementHandle,SQL_HANDLE_STMT,*this); + return m_nColCount = nNumResultCols; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_CASE_SENSITIVE) == SQL_TRUE; +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_SCHEMA_NAME); +} +// ------------------------------------------------------------------------- + +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_NAME); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_TABLE_NAME); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_CATALOG_NAME); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_TYPE_NAME +); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getCharColAttrib(column,SQL_DESC_LABEL); +} +// ------------------------------------------------------------------------- +::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return ::rtl::OUString(); +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_FIXED_PREC_SCALE) == SQL_TRUE; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_AUTO_UNIQUE_VALUE) == SQL_TRUE; +} +// ------------------------------------------------------------------------- + + +sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_UNSIGNED) == SQL_FALSE; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_PRECISION); +} +sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_SCALE); +} +// ------------------------------------------------------------------------- + +sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_NULLABLE) == SQL_NULLABLE; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_SEARCHABLE) != SQL_PRED_NONE; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_UPDATABLE) == SQL_ATTR_READONLY; +} +// ------------------------------------------------------------------------- + +sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_UPDATABLE) == SQL_ATTR_WRITE; +; +} +// ------------------------------------------------------------------------- +sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(starsdbc::SQLException, staruno::RuntimeException) +{ + return getNumColAttrib(column,SQL_DESC_UPDATABLE) == SQL_ATTR_WRITE; +} +// ------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/adabas/BTable.cxx b/connectivity/source/drivers/adabas/BTable.cxx new file mode 100644 index 000000000000..3452ed9b80df --- /dev/null +++ b/connectivity/source/drivers/adabas/BTable.cxx @@ -0,0 +1,590 @@ +/************************************************************************* + * + * $RCSfile: BTable.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_INDEXES_HXX_ +#include "adabas/BIndexes.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_COLUMNS_HXX_ +#include "adabas/BColumns.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_KEYS_HXX_ +#include "adabas/BKeys.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ +#include <com/sun/star/sdbcx/KeyType.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ +#include <com/sun/star/sdbc/KeyRule.hpp> +#endif +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#include <cppuhelper/typeprovider.hxx> +#endif +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ +#include <com/sun/star/lang/DisposedException.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _UTL_SEQUENCE_HXX_ +#include <unotools/sequence.hxx> +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +OAdabasTable::OAdabasTable(OAdabasConnection* _pConnection) : OTable_TYPEDEF(sal_True) + ,m_pConnection(_pConnection) +{ + construct(); + ::std::vector< ::rtl::OUString> aVector; + m_pColumns = new OColumns(this,m_aMutex,aVector); + m_pKeys = new OKeys(this,m_aMutex,aVector); + m_pIndexes = new OIndexes(this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +OAdabasTable::OAdabasTable( OAdabasConnection* _pConnection, + const ::rtl::OUString& _Name, + const ::rtl::OUString& _Type, + const ::rtl::OUString& _Description , + const ::rtl::OUString& _SchemaName, + const ::rtl::OUString& _CatalogName + ) : OTable_TYPEDEF(sal_True,_Name, + _Type, + _Description, + _SchemaName, + _CatalogName) + ,m_pConnection(_pConnection) +{ + construct(); + refreshColumns(); + refreshKeys(); + refreshIndexes(); +} +// ------------------------------------------------------------------------- +void OAdabasTable::refreshColumns() +{ + ::std::vector< ::rtl::OUString> aVector; + Reference< XResultSet > xResult = m_pConnection->getMetaData()->getColumns(Any(), + m_SchemaName,m_Name,::rtl::OUString::createFromAscii("%")); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + aVector.push_back(xRow->getString(4)); + } + + if(m_pColumns) + delete m_pColumns; + m_pColumns = new OColumns(this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +void OAdabasTable::refreshPrimaryKeys(std::vector< ::rtl::OUString>& _rKeys) +{ + Reference< XResultSet > xResult = m_pConnection->getMetaData()->getPrimaryKeys(Any(),m_SchemaName,m_Name); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + if(xResult->next()) // there can be only one primary key + { + ::rtl::OUString aPkName = xRow->getString(6); + _rKeys.push_back(aPkName); + } + } +} +// ------------------------------------------------------------------------- +void OAdabasTable::refreshForgeinKeys(std::vector< ::rtl::OUString>& _rKeys) +{ + Reference< XResultSet > xResult = m_pConnection->getMetaData()->getExportedKeys(Any(),m_SchemaName,m_Name); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + _rKeys.push_back(xRow->getString(12)); + } +} +// ------------------------------------------------------------------------- +void OAdabasTable::refreshKeys() +{ + ::std::vector< ::rtl::OUString> aVector; + + refreshPrimaryKeys(aVector); + refreshForgeinKeys(aVector); + if(m_pKeys) + delete m_pKeys; + m_pKeys = new OKeys(this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +void OAdabasTable::refreshIndexes() +{ + ::std::vector< ::rtl::OUString> aVector; + // fill indexes + Reference< XResultSet > xResult = m_pConnection->getMetaData()->getIndexInfo(Any(), + m_SchemaName,m_Name,sal_False,sal_False); + + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + ::rtl::OUString aName,aDot = ::rtl::OUString::createFromAscii("."); + while(xResult->next()) + { + aName = xRow->getString(5); + if(aName.getLength()) + aName += aDot; + aName += xRow->getString(6); + if(aName.getLength()) + aVector.push_back(aName); + } + } + + if(m_pIndexes) + delete m_pIndexes; + m_pIndexes = new OIndexes(this,m_aMutex,aVector); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OAdabasTable::queryInterface( const Type & rType ) throw(RuntimeException) +{ + Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); + if(aRet.hasValue()) + return aRet; + return OTable_TYPEDEF::queryInterface(rType); +} + +//-------------------------------------------------------------------------- +Sequence< sal_Int8 > OAdabasTable::getUnoTunnelImplementationId() +{ + static ::cppu::OImplementationId * pId = 0; + if (! pId) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pId) + { + static ::cppu::OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// com::sun::star::lang::XUnoTunnel +//------------------------------------------------------------------ +sal_Int64 OAdabasTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) +{ + if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + return (sal_Int64)this; + + return 0; +} +// ------------------------------------------------------------------------- +sal_Bool OAdabasTable::create() throw(SQLException, RuntimeException) +{ + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE TABLE "); + ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + ::rtl::OUString aComma = ::rtl::OUString::createFromAscii(", "); + + aSql += aQuote + m_SchemaName + aQuote + aDot + aQuote + m_Name + aQuote; + aSql += ::rtl::OUString::createFromAscii(" ( "); + + sal_Int32 nCount = m_pColumns->getCount(); + Reference< XPropertySet > xProp; + for(sal_Int32 i=0;i<nCount;++i) + { + m_pColumns->getByIndex(i) >>= xProp; + aSql += aQuote + getString(xProp->getPropertyValue(PROPERTY_NAME)) + aQuote + + getString(xProp->getPropertyValue(PROPERTY_TYPENAME)); + + // add type definition + switch(getINT32(xProp->getPropertyValue(PROPERTY_TYPE))) + { + case DataType::CHAR: + case DataType::VARCHAR: + aSql += ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(xProp->getPropertyValue(PROPERTY_TYPE))) + + ::rtl::OUString::createFromAscii(")"); + break; + + case DataType::DECIMAL: + case DataType::NUMERIC: + aSql += ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(xProp->getPropertyValue(PROPERTY_TYPE))) + + ::rtl::OUString::createFromAscii(",") + + ::rtl::OUString::valueOf(getINT32(xProp->getPropertyValue(PROPERTY_SCALE))) + + ::rtl::OUString::createFromAscii(")"); + break; + } + + ::rtl::OUString aDefault = getString(xProp->getPropertyValue(PROPERTY_DEFAULTVALUE)); + if(getINT32(xProp->getPropertyValue(PROPERTY_ISNULLABLE)) == ColumnValue::NO_NULLS) + { + aSql += ::rtl::OUString::createFromAscii(" NOT NULL"); + if(aDefault.getLength()) + aSql += ::rtl::OUString::createFromAscii(" WITH DEFAULT"); + } + else if(aDefault.getLength()) + aSql += ::rtl::OUString::createFromAscii(" DEFAULT ") + aDefault; + + aSql += aComma; + } + + // create the key columns ( only the string ) + nCount = m_pKeys->getCount(); + + for(i=0;i<nCount;++i) + { + m_pKeys->getByIndex(i) >>= xProp; + Reference< XColumnsSupplier > xKey(xProp,UNO_QUERY); + Reference< ::com::sun::star::container::XIndexAccess > xCols(xKey->getColumns(),UNO_QUERY); + switch(getINT32(xProp->getPropertyValue(PROPERTY_TYPE))) + { + case KeyType::PRIMARY: + { + sal_Int32 nCols = xCols->getCount(); + if(nCols) + aSql += ::rtl::OUString::createFromAscii(" PRIMARY KEY( "); + for(sal_Int32 i=0;i<nCols;++i) + { + xCols->getByIndex(i) >>= xProp; + aSql += aQuote + getString(xProp->getPropertyValue(PROPERTY_NAME)) + aQuote; + aSql += aComma; + } + if(nCols) + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + } + case KeyType::UNIQUE: + { + sal_Int32 nCols = xCols->getCount(); + if(nCols) + aSql += ::rtl::OUString::createFromAscii(" UNIQUE( "); + for(sal_Int32 i=0;i<nCols;++i) + { + xCols->getByIndex(i) >>= xProp; + aSql += aQuote + getString(xProp->getPropertyValue(PROPERTY_NAME)) + aQuote; + aSql += aComma; + } + if(nCols) + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + } + case KeyType::FOREIGN: + { + sal_Int32 nCols = xCols->getCount(); + if(nCols) + { + aSql += ::rtl::OUString::createFromAscii(" FOREIGN KEY( "); + ::rtl::OUString aKeyName = getString(xProp->getPropertyValue(PROPERTY_NAME)); + ::rtl::OUString aRefTableName = getString(xProp->getPropertyValue(PROPERTY_REFERENCEDTABLE)); + sal_Int32 nDeleteRule = getINT32(xProp->getPropertyValue(PROPERTY_DELETERULE)); + if(aKeyName.getLength()) + { + aSql += aQuote + aKeyName + aQuote; + aSql += ::rtl::OUString::createFromAscii(" "); + } + + for(sal_Int32 i=0;i<nCols;++i) + { + xCols->getByIndex(i) >>= xProp; + aSql += aQuote + getString(xProp->getPropertyValue(PROPERTY_NAME)) + aQuote; + aSql += aComma; + } + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + aSql += ::rtl::OUString::createFromAscii(" REFERENCES ") + + aQuote + aRefTableName + aQuote; + switch(nDeleteRule) + { + case KeyRule::CASCADE: + aSql += ::rtl::OUString::createFromAscii(" ON DELETE CASCADE "); + break; + case KeyRule::RESTRICT: + aSql += ::rtl::OUString::createFromAscii(" ON DELETE RESTRICT "); + break; + case KeyRule::SET_NULL: + aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET NULL "); + break; + case KeyRule::NO_ACTION: + break; + case KeyRule::SET_DEFAULT: + aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET DEFAULT "); + break; + } + } + + } + } + } + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + xStmt->execute(aSql); + return sal_True; +} +// ------------------------------------------------------------------------- +// XRename +void SAL_CALL OAdabasTable::rename( const ::rtl::OUString& newName ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( +#ifdef GCC + sdbcx::OTable_BASE::rBHelper.bDisposed +#else + rBHelper.bDisposed +#endif + ) + throw DisposedException(); + + if(!isNew()) + { + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("RENAME TABLE "); + ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + ::rtl::OUString aName,aSchema; + sal_Int32 nLen = newName.indexOf('.'); + aSchema = newName.copy(0,nLen); + aName = newName.copy(nLen+1); + + aSql += aQuote + m_SchemaName + aQuote + aDot + aQuote + m_Name + aQuote + + ::rtl::OUString::createFromAscii(" TO ") + + aQuote + aSchema + aQuote + aDot + aQuote + aName + aQuote; + + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + xStmt->execute(aSql); + } + else + m_Name = newName; +} +// ------------------------------------------------------------------------- +// XAlterTable +void SAL_CALL OAdabasTable::alterColumnByName( const ::rtl::OUString& colName, const Reference< XPropertySet >& descriptor ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( +#ifdef GCC + sdbcx::OTable_BASE::rBHelper.bDisposed +#else + rBHelper.bDisposed +#endif + ) + throw DisposedException(); + + if(!isNew()) + { + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE "); + ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql += aQuote + m_SchemaName + aQuote + aDot + aQuote + m_Name + aQuote + + ::rtl::OUString::createFromAscii(" COLUMN ") + + aQuote + colName + aQuote + + ::rtl::OUString::createFromAscii(" ALTER "); + + aSql += aQuote + getString(descriptor->getPropertyValue(PROPERTY_NAME)) + aQuote + + getString(descriptor->getPropertyValue(PROPERTY_TYPENAME)); + + switch(getINT32(descriptor->getPropertyValue(PROPERTY_TYPE))) + { + case DataType::CHAR: + case DataType::VARCHAR: + aSql += ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(descriptor->getPropertyValue(PROPERTY_TYPE))) + + ::rtl::OUString::createFromAscii(")"); + break; + + case DataType::DECIMAL: + case DataType::NUMERIC: + aSql += ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(descriptor->getPropertyValue(PROPERTY_TYPE))) + + ::rtl::OUString::createFromAscii(",") + + ::rtl::OUString::valueOf(getINT32(descriptor->getPropertyValue(PROPERTY_SCALE))) + + ::rtl::OUString::createFromAscii(")"); + break; + } + ::rtl::OUString aDefault = getString(descriptor->getPropertyValue(PROPERTY_DEFAULTVALUE)); + if(getINT32(descriptor->getPropertyValue(PROPERTY_ISNULLABLE)) == ColumnValue::NO_NULLS) + { + aSql += ::rtl::OUString::createFromAscii(" NOT NULL"); + if(aDefault.getLength()) + aSql += ::rtl::OUString::createFromAscii(" WITH DEFAULT"); + } + else if(aDefault.getLength()) + aSql += ::rtl::OUString::createFromAscii(" DEFAULT ") + aDefault; + + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + xStmt->execute(aSql); + + refreshColumns(); + } + else + { + if(m_pColumns) + { + m_pColumns->dropByName(colName); + m_pColumns->appendByDescriptor(descriptor); + } + } + +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdabasTable::alterColumnByIndex( sal_Int32 index, const Reference< XPropertySet >& descriptor ) throw(SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + if ( +#ifdef GCC + sdbcx::OTable_BASE::rBHelper.bDisposed +#else + rBHelper.bDisposed +#endif + ) + throw DisposedException(); + + Reference< XPropertySet > xOld; + if(m_pColumns->getByIndex(index) >>= xOld) + alterColumnByName(getString(xOld->getPropertyValue(PROPERTY_NAME)),descriptor); +} + +// ------------------------------------------------------------------------- +::rtl::OUString connectivity::adabas::getTypeString(const Reference< ::com::sun::star::beans::XPropertySet >& xColProp) +{ + ::rtl::OUString aValue; + switch(getINT32(xColProp->getPropertyValue(PROPERTY_TYPE))) + { + case DataType::BIT: + aValue = ::rtl::OUString::createFromAscii("BOOLEAN"); + break; + case DataType::TINYINT: + aValue = ::rtl::OUString::createFromAscii("SMALLINT"); + break; + case DataType::SMALLINT: + aValue = ::rtl::OUString::createFromAscii("SMALLINT"); + break; + case DataType::INTEGER: + aValue = ::rtl::OUString::createFromAscii("INT"); + break; + case DataType::FLOAT: + aValue = ::rtl::OUString::createFromAscii("FLOAT"); + break; + case DataType::REAL: + aValue = ::rtl::OUString::createFromAscii("REAL"); + break; + case DataType::DOUBLE: + aValue = ::rtl::OUString::createFromAscii("DOUBLE"); + break; + case DataType::NUMERIC: + aValue = ::rtl::OUString::createFromAscii("DECIMAL"); + break; + case DataType::DECIMAL: + aValue = ::rtl::OUString::createFromAscii("DECIMAL"); + break; + case DataType::CHAR: + aValue = ::rtl::OUString::createFromAscii("CHAR"); + break; + case DataType::VARCHAR: + aValue = ::rtl::OUString::createFromAscii("VARCHAR"); + break; + case DataType::LONGVARCHAR: + aValue = ::rtl::OUString::createFromAscii("LONG VARCHAR"); + break; + case DataType::DATE: + aValue = ::rtl::OUString::createFromAscii("DATE"); + break; + case DataType::TIME: + aValue = ::rtl::OUString::createFromAscii("TIME"); + break; + case DataType::TIMESTAMP: + aValue = ::rtl::OUString::createFromAscii("TIMESTAMP"); + break; + case DataType::BINARY: + aValue = ::rtl::OUString::createFromAscii("BOOLEAN"); + break; + case DataType::VARBINARY: + aValue = ::rtl::OUString::createFromAscii("VARCHAR BYTE"); + break; + case DataType::LONGVARBINARY: + aValue = ::rtl::OUString::createFromAscii("LONG BYTE"); + break; + } + return aValue; +} +// ------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OAdabasTable::getTypes( ) throw(::com::sun::star::uno::RuntimeException) +{ + ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > *)0 )); + + return ::utl::concatSequences(aTypes.getTypes(),OTable_TYPEDEF::getTypes()); +} + + + diff --git a/connectivity/source/drivers/adabas/BTables.cxx b/connectivity/source/drivers/adabas/BTables.cxx new file mode 100644 index 000000000000..93c4e3961715 --- /dev/null +++ b/connectivity/source/drivers/adabas/BTables.cxx @@ -0,0 +1,419 @@ +/************************************************************************* + * + * $RCSfile: BTables.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADABAS_TABLES_HXX_ +#include "adabas/BTables.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ +#include <com/sun/star/sdbc/KeyRule.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ +#include <com/sun/star/sdbcx/KeyType.hpp> +#endif +#ifndef _CONNECTIVITY_ADABAS_CATALOG_HXX_ +#include "adabas/BCatalog.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_BCONNECTION_HXX_ +#include "adabas/BConnection.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OTables::createObject(const ::rtl::OUString& _rName) +{ + ::rtl::OUString aName,aSchema; + sal_Int32 nLen = _rName.indexOf('.'); + aSchema = _rName.copy(0,nLen); + aName = _rName.copy(nLen+1); + + Sequence< ::rtl::OUString > aTypes(1); + aTypes[0] = ::rtl::OUString::createFromAscii("%"); + // aTypes[0] = ::rtl::OUString::createFromAscii("TABLE"); + // aTypes[1] = ::rtl::OUString::createFromAscii("SYSTEMTABLE"); + + Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), + aSchema,aName,aTypes); + + Reference< XNamed > xRet = NULL; + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + if(xResult->next()) // there can be only one table with this name + { + OAdabasTable* pRet = new OAdabasTable( static_cast<OAdabasCatalog&>(m_rParent).getConnection(), + aName,xRow->getString(4),xRow->getString(5),aSchema); + xRet = pRet; + } + } + + return xRet; +} +// ------------------------------------------------------------------------- +void OTables::impl_refresh( ) throw(RuntimeException) +{ + static_cast<OAdabasCatalog&>(m_rParent).refreshTables(); +} +// ------------------------------------------------------------------------- +void OTables::disposing(void) +{ + m_xMetaData = NULL; + OCollection::disposing(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OTables::createEmptyObject() +{ + OAdabasTable* pNew = new OAdabasTable(static_cast<OAdabasCatalog&>(m_rParent).getConnection()); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OTables::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME)); + ObjectMap::iterator aIter = m_aNameMap.find(aName); + if( aIter != m_aNameMap.end()) + throw ElementExistException(aName,*this); + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE TABLE "); + ::rtl::OUString aQuote = static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + aSql = aSql + aQuote + getString(descriptor->getPropertyValue(PROPERTY_SCHEMANAME)) + aQuote + aDot + + aQuote + getString(descriptor->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(" ("); + + // columns + Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY); + Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY); + Reference< XPropertySet > xColProp; + + Any aTypeName; + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + if(xColumns->getByIndex(i) >>= xColProp) + { + + aSql = aSql + aQuote + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote; + + aSql = aSql + ::rtl::OUString::createFromAscii(" "); + + aTypeName = xColProp->getPropertyValue(PROPERTY_TYPENAME); + + if(aTypeName.hasValue() && getString(aTypeName).getLength()) + aSql = aSql + getString(aTypeName); + else + aSql = aSql + getTypeString(xColProp) + ::rtl::OUString::createFromAscii(" "); + + switch(getINT32(xColProp->getPropertyValue(PROPERTY_TYPE))) + { + case DataType::CHAR: + case DataType::VARCHAR: + aSql = aSql + ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(xColProp->getPropertyValue(PROPERTY_PRECISION))) + + ::rtl::OUString::createFromAscii(")"); + break; + + case DataType::DECIMAL: + case DataType::NUMERIC: + aSql = aSql + ::rtl::OUString::createFromAscii("(") + + ::rtl::OUString::valueOf(getINT32(xColProp->getPropertyValue(PROPERTY_PRECISION))) + + ::rtl::OUString::createFromAscii(",") + + ::rtl::OUString::valueOf(getINT32(xColProp->getPropertyValue(PROPERTY_SCALE))) + + ::rtl::OUString::createFromAscii(")"); + break; + } + ::rtl::OUString aDefault = getString(xColProp->getPropertyValue(PROPERTY_DEFAULTVALUE)); + if(getINT32(xColProp->getPropertyValue(PROPERTY_ISNULLABLE)) == ColumnValue::NO_NULLS) + { + aSql = aSql + ::rtl::OUString::createFromAscii(" NOT NULL"); + if(aDefault.getLength()) + aSql = aSql + ::rtl::OUString::createFromAscii(" WITH DEFAULT"); + } + else if(aDefault.getLength()) + aSql = aSql + ::rtl::OUString::createFromAscii(" DEFAULT ") + aDefault; + + aSql = aSql + ::rtl::OUString::createFromAscii(","); + } + } + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + + // keys + + Reference<XKeysSupplier> xKeySup(descriptor,UNO_QUERY); + + Reference<XIndexAccess> xKeys = xKeySup->getKeys(); + if(xKeys.is()) + { + sal_Bool bPKey = sal_False; + for(sal_Int32 i=0;i<xKeys->getCount();++i) + { + if(xColumns->getByIndex(i) >>= xColProp) + { + + sal_Int32 nKeyType = getINT32(xColProp->getPropertyValue(PROPERTY_TYPE)); + + if(nKeyType == KeyType::PRIMARY) + { + if(!bPKey) + throw SQLException(); + + bPKey = sal_True; + xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY); + xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY); + if(!xColumns->getCount()) + throw SQLException(); + + aSql = aSql + ::rtl::OUString::createFromAscii(" PRIMARY KEY ("); + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + if(xColumns->getByIndex(i) >>= xColProp) + aSql = aSql + aQuote + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(","); + } + + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + } + else if(nKeyType == KeyType::UNIQUE) + { + xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY); + xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY); + if(!xColumns->getCount()) + throw SQLException(); + + aSql = aSql + ::rtl::OUString::createFromAscii(" UNIQUE ("); + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + if(xColumns->getByIndex(i) >>= xColProp) + aSql = aSql + aQuote + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(","); + } + + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + } + else if(nKeyType == KeyType::FOREIGN) + { + sal_Int32 nDeleteRule = getINT32(xColProp->getPropertyValue(PROPERTY_DELETERULE)); + + xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY); + xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY); + if(!xColumns->getCount()) + throw SQLException(); + + aSql = aSql + ::rtl::OUString::createFromAscii(" FOREIGN KEY "); + ::rtl::OUString aName,aSchema,aRefTable = getString(xColProp->getPropertyValue(PROPERTY_REFERENCEDTABLE)); + sal_Int32 nLen = aRefTable.indexOf('.'); + aSchema = aRefTable.copy(0,nLen); + aName = aRefTable.copy(nLen+1); + + aSql = aSql + aQuote + aSchema + aQuote + aDot + + aQuote + aName + aQuote + + ::rtl::OUString::createFromAscii(" ("); + + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + if(xColumns->getByIndex(i) >>= xColProp) + aSql = aSql + aQuote + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(","); + } + + aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")")); + + switch(nDeleteRule) + { + case KeyRule::CASCADE: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE CASCADE "); + break; + case KeyRule::RESTRICT: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE RESTRICT "); + break; + case KeyRule::SET_NULL: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE SET NULL "); + break; + case KeyRule::SET_DEFAULT: + aSql = aSql + ::rtl::OUString::createFromAscii(" ON DELETE SET DEFAULT "); + break; + default: + ; + } + } + } + } + } + + OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection(); + Reference< XStatement > xStmt = pConnection->createStatement( ); + xStmt->execute(aSql); + + if(getString(descriptor->getPropertyValue(PROPERTY_DESCRIPTION)).getLength()) + setComments(descriptor); + + + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +void OTables::setComments(const Reference< XPropertySet >& descriptor ) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE TABLE "); + ::rtl::OUString aQuote = static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString aDot = ::rtl::OUString::createFromAscii("."); + + OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection(); + Reference< XStatement > xStmt = pConnection->createStatement( ); + aSql = ::rtl::OUString::createFromAscii("COMMENT ON TABLE ") + + aQuote + getString(descriptor->getPropertyValue(PROPERTY_SCHEMANAME)) + aQuote + aDot + + aQuote + getString(descriptor->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(" '") + + getString(descriptor->getPropertyValue(PROPERTY_DESCRIPTION)) + + ::rtl::OUString::createFromAscii("'"); + xStmt->execute(aSql); + + // columns + Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY); + Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY); + Reference< XPropertySet > xColProp; + + aSql = ::rtl::OUString::createFromAscii("COMMENT ON COLUMN ") + + aQuote + getString(descriptor->getPropertyValue(PROPERTY_SCHEMANAME)) + aQuote + aDot + + aQuote + getString(descriptor->getPropertyValue(PROPERTY_NAME)) + aQuote + aDot + + aQuote; + + for(sal_Int32 i=0;i<xColumns->getCount();++i) + { + xColumns->getByIndex(i) >>= xColProp; + ::rtl::OUString aDescription = getString(xColProp->getPropertyValue(PROPERTY_DESCRIPTION)); + if(aDescription.getLength()) + { + ::rtl::OUString aCom = aSql + getString(xColProp->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(" '") + + aDescription + + ::rtl::OUString::createFromAscii("'"); + xStmt->execute(aSql); + } + } +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OTables::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + + ObjectMap::iterator aIter = m_aNameMap.find(elementName); + if( aIter == m_aNameMap.end()) + throw NoSuchElementException(elementName,*this); + + Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(aIter->second.get(),UNO_QUERY); + if(xTunnel.is()) + { + OAdabasTable* pTable = (OAdabasTable*)xTunnel->getSomething(OAdabasTable:: getUnoTunnelImplementationId()); + + if(!pTable->isNew()) + { + OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection(); + Reference< XStatement > xStmt = pConnection->createStatement( ); + + ::rtl::OUString aName,aSchema; + sal_Int32 nLen = elementName.indexOf('.'); + aSchema = elementName.copy(0,nLen); + aName = elementName.copy(nLen+1); + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP TABLE "); + aSql = aSql + m_xMetaData->getIdentifierQuoteString( ) + aSchema + m_xMetaData->getIdentifierQuoteString( ); + aSql = aSql + ::rtl::OUString::createFromAscii("."); + aSql = aSql + m_xMetaData->getIdentifierQuoteString( ) + aName + m_xMetaData->getIdentifierQuoteString( ); + xStmt->execute(aSql); + } + } + + OCollection_TYPE::dropByName(elementName); +} +// ------------------------------------------------------------------------- +void SAL_CALL OTables::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + dropByName((*m_aElements[index]).first); +} +// ------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/adabas/BUser.cxx b/connectivity/source/drivers/adabas/BUser.cxx new file mode 100644 index 000000000000..b017fc2d1f18 --- /dev/null +++ b/connectivity/source/drivers/adabas/BUser.cxx @@ -0,0 +1,151 @@ +/************************************************************************* + * + * $RCSfile: BUser.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADABAS_USER_HXX_ +#include "adabas/BUser.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_GROUPS_HXX_ +#include "adabas/BGroups.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CONNECTIVITY_ADABAS_BCONNECTION_HXX_ +#include "adabas/BConnection.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif + +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +// ------------------------------------------------------------------------- +OAdabasUser::OAdabasUser( OAdabasConnection* _pConnection) : connectivity::sdbcx::OUser(sal_True) + ,m_pConnection(_pConnection) +{ + construct(); +} +// ------------------------------------------------------------------------- +OAdabasUser::OAdabasUser( OAdabasConnection* _pConnection, + const ::rtl::OUString& _Name + ) : connectivity::sdbcx::OUser(_Name,sal_True) + ,m_pConnection(_pConnection) +{ + construct(); +} +// ------------------------------------------------------------------------- +Any SAL_CALL OAdabasUser::queryInterface( const Type & rType ) throw(RuntimeException) +{ +// if(rType == ::getCppuType((const ::com::sun::star::uno::Reference< XGroupsSupplier>*)0)) +// return Any(); + + return OUser_TYPEDEF::queryInterface(rType); +} +// ------------------------------------------------------------------------- +void OAdabasUser::refreshGroups() +{ + if(!m_pConnection) + return; + + ::std::vector< ::rtl::OUString> aVector; + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("SELECT DISTINCT GROUPNAME FROM DOMAIN.USERS WHERE GROUPNAME IS NOT NULL AND GROUPNAME <> ' ' AND USERNAME = '"); + aSql += getName( ); + aSql += ::rtl::OUString::createFromAscii("'"); + + Reference< XResultSet > xResult = xStmt->executeQuery(aSql); + if(xResult.is()) + { + Reference< XRow > xRow(xResult,UNO_QUERY); + while(xResult->next()) + aVector.push_back(xRow->getString(1)); + } + + if(m_pGroups) + delete m_pGroups; + m_pGroups = new OGroups(*this,m_aMutex,aVector,m_pConnection,this); +} +// ------------------------------------------------------------------------- +OUserExtend::OUserExtend( OAdabasConnection* _pConnection) : OAdabasUser(_pConnection) +{ + construct(); +} +// ------------------------------------------------------------------------- +OUserExtend::OUserExtend( OAdabasConnection* _pConnection,const ::rtl::OUString& _Name) : OAdabasUser(_pConnection,_Name) +{ + construct(); +} +// ------------------------------------------------------------------------- +typedef connectivity::sdbcx::OUser OUser_TYPEDEF; +void OUserExtend::construct() +{ + OUser_TYPEDEF::construct(); + registerProperty(PROPERTY_PASSWORD, PROPERTY_ID_PASSWORD,0,&m_Password,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); +} + diff --git a/connectivity/source/drivers/adabas/BUsers.cxx b/connectivity/source/drivers/adabas/BUsers.cxx new file mode 100644 index 000000000000..50d896c0b05a --- /dev/null +++ b/connectivity/source/drivers/adabas/BUsers.cxx @@ -0,0 +1,160 @@ +/************************************************************************* + * + * $RCSfile: BUsers.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADABAS_USERS_HXX_ +#include "adabas/BUsers.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_USER_HXX_ +#include "adabas/BUser.hxx" +#endif +#ifndef _CONNECTIVITY_ADABAS_TABLE_HXX_ +#include "adabas/BTable.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ +#include <com/sun/star/sdbc/XRow.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBC_XRESULTSET_HPP_ +#include <com/sun/star/sdbc/XResultSet.hpp> +#endif +#ifndef _CONNECTIVITY_SDBCX_IREFRESHABLE_HXX_ +#include "connectivity/sdbcx/IRefreshable.hxx" +#endif +#ifndef _CONNECTIVITY_PROPERTYIDS_HXX_ +#include "propertyids.hxx" +#endif +using namespace connectivity::adabas; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +typedef connectivity::sdbcx::OCollection OCollection_TYPE; + +Reference< XNamed > OUsers::createObject(const ::rtl::OUString& _rName) +{ + OAdabasUser* pRet = new OAdabasUser(m_pConnection,_rName); + Reference< XNamed > xRet = pRet; + return xRet; +} +// ------------------------------------------------------------------------- +void OUsers::impl_refresh() throw(RuntimeException) +{ + m_pParent->refreshUsers(); +} +// ------------------------------------------------------------------------- +Reference< XPropertySet > OUsers::createEmptyObject() +{ + OUserExtend* pNew = new OUserExtend(m_pConnection); + return pNew; +} +// ------------------------------------------------------------------------- +// XAppend +void SAL_CALL OUsers::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME)); + ObjectMap::iterator aIter = m_aNameMap.find(aName); + if( aIter != m_aNameMap.end()) + throw ElementExistException(aName,*this); + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE USER "); + ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( ); + + aSql = aSql + aQuote + getString(descriptor->getPropertyValue(PROPERTY_NAME)) + aQuote + + ::rtl::OUString::createFromAscii(" PASSWORD ") + + getString(descriptor->getPropertyValue(PROPERTY_PASSWORD)); + + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + xStmt->execute(aSql); + + OCollection_TYPE::appendByDescriptor(descriptor); +} +// ------------------------------------------------------------------------- +// XDrop +void SAL_CALL OUsers::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + ObjectMap::iterator aIter = m_aNameMap.find(elementName); + if( aIter == m_aNameMap.end()) + throw NoSuchElementException(elementName,*this); + + ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP USER "); + ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( ); + + aSql = aSql + aQuote + elementName + aQuote; + + Reference< XStatement > xStmt = m_pConnection->createStatement( ); + xStmt->execute(aSql); + + OCollection_TYPE::dropByName(elementName); +} + +// ------------------------------------------------------------------------- +void SAL_CALL OUsers::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_rMutex); + if (index < 0 || index >= getCount()) + throw IndexOutOfBoundsException(); + + dropByName(m_aElements[index]->first); +} + diff --git a/connectivity/source/drivers/adabas/Bservices.cxx b/connectivity/source/drivers/adabas/Bservices.cxx new file mode 100644 index 000000000000..7485587dc4b8 --- /dev/null +++ b/connectivity/source/drivers/adabas/Bservices.cxx @@ -0,0 +1,212 @@ +/************************************************************************* + * + * $RCSfile: Bservices.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CONNECTIVITY_ADABAS_BDRIVER_HXX_ +#include "adabas/BDriver.hxx" +#endif +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include <cppuhelper/factory.hxx> +#endif +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +using namespace connectivity::adabas; +using ::rtl::OUString; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::registry::XRegistryKey; +using ::com::sun::star::lang::XSingleServiceFactory; +using ::com::sun::star::lang::XMultiServiceFactory; + +typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc) + ( + const Reference< XMultiServiceFactory > & rServiceManager, + const OUString & rComponentName, + ::cppu::ComponentInstantiation pCreateFunction, + const Sequence< OUString > & rServiceNames + ); + +//*************************************************************************************** +// +// Die vorgeschriebene C-Api muss erfuellt werden! +// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen. +// + +//--------------------------------------------------------------------------------------- +void REGISTER_PROVIDER( + const OUString& aServiceImplName, + const Sequence< OUString>& Services, + const Reference< ::com::sun::star::registry::XRegistryKey > & xKey) +{ + OUString aMainKeyName; + aMainKeyName = OUString::createFromAscii("/"); + aMainKeyName += aServiceImplName; + aMainKeyName += OUString::createFromAscii("/UNO/SERVICES"); + + Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) ); + OSL_ENSHURE(xNewKey.is(), "ADABAS::component_writeInfo : could not create a registry key !"); + + for (sal_uInt32 i=0; i<Services.getLength(); ++i) + xNewKey->createKey(Services[i]); +} + + +//--------------------------------------------------------------------------------------- +struct ProviderRequest +{ + Reference< XSingleServiceFactory > xRet; + Reference< XMultiServiceFactory > const xServiceManager; + OUString const sImplementationName; + + ProviderRequest( + void* pServiceManager, + sal_Char const* pImplementationName + ) + : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager)) + , sImplementationName(OUString::createFromAscii(pImplementationName)) + { + } + + inline + sal_Bool CREATE_PROVIDER( + const OUString& Implname, + const Sequence< OUString > & Services, + ::cppu::ComponentInstantiation Factory, + createFactoryFunc creator + ) + { + if (!xRet.is() && (Implname == sImplementationName)) + try + { + xRet = creator( xServiceManager, sImplementationName,Factory, Services); + } + catch(...) + { + } + return xRet.is(); + } + + void* getProvider() const { return xRet.get(); } +}; + +//--------------------------------------------------------------------------------------- + +extern "C" void SAL_CALL component_getImplementationEnvironment( + const sal_Char **ppEnvTypeName, + uno_Environment **ppEnv + ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +//--------------------------------------------------------------------------------------- +extern "C" sal_Bool SAL_CALL component_writeInfo( + void* pServiceManager, + void* pRegistryKey + ) +{ + if (pRegistryKey) + try + { + Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey)); + + REGISTER_PROVIDER( + ODriver::getImplementationName_Static(), + ODriver::getSupportedServiceNames_Static(), xKey); + + return sal_True; + } + catch (::com::sun::star::registry::InvalidRegistryException& ) + { + OSL_ENSHURE(sal_False, "ODBC::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !"); + } + + return sal_False; +} + +//--------------------------------------------------------------------------------------- +extern "C" void* SAL_CALL component_getFactory( + const sal_Char* pImplementationName, + void* pServiceManager, + void* pRegistryKey) +{ + void* pRet = 0; + if (pServiceManager) + { + ProviderRequest aReq(pServiceManager,pImplementationName); + + aReq.CREATE_PROVIDER( + ODriver::getImplementationName_Static(), + ODriver::getSupportedServiceNames_Static(), + ODriver_CreateInstance, ::cppu::createSingleFactory) + ; + + if(aReq.xRet.is()) + aReq.xRet->acquire(); + + pRet = aReq.getProvider(); + } + + return pRet; +}; + + diff --git a/connectivity/source/drivers/adabas/adabas.map b/connectivity/source/drivers/adabas/adabas.map new file mode 100644 index 000000000000..7ce4c703e6b3 --- /dev/null +++ b/connectivity/source/drivers/adabas/adabas.map @@ -0,0 +1,8 @@ +ADABAS_2_0 { + global: + component_getImplementationEnvironment; + component_writeInfo; + component_getFactory; + local: + *; +}; diff --git a/connectivity/source/drivers/adabas/adabas.xml b/connectivity/source/drivers/adabas/adabas.xml new file mode 100644 index 000000000000..40070e191e75 --- /dev/null +++ b/connectivity/source/drivers/adabas/adabas.xml @@ -0,0 +1,70 @@ +<?xml version='1.0' encoding="UTF-8"?> +<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//W3C//DTD HTML 3.2//EN" "componentdependencies.dtd"> +<COMPONENTDESCRIPTION> + +<Name> com.sun.star.sdbc.BDriver </Name> + +<Description> + This is the implementation of the sdbc-odbc bridge. +</Description> + +<ModuleName> odbc </ModuleName> + +<LoaderName> com.sun.star.loader.SharedLibrary </LoaderName> + +<SupportedService> com.sun.star.sdbc.Driver </SupportedService> + +<ServiceDependency> ... </ServiceDependency> + +<ProjectBuildDependency> cppuhelper </ProjectBuildDependency> +<ProjectBuildDependency> cppu </ProjectBuildDependency> +<ProjectBuildDependency> sal </ProjectBuildDependency> +<ProjectBuildDependency> vos </ProjectBuildDependency> + +<RuntimeModuleDependency> cppuhelper </RuntimeModuleDependency> +<RuntimeModuleDependency> cppu1 </RuntimeModuleDependency> +<RuntimeModuleDependency> sal1 </RuntimeModuleDependency> +<RuntimeModuleDependency> vos </RuntimeModuleDependency> + +<Language> c++ </Language> + +<Status StatusValue="final"/> + +<Type> com.sun.star.util.XCancellable </Type> +<Type> com.sun.star.util.XNumberFormatter </Type> +<Type> com.sun.star.uno.TypeClass </Type> +<Type> com.sun.star.uno.XWeak </Type> +<Type> com.sun.star.uno.XAggregation </Type> +<Type> com.sun.star.beans.XPropertyState </Type> +<Type> com.sun.star.beans.XPropertySet </Type> +<Type> com.sun.star.beans.PropertyValue </Type> +<Type> com.sun.star.beans.XMultiPropertySet </Type> +<Type> com.sun.star.beans.XFastPropertySet </Type> +<Type> com.sun.star.lang.XTypeProvider </Type> +<Type> com.sun.star.lang.EventObject </Type> +<Type> com.sun.star.lang.XComponent </Type> +<Type> com.sun.star.lang.IllegalArgumentException </Type> +<Type> com.sun.star.lang.XMultiServiceFactory </Type> +<Type> com.sun.star.java.XJavaThreadRegister_11 </Type> +<Type> com.sun.star.java.XJavaVM </Type> +<Type> com.sun.star.sdbc.XConnection </Type> +<Type> com.sun.star.sdbc.XStatement </Type> +<Type> com.sun.star.sdbc.XResultSet </Type> +<Type> com.sun.star.sdbc.XResultSetMetaDataSupplier</Type> +<Type> com.sun.star.sdbc.XColumnLocate </Type> +<Type> com.sun.star.sdbc.XResultSetUpdate </Type> +<Type> com.sun.star.sdbc.XWarningsSupplier </Type> +<Type> com.sun.star.sdbc.XRowUpdate </Type> +<Type> com.sun.star.sdbc.XMultipleResults </Type> +<Type> com.sun.star.sdbc.XBatchExecution </Type> +<Type> com.sun.star.sdbc.XPreparedBatchExecution </Type> +<Type> com.sun.star.sdbc.XParameters </Type> +<Type> com.sun.star.sdbc.XOutParameters </Type> +<Type> com.sun.star.sdbc.DriverPropertyInfo </Type> +<Type> com.sun.star.sdbc.XRow </Type> +<Type> com.sun.star.sdb.XColumnUpdate </Type> +<Type> com.sun.star.sdb.XColumn </Type> + +</COMPONENTDESCRIPTION> + + diff --git a/connectivity/source/drivers/adabas/exports.dxp b/connectivity/source/drivers/adabas/exports.dxp new file mode 100644 index 000000000000..9630d7e06768 --- /dev/null +++ b/connectivity/source/drivers/adabas/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/connectivity/source/drivers/adabas/makefile.mk b/connectivity/source/drivers/adabas/makefile.mk new file mode 100644 index 000000000000..2df67f8df3d1 --- /dev/null +++ b/connectivity/source/drivers/adabas/makefile.mk @@ -0,0 +1,199 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:14:20 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJINC=..$/.. +PRJNAME=connectivity +TARGET=adabas + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ---------------------------------- +.IF "$(DBGUTIL_OJ)"!="" +ENVCFLAGS+=/FR$(SLO)$/ +.ENDIF + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/version.mk + +# --- Types ------------------------------------- + + +UNOUCRDEP=$(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB=$(SOLARBINDIR)$/applicat.rdb + +UNOUCROUT=$(OUT)$/inc +INCPRE+=$(UNOUCROUT) + +# --- Types ------------------------------------- + +UNOTYPES+= \ + com.sun.star.util.XCancellable \ + com.sun.star.util.XNumberFormatter \ + com.sun.star.uno.TypeClass \ + com.sun.star.uno.XWeak \ + com.sun.star.uno.XAggregation \ + com.sun.star.beans.XPropertyState \ + com.sun.star.beans.XPropertySet \ + com.sun.star.beans.PropertyValue \ + com.sun.star.beans.XMultiPropertySet \ + com.sun.star.beans.XFastPropertySet \ + com.sun.star.lang.XTypeProvider \ + com.sun.star.lang.EventObject \ + com.sun.star.lang.XComponent \ + com.sun.star.lang.IllegalArgumentException \ + com.sun.star.lang.DisposedException \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.lang.XUnoTunnel \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.java.XJavaThreadRegister_11 \ + com.sun.star.java.XJavaVM \ + com.sun.star.sdbc.XConnection \ + com.sun.star.sdbc.XStatement \ + com.sun.star.sdbc.XResultSet \ + com.sun.star.sdbc.XResultSetMetaDataSupplier \ + com.sun.star.sdbc.XColumnLocate \ + com.sun.star.sdbc.XResultSetUpdate \ + com.sun.star.sdbc.XWarningsSupplier \ + com.sun.star.sdbc.XRowUpdate \ + com.sun.star.sdbc.XMultipleResults \ + com.sun.star.sdbc.XBatchExecution \ + com.sun.star.sdbc.XPreparedBatchExecution \ + com.sun.star.sdbc.XParameters \ + com.sun.star.sdbc.XOutParameters \ + com.sun.star.sdbc.DriverPropertyInfo \ + com.sun.star.sdbc.XDriver \ + com.sun.star.sdbc.XRow \ + com.sun.star.sdbc.SQLWarning \ + com.sun.star.sdbc.ColumnSearch \ + com.sun.star.sdbc.DataType \ + com.sun.star.sdbc.ResultSetConcurrency \ + com.sun.star.sdbc.ResultSetType \ + com.sun.star.sdbc.ColumnValue \ + com.sun.star.sdbcx.KeyType \ + com.sun.star.sdb.XColumnUpdate \ + com.sun.star.sdb.XColumn \ + + + +# --- Files ------------------------------------- + +SLOFILES=\ + $(SLO)$/BConnection.obj \ + $(SLO)$/BDriver.obj \ + $(SLO)$/BCatalog.obj \ + $(SLO)$/BGroups.obj \ + $(SLO)$/BGroup.obj \ + $(SLO)$/BUser.obj \ + $(SLO)$/BUsers.obj \ + $(SLO)$/BKeyColumns.obj \ + $(SLO)$/BKey.obj \ + $(SLO)$/BKeys.obj \ + $(SLO)$/BColumns.obj \ + $(SLO)$/BIndex.obj \ + $(SLO)$/BIndexColumns.obj \ + $(SLO)$/BIndexes.obj \ + $(SLO)$/BTable.obj \ + $(SLO)$/BTables.obj \ + $(SLO)$/Bservices.obj \ + $(SLO)$/BDatabaseMetaData.obj \ + $(SLO)$/OPreparedStatement.obj \ + $(SLO)$/OStatement.obj \ + $(SLO)$/OResultSetMetaData.obj \ + $(SLO)$/OResultSet.obj \ + $(SLO)$/OTools.obj \ + $(SLO)$/ODatabaseMetaData.obj \ + $(SLO)$/ODriver.obj \ + $(SLO)$/OFunctions.obj \ + $(SLO)$/OConnection.obj + + +# --- Library ----------------------------------- + +SHL1TARGET= $(ADABAS_TARGET)$(ADABAS_MAJOR) +SHL1VERSIONMAP= $(TARGET).map +SHL1OBJS=$(SLOFILES) +SHL1STDLIBS=\ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VOSLIB) \ + $(OSLLIB) \ + $(SALLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(SHL1TARGET) +SHL1LIBS= $(SLB)$/commontools.lib \ + $(SLB)$/resource.lib \ + $(SLB)$/sdbcx.lib + +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + + +# --- Targets ---------------------------------- + +.INCLUDE : target.mk + + |