Data Exchange - Fixed issue in DBObjectSet, doubling the count of SynchroAttribute initially created

SVN:trunk[1108]
This commit is contained in:
Romain Quetiez
2011-03-03 08:34:24 +00:00
parent 3d4e76d8b0
commit 8b6672c0dd
2 changed files with 45 additions and 27 deletions

View File

@@ -487,29 +487,32 @@ EOF
// for each field of the target class
// Create all the SynchroAttribute records
$oAttributeSet = $this->Get('attribute_list');
foreach(MetaModel::ListAttributeDefs($this->GetTargetClass()) as $sAttCode=>$oAttDef)
if ($oAttributeSet->Count() == 0)
{
if ($oAttDef->IsScalar() && $oAttDef->IsWritable())
foreach(MetaModel::ListAttributeDefs($this->GetTargetClass()) as $sAttCode=>$oAttDef)
{
$oAttDef = MetaModel::GetAttributeDef($this->GetTargetClass(), $sAttCode);
if ($oAttDef->IsExternalKey())
if ($oAttDef->IsScalar() && $oAttDef->IsWritable())
{
$oAttribute = new SynchroAttExtKey();
$oAttribute->Set('reconciliation_attcode', ''); // Blank means by pkey
$oAttDef = MetaModel::GetAttributeDef($this->GetTargetClass(), $sAttCode);
if ($oAttDef->IsExternalKey())
{
$oAttribute = new SynchroAttExtKey();
$oAttribute->Set('reconciliation_attcode', ''); // Blank means by pkey
}
else
{
$oAttribute = new SynchroAttribute();
}
$oAttribute->Set('sync_source_id', $this->GetKey());
$oAttribute->Set('attcode', $sAttCode);
$oAttribute->Set('reconcile', MetaModel::IsReconcKey($this->GetTargetClass(), $sAttCode) ? 1 : 0);
$oAttribute->Set('update', 1);
$oAttribute->Set('update_policy', 'master_locked');
$oAttributeSet->AddObject($oAttribute);
}
else
{
$oAttribute = new SynchroAttribute();
}
$oAttribute->Set('sync_source_id', $this->GetKey());
$oAttribute->Set('attcode', $sAttCode);
$oAttribute->Set('reconcile', MetaModel::IsReconcKey($this->GetTargetClass(), $sAttCode) ? 1 : 0);
$oAttribute->Set('update', 1);
$oAttribute->Set('update_policy', 'master_locked');
$oAttributeSet->AddObject($oAttribute);
}
$this->Set('attribute_list', $oAttributeSet);
}
$this->Set('attribute_list', $oAttributeSet);
}
}
public function DoCheckToWrite()