Result structure and documentation changes in searchMetadata/localSearch

methods. (http://bugs.campware.org/view.php?id=481)
File doc/search.html removed - content moved to inline docs.
XR_LocStor class moved to separate file.
This commit is contained in:
tomas 2005-01-07 02:46:52 +00:00
parent 3d6cb307de
commit 8001ffdce4
11 changed files with 1415 additions and 1355 deletions

View File

@ -22,7 +22,7 @@
# #
# #
# Author : $Author: tomas $ # Author : $Author: tomas $
# Version : $Revision: 1.1 $ # Version : $Revision: 1.2 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/bin/setupDirs.sh,v $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/bin/setupDirs.sh,v $
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------

View File

@ -1,16 +0,0 @@
- required packages: apache, php, mod_php, postgreSQL, wget, curl, PEAR_DB
- check if PEAR DB installed: 'pear list' or install it: 'pear install DB'
- check if include_path in php.ini points to PEAR too
(/usr/lib/php or /usr/local/lib/php)
- setup var/conf.php - at least "basic configuration" part
(follow comments in the source - or use doxygen and its output)
- setup archiveServer/var/conf.php too - test scripts will use archive
- create symlink with name corresponding to "URL configuration" part
of var/conf.php file - example for default values:
http://localhost:80/livesupportStorageServer/ should point to
<livesupport-cvs>/modules/storageServer/var directory
- configure apache for archiveServer file upload
(as described in archiveServer/doc/INSTALL)
- run 'make check' to: setup directories, create db tables and run test scripts
OR 'make all' without tests

View File

@ -14,7 +14,7 @@ Development Loan Fund</a>, under the GNU <a
href="http://www.gnu.org/licenses/gpl.html">GPL</a>.<br> href="http://www.gnu.org/licenses/gpl.html">GPL</a>.<br>
<ul> <ul>
<li>Author: $Author: tomas $</li> <li>Author: $Author: tomas $</li>
<li>Version: $Revision: 1.1 $</li> <li>Version: $Revision: 1.2 $</li>
<li>Location: $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/doc/index.html,v $</li> <li>Location: $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/doc/index.html,v $</li>
</ul> </ul>
<h1>Scope</h1> <h1>Scope</h1>
@ -25,8 +25,7 @@ The links below provide useful documentation for the storageServer
developer or user.<br> developer or user.<br>
<h1>Static documentation.</h1> <h1>Static documentation.</h1>
<ul> <ul>
<li> <a href="search.html">search query format description</a><br> <!-- <li> <a href=".html"></a></li>-->
</li>
</ul> </ul>
<h1>Generated documentation</h1> <h1>Generated documentation</h1>
<ul> <ul>

View File

@ -1,67 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<title>storageServer search query format description</title>
<meta content="$Author: tomas $" name="author">
</head>
<body>
<h1>Preface</h1>
This document is part of the
<a href="http://livesupport.campware.org/">LiveSupport</a>
project, Copyright © 2004 <a href="http://www.mdlf.org/">Media
Development Loan Fund</a>, under the GNU <a
href="http://www.gnu.org/licenses/gpl.html">GPL</a>.<br>
<ul>
<li>Author: $Author: tomas $</li>
<li>Version: $Revision: 1.1 $</li>
<li>Location: $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/doc/Attic/search.html,v $</li>
</ul>
<h1>Scope</h1>
This document describes search query format for searching in storageServer
metadata database.<br>
<h1>Introduction</h1>
How to call search methods:
<ul>
<li>PHP: <code>$locStor-&gt;searchMetadata($sessid, $criteria)</code></li>
<li>XMLRPC: <code>locstor.searchMetadata</code>
(with struct parameter containing <code>sessid</code> string and
<code>criteria</code> struct)
</li>
</ul>
<h2>Criteria format (php/xmlrpc)</h2>
Type: hash/struct with following fields:<br>
<ul>
<li>filetype - string, type of searched files,
meaningful values: 'audioclip', 'playlist', 'all'</li>
<li>operator - string, type of conditions join
(any condition matches / all conditions match),
meaningful values: 'and', 'or', ''
(may be empty or ommited only with less then 2 items in
&quot;conditions&quot; field)
</li>
<li>conditions - array of hashes/structs with structure:
<ul>
<li>cat - string, metadata category name</li>
<li>op - string, operator - meaningful values:
'full', 'partial', 'prefix', '=', '&lt;', '&lt;=', '&gt;', '&gt;='</li>
<li>val - string, search value</li>
</ul>
</li>
</ul>
<h2>Return value</h2>
Hash/struct with fields:<br>
<ul>
<li>results - array, array with gunid strings of files have been found</li>
</ul>
<!--
<h2></h2>
<ul>
</ul>
-->
<br>
</body>
</html>

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $ Author : $Author: tomas $
Version : $Revision: 1.11 $ Version : $Revision: 1.12 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/BasicStor.php,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -40,7 +40,7 @@ define('GBERR_NOTIMPL', 50);
require_once "../../../alib/var/alib.php"; require_once "../../../alib/var/alib.php";
require_once "StoredFile.php"; require_once "StoredFile.php";
require_once "Transport.php"; #require_once "Transport.php";
/** /**
* BasicStor class * BasicStor class
@ -48,7 +48,7 @@ require_once "Transport.php";
* Core of LiveSupport file storage module * Core of LiveSupport file storage module
* *
* @author $Author: tomas $ * @author $Author: tomas $
* @version $Revision: 1.11 $ * @version $Revision: 1.12 $
* @see Alib * @see Alib
*/ */
class BasicStor extends Alib{ class BasicStor extends Alib{
@ -489,8 +489,27 @@ class BasicStor extends Alib{
/** /**
* Search in local metadata database. * Search in local metadata database.
* *
* @param criteria hash, search criteria - see * @param criteria hash, with following structure:<br>
* <a href="../../search.html">format description</a> * <ul>
* <li>filetype - string, type of searched files,
* meaningful values: 'audioclip', 'playlist'</li>
* <li>operator - string, type of conditions join
* (any condition matches / all conditions match),
* meaningful values: 'and', 'or', ''
* (may be empty or ommited only with less then 2 items in
* &quot;conditions&quot; field)
* </li>
* <li>conditions - array of hashes with structure:
* <ul>
* <li>cat - string, metadata category name</li>
* <li>op - string, operator - meaningful values:
* 'full', 'partial', 'prefix', '=', '&lt;',
* '&lt;=', '&gt;', '&gt;='</li>
* <li>val - string, search value</li>
* </ul>
* </li>
* </ul>
*
* @return hash, field 'results' is an array with gunid strings * @return hash, field 'results' is an array with gunid strings
* of files have been found * of files have been found
*/ */
@ -500,6 +519,7 @@ class BasicStor extends Alib{
$ops = array('full'=>"='%s'", 'partial'=>"like '%%%s%%'", 'prefix'=>"like '%s%%'", $ops = array('full'=>"='%s'", 'partial'=>"like '%%%s%%'", 'prefix'=>"like '%s%%'",
'<'=>"< '%s'", '='=>"= '%s'", '>'=>"> '%s'", '<='=>"<= '%s'", '>='=>">= '%s'" '<'=>"< '%s'", '='=>"= '%s'", '>'=>"> '%s'", '<='=>"<= '%s'", '>='=>">= '%s'"
); );
$filetype = strtolower($criteria['filetype']);
$operator = strtolower($criteria['operator']); $operator = strtolower($criteria['operator']);
$conds = $criteria['conditions']; $conds = $criteria['conditions'];
$whereArr = array(); $whereArr = array();
@ -516,9 +536,12 @@ class BasicStor extends Alib{
"; ";
$whereArr[] = "$sqlCond"; $whereArr[] = "$sqlCond";
} }
$selPart = "SELECT DISTINCT to_hex(f.gunid)as gunid, f.ftype as filetype";
$ftypeCond = " AND f.ftype='$filetype'";
if($operator == 'and'){ if($operator == 'and'){
// operator: and // operator: and
$from = array(); $joinArr = array(); $from = array("{$this->filesTable} f");
$joinArr = array("f.gunid = md0.gunid".$ftypeCond);
foreach($whereArr as $i=>$v){ foreach($whereArr as $i=>$v){
$from[] = "{$this->mdataTable} md$i"; $from[] = "{$this->mdataTable} md$i";
$whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i"); $whereArr[$i] = sprintf($v, "md$i", "md$i", "md$i");
@ -527,7 +550,7 @@ class BasicStor extends Alib{
// there are n-1 join condtions for join n tables - remove last: // there are n-1 join condtions for join n tables - remove last:
array_pop($joinArr); array_pop($joinArr);
// query construcion: // query construcion:
$sql = "SELECT to_hex(md0.gunid)as gunid \nFROM ".join(", ", $from). $sql = "$selPart\nFROM ".join(", ", $from).
"\nWHERE ".join(' AND ', $whereArr); "\nWHERE ".join(' AND ', $whereArr);
// add join conditions if there are any: // add join conditions if there are any:
if(count($joinArr)>0){ $sql .= " AND ".join(" AND ", $joinArr); } if(count($joinArr)>0){ $sql .= " AND ".join(" AND ", $joinArr); }
@ -537,8 +560,9 @@ class BasicStor extends Alib{
$whereArr[$i] = sprintf($v, "md", "md", "md"); $whereArr[$i] = sprintf($v, "md", "md", "md");
} }
// query construcion: // query construcion:
$sql = "\nSELECT to_hex(gunid)as gunid \n". $sql = "\n$selPart\nFROM {$this->mdataTable} md\n".
"FROM {$this->mdataTable} md \nWHERE ".join(' OR ', $whereArr); "INNER JOIN {$this->filesTable} f ON md.gunid=f.gunid $ftypeCond\n".
"WHERE ".join(' OR ', $whereArr);
} }
$res = $this->dbc->getCol($sql); $res = $this->dbc->getCol($sql);
if(!is_array($res)) $res = array(); if(!is_array($res)) $res = array();

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $ Author : $Author: tomas $
Version : $Revision: 1.17 $ Version : $Revision: 1.18 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -35,7 +35,7 @@ require_once "BasicStor.php";
* LiveSupport file storage module * LiveSupport file storage module
* *
* @author $Author: tomas $ * @author $Author: tomas $
* @version $Revision: 1.17 $ * @version $Revision: 1.18 $
* @see BasicStor * @see BasicStor
*/ */
class GreenBox extends BasicStor{ class GreenBox extends BasicStor{
@ -260,11 +260,30 @@ class GreenBox extends BasicStor{
/** /**
* Search in local metadata database. * Search in local metadata database.
* *
* @param criteria hash, search criteria - see * @param criteria hash, with following structure:<br>
* <a href="../../search.html">format description</a> * <ul>
* <li>filetype - string, type of searched files,
* meaningful values: 'audioclip', 'playlist'</li>
* <li>operator - string, type of conditions join
* (any condition matches / all conditions match),
* meaningful values: 'and', 'or', ''
* (may be empty or ommited only with less then 2 items in
* &quot;conditions&quot; field)
* </li>
* <li>conditions - array of hashes with structure:
* <ul>
* <li>cat - string, metadata category name</li>
* <li>op - string, operator - meaningful values:
* 'full', 'partial', 'prefix', '=', '&lt;',
* '&lt;=', '&gt;', '&gt;='</li>
* <li>val - string, search value</li>
* </ul>
* </li>
* </ul>
* @param sessid string, session id * @param sessid string, session id
* @return hash, field 'results' is an array with gunid strings * @return hash, field 'results' is an array with gunid strings
* of files have been found * of files have been found
* @see BasicStor::bsLocalSearch
*/ */
function localSearch($criteria, $sessid='') function localSearch($criteria, $sessid='')
{ {

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $ Author : $Author: tomas $
Version : $Revision: 1.16 $ Version : $Revision: 1.17 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/LocStor.php,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/LocStor.php,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -242,13 +242,58 @@ class LocStor extends GreenBox{
* Search in metadata database * Search in metadata database
* *
* @param sessid string * @param sessid string
* @param criteria string * @param criteria hash, with following structure:<br>
* @return array or PEAR::error * <ul>
* <li>filetype - string, type of searched files,
* meaningful values: 'audioclip', 'playlist', 'all'</li>
* <li>operator - string, type of conditions join
* (any condition matches / all conditions match),
* meaningful values: 'and', 'or', ''
* (may be empty or ommited only with less then 2 items in
* &quot;conditions&quot; field)
* </li>
* <li>conditions - array of hashes with structure:
* <ul>
* <li>cat - string, metadata category name</li>
* <li>op - string, operator - meaningful values:
* 'full', 'partial', 'prefix', '=', '&lt;',
* '&lt;=', '&gt;', '&gt;='</li>
* <li>val - string, search value</li>
* </ul>
* </li>
* </ul>
* @return hash, with fields:
* <ul>
* <li>audioClipResults : array with gunid strings
* of audioClips have been found</li>
* <li>playlistResults : array with gunid strings
* of playlists have been found</li>
* </ul>
* @see GreenBox::localSearch * @see GreenBox::localSearch
*/ */
function searchMetadata($sessid, $criteria) function searchMetadata($sessid, $criteria)
{ {
$res = $this->localSearch($criteria, $sessid); $filetype = strtolower($criteria['filetype']);
if($filetype=='all'){
$criteriaAC = $criteria; $criteriaAC['filetype'] = 'audioclip';
$criteriaPL = $criteria; $criteriaPL['filetype'] = 'playlist';
$resAC = $this->localSearch($criteriaAC);
$resPL = $this->localSearch($criteriaPL);
return array(
'audioClipResults' => $resAC['results'],
'playlistResults' => $resPL['results']
);
}
$srchRes = $this->localSearch($criteria, $sessid);
$res = array('audioClipResults'=>NULL, 'playlistResults'=>NULL);
switch($filetype){
case"audioclip":
$res['audioClipResults'] = $srchRes['results'];
break;
case"playlist":
$res['playlistResults'] = $srchRes['results'];
break;
}
return $res; return $res;
} }

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $ Author : $Author: tomas $
Version : $Revision: 1.4 $ Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/put.php,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/put.php,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -62,7 +62,7 @@ require_once '../LocStor.php';
PEAR::setErrorHandling(PEAR_ERROR_RETURN); PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$dbc = DB::connect($config['dsn'], TRUE); $dbc = DB::connect($config['dsn'], TRUE);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb = &new GreenBox(&$dbc, $config); $gb = &new LocStor(&$dbc, $config);
function http_error($code, $err){ function http_error($code, $err){
header("HTTP/1.1 $code"); header("HTTP/1.1 $code");

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@
# #
# #
# Author : $Author: tomas $ # Author : $Author: tomas $
# Version : $Revision: 1.10 $ # Version : $Revision: 1.11 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/Attic/xr_cli_test.py,v $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/Attic/xr_cli_test.py,v $
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -34,7 +34,7 @@ import sys
if len(sys.argv)<3: if len(sys.argv)<3:
print """ print """
Usage: xr_cli_pok.py [-v] [-s http://<server>/<path>/xmlrpc/xrGreenBox.php] <command> <args> Usage: xr_cli_pok.py [-v] [-s http://<server>/<path>/xmlrpc/xrLocStor.php] <command> <args>
commands and args: commands and args:
listMethods listMethods
methodHelp <method> methodHelp <method>