LCOV - code coverage report
Current view: top level - connectivity/source/drivers/postgresql - pq_updateableresultset.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 19 0.0 %
Date: 2014-11-03 Functions: 0 7 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             : #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_UPDATEABLERESULTSET_HXX
      38             : #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_UPDATEABLERESULTSET_HXX
      39             : 
      40             : #include "pq_sequenceresultset.hxx"
      41             : #include "pq_resultsetmetadata.hxx"
      42             : 
      43             : #include <com/sun/star/sdbc/FetchDirection.hpp>
      44             : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
      45             : #include <com/sun/star/sdbc/ResultSetType.hpp>
      46             : #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
      47             : #include <com/sun/star/sdbc/XRowUpdate.hpp>
      48             : 
      49             : namespace pq_sdbc_driver
      50             : {
      51             : 
      52           0 : struct UpdateableField
      53             : {
      54           0 :     UpdateableField( )
      55           0 :         : isTouched(false)
      56           0 :     {}
      57             :     com::sun::star::uno::Any value;
      58             :     bool    isTouched;
      59             : };
      60             : 
      61             : typedef ::std::vector< UpdateableField > UpdateableFieldVector;
      62             : 
      63           0 : class UpdateableResultSet :
      64             :         public SequenceResultSet,
      65             :         public com::sun::star::sdbc::XResultSetUpdate,
      66             :         public com::sun::star::sdbc::XRowUpdate
      67             : {
      68             :     ConnectionSettings **m_ppSettings;
      69             :     OUString m_schema;
      70             :     OUString m_table;
      71             :     com::sun::star::uno::Sequence< OUString > m_primaryKey;
      72             :     UpdateableFieldVector m_updateableField;
      73             :     com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSetMetaData > m_meta;
      74             :     bool  m_insertRow;
      75             : 
      76             : protected:
      77           0 :     UpdateableResultSet(
      78             :         const ::rtl::Reference< RefCountedMutex > & mutex,
      79             :         const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
      80             :         const com::sun::star::uno::Sequence< OUString > &colNames,
      81             :         const com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::uno::Any > > &data,
      82             :         ConnectionSettings **ppSettings,
      83             :         const OUString &schema,
      84             :         const OUString &table,
      85             :         const com::sun::star::uno::Sequence< OUString > &primaryKey)
      86             :         : SequenceResultSet( mutex, owner, colNames, data, (*ppSettings)->tc ),
      87             :           m_ppSettings( ppSettings ),
      88             :           m_schema( schema ),
      89             :           m_table( table ),
      90             :           m_primaryKey( primaryKey ),
      91           0 :           m_insertRow( false )
      92             :     {
      93             :         // LEM TODO: this duplicates code in pq_resultset.cxx, except for different value
      94             :         //           of ResultSetConcurrency. Baaad.
      95             :         //           Why is an updatable ResultSet a sequenceresultset in the first place?
      96             :         //           This seems to imply that the whole data is fetched once and kept in memory. BAAAAD.
      97             :         // LEM TODO: shouldn't these things be inherited from the statement or something like that?
      98           0 :         sal_Bool b = sal_False;
      99             :         // Positioned update/delete not supported, so no cursor name
     100             :         // Fetch direction and size are cursor-specific things, so not used now.
     101             :         // Fetch size not set
     102           0 :         m_props[ BASERESULTSET_FETCH_DIRECTION ] = com::sun::star::uno::makeAny(
     103           0 :             com::sun::star::sdbc::FetchDirection::UNKNOWN);
     104             :         // No escape processing for now
     105           0 :         m_props[ BASERESULTSET_ESCAPE_PROCESSING ] = com::sun::star::uno::Any( &b, getBooleanCppuType() );
     106             :         // Bookmarks not implemented for now
     107           0 :         m_props[ BASERESULTSET_IS_BOOKMARKABLE ] = com::sun::star::uno::Any( &b, getBooleanCppuType() );
     108           0 :         m_props[ BASERESULTSET_RESULT_SET_CONCURRENCY ] = com::sun::star::uno::makeAny(
     109           0 :             com::sun::star::sdbc::ResultSetConcurrency::UPDATABLE );
     110           0 :         m_props[ BASERESULTSET_RESULT_SET_TYPE ] = com::sun::star::uno::makeAny(
     111           0 :             com::sun::star::sdbc::ResultSetType::SCROLL_INSENSITIVE );
     112           0 :     }
     113             : 
     114             :     OUString buildWhereClause();
     115             :     void checkUpdate( sal_Int32 column );
     116             : 
     117             : public:
     118             :     static com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > createFromPGResultSet(
     119             :         const ::rtl::Reference< RefCountedMutex > & mutex,
     120             :         const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
     121             :         ConnectionSettings **ppSettings,
     122             :         PGresult *result,
     123             :         const OUString &schema,
     124             :         const OUString &table,
     125             :         const com::sun::star::uno::Sequence< OUString > &primaryKey );
     126             : 
     127             : public: // XInterface
     128           0 :     virtual void SAL_CALL acquire() throw() SAL_OVERRIDE { SequenceResultSet::acquire(); }
     129           0 :     virtual void SAL_CALL release() throw() SAL_OVERRIDE { SequenceResultSet::release(); }
     130             :     virtual com::sun::star::uno::Any  SAL_CALL queryInterface(
     131             :         const com::sun::star::uno::Type & reqType )
     132             :         throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     133             : 
     134             : public: // XTypeProvider
     135             :     virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
     136             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     137             :     virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
     138             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     139             : 
     140             : public: // XResultSetUpdate
     141             :     virtual void SAL_CALL insertRow(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     142             :     virtual void SAL_CALL updateRow(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     143             :     virtual void SAL_CALL deleteRow(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     144             :     virtual void SAL_CALL cancelRowUpdates(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     145             :     virtual void SAL_CALL moveToInsertRow(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     146             :     virtual void SAL_CALL moveToCurrentRow(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     147             : 
     148             : public: // XRowUpdate
     149             :     virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     150             :     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;
     151             :     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;
     152             :     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;
     153             :     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;
     154             :     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;
     155             :     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;
     156             :     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;
     157             :     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;
     158             :     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;
     159             :     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;
     160             :     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;
     161             :     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;
     162             :     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;
     163             :     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;
     164             :     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;
     165             :     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;
     166             : 
     167             : public: // XResultSetMetaDataSupplier
     168             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData(  )
     169             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     170             : 
     171             : 
     172             :     static com::sun::star::uno::Sequence< com::sun::star::uno::Type > getStaticTypes( bool updateable )
     173             :         throw( com::sun::star::uno::RuntimeException );
     174             : 
     175             : };
     176             : 
     177             : 
     178             : 
     179             : }
     180             : 
     181             : #endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_UPDATEABLERESULTSET_HXX
     182             : 
     183             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10