From: preecej Date: Mon, 14 Nov 2011 21:23:17 +0000 (+0000) Subject: Added more querystring options X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=b1cb0cb2258a0f43fea42e0eb54f7499013ef64f;p=old-jaiswallab-svn%2F.git Added more querystring options svn path=/; revision=215 --- diff --git a/Personnel/preecej/php_singletons/PO_web_service.php b/Personnel/preecej/php_singletons/PO_web_service.php index 1317b54..d447a9d 100644 --- a/Personnel/preecej/php_singletons/PO_web_service.php +++ b/Personnel/preecej/php_singletons/PO_web_service.php @@ -11,10 +11,10 @@ Optional parameters: Public Request Types: term_search(req str search_value, opt bool inc_synonyms, - opt bool inc_accessions, opt str branch_filter) + opt bool inc_accession_synonyms, opt str branch_filter) term_detail(req str accession_id) -Restricted Request Types (requires user key): +TODO: Restricted Request Types (requires user key): wiki_autocomplete(req str search_value) wiki_term_detail(req str accession_id || req str term_name) */ @@ -31,7 +31,18 @@ $format = isset($_GET['format']) && strtolower($_GET['format']) != 'json' ? strtolower($_GET['format']) : 'json'; //json is the default -$inc_synonyms = isset($_GET['inc_synonyms']) ? 1 : 0; // default +// includes synonyms in term search results +$inc_synonyms = isset($_GET['inc_synonyms']) ? 1 : 0; + +// includes accession ids listed as synonyms, in both term_search and +// term_detail methods +$inc_accession_synonyms = isset($_GET['inc_accession_synonyms']) ? 1 : 0; + +// filters out results not matching the comma-delimited list of branches +// specified here: +$branch_filter = isset($_GET['branch_filter']) && strlen($_GET['branch_filter']) > 0 + ? "'" . strtolower($_GET['branch_filter']) . "'" + : "'plant_anatomy','plant_growth_and_development_stage'"; /* connect to the db */ $link = mysql_connect($_SERVER['dev_po_host'], $_SERVER['dev_po_user'], @@ -52,7 +63,7 @@ switch ($request_type) { . " LEFT JOIN term_definition d ON d.term_id = t.id" . " LEFT JOIN term_synonym s ON s.term_id = t.id" . " WHERE t.name LIKE '%$search_value%'" - . " AND t.term_type in ('plant_anatomy','plant_growth_and_development_stage')" + . " AND t.term_type in (" . $branch_filter . ")" . " AND t.is_obsolete = 0" . " AND UCASE(t.name) NOT LIKE 'OBSOLETE%'" . " AND UCASE(d.term_definition) NOT LIKE 'OBSOLETE%'" @@ -63,8 +74,11 @@ switch ($request_type) { . " FROM term_synonym ts" . " LEFT JOIN term t2 ON ts.term_id = t2.id" . " LEFT JOIN term_definition d2 ON d2.term_id = t2.id" - . " WHERE ts.term_synonym LIKE '%$search_value%'" - . " AND t2.term_type in ('plant_anatomy','plant_growth_and_development_stage')" + . " WHERE ts.term_synonym LIKE '%$search_value%'"; + if (!$inc_accession_synonyms) { + $query .= " AND ts.acc_synonym IS NULL"; + } + $query .= " AND t2.term_type in (" . $branch_filter . ")" . " AND t2.is_obsolete = 0" . " AND UCASE(t2.name) NOT LIKE 'OBSOLETE%'" . " AND UCASE(d2.term_definition) NOT LIKE 'OBSOLETE%')"; @@ -82,7 +96,7 @@ switch ($request_type) { 'match_type'=>$term['match_type'], 'accession_id'=>$term['acc']); if ($term['match_type'] == 'synonym') { - $ary_match['has_parent_term_name'] = $term['parent_name']; + $ary_match['term_name'] = $term['parent_name']; } $term_matches[] = $ary_match; } @@ -110,9 +124,12 @@ switch ($request_type) { . " group_concat(s.term_synonym separator ', ') as synonyms" . " FROM term t" . " LEFT JOIN term_definition d ON d.term_id = t.id" - . " LEFT JOIN term_synonym s ON s.term_id = t.id" - . " WHERE t.acc = '$accession_id'" - . " AND t.term_type in ('plant_anatomy','plant_growth_and_development_stage')" + . " LEFT JOIN term_synonym s ON s.term_id = t.id"; + if (!$inc_accession_synonyms) { + $query .= " AND s.acc_synonym IS NULL"; + } + $query .= " WHERE t.acc = '$accession_id'" + . " AND t.term_type in (" . $branch_filter . ")" . " AND t.is_obsolete = 0" . " AND UCASE(t.name) NOT LIKE 'OBSOLETE%'" . " AND UCASE(d.term_definition) NOT LIKE 'OBSOLETE%'"