LCOV - code coverage report
Current view: top level - connectivity/source/drivers/postgresql - pq_updateableresultset.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 19 0.0 %
Date: 2014-04-14 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*************************************************************************
       3             :  *
       4             :  *  Effective License of whole file:
       5             :  *
       6             :  *    This library is free software; you can redistribute it and/or
       7             :  *    modify it under the terms of the GNU Lesser General Public
       8             :  *    License version 2.1, as published by the Free Software Foundation.
       9             :  *
      10             :  *    This library is distributed in the hope that it will be useful,
      11             :  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :  *    Lesser General Public License for more details.
      14             :  *
      15             :  *    You should have received a copy of the GNU Lesser General Public
      16             :  *    License along with this library; if not, write to the Free Software
      17             :  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      18             :  *    MA  02111-1307  USA
      19             :  *
      20             :  *  Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
      21             :  *
      22             :  *    The Contents of this file are made available subject to the terms of
      23             :  *    the GNU Lesser General Public License Version 2.1
      24             :  *
      25             :  *    Copyright: 200? by Sun Microsystems, Inc.
      26             :  *
      27             :  *    Contributor(s): Joerg Budischewski
      28             :  *
      29             :  *  All parts contributed on or after August 2011:
      30             :  *
      31             :  *    This Source Code Form is subject to the terms of the Mozilla Public
      32             :  *    License, v. 2.0. If a copy of the MPL was not distributed with this
      33             :  *    file, You can obtain one at http://mozilla.org/MPL/2.0/.
      34             :  *
      35             :  ************************************************************************/
      36             : 
      37             : #include "pq_sequenceresultset.hxx"
      38             : #include "pq_resultsetmetadata.hxx"
      39             : 
      40             : #include <com/sun/star/sdbc/FetchDirection.hpp>
      41             : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
      42             : #include <com/sun/star/sdbc/ResultSetType.hpp>
      43             : #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
      44             : #include <com/sun/star/sdbc/XRowUpdate.hpp>
      45             : 
      46             : namespace pq_sdbc_driver
      47             : {
      48             : 
      49           0 : struct UpdateableField
      50             : {
      51           0 :     UpdateableField( )
      52           0 :         : isTouched(false)
      53           0 :     {}
      54             :     com::sun::star::uno::Any value;
      55             :     bool    isTouched;
      56             : };
      57             : 
      58             : typedef ::std::vector< UpdateableField , Allocator< UpdateableField > > UpdateableFieldVector;
      59             : 
      60           0 : class UpdateableResultSet :
      61             :         public SequenceResultSet,
      62             :         public com::sun::star::sdbc::XResultSetUpdate,
      63             :         public com::sun::star::sdbc::XRowUpdate
      64             : {
      65             :     ConnectionSettings **m_ppSettings;
      66             :     OUString m_schema;
      67             :     OUString m_table;
      68             :     com::sun::star::uno::Sequence< OUString > m_primaryKey;
      69             :     UpdateableFieldVector m_updateableField;
      70             :     com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSetMetaData > m_meta;
      71             :     bool  m_insertRow;
      72             : 
      73             : protected:
      74           0 :     UpdateableResultSet(
      75             :         const ::rtl::Reference< RefCountedMutex > & mutex,
      76             :         const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
      77             :         const com::sun::star::uno::Sequence< OUString > &colNames,
      78             :         const com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::uno::Any > > &data,
      79             :         ConnectionSettings **ppSettings,
      80             :         const OUString &schema,
      81             :         const OUString &table,
      82             :         const com::sun::star::uno::Sequence< OUString > &primaryKey)
      83             :         : SequenceResultSet( mutex, owner, colNames, data, (*ppSettings)->tc ),
      84             :           m_ppSettings( ppSettings ),
      85             :           m_schema( schema ),
      86             :           m_table( table ),
      87             :           m_primaryKey( primaryKey ),
      88           0 :           m_insertRow( false )
      89             :     {
      90             :         // LEM TODO: this duplicates code in pq_resultset.cxx, except for different value
      91             :         //           of ResultSetConcurrency. Baaad.
      92             :         //           Why is an updatable ResultSet a sequenceresultset in the first place?
      93             :         //           This seems to imply that the whole data is fetched once and kept in memory. BAAAAD.
      94             :         // LEM TODO: shouldn't these things be inherited from the statement or something like that?
      95           0 :         sal_Bool b = sal_False;
      96             :         // Positioned update/delete not supported, so no cursor name
      97             :         // Fetch direction and size are cursor-specific things, so not used now.
      98             :         // Fetch size not set
      99           0 :         m_props[ BASERESULTSET_FETCH_DIRECTION ] = com::sun::star::uno::makeAny(
     100           0 :             com::sun::star::sdbc::FetchDirection::UNKNOWN);
     101             :         // No escape processing for now
     102           0 :         m_props[ BASERESULTSET_ESCAPE_PROCESSING ] = com::sun::star::uno::Any( &b, getBooleanCppuType() );
     103             :         // Bookmarks not implemented for now
     104           0 :         m_props[ BASERESULTSET_IS_BOOKMARKABLE ] = com::sun::star::uno::Any( &b, getBooleanCppuType() );
     105           0 :         m_props[ BASERESULTSET_RESULT_SET_CONCURRENCY ] = com::sun::star::uno::makeAny(
     106           0 :             com::sun::star::sdbc::ResultSetConcurrency::UPDATABLE );
     107           0 :         m_props[ BASERESULTSET_RESULT_SET_TYPE ] = com::sun::star::uno::makeAny(
     108           0 :             com::sun::star::sdbc::ResultSetType::SCROLL_INSENSITIVE );
     109           0 :     }
     110             : 
     111             :     OUString buildWhereClause();
     112             :     void checkUpdate( sal_Int32 column );
     113             : 
     114             : public:
     115             :     static com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > createFromPGResultSet(
     116             :         const ::rtl::Reference< RefCountedMutex > & mutex,
     117             :         const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
     118             :         ConnectionSettings **ppSettings,
     119             :         PGresult *result,
     120             :         const OUString &schema,
     121             :         const OUString &table,
     122             :         const com::sun::star::uno::Sequence< OUString > &primaryKey );
     123             : 
     124             : public: // XInterface
     125           0 :     virtual void SAL_CALL acquire() throw() SAL_OVERRIDE { SequenceResultSet::acquire(); }
     126           0 :     virtual void SAL_CALL release() throw() SAL_OVERRIDE { SequenceResultSet::release(); }
     127             :     virtual com::sun::star::uno::Any  SAL_CALL queryInterface(
     128             :         const com::sun::star::uno::Type & reqType )
     129             :         throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     130             : 
     131             : public: // XTypeProvider
     132             :     virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
     133             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     134             :     virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
     135             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     136             : 
     137             : public: // XResultSetUpdate
     138             :     virtual void SAL_CALL insertRow(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     139             :     virtual void SAL_CALL updateRow(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     140             :     virtual void SAL_CALL deleteRow(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     141             :     virtual void SAL_CALL cancelRowUpdates(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     142             :     virtual void SAL_CALL moveToInsertRow(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     143             :     virtual void SAL_CALL moveToCurrentRow(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     144             : 
     145             : public: // XRowUpdate
     146             :     virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     147             :     virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     148             :     virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     149             :     virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     150             :     virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     151             :     virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     152             :     virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     153             :     virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     154             :     virtual void SAL_CALL updateString( sal_Int32 columnIndex, const OUString& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     155             :     virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     156             :     virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     157             :     virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     158             :     virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     159             :     virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     160             :     virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     161             :     virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     162             :     virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     163             : 
     164             : public: // XResultSetMetaDataSupplier
     165             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData(  )
     166             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     167             : 
     168             : 
     169             :     static com::sun::star::uno::Sequence< com::sun::star::uno::Type > getStaticTypes( bool updateable )
     170             :         throw( com::sun::star::uno::RuntimeException );
     171             : 
     172             : };
     173             : 
     174             : 
     175             : 
     176             : }
     177             : 
     178             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10