mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-20 17:18:51 +02:00
N°454 - Check data validity during CSV import
* "simulate" phase is more permissive on new hierarchical entries * Better check during "apply" phase SVN:trunk[5005]
This commit is contained in:
@@ -1203,9 +1203,10 @@ abstract class DBObject implements iDisplay
|
||||
if (!MetaModel::SkipCheckExtKeys() || $oAtt->IsHierarchicalKey())
|
||||
{
|
||||
// Check allowed values
|
||||
$aValues = $oAtt->GetAllowedValues($this->ToArgsForQuery());
|
||||
$aValues = $oAtt->GetAllowedValues(array('this' => $this));
|
||||
if (!array_key_exists($toCheck, $aValues))
|
||||
{
|
||||
// TODO Better error message
|
||||
return "Value not allowed [$toCheck]";
|
||||
}
|
||||
}
|
||||
@@ -1260,7 +1261,8 @@ abstract class DBObject implements iDisplay
|
||||
if ($res !== true)
|
||||
{
|
||||
// $res contains the error description
|
||||
$this->m_aCheckIssues[] = "Unexpected value for attribute '$sAttCode': $res";
|
||||
$sAttributeName = Dict::S('Class:'.get_class($this).'/Attribute:'.$sAttCode);
|
||||
$this->m_aCheckIssues[] = "Unexpected value for attribute '$sAttributeName': $res";
|
||||
}
|
||||
}
|
||||
if (count($this->m_aCheckIssues) > 0)
|
||||
@@ -1673,7 +1675,8 @@ abstract class DBObject implements iDisplay
|
||||
if (!$bRes)
|
||||
{
|
||||
$sIssues = implode(', ', $aIssues);
|
||||
throw new CoreException("Object not following integrity rules", array('issues' => $sIssues, 'class' => get_class($this), 'id' => $this->GetKey()));
|
||||
$sClassName = Dict::S('Class:'.get_class($this));
|
||||
throw new CoreException("Object not following integrity rules", array('<br>issues' => $sIssues, '<br>class' => $sClassName, '<br>id' => $this->GetKey()));
|
||||
}
|
||||
|
||||
// Stop watches
|
||||
@@ -1938,7 +1941,8 @@ abstract class DBObject implements iDisplay
|
||||
if (!$bRes)
|
||||
{
|
||||
$sIssues = implode(', ', $aIssues);
|
||||
throw new CoreException("Object not following integrity rules", array('issues' => $sIssues, 'class' => get_class($this), 'id' => $this->GetKey()));
|
||||
$sClassName = Dict::S('Class:'.get_class($this));
|
||||
throw new CoreException("Object not following integrity rules", array('<br>issues' => $sIssues, '<br>class' => $sClassName, '<br>id' => $this->GetKey()));
|
||||
}
|
||||
|
||||
// Save the original values (will be reset to the new values when the object get written to the DB)
|
||||
|
||||
Reference in New Issue
Block a user