diff --git a/test/test.php b/test/test.php index 526325437..2e9458d6c 100644 --- a/test/test.php +++ b/test/test.php @@ -30,7 +30,7 @@ font-size:8pt; line-height:100%; } - 'NetworkDevice', 'output' => 'details', 'separator' => ';', - 'reconciliationkeys' => 'org_id->name,name', + 'reconciliationkeys' => 'org_id,Name', ), - 'csvdata' => 'name;management_ip;importance;org_id->name;type + 'csvdata' => 'name;management_ip;importance;Owner organization->Name;type truc-machin-bidule;172.15.255.150;high;My Company/Department;switch 10.15.255.222;10.15.255.222;high;My Company/Department;switch', ), diff --git a/webservices/import.php b/webservices/import.php index 6fd764b94..924f1176b 100644 --- a/webservices/import.php +++ b/webservices/import.php @@ -344,7 +344,13 @@ try ////////////////////////////////////////////////// // - // Make translated header reference + // Make translated column reference + // + // array of => + // + // Examples: + // 'organization' => 'org_id' + // 'organization->name' => 'org_id->name' // $aFriendlyToInternalAttCode = array(); foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) @@ -487,9 +493,19 @@ try $sReconcKey = trim($sReconcKey); if (empty($sReconcKey)) continue; // skip empty spec + if (array_key_exists(strtolower($sReconcKey), $aFriendlyToInternalAttCode)) + { + // Translate from a translated name to codes + $sReconcKey = $aFriendlyToInternalAttCode[strtolower($sReconcKey)]; + } + + // Check that the reconciliation key is either a given column, or an external key if (!in_array($sReconcKey, $aFieldList)) { - throw new BulkLoadException("Reconciliation keys not found in the input columns '$sReconcKey' (class: '$sClass')"); + if (!array_key_exists($sReconcKey, $aExtKeys)) + { + throw new BulkLoadException("Reconciliation keys not found in the input columns '$sReconcKey' (class: '$sClass')"); + } } if (preg_match('/^(.+)->(.+)$/', trim($sReconcKey), $aMatches))