From 812ec37ab4a6900d77aa6e9b72b8cd8a2a0bb89c Mon Sep 17 00:00:00 2001 From: Laetitia Fesselier Date: Thu, 11 Apr 2024 13:39:15 -0400 Subject: [PATCH 1/2] data_dictionary_builder.php unique constraint fix --- tools/exporters/data_dictionary_builder.php | 23 +++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/exporters/data_dictionary_builder.php b/tools/exporters/data_dictionary_builder.php index 8ffaab279f2..e916529f9aa 100755 --- a/tools/exporters/data_dictionary_builder.php +++ b/tools/exporters/data_dictionary_builder.php @@ -51,11 +51,13 @@ $instrumentParameterTypeCategoryIDs = []; $instrumentParameterTypeIDs = []; - $parameter_types = $DB->pselectColWithIndexKey( - "Select Name, ParameterTypeID from parameter_type", + "SELECT + CONCAT(`Name`, '-', `SourceFrom`) AS paramkey, + ParameterTypeID + FROM parameter_type", [], - "Name" + "paramkey" ); // 2 query to clear all old parameter_type data associated to instruments. @@ -205,11 +207,12 @@ "Queryable" => "1", ]; + $key = "$Name-$testname"; // Check if the same element existed in the parameter_type table // before deleting the data. - if (array_key_exists($Name, $parameter_types)) { + if (array_key_exists($key, $parameter_types)) { //If element existed, reuse the same id - $ParameterTypeID = $parameter_types[$Name]; + $ParameterTypeID = $parameter_types[$key]; $query_params["ParameterTypeID"] = $ParameterTypeID; } else { //If it's new set it to empty string @@ -265,8 +268,9 @@ "Queryable" => "1", ]; - if (array_key_exists($Name, $parameter_types)) { - $ParameterTypeID = $parameter_types[$Name]; + $key = "$Name-$testname"; + if (array_key_exists($key, $parameter_types)) { + $ParameterTypeID = $parameter_types[$key]; $query_params["ParameterTypeID"] = $ParameterTypeID; } else { $ParameterTypeID = ""; @@ -309,8 +313,9 @@ "Queryable" => "1", ]; - if (array_key_exists($Name, $parameter_types)) { - $ParameterTypeID = $parameter_types[$Name]; + $key = "$Name-$testname"; + if (array_key_exists($key, $parameter_types)) { + $ParameterTypeID = $parameter_types[$key]; $query_params["ParameterTypeID"] = $ParameterTypeID; } else { $ParameterTypeID = ""; From 40a51a61b3935f3868781bf383cdb756d408e83c Mon Sep 17 00:00:00 2001 From: Laetitia Fesselier Date: Thu, 18 Apr 2024 21:48:23 -0400 Subject: [PATCH 2/2] Filter the query with parameter_type_category.Type = instrument --- tools/exporters/data_dictionary_builder.php | 26 ++++++++++----------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tools/exporters/data_dictionary_builder.php b/tools/exporters/data_dictionary_builder.php index e916529f9aa..ade314778a0 100755 --- a/tools/exporters/data_dictionary_builder.php +++ b/tools/exporters/data_dictionary_builder.php @@ -52,12 +52,13 @@ $instrumentParameterTypeIDs = []; $parameter_types = $DB->pselectColWithIndexKey( - "SELECT - CONCAT(`Name`, '-', `SourceFrom`) AS paramkey, - ParameterTypeID - FROM parameter_type", + "SELECT pt.Name, pt.ParameterTypeID + FROM parameter_type pt + JOIN parameter_type_category_rel ptcr USING (ParameterTypeID) + JOIN parameter_type_category ptc USING (ParameterTypeCategoryID) + WHERE ptc.Type = 'Instrument'", [], - "paramkey" + "Name" ); // 2 query to clear all old parameter_type data associated to instruments. @@ -207,12 +208,11 @@ "Queryable" => "1", ]; - $key = "$Name-$testname"; // Check if the same element existed in the parameter_type table // before deleting the data. - if (array_key_exists($key, $parameter_types)) { + if (array_key_exists($Name, $parameter_types)) { //If element existed, reuse the same id - $ParameterTypeID = $parameter_types[$key]; + $ParameterTypeID = $parameter_types[$Name]; $query_params["ParameterTypeID"] = $ParameterTypeID; } else { //If it's new set it to empty string @@ -268,9 +268,8 @@ "Queryable" => "1", ]; - $key = "$Name-$testname"; - if (array_key_exists($key, $parameter_types)) { - $ParameterTypeID = $parameter_types[$key]; + if (array_key_exists($Name, $parameter_types)) { + $ParameterTypeID = $parameter_types[$Name]; $query_params["ParameterTypeID"] = $ParameterTypeID; } else { $ParameterTypeID = ""; @@ -313,9 +312,8 @@ "Queryable" => "1", ]; - $key = "$Name-$testname"; - if (array_key_exists($key, $parameter_types)) { - $ParameterTypeID = $parameter_types[$key]; + if (array_key_exists($Name, $parameter_types)) { + $ParameterTypeID = $parameter_types[$Name]; $query_params["ParameterTypeID"] = $ParameterTypeID; } else { $ParameterTypeID = "";