21#include <com/sun/star/sdbc/KeyRule.hpp>
22#include <com/sun/star/sdbcx/KeyType.hpp>
23#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
24#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
25#include <com/sun/star/sdbcx/XAppend.hpp>
26#include <com/sun/star/sdbcx/XDrop.hpp>
27#include <com/sun/star/container/XIndexAccess.hpp>
30#include <core_resource.hxx>
33#include <osl/diagnose.h>
43ORelationTableConnectionData::ORelationTableConnectionData()
44 :m_nUpdateRules(KeyRule::NO_ACTION)
45 ,m_nDeleteRules(KeyRule::NO_ACTION)
51 const TTableWindowData::value_type& _pReferencedTable,
52 const OUString& rConnName )
54 ,m_nUpdateRules(KeyRule::NO_ACTION)
55 ,m_nDeleteRules(KeyRule::NO_ACTION)
76 ::osl::MutexGuard aGuard(
m_aMutex );
82 const sal_Int32
nCount = xKeys->getCount();
86 OSL_ENSURE(xKey.is(),
"Key is not valid!");
94 OSL_ENSURE(xDrop.is(),
"can't drop key because we haven't a drop interface!");
96 xDrop->dropByIndex(
i);
106 OUString sTempString;
109 sTempString = elem->GetSourceFieldName();
110 elem->SetSourceFieldName( elem->GetDestFieldName() );
111 elem->SetDestFieldName( sTempString );
120 ::osl::MutexGuard aGuard(
m_aMutex );
142 sal_uInt16 nPrimKeysCount = 0,
143 nValidLinesCount = 0;
145 if ( xKeyColumns.is() )
148 const OUString* pKeyIter = aKeyColumns.getConstArray();
149 const OUString* pKeyEnd = pKeyIter + aKeyColumns.getLength();
151 for(;pKeyIter != pKeyEnd;++pKeyIter)
156 if ( elem->GetFieldName(_eEConnectionSide) == *pKeyIter )
163 if ( nPrimKeysCount != aKeyColumns.getLength() )
166 return nPrimKeysCount && nPrimKeysCount == nValidLinesCount;
171 ::osl::MutexGuard aGuard(
m_aMutex );
186 if (&rConnData ==
this)
229 ::osl::MutexGuard aGuard(
m_aMutex );
244 OSL_ENSURE(xKeyFactory.is(),
"No XDataDescriptorFactory Interface!");
246 OSL_ENSURE(xAppend.is(),
"No XAppend Interface!");
249 OSL_ENSURE(xKey.is(),
"Key is null!");
250 if ( xKey.is() && xTableProp.is() )
253 OUString sSourceName;
270 if ( xColumnFactory.is() )
274 if(!(elem->GetSourceFieldName().isEmpty() || elem->GetDestFieldName().isEmpty()))
281 xColumnAppend->appendByDescriptor(
xColumn);
286 if ( xColumns->hasElements() )
287 xAppend->appendByDescriptor(xKey);
295 bool bDropRelation =
false;
296 for(sal_Int32
i=0;
i<xKeys->getCount();++
i)
298 xKeys->getByIndex(
i) >>= xKey;
299 OSL_ENSURE(xKey.is(),
"Key is not valid!");
302 OUString sReferencedTable;
306 xColSup.set(xKey,UNO_QUERY_THROW);
311 const OUString* pIter = aNames.getConstArray();
312 const OUString* pEnd = pIter + aNames.getLength();
315 OUString
sName,sRelatedColumn;
316 for ( ; pIter != pEnd ; ++pIter )
318 xColumn.set(xColumns->getByName(*pIter),UNO_QUERY_THROW);
322 bool bFoundElem =
false;
325 if( elem->GetSourceFieldName() ==
sName
326 && elem->GetDestFieldName() == sRelatedColumn )
339 bDropRelation = !aNames.hasElements();
355 OUString sError(
DBA_RES(STR_QUERY_REL_COULD_NOT_CREATE));
356 ::dbtools::throwGenericSQLException(sError,
nullptr);
365 const OUString* pIter = aNames.getConstArray();
366 const OUString* pEnd = pIter + aNames.getLength();
370 OUString
sName,sRelatedColumn;
372 for(;pIter != pEnd;++pIter)
374 xColumns->getByName(*pIter) >>=
xColumn;
382 pNewData->SetSourceFieldName(
sName);
383 pNewData->SetDestFieldName(sRelatedColumn);
the class OConnectionLineData contains the data of a connection e.g.
ORelationTableConnectionData & operator=(const ORelationTableConnectionData &rConnData)
sal_Int32 GetUpdateRules() const
sal_Int32 GetDeleteRules() const
void IsConnectionPossible()
virtual ~ORelationTableConnectionData() override
Cardinality m_nCardinality
bool IsSourcePrimKey() const
virtual bool Update() override
Update create a new relation.
bool IsDestPrimKey() const
Cardinality GetCardinality() const
bool checkPrimaryKey(const css::uno::Reference< css::beans::XPropertySet > &i_xTable, EConnectionSide _eEConnectionSide) const
ORelationTableConnectionData()
virtual void CopyFrom(const OTableConnectionData &rSource) override
initialise from a source (more comfortable than a virtual assignment operator)
Contains all connection data which exists between two windows.
const TTableWindowData::value_type & getReferencingTable() const
TTableWindowData::value_type m_pReferencedTable
TTableWindowData::value_type m_pReferencingTable
const TTableWindowData::value_type & getReferencedTable() const
OConnectionLineDataVec m_vConnLineData
OTableConnectionData & operator=(const OTableConnectionData &rConnData)
std::vector< OConnectionLineDataRef > OConnectionLineDataVec
static bool operator==(const OIndexField &_rLHS, const OIndexField &_rRHS)
constexpr OUStringLiteral PROPERTY_UPDATERULE(u"UpdateRule")
constexpr OUStringLiteral PROPERTY_DELETERULE(u"DeleteRule")
constexpr OUStringLiteral PROPERTY_RELATEDCOLUMN(u"RelatedColumn")
constexpr OUStringLiteral PROPERTY_TYPE(u"Type")
constexpr OUStringLiteral PROPERTY_REFERENCEDTABLE(u"ReferencedTable")
constexpr OUStringLiteral PROPERTY_NAME(u"Name")