1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_DBACCESS_SOURCE_CORE_API_OPTIMISTICSET_HXX
21 #define INCLUDED_DBACCESS_SOURCE_CORE_API_OPTIMISTICSET_HXX
24 #include <cppuhelper/implbase1.hxx>
26 #include <connectivity/sqlparse.hxx>
27 #include <connectivity/sqliterator.hxx>
29 #include <com/sun/star/lang/XUnoTunnel.hpp>
30 #include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp>
34 // is used when the source supports keys
35 class OptimisticSet
: public OKeySet
37 ::connectivity::OSQLParser m_aSqlParser
;
38 ::connectivity::OSQLParseTreeIterator m_aSqlIterator
;
40 ::std::map
<sal_Int32
,sal_Int32
> m_aJoinedColumns
;
41 ::std::map
<sal_Int32
,sal_Int32
> m_aJoinedKeyColumns
;
43 mutable bool m_bResultSetChanged
;
45 void impl_convertValue_throw(const ORowSetRow
& _rInsertRow
,const SelectColumnDescription
& i_aMetaData
);
47 void executeDelete(const ORowSetRow
& _rDeleteRow
,const OUString
& i_sSQL
,const OUString
& i_sTableName
);
48 void fillJoinedColumns_throw(const ::std::vector
< ::connectivity::TNodePair
>& i_aJoinColumns
);
49 void fillJoinedColumns_throw(const OUString
& i_sLeftColumn
,const OUString
& i_sRightColumn
);
51 virtual void makeNewStatement( ) SAL_OVERRIDE
;
52 virtual ~OptimisticSet();
54 OptimisticSet(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rContext
,
55 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& i_xConnection
,
56 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer
>& _xComposer
,
57 const ORowSetValueVector
& _aParameterValueForCache
,
59 sal_Int32
& o_nRowCount
);
61 // late ctor which can throw exceptions
62 virtual void construct(const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
>& _xDriverSet
,const OUString
& i_sRowSetFilter
) SAL_OVERRIDE
;
64 // ::com::sun::star::sdbcx::XDeleteRows
65 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
) SAL_OVERRIDE
;
66 // ::com::sun::star::sdbc::XResultSetUpdate
67 virtual void SAL_CALL
updateRow(const ORowSetRow
& _rInsertRow
,const ORowSetRow
& _rOriginalRow
,const connectivity::OSQLTable
& _xTable
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
68 virtual void SAL_CALL
deleteRow(const ORowSetRow
& _rInsertRow
,const connectivity::OSQLTable
& _xTable
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
69 virtual void SAL_CALL
insertRow( const ORowSetRow
& _rInsertRow
,const connectivity::OSQLTable
& _xTable
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
72 virtual bool isResultSetChanged() const SAL_OVERRIDE
;
73 virtual void mergeColumnValues(sal_Int32 i_nColumnIndex
,ORowSetValueVector::Vector
& io_aInsertRow
,ORowSetValueVector::Vector
& io_aRow
,::std::vector
<sal_Int32
>& o_aChangedColumns
) SAL_OVERRIDE
;
74 virtual bool columnValuesUpdated(ORowSetValueVector::Vector
& o_aCachedRow
,const ORowSetValueVector::Vector
& i_aRow
) SAL_OVERRIDE
;
75 virtual bool updateColumnValues(const ORowSetValueVector::Vector
& io_aCachedRow
,ORowSetValueVector::Vector
& io_aRow
,const ::std::vector
<sal_Int32
>& i_aChangedColumns
) SAL_OVERRIDE
;
76 virtual void fillMissingValues(ORowSetValueVector::Vector
& io_aRow
) const SAL_OVERRIDE
;
78 bool isReadOnly() const { return m_aJoinedKeyColumns
.empty(); }
79 const ::std::map
<sal_Int32
,sal_Int32
>& getJoinedColumns() const { return m_aJoinedColumns
; }
80 const ::std::map
<sal_Int32
,sal_Int32
>& getJoinedKeyColumns() const { return m_aJoinedKeyColumns
; }
83 #endif // INCLUDED_DBACCESS_SOURCE_CORE_API_OPTIMISTICSET_HXX
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */