9 |
*/ |
*/ |
10 |
|
|
11 |
/** |
/** |
12 |
|
* <b>Cvs-Log:</b> |
13 |
|
* |
14 |
|
* <pre> |
15 |
* $Id$ |
* $Id$ |
16 |
* |
* |
17 |
* $Log$ |
* $Log$ |
18 |
|
* Revision 1.11 2003/03/28 06:45:26 joko |
19 |
|
* VERBOSE mode |
20 |
|
* |
21 |
|
* Revision 1.10 2003/03/28 03:01:02 joko |
22 |
|
* more fancy debugging-output |
23 |
|
* |
24 |
|
* Revision 1.9 2003/03/27 16:24:26 jonen |
25 |
|
* + mugled namespace |
26 |
|
* + added enhanced 'queryData' |
27 |
|
* |
28 |
|
* Revision 1.8 2003/03/20 07:22:14 jonen |
29 |
|
* + modified case 'object' to 'objects' |
30 |
|
* (cause its loads all *objects* of a given classname) |
31 |
|
* |
32 |
|
* Revision 1.7 2003/03/11 01:43:00 joko |
33 |
|
* + fixed metadata for phpDocumentor |
34 |
|
* |
35 |
|
* Revision 1.6 2003/03/11 01:22:25 joko |
36 |
|
* + fixed metadata for phpDocumentor |
37 |
|
* |
38 |
* Revision 1.5 2003/03/11 00:12:49 joko |
* Revision 1.5 2003/03/11 00:12:49 joko |
39 |
* + fixed metadata for phpDocumentor |
* + fixed metadata for phpDocumentor |
40 |
* |
* |
73 |
* |
* |
74 |
* Revision 1.1 2003/03/01 03:10:40 joko |
* Revision 1.1 2003/03/01 03:10:40 joko |
75 |
* + initial commit |
* + initial commit |
76 |
* |
* </pre> |
77 |
* |
* |
78 |
*/ |
*/ |
79 |
|
|
152 |
* --- snipped into here from above --- |
* --- snipped into here from above --- |
153 |
* </pre> |
* </pre> |
154 |
* |
* |
155 |
* |
* <p> |
156 |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
157 |
* |
* |
158 |
* Data::Driver::Proxy instantiates "handlers" below itself |
* Data::Driver::Proxy instantiates "handlers" below itself |
173 |
* </pre> |
* </pre> |
174 |
* |
* |
175 |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
176 |
|
* </p> |
177 |
* |
* |
178 |
* |
* |
179 |
|
* <p> |
180 |
* <b>How to use?</b> |
* <b>How to use?</b> |
181 |
* |
* |
182 |
* Pass an array holding "locator metadata" to the constructor. |
* Pass an array holding "locator metadata" to the constructor. |
183 |
* GenericDataSource takes care of the rest. |
* GenericDataSource takes care of the rest. |
184 |
* |
* |
185 |
|
* <pre> |
186 |
* Pass an array to the constructor: (e.g.) |
* Pass an array to the constructor: (e.g.) |
187 |
* |
* |
188 |
* 1. doing rpc-calls.... |
* 1. doing rpc-calls.... |
204 |
* $source = ne w GenericDataSource($locator); |
* $source = ne w GenericDataSource($locator); |
205 |
* $this->set_data_source( &$source ); |
* $this->set_data_source( &$source ); |
206 |
* </code> |
* </code> |
207 |
|
* </pre> |
208 |
|
* </p> |
209 |
|
* |
210 |
* |
* |
211 |
* @link http://www.netfrag.org/~joko/ |
* @link http://www.netfrag.org/~joko/ |
212 |
* @author Andreas Motl <andreas.motl@ilo.de> |
* @author Andreas Motl <andreas.motl@ilo.de> |
225 |
* @name DataSource::Generic |
* @name DataSource::Generic |
226 |
* |
* |
227 |
* @todo this: |
* @todo this: |
|
* |
|
228 |
* o mungle this to be able to be wrapped around phpHtmlLib's own storage-handles |
* o mungle this to be able to be wrapped around phpHtmlLib's own storage-handles |
229 |
* o implement another Data::Driver::Proxy container |
* o implement another Data::Driver::Proxy container |
230 |
* |
* |
472 |
case 'phpHtmlLib': |
case 'phpHtmlLib': |
473 |
//$adapter_arguments = $args[title]; |
//$adapter_arguments = $args[title]; |
474 |
|
|
475 |
$this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataListSource'); |
$this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataSource'); |
476 |
|
|
477 |
// in order to let the Adapter communicate with the Proxy, |
// in order to let the Adapter communicate with the Proxy, |
478 |
// instantiate a wrapper method in a third namespace via |
// instantiate a wrapper method in a third namespace via |
677 |
// FIXME: abstract this some more (e.g. via a CommandMapper|Registry) |
// FIXME: abstract this some more (e.g. via a CommandMapper|Registry) |
678 |
switch ($this->_query[metatype]) { |
switch ($this->_query[metatype]) { |
679 |
case 'data': |
case 'data': |
680 |
//$command = 'queryData'; |
$command = 'queryData'; |
681 |
$command = 'getObjects'; // FIXME!!! |
//$command = 'getObjects'; // FIXME!!! |
682 |
//$this->_locator->set_option('metadata.command', $command); |
//$this->_locator->set_option('metadata.command', $command); |
683 |
|
/* |
684 |
$args = array(); |
$args = array(); |
685 |
switch ($this->_query[vartype]) { |
switch ($this->_query[vartype]) { |
686 |
case 'object': |
case 'objects': |
687 |
if (!$this->_query[classname]) { |
if (!$this->_query[classname]) { |
688 |
$msg = "_query[vartype] == 'object' requires _query[classname]"; |
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
689 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
690 |
} |
} |
691 |
array_push($args, $this->_query[classname]); |
array_push($args, $this->_query[classname]); |
692 |
break; |
break; |
693 |
} |
} |
694 |
break; |
*/ |
695 |
|
$query_args = array(); |
696 |
|
switch ($this->_query[abstract_type]) { |
697 |
|
case 'list': |
698 |
|
if (!$this->_query[classname]) { |
699 |
|
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
700 |
|
user_error("GenericDataSource::query_data() - failed: " . $msg); |
701 |
|
} |
702 |
|
//array_push($query_args, $this->_query[classname]); |
703 |
|
$query_args[classname] = $this->_query[classname]; |
704 |
|
break; |
705 |
|
case 'item': |
706 |
|
if (!$this->_query[classname]) { |
707 |
|
$msg = "_query[vartype] == 'objects' requires _query[classname]"; |
708 |
|
user_error("GenericDataSource::query_data() - failed: " . $msg); |
709 |
|
} |
710 |
|
$query_args[guid] = $this->_query[ident]; |
711 |
|
$query_args[classname] = $this->_query[classname]; |
712 |
|
break; |
713 |
|
} |
714 |
|
$args = array( |
715 |
|
'data_type' => $this->_query[abstract_type], |
716 |
|
'query_args' => $query_args |
717 |
|
); |
718 |
|
break; |
719 |
|
|
720 |
|
// querySchema |
721 |
case 'schema': |
case 'schema': |
722 |
|
//print "Testing schema:" . "<br>"; |
723 |
$command = 'querySchema'; |
$command = 'querySchema'; |
724 |
break; |
break; |
725 |
} |
} |
756 |
|
|
757 |
} |
} |
758 |
|
|
759 |
|
|
760 |
|
|
761 |
function &fetch_result() { |
function &fetch_result() { |
762 |
|
|
763 |
$this->datasource_handler_buildoptions(); |
$this->datasource_handler_buildoptions(); |
764 |
|
|
765 |
$method = $this->_locator->_call[_method]; |
$call = $this->_locator->get_call(); |
766 |
$args = $this->_locator->_call[_arguments]; |
//print Dumper($call); |
767 |
|
|
768 |
// pre-flight checks |
// pre-flight checks |
769 |
if (!$method) { |
if (!$call[method]) { |
770 |
$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."; |
771 |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
user_error("GenericDataSource::query_data() - failed: " . $msg); |
772 |
return; |
return; |
773 |
} |
} |
776 |
|
|
777 |
// do remote call here and get result |
// do remote call here and get result |
778 |
// FIXME: handle synchronous/asynchronous mode here!!! |
// FIXME: handle synchronous/asynchronous mode here!!! |
779 |
$this->datasource_handler_call($method, $args); |
$this->datasource_handler_call($call[method], $call[args]); |
780 |
|
|
781 |
|
|
782 |
// TODO: ... = $this->poll_handler_result and $this->get_handler_result |
// TODO: ... = $this->poll_handler_result and $this->get_handler_result |
787 |
$this->_result_count = sizeof($this->_result); |
$this->_result_count = sizeof($this->_result); |
788 |
|
|
789 |
// trace |
// trace |
790 |
if ($this->_debug[notice]) { |
//if (constants::get('VERBOSE') && $this->_debug[notice]) { |
791 |
|
if (constants::get('VERBOSE')) { |
792 |
//print "_result = " . Dumper($this->_result); |
//print "_result = " . Dumper($this->_result); |
793 |
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>"; |
794 |
|
$this->draw_status_box(); |
795 |
} |
} |
796 |
|
|
797 |
return $this->_result; |
return $this->_result; |
798 |
|
|
799 |
} |
} |
800 |
|
|
801 |
|
function draw_status_box() { |
802 |
|
|
803 |
|
static $boxcount; |
804 |
|
|
805 |
|
$boxcount++; |
806 |
|
|
807 |
|
// box client code (javascript) |
808 |
|
$code_js = " |
809 |
|
<script language=\"javascript\"> |
810 |
|
function toggle_vis(id) { |
811 |
|
elem = eval('document.all.' + id); |
812 |
|
status = elem.style.getAttribute('display'); |
813 |
|
if (status == 'none') { |
814 |
|
elem.style.setAttribute('display', 'block'); |
815 |
|
} else { |
816 |
|
elem.style.setAttribute('display', 'none'); |
817 |
|
} |
818 |
|
} |
819 |
|
</script> |
820 |
|
"; |
821 |
|
//$script = html_script($code_js); |
822 |
|
//print $script->render(); |
823 |
|
print $code_js; |
824 |
|
|
825 |
|
// box style |
826 |
|
$style = container( |
827 |
|
html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'), |
828 |
|
html_style("text/css", '.box_dsg { background: #20ab39; color: white; border: 2px black groove; width:640px; padding:10px; margin:40px; }') |
829 |
|
); |
830 |
|
print $style->render(); |
831 |
|
|
832 |
|
// box content |
833 |
|
$statusbox = html_div('box_dsg'); |
834 |
|
$statusbox->add( html_b("DataSource::Generic"), html_br() ); |
835 |
|
$locatorbox = html_div('box_dsg'); |
836 |
|
$locatorbox->set_id("locatorbox_$boxcount"); |
837 |
|
$locatorbox->add( Dumper($this->_locator) ); |
838 |
|
//$locatorbox->set_style('visibility:false;'); |
839 |
|
$locatorbox->set_style('display:none;'); |
840 |
|
|
841 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), html_a("javascript:toggle_vis('locatorbox_$boxcount');", '[show]'), $locatorbox, html_br() ); |
842 |
|
$call = $this->_locator->get_call(); |
843 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() ); |
844 |
|
if (sizeof($call[args])) { |
845 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Arguments:"), Dumper($call[args]), html_br() ); |
846 |
|
} |
847 |
|
$statusbox->add( html_span('boxlabel_darkgreen', "Count:"), $this->get_result_count(), html_br() ); |
848 |
|
print $statusbox->render(); |
849 |
|
|
850 |
|
} |
851 |
|
|
852 |
|
|
853 |
function &query_data() { |
function &query_data() { |
854 |
//print "query!<br/>"; |
//print "query!<br/>"; |
864 |
function &get_result() { |
function &get_result() { |
865 |
return $this->_result; |
return $this->_result; |
866 |
} |
} |
867 |
|
|
868 |
|
function get_result_count() { |
869 |
|
return $this->_result_count; |
870 |
|
} |
871 |
|
|
872 |
} |
} |
873 |
|
|