| 15 |
* $Id$ |
* $Id$ |
| 16 |
* |
* |
| 17 |
* $Log$ |
* $Log$ |
| 18 |
|
* Revision 1.15 2003/04/06 04:46:33 joko |
| 19 |
|
* renamed linking function |
| 20 |
|
* mozilla fixes |
| 21 |
|
* |
| 22 |
|
* Revision 1.14 2003/04/04 21:19:21 joko |
| 23 |
|
* modified exception handling (enhanced, purged redundant code) |
| 24 |
|
* |
| 25 |
|
* Revision 1.13 2003/04/04 02:37:14 jonen |
| 26 |
|
* _query[action] == write |
| 27 |
|
* |
| 28 |
|
* Revision 1.12 2003/03/29 08:00:48 joko |
| 29 |
|
* modified ErrorBoxing |
| 30 |
|
* |
| 31 |
|
* Revision 1.11 2003/03/28 06:45:26 joko |
| 32 |
|
* VERBOSE mode |
| 33 |
|
* |
| 34 |
|
* Revision 1.10 2003/03/28 03:01:02 joko |
| 35 |
|
* more fancy debugging-output |
| 36 |
|
* |
| 37 |
|
* Revision 1.9 2003/03/27 16:24:26 jonen |
| 38 |
|
* + mugled namespace |
| 39 |
|
* + added enhanced 'queryData' |
| 40 |
|
* |
| 41 |
* Revision 1.8 2003/03/20 07:22:14 jonen |
* Revision 1.8 2003/03/20 07:22:14 jonen |
| 42 |
* + modified case 'object' to 'objects' |
* + modified case 'object' to 'objects' |
| 43 |
* (cause its loads all *objects* of a given classname) |
* (cause its loads all *objects* of a given classname) |
| 485 |
case 'phpHtmlLib': |
case 'phpHtmlLib': |
| 486 |
//$adapter_arguments = $args[title]; |
//$adapter_arguments = $args[title]; |
| 487 |
|
|
| 488 |
$this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataListSource'); |
$this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataSource'); |
| 489 |
|
|
| 490 |
// in order to let the Adapter communicate with the Proxy, |
// in order to let the Adapter communicate with the Proxy, |
| 491 |
// instantiate a wrapper method in a third namespace via |
// instantiate a wrapper method in a third namespace via |
| 690 |
// FIXME: abstract this some more (e.g. via a CommandMapper|Registry) |
// FIXME: abstract this some more (e.g. via a CommandMapper|Registry) |
| 691 |
switch ($this->_query[metatype]) { |
switch ($this->_query[metatype]) { |
| 692 |
case 'data': |
case 'data': |
| 693 |
//$command = 'queryData'; |
$command = 'queryData'; |
| 694 |
$command = 'getObjects'; // FIXME!!! |
|
| 695 |
|
//$command = 'getObjects'; // FIXME!!! |
| 696 |
//$this->_locator->set_option('metadata.command', $command); |
//$this->_locator->set_option('metadata.command', $command); |
| 697 |
|
/* |
| 698 |
$args = array(); |
$args = array(); |
| 699 |
switch ($this->_query[vartype]) { |
switch ($this->_query[vartype]) { |
| 700 |
case 'objects': |
case 'objects': |
| 705 |
array_push($args, $this->_query[classname]); |
array_push($args, $this->_query[classname]); |
| 706 |
break; |
break; |
| 707 |
} |
} |
| 708 |
break; |
*/ |
| 709 |
|
$query_args = array(); |
| 710 |
|
switch ($this->_query[abstract_type]) { |
| 711 |
|
case 'list': |
| 712 |
|
if (!$this->_query[classname]) { |
| 713 |
|
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
| 714 |
|
user_error("GenericDataSource::query_data() - failed: " . $msg); |
| 715 |
|
} |
| 716 |
|
//array_push($query_args, $this->_query[classname]); |
| 717 |
|
$query_args[classname] = $this->_query[classname]; |
| 718 |
|
break; |
| 719 |
|
case 'item': |
| 720 |
|
if (!$this->_query[classname]) { |
| 721 |
|
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
| 722 |
|
user_error("GenericDataSource::query_data() - failed: " . $msg); |
| 723 |
|
} |
| 724 |
|
$query_args[guid] = $this->_query[ident]; |
| 725 |
|
$query_args[classname] = $this->_query[classname]; |
| 726 |
|
break; |
| 727 |
|
} |
| 728 |
|
if($this->_query[action] == 'write') { |
| 729 |
|
$query_args[action] = $this->_query[action]; |
| 730 |
|
$query_args[data] = $this->_query[data]; |
| 731 |
|
} |
| 732 |
|
$args = array( |
| 733 |
|
'data_type' => $this->_query[abstract_type], |
| 734 |
|
'query_args' => $query_args |
| 735 |
|
); |
| 736 |
|
break; |
| 737 |
|
|
| 738 |
|
// querySchema |
| 739 |
case 'schema': |
case 'schema': |
| 740 |
|
//print "Testing schema:" . "<br>"; |
| 741 |
$command = 'querySchema'; |
$command = 'querySchema'; |
| 742 |
|
$args = array( $this->_query[filter] ); |
| 743 |
break; |
break; |
| 744 |
} |
} |
| 745 |
|
|
| 775 |
|
|
| 776 |
} |
} |
| 777 |
|
|
| 778 |
|
|
| 779 |
|
|
| 780 |
function &fetch_result() { |
function &fetch_result() { |
| 781 |
|
|
| 782 |
$this->datasource_handler_buildoptions(); |
$this->datasource_handler_buildoptions(); |
| 783 |
|
|
| 784 |
$method = $this->_locator->_call[_method]; |
$call = $this->_locator->get_call(); |
| 785 |
$args = $this->_locator->_call[_arguments]; |
//print Dumper($call); |
| 786 |
|
|
| 787 |
// pre-flight checks |
// pre-flight checks |
| 788 |
if (!$method) { |
if (!$call[method]) { |
| 789 |
$msg = "Remote command could not be resolved, please pass in or check configuration."; |
$msg = "Remote method is empty, please pass in proper metadata or check configuration."; |
| 790 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
| 791 |
return; |
return; |
| 792 |
} |
} |
| 795 |
|
|
| 796 |
// do remote call here and get result |
// do remote call here and get result |
| 797 |
// FIXME: handle synchronous/asynchronous mode here!!! |
// FIXME: handle synchronous/asynchronous mode here!!! |
| 798 |
$this->datasource_handler_call($method, $args); |
$this->datasource_handler_call($call[method], $call[args]); |
| 799 |
|
|
| 800 |
|
|
| 801 |
// TODO: ... = $this->poll_handler_result and $this->get_handler_result |
// TODO: ... = $this->poll_handler_result and $this->get_handler_result |
| 806 |
$this->_result_count = sizeof($this->_result); |
$this->_result_count = sizeof($this->_result); |
| 807 |
|
|
| 808 |
// trace |
// trace |
| 809 |
if ($this->_debug[notice]) { |
//if (constants::get('VERBOSE') && $this->_debug[notice]) { |
| 810 |
|
if (constants::get('VERBOSE') or constants::get('ERRORS_ONLY')) { |
| 811 |
//print "_result = " . Dumper($this->_result); |
//print "_result = " . Dumper($this->_result); |
| 812 |
print "DataSource::Generic->_result_count = " . $this->_result_count . "<br/>"; |
//print "<div><b><font color=\"darkgreen\">Debug:</font></b> DataSource::Generic->_result_count = <b>" . $this->_result_count . "</b></div>"; |
| 813 |
|
$this->draw_status_box(); |
| 814 |
} |
} |
| 815 |
|
|
| 816 |
return $this->_result; |
return $this->_result; |
| 817 |
|
|
| 818 |
} |
} |
| 819 |
|
|
| 820 |
|
function draw_status_box() { |
| 821 |
|
|
| 822 |
|
static $boxcount; |
| 823 |
|
|
| 824 |
|
$boxcount++; |
| 825 |
|
|
| 826 |
|
$box = container(); |
| 827 |
|
|
| 828 |
|
// box style |
| 829 |
|
$style = container( |
| 830 |
|
html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'), |
| 831 |
|
html_style("text/css", '.box_dsg { background: #20ab39; color: white; border: 2px black groove; width:640px; padding:10px; margin:40px; }') |
| 832 |
|
); |
| 833 |
|
$box->add( $style ); |
| 834 |
|
|
| 835 |
|
// box content |
| 836 |
|
$statusbox = html_div('box_dsg'); |
| 837 |
|
$statusbox->add( html_b("DataSource::Generic"), html_br() ); |
| 838 |
|
$locatorbox = html_div('box_dsg'); |
| 839 |
|
$locatorbox->set_id("locatorbox_$boxcount"); |
| 840 |
|
$locatorbox->add( Dumper($this->_locator) ); |
| 841 |
|
|
| 842 |
|
// FIXME: ie/mozilla? |
| 843 |
|
//$locatorbox->set_style('display:none;'); |
| 844 |
|
//$locatorbox->set_style('visibility:hidden;'); |
| 845 |
|
// already duplicate inside Tracer!!! |
| 846 |
|
$locatorbox->set_style('visibility:hidden; position:absolute; z-index:1; margin-top:30px; padding:5px;'); |
| 847 |
|
|
| 848 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), link::js_function( 'toggleVisibility', array("locatorbox_$boxcount"), '[show]'), $locatorbox, html_br() ); |
| 849 |
|
$call = $this->_locator->get_call(); |
| 850 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() ); |
| 851 |
|
if (sizeof($call[args])) { |
| 852 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Arguments:"), Dumper($call[args]), html_br() ); |
| 853 |
|
} |
| 854 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Count:"), $this->get_result_count(), html_br() ); |
| 855 |
|
$box->add( $statusbox ); |
| 856 |
|
|
| 857 |
|
//print $box->render(); |
| 858 |
|
trace( $box ); |
| 859 |
|
|
| 860 |
|
} |
| 861 |
|
|
| 862 |
|
|
| 863 |
function &query_data() { |
function &query_data() { |
| 864 |
//print "query!<br/>"; |
//print "query!<br/>"; |
| 874 |
function &get_result() { |
function &get_result() { |
| 875 |
return $this->_result; |
return $this->_result; |
| 876 |
} |
} |
| 877 |
|
|
| 878 |
|
function get_result_count() { |
| 879 |
|
return $this->_result_count; |
| 880 |
|
} |
| 881 |
|
|
| 882 |
} |
} |
| 883 |
|
|