Source for file doQuery.php

Documentation is available at doQuery.php

  1. <?php
  2. /**
  3. * Building query for getting specimen data from original provider
  4. * <br/><br/>
  5. * @author Gabriele Droege, DNA Bank Network <contact@dnabank-network.org>
  6. * @version 2.0
  7. * @package Input
  8. * @copyright Copyright © 2011 DNA Bank Network http://www.dnabank-network.org<br>The contents of this file are subject to the Mozilla Public License Version 1.1
  9. * @filesource
  10. * @license http://www.mozilla.org/MPL/ MPL
  11. */
  12.  
  13.  
  14. if($formSubmitVerify and (!isset($_SESSION['guest']) && !$_SESSION['guest'])) 
  15. {
  16.  
  17. $SpecimenNumber = urlencode($_POST['formSpecimenNumber']);
  18.  
  19. if(empty($formProviderIntern) and empty($formProviderExtern))
  20. {
  21. unset($formProviderIntern);
  22. unset($formProviderExtern); 
  23. echo "<a id='Red'>Please select a Specimen Database!</a>";}
  24.  
  25. else {
  26.  
  27. if(!empty($formProviderIntern) and !empty($formProviderExtern))
  28. {
  29. echo '<a id="Red">Please select either an "Internal" or "External" Specimen database!</a>'; }
  30.  
  31. else
  32. {
  33. if(!empty($formProviderIntern))
  34. {
  35. $sql = mysql_query
  36. ("SELECT dataset.ID_Dataset, " .
  37.  "       dataset.ID_Provider, " .
  38.  "       schemata.QueryPart1, " .
  39.  "       schemata.QueryPart1_1, " .
  40.  "       schemata.QueryPart1_2, " .
  41.  "       schemata.QueryPart2, " .
  42.  "       schemata.QueryPart3, " .
  43.  "       schemata.QueryPart4, " . 
  44.  "       dataset.Digir_Resource, " .
  45.  "       dataset.Digir_Source, " .
  46.  "       provider.Provider, " .
  47.  "       provider.ID_Schema " .
  48.  "  FROM dataset " .
  49.  "  LEFT JOIN provider ON dataset.ID_Provider = provider.ID_Provider " .
  50.  "  LEFT JOIN schemata ON provider.ID_Schema = schemata.ID_Schema " .
  51.  "  WHERE dataset.ID_Dataset = '$formProviderIntern'");
  52. }
  53.  
  54. if(!empty($formProviderExtern))
  55. {
  56. $sql = mysql_query
  57. ("SELECT dataset.ID_Dataset, " .
  58.  "       dataset.ID_Provider, " .
  59.  "       schemata.QueryPart1, " .
  60.  "       schemata.QueryPart1_1, " .
  61.  "       schemata.QueryPart1_2, " .
  62.  "       schemata.QueryPart2, " .
  63.  "       schemata.QueryPart2a, " . 
  64.  "       schemata.QueryPart3, " .
  65.  "       schemata.QueryPart4, " .
  66.  "       dataset.Digir_Resource, " .
  67.  "       dataset.Digir_Source, " .
  68.  "       provider.Provider, " . 
  69.  "       provider.ID_Schema " .
  70.  "  FROM dataset " .
  71.  "  LEFT JOIN provider ON dataset.ID_Provider = provider.ID_Provider " . 
  72.  "  LEFT JOIN schemata ON provider.ID_Schema = schemata.ID_Schema " .
  73.  "  WHERE dataset.ID_Dataset = '$formProviderExtern'");
  74. }
  75.  
  76. while($row = mysql_fetch_object($sql)) 
  77.       {
  78.     /********************************************************************************************
  79.     * All parts of the query are recorded in a table                                            *
  80.     * it depends on required provider software and data schema which one to chose               *
  81.     * the connection to a single specimen data provider is defined via new_dataset.php          *
  82.     *********************************************************************************************/
  83.       
  84. $ID_Dataset = $row->ID_Dataset;
  85. $ID_Provider = $row->ID_Provider;
  86. $Provider = $row->Provider; 
  87. $QueryPart1 = $row->QueryPart1;
  88. $QueryPart1_1 = $row->QueryPart1_1;
  89. $QueryPart1_2 = $row->QueryPart1_2;
  90. $QueryPart2 = $row->QueryPart2;
  91. $QueryPart2a = $row->QueryPart2a;
  92. $QueryPart3 = $row->QueryPart3;
  93. $QueryPart4 = $row->QueryPart4;
  94. $Digir_Resource = $row->Digir_Resource;
  95. $Digir_Source = $row->Digir_Source;
  96. $ID_Schema = $row->ID_Schema;
  97.  
  98. }
  99.  
  100. $Digir_Resource1 = urlencode($Digir_Resource);
  101. $Digir_Source1 = urlencode($Digir_Source);
  102.  
  103.  
  104. if($ID_Dataset == '1' and $ID_Provider == '0')
  105. { 
  106.     /**
  107.     * if specimen provider = Specimen Tool and its data are not yet availbae via a wrapper, calling this script
  108.     */
  109.     include ("../sptool/show_cache_data.php"); }
  110.  
  111.     
  112.     /**
  113.     * calling script for building query and transforming received xml data into xslt and html
  114.     */
  115.     include ("verify.php"); 
  116. }
  117. }
  118. }
  119.  
  120.     /**********************************************************************************************
  121.     * sometimes the user received more than one specimen record, than he/she has to select one    *
  122.     * to be sure that during query process the right one is called some further help form elements*
  123.     * are filled with content and are checked here                                                *
  124.     * this parameters are filled during the xslt transformation  (see scripts in folder XSLT)     *
  125.     **********************************************************************************************/
  126.  
  127.  
  128.    $variable1 = $_POST['formUnitID']; 
  129.    $CatalogNoText = $_POST['CatalogNoText']; 
  130.    $variable2 = $_POST['formSourceInstitutionID'];
  131.    $variable3 = $_POST['formSourceID']; 
  132.    $variable4 = $_POST['formProviderExtern'];
  133.    $variable5 = $_POST['formTest'];
  134.    $variable6 = $_POST['formProviderIntern'];
  135.  
  136.    
  137.    if($variable5 != "" and !$formSubmitVerify and !$formSubmitSave)
  138.    {
  139.  
  140. $mykey = key($variable5);   
  141.  
  142. if(!empty($variable4))
  143. {   
  144. $sql = mysql_query
  145. ("SELECT dataset.ID_Dataset AS ID_Dataset, " .
  146.  "       schema.QueryPart1b AS QueryPart1b, " .
  147.  "       schema.QueryPart1_1 AS QueryPart1_1, " .
  148.  "       schema.QueryPart1_2b AS QueryPart1_2b, " .
  149.  "       schema.QueryPart2 AS QueryPart2, " .
  150.  "       schema.QueryPart3 AS QueryPart3, " .
  151.  "       schema.QueryPart4 AS QueryPart4, " . 
  152.  "       schema.QueryPart5 AS QueryPart5, " . 
  153.  "       provider.Provider AS Provider, " .
  154.  "       dataset.Digir_Resource AS Digir_Resource, " .
  155.  "       dataset.Digir_Source AS Digir_Source, " .
  156.  "       provider.Provider AS Provider, " . 
  157.  "       provider.ID_Schema AS ID_Schema " .
  158.  "  FROM dataset " .
  159.  "  LEFT JOIN provider ON dataset.ID_Provider = provider.ID_Provider " . 
  160.  "  LEFT JOIN schemata ON provider.ID_Schema = schemata.ID_Schema " .
  161.  " WHERE dataset.ID_Dataset = '$variable4'");
  162. }
  163.  
  164. if(!empty($variable6))
  165. {  
  166.  
  167. $sql = mysql_query
  168. ("SELECT dataset.ID_Dataset AS ID_Dataset, " .
  169.  "       schemata.QueryPart1b AS QueryPart1b, " .
  170.  "       schemata.QueryPart1_1 AS QueryPart1_1, " .
  171.  "       schemata.QueryPart1_2b AS QueryPart1_2b, " .
  172.  "       schemata.QueryPart2 AS QueryPart2, " .
  173.  "       schemata.QueryPart3 AS QueryPart3, " .
  174.  "       schemata.QueryPart4 AS QueryPart4, " . 
  175.  "       schemata.QueryPart5 AS QueryPart5, " . 
  176.  "       provider.Provider AS Provider, " .
  177.  "       dataset.Digir_Resource AS Digir_Resource, " .
  178.  "       dataset.Digir_Source AS Digir_Source, " .
  179.  "       provider.Provider AS Provider, " . 
  180.  "       provider.ID_Schema AS ID_Schema " .
  181.  "  FROM dataset " .
  182.  "  LEFT JOIN provider ON dataset.ID_Provider = provider.ID_Provider " . 
  183.  "  LEFT JOIN schemata ON provider.ID_Schema = schemata.ID_Schema " .
  184.  " WHERE dataset.ID_Dataset = '$variable6'");
  185. }
  186.  
  187. while($row = mysql_fetch_object($sql)) 
  188.       {
  189. $ID_Dataset = $row->ID_Dataset;      
  190. $Provider = $row->Provider; 
  191. $QueryPart1b = $row->QueryPart1b;
  192. $QueryPart1_1 = $row->QueryPart1_1;
  193. $QueryPart1_2b = $row->QueryPart1_2b;
  194. $QueryPart2 = $row->QueryPart2;
  195. $QueryPart3 = $row->QueryPart3;
  196. $QueryPart4 = $row->QueryPart4;
  197. $QueryPart5 = $row->QueryPart5;
  198. $Digir_Resource = $row->Digir_Resource;
  199. $Digir_Source = $row->Digir_Source;
  200. $ID_Schema = $row->ID_Schema;
  201. }
  202.  
  203. $SourceUnitID = urlencode($variable1[$mykey]);
  204. $SourceInstitutionCode = urlencode($variable2[$mykey]);
  205. $SourceCode = urlencode($variable3[$mykey]);
  206. $Digir_Resource1 = urlencode($Digir_Resource);
  207. $Digir_Source1 = urlencode($Digir_Source);
  208.  
  209. if($ID_Dataset == '1')
  210. {
  211.     /**
  212.     * if specimen provider = Specimen Tool and its data are not yet availbae via a wrapper, calling this script
  213.     */
  214.     include ("../sptool/show_cache_data.php");
  215. }
  216.  
  217. else {
  218.    
  219.     /**
  220.     * calling script for transferring received xml data into html
  221.     */
  222.     include ("verify.php");
  223. }
  224.  
  225.     
  226.  
  227. }
  228.  
  229.  
  230.  
  231. ?>

Documentation generated on Tue, 29 Nov 2011 10:44:49 +0100 by phpDocumentor 1.4.3