LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/drivers/postgresql - pq_updateableresultset.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 16 0.0 %
Date: 2012-12-27 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             :  *    Version: MPL 1.1 / GPLv3+ / LGPLv2.1+
      32             :  *
      33             :  *    The contents of this file are subject to the Mozilla Public License Version
      34             :  *    1.1 (the "License"); you may not use this file except in compliance with
      35             :  *    the License or as specified alternatively below. You may obtain a copy of
      36             :  *    the License at http://www.mozilla.org/MPL/
      37             :  *
      38             :  *    Software distributed under the License is distributed on an "AS IS" basis,
      39             :  *    WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      40             :  *    for the specific language governing rights and limitations under the
      41             :  *    License.
      42             :  *
      43             :  *    Major Contributor(s):
      44             :  *    [ Copyright (C) 2011 Lionel Elie Mamane <lionel@mamane.lu> ]
      45             :  *
      46             :  *    All Rights Reserved.
      47             :  *
      48             :  *    For minor contributions see the git repository.
      49             :  *
      50             :  *    Alternatively, the contents of this file may be used under the terms of
      51             :  *    either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      52             :  *    the GNU Lesser General Public License Version 2.1 or later (the "LGPLv2.1+"),
      53             :  *    in which case the provisions of the GPLv3+ or the LGPLv2.1+ are applicable
      54             :  *    instead of those above.
      55             :  *
      56             :  ************************************************************************/
      57             : 
      58             : #include "pq_sequenceresultset.hxx"
      59             : #include "pq_resultsetmetadata.hxx"
      60             : 
      61             : #include <com/sun/star/sdbc/FetchDirection.hpp>
      62             : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
      63             : #include <com/sun/star/sdbc/ResultSetType.hpp>
      64             : #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
      65             : #include <com/sun/star/sdbc/XRowUpdate.hpp>
      66             : 
      67             : namespace pq_sdbc_driver
      68             : {
      69             : 
      70           0 : struct UpdateableField
      71             : {
      72           0 :     UpdateableField( )
      73           0 :         : isTouched(false)
      74           0 :     {}
      75             :     com::sun::star::uno::Any value;
      76             :     bool    isTouched;
      77             : };
      78             : 
      79             : typedef ::std::vector< UpdateableField , Allocator< UpdateableField > > UpdateableFieldVector;
      80             : 
      81           0 : class UpdateableResultSet :
      82             :         public SequenceResultSet,
      83             :         public com::sun::star::sdbc::XResultSetUpdate,
      84             :         public com::sun::star::sdbc::XRowUpdate
      85             : {
      86             :     ConnectionSettings **m_ppSettings;
      87             :     rtl::OUString m_schema;
      88             :     rtl::OUString m_table;
      89             :     com::sun::star::uno::Sequence< rtl::OUString > m_primaryKey;
      90             :     UpdateableFieldVector m_updateableField;
      91             :     com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSetMetaData > m_meta;
      92             :     bool  m_insertRow;
      93             : 
      94             : protected:
      95           0 :     UpdateableResultSet(
      96             :         const ::rtl::Reference< RefCountedMutex > & mutex,
      97             :         const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
      98             :         const com::sun::star::uno::Sequence< rtl::OUString > &colNames,
      99             :         const com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::uno::Any > > &data,
     100             :         ConnectionSettings **ppSettings,
     101             :         const rtl::OUString &schema,
     102             :         const rtl::OUString &table,
     103             :         const com::sun::star::uno::Sequence< ::rtl::OUString > &primaryKey)
     104             :         : SequenceResultSet( mutex, owner, colNames, data, (*ppSettings)->tc ),
     105             :           m_ppSettings( ppSettings ),
     106             :           m_schema( schema ),
     107             :           m_table( table ),
     108             :           m_primaryKey( primaryKey ),
     109           0 :           m_insertRow( false )
     110             :     {
     111             :         // LEM TODO: this duplicates code in pq_resultset.cxx, except for different value
     112             :         //           of ResultSetConcurrency. Baaad.
     113             :         //           Why is an updatable ResultSet a sequenceresultset in the first place?
     114             :         //           This seems to imply that the whole data is fetched once and kept in memory. BAAAAD.
     115             :         // LEM TODO: shouldn't these things be inherited from the statement or something like that?
     116           0 :         sal_Bool b = sal_False;
     117             :         // Positioned update/delete not supported, so no cursor name
     118             :         // Fetch direction and size are cursor-specific things, so not used now.
     119             :         // Fetch size not set
     120             :         m_props[ BASERESULTSET_FETCH_DIRECTION ] = com::sun::star::uno::makeAny(
     121           0 :             com::sun::star::sdbc::FetchDirection::UNKNOWN);
     122             :         // No escape processing for now
     123           0 :         m_props[ BASERESULTSET_ESCAPE_PROCESSING ] = com::sun::star::uno::Any( &b, getBooleanCppuType() );
     124             :         // Bookmarks not implemented for now
     125           0 :         m_props[ BASERESULTSET_IS_BOOKMARKABLE ] = com::sun::star::uno::Any( &b, getBooleanCppuType() );
     126             :         m_props[ BASERESULTSET_RESULT_SET_CONCURRENCY ] = com::sun::star::uno::makeAny(
     127           0 :             com::sun::star::sdbc::ResultSetConcurrency::UPDATABLE );
     128             :         m_props[ BASERESULTSET_RESULT_SET_TYPE ] = com::sun::star::uno::makeAny(
     129           0 :             com::sun::star::sdbc::ResultSetType::SCROLL_INSENSITIVE );
     130           0 :     }
     131             : 
     132             :     rtl::OUString buildWhereClause();
     133             :     void checkUpdate( sal_Int32 column );
     134             : 
     135             : public:
     136             :     static com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > createFromPGResultSet(
     137             :         const ::rtl::Reference< RefCountedMutex > & mutex,
     138             :         const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
     139             :         ConnectionSettings **ppSettings,
     140             :         PGresult *result,
     141             :         const rtl::OUString &schema,
     142             :         const rtl::OUString &table,
     143             :         const com::sun::star::uno::Sequence< ::rtl::OUString > &primaryKey );
     144             : 
     145             : public: // XInterface
     146           0 :     virtual void SAL_CALL acquire() throw() { SequenceResultSet::acquire(); }
     147           0 :     virtual void SAL_CALL release() throw() { SequenceResultSet::release(); }
     148             :     virtual com::sun::star::uno::Any  SAL_CALL queryInterface(
     149             :         const com::sun::star::uno::Type & reqType )
     150             :         throw (com::sun::star::uno::RuntimeException);
     151             : 
     152             : public: // XTypeProvider
     153             :     virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
     154             :         throw( com::sun::star::uno::RuntimeException );
     155             :     virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
     156             :         throw( com::sun::star::uno::RuntimeException );
     157             : 
     158             : public: // XResultSetUpdate
     159             :     virtual void SAL_CALL insertRow(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     160             :     virtual void SAL_CALL updateRow(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     161             :     virtual void SAL_CALL deleteRow(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     162             :     virtual void SAL_CALL cancelRowUpdates(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     163             :     virtual void SAL_CALL moveToInsertRow(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     164             :     virtual void SAL_CALL moveToCurrentRow(  ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     165             : 
     166             : public: // XRowUpdate
     167             :     virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     168             :     virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     169             :     virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     170             :     virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     171             :     virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     172             :     virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     173             :     virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     174             :     virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     175             :     virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     176             :     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);
     177             :     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);
     178             :     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);
     179             :     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);
     180             :     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);
     181             :     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);
     182             :     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);
     183             :     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);
     184             : 
     185             : public: // XResultSetMetaDataSupplier
     186             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData(  )
     187             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     188             : 
     189             : 
     190             :     static com::sun::star::uno::Sequence< com::sun::star::uno::Type > getStaticTypes( bool updateable )
     191             :         throw( com::sun::star::uno::RuntimeException );
     192             : 
     193             : };
     194             : 
     195             : 
     196             : 
     197             : }

Generated by: LCOV version 1.10