Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef DBACCESS_CORE_API_OPTIMISTICSET_HXX
21 : : #define DBACCESS_CORE_API_OPTIMISTICSET_HXX
22 : :
23 : : #include "KeySet.hxx"
24 : : #include <cppuhelper/implbase1.hxx>
25 : :
26 : : #include <connectivity/sqlparse.hxx>
27 : : #include <connectivity/sqliterator.hxx>
28 : :
29 : : #include <com/sun/star/lang/XUnoTunnel.hpp>
30 : : #include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
31 : : #include <comphelper/stl_types.hxx>
32 : : #include <comphelper/componentcontext.hxx>
33 : :
34 : : namespace dbaccess
35 : : {
36 : : // is used when the source supports keys
37 : : class OptimisticSet : public OKeySet
38 : : {
39 : : ::connectivity::OSQLParser m_aSqlParser;
40 : : ::connectivity::OSQLParseTreeIterator m_aSqlIterator;
41 : :
42 : : ::std::map<sal_Int32,sal_Int32> m_aJoinedColumns;
43 : : ::std::map<sal_Int32,sal_Int32> m_aJoinedKeyColumns;
44 : :
45 : : mutable bool m_bResultSetChanged;
46 : :
47 : : void impl_convertValue_throw(const ORowSetRow& _rInsertRow,const SelectColumnDescription& i_aMetaData);
48 : :
49 : : void executeDelete(const ORowSetRow& _rDeleteRow,const ::rtl::OUString& i_sSQL,const ::rtl::OUString& i_sTableName);
50 : : void fillJoinedColumns_throw(const ::std::vector< ::connectivity::TNodePair>& i_aJoinColumns);
51 : : void fillJoinedColumns_throw(const ::rtl::OUString& i_sLeftColumn,const ::rtl::OUString& i_sRightColumn);
52 : : protected:
53 : : virtual ~OptimisticSet();
54 : : public:
55 : : OptimisticSet(const ::comphelper::ComponentContext& _rContext,
56 : : const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& i_xConnection,
57 : : const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer,
58 : : const ORowSetValueVector& _aParameterValueForCache,
59 : : sal_Int32 i_nMaxRows,
60 : : sal_Int32& o_nRowCount);
61 : :
62 : : // late ctor which can throw exceptions
63 : : virtual void construct(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet,const ::rtl::OUString& i_sRowSetFilter);
64 : :
65 : : // ::com::sun::star::sdbcx::XDeleteRows
66 : : virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rows ,const connectivity::OSQLTable& _xTable) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
67 : : // ::com::sun::star::sdbc::XResultSetUpdate
68 : : virtual void SAL_CALL updateRow(const ORowSetRow& _rInsertRow,const ORowSetRow& _rOrginalRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
69 : : virtual void SAL_CALL deleteRow(const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
70 : : virtual void SAL_CALL insertRow( const ORowSetRow& _rInsertRow,const connectivity::OSQLTable& _xTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
71 : :
72 : : // CacheSet
73 : : virtual bool isResultSetChanged() const;
74 : : virtual void reset(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xDriverSet);
75 : : virtual void mergeColumnValues(sal_Int32 i_nColumnIndex,ORowSetValueVector::Vector& io_aInsertRow,ORowSetValueVector::Vector& io_aRow,::std::vector<sal_Int32>& o_aChangedColumns);
76 : : virtual bool columnValuesUpdated(ORowSetValueVector::Vector& o_aCachedRow,const ORowSetValueVector::Vector& i_aRow);
77 : : virtual bool updateColumnValues(const ORowSetValueVector::Vector& io_aCachedRow,ORowSetValueVector::Vector& io_aRow,const ::std::vector<sal_Int32>& i_aChangedColumns);
78 : : virtual void fillMissingValues(ORowSetValueVector::Vector& io_aRow) const;
79 : :
80 : 0 : bool isReadOnly() const { return m_aJoinedKeyColumns.empty(); }
81 : : const ::std::map<sal_Int32,sal_Int32>& getJoinedColumns() const { return m_aJoinedColumns; }
82 : 0 : const ::std::map<sal_Int32,sal_Int32>& getJoinedKeyColumns() const { return m_aJoinedKeyColumns; }
83 : : };
84 : : }
85 : : #endif // DBACCESS_CORE_API_OPTIMISTICSET_HXX
86 : :
87 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|