Skip to content

Commit

Permalink
[DQT] Fix dictionary builder and dictionary display issues (aces#8116)
Browse files Browse the repository at this point in the history
- backporting fix for the display of the dictionary in the DQT module aces#7098
- in the data_dictionary_builder script, reference the tesname value in parsed instruments (lorisform parser output format) instead of table while keeping it backwards compatible. This is needed because JSONdata instruments do not define a table variable and since [23.0.3] (https://github.com/aces/Loris/pull/7153/files#diff-962394c093e5275dcfa7cc6eca8927b2f8f592f42b7b95ec5921cb7fc0dc8453R88) the lorisform parser exports the test name in its output for this specific reason.
  • Loading branch information
ridz1208 authored and cmadjar committed Sep 20, 2022
1 parent 8a4734a commit 5be7b07
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions tools/exporters/data_dictionary_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
foreach ($instruments AS $instrument) {
$catId = "";
$table = "";
$testname = "";
$items = explode("\n", trim($instrument));
foreach ($items AS $item) {
$paramId = "";
Expand Down Expand Up @@ -230,13 +231,13 @@
}
}

if (empty($table)) {
if (empty($testname)) {
continue;
}

// INSTRUMENT VALIDITY
print "\tInserting validity for $table\n";
$Name = $table . "_Validity";
print "\tInserting validity for $testname\n";
$Name = $testname . "_Validity";

if (in_array($Name, $parameterNames, true)) {
// this specific table_validity combination was already inserted, skip.
Expand All @@ -248,9 +249,9 @@
$query_params = [
"Name" => $Name,
"Type" => $_type_enum,
"Description" => "Validity of $table",
"Description" => "Validity of $testname",
"SourceField" => "Validity",
"SourceFrom" => $table,
"SourceFrom" => $testname,
"Queryable" => "1",
];

Expand Down Expand Up @@ -280,8 +281,8 @@
);

// INSTRUMENT ADMINISTRATION
print "\tInserting administration for $table\n";
$Name = $table . "_Administration";
print "\tInserting administration for $testname\n";
$Name = $testname . "_Administration";
if (in_array($Name, $parameterNames, true)) {
// this specific table__Administration combination
// was already inserted, skip.
Expand All @@ -292,9 +293,9 @@
$query_params = [
"Name" => $Name,
"Type" => $_type_enum,
"Description" => "Administration for $table",
"Description" => "Administration for $testname",
"SourceField" => "Administration",
"SourceFrom" => $table,
"SourceFrom" => $testname,
"Queryable" => "1",
];

Expand Down Expand Up @@ -352,12 +353,12 @@
* enums
*
* @param string $options The line of the ip_output.txt to enumize
* @param string $table The table containing this line
* @param string $testname The table containing this line
* @param string $name The name of the field being enumized
*
* @return string A valid MySQL format enum field string
*/
function enumizeOptions($options, $table, $name)
function enumizeOptions($options, $testname, $name)
{
$options =explode("{-}", $options);
foreach ($options as $option) {
Expand All @@ -367,7 +368,7 @@ function enumizeOptions($options, $table, $name)
}
}
if (!is_array($enum)) {
echo "$table $name $options\n";
echo "$testname $name $options\n";
}
$enum =implode(",", $enum);
return "enum($enum)";
Expand Down

0 comments on commit 5be7b07

Please # to comment.