From 56e14fc1073e72eeae1f13da3b516b48eb6c5dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Espi=C3=A9?= Date: Wed, 11 Oct 2017 15:31:57 +0000 Subject: [PATCH] =?UTF-8?q?N=C2=B0454=20-=20Check=20data=20validity=20duri?= =?UTF-8?q?ng=20CSV=20import=20*=20"simulate"=20phase=20is=20more=20permis?= =?UTF-8?q?sive=20on=20new=20hierarchical=20entries=20*=20Better=20check?= =?UTF-8?q?=20during=20"apply"=20phase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SVN:trunk[5005] --- core/bulkchange.class.inc.php | 25 ++++++++++++------------- core/dbobject.class.php | 12 ++++++++---- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/core/bulkchange.class.inc.php b/core/bulkchange.class.inc.php index 4c8ec0081..67c21fb6f 100644 --- a/core/bulkchange.class.inc.php +++ b/core/bulkchange.class.inc.php @@ -109,11 +109,11 @@ class CellStatus_Modify extends CellChangeSpec class CellStatus_Issue extends CellStatus_Modify { - protected $m_sReason; + protected $m_sDictEntry; public function __construct($proposedValue, $previousValue, $sReason) { - $this->m_sReason = $sReason; + $this->m_sDictEntry = $sReason; parent::__construct($proposedValue, $previousValue); } @@ -121,9 +121,9 @@ class CellStatus_Issue extends CellStatus_Modify { if (is_null($this->m_proposedValue)) { - return Dict::Format('UI:CSVReport-Value-SetIssue', $this->m_sReason); + return Dict::Format('UI:CSVReport-Value-SetIssue', $this->m_sDictEntry); } - return Dict::Format('UI:CSVReport-Value-ChangeIssue', $this->m_proposedValue, $this->m_sReason); + return Dict::Format('UI:CSVReport-Value-ChangeIssue', $this->m_proposedValue, $this->m_sDictEntry); } } @@ -367,8 +367,8 @@ class BulkChange else { // Check for additional rules - $oReconFilter = $oExtKey->GetAllowedValuesAsFilter(array('this' => $oTargetObj)); - //$oReconFilter = new DBObjectSearch($oExtKey->GetTargetClass()); + //$oReconFilter = $oExtKey->GetAllowedValuesAsFilter(array('this' => $oTargetObj)); + $oReconFilter = new DBObjectSearch($oExtKey->GetTargetClass()); $aCacheKeys = array(); foreach ($aKeyConfig as $sForeignAttCode => $iCol) @@ -414,13 +414,12 @@ class BulkChange $oForeignObj = $oExtObjects->Fetch(); $iForeignKey = $oForeignObj->GetKey(); } - // Cannot cache the entry in this case as the conditions can change... - //$this->m_aExtKeysMappingCache[$sAttCode][$sCacheKey] = array( - // 'c' => $iCount, - // 'k' => $iForeignKey, - // 'oql' => $oReconFilter->ToOql(), - // 'h' => 0, // number of hits on this cache entry - //); + $this->m_aExtKeysMappingCache[$sAttCode][$sCacheKey] = array( + 'c' => $iCount, + 'k' => $iForeignKey, + 'oql' => $oReconFilter->ToOql(), + 'h' => 0, // number of hits on this cache entry + ); } switch($iCount) { diff --git a/core/dbobject.class.php b/core/dbobject.class.php index c1c060ead..9e5a554d8 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -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('
issues' => $sIssues, '
class' => $sClassName, '
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('
issues' => $sIssues, '
class' => $sClassName, '
id' => $this->GetKey())); } // Save the original values (will be reset to the new values when the object get written to the DB)