/[cvs]/nfo/php/libs/org.netfrag.glib/DataSource/Generic.php
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.glib/DataSource/Generic.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations)
Tue Mar 11 01:43:00 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.6: +11 -3 lines
+ fixed metadata for phpDocumentor

1 joko 1.1 <?php
2     /**
3     * This file contains the GenericDataSource child class
4     *
5     * @author Andreas Motl <andreas.motl@ilo.de>
6 joko 1.2 * @package org.netfrag.glib
7     * @name DataSource::Generic
8 joko 1.1 *
9     */
10    
11     /**
12 joko 1.6 * <b>Cvs-Log:</b>
13     *
14     * <pre>
15 joko 1.7 * $Id: Generic.php,v 1.6 2003/03/11 01:22:25 joko Exp $
16 joko 1.2 *
17     * $Log: Generic.php,v $
18 joko 1.7 * Revision 1.6 2003/03/11 01:22:25 joko
19     * + fixed metadata for phpDocumentor
20     *
21 joko 1.6 * Revision 1.5 2003/03/11 00:12:49 joko
22     * + fixed metadata for phpDocumentor
23     *
24 joko 1.5 * Revision 1.4 2003/03/10 23:25:03 joko
25     * + fixed metadata for phpDocumentor
26     *
27 joko 1.4 * Revision 1.3 2003/03/09 15:50:36 joko
28     * + additional metadata for Autodia
29     *
30 joko 1.3 * Revision 1.2 2003/03/05 17:28:43 joko
31     * updated docu (phpDocumentor testing....)
32     *
33 joko 1.2 * Revision 1.1 2003/03/05 12:04:00 joko
34     * + initial commit, from GenericDataSource
35 joko 1.1 *
36     * Revision 1.3 2003/03/03 21:24:18 joko
37     * now based on DesignPattern::RemoteProxy
38     *
39     * Revision 1.2 2003/03/02 01:05:13 joko
40     * - purged old code
41     *
42     * Revision 1.1 2003/03/01 21:47:15 joko
43     * renamed from AbstractDataSource.inc
44     *
45     * Revision 1.1 2003/03/01 20:17:15 joko
46     * renamed from GenericDataSource.inc
47     * replaced '_proxy' through '_handler' to better associate the ability to act as a generic dispatcher handler
48     *
49     * Revision 1.3 2003/03/01 15:36:11 joko
50     * + debugging
51     * + renamed some methods regarding new proposal (build_handler_options, fetch_result, etc.)
52     *
53     * Revision 1.2 2003/03/01 04:50:27 joko
54     * encapsulated all output into tracing mode
55     * disabled tracing
56     *
57     * Revision 1.1 2003/03/01 03:10:40 joko
58     * + initial commit
59 joko 1.6 * </pre>
60 joko 1.1 *
61     */
62    
63     /**
64     * This requires the MemoryDataSource base class
65     *
66     */
67    
68     // V1: compile-time-include, stable since years ;-)
69     //include_once($phphtmllib."/widgets/data_source/MemoryDataSource.inc");
70    
71     // V2: runtime-load proposal, more flexible
72     // loadModule('MemoryDataSource', 'inc'); // doesn't work (would do if basepath of module is in libpath)
73     // loadModule($phphtmllib . '::widgets::data_source::MemoryDataSource', 'inc'); // works (by accident)
74     // loadModule($phphtmllib . "/widgets/data_source/MemoryDataSource", "inc"); // works (should be stable)
75     // loadModule($phphtmllib . "/widgets/data_source/MemoryDataSource.inc", null); // works (should be stable)
76    
77    
78    
79     /**
80     * Have to have PEAR and DB included
81     * the pear dir must be in the
82     * include path.
83     */
84     // require_once("PEAR.php"); // FIXME: what about PEAR::XML::RPC?
85     // require_once("DB.php");
86    
87 joko 1.2
88     loadModule('DesignPattern::Proxy');
89     loadModule('DesignPattern::TransparentProxy');
90     loadModule('DesignPattern::RemoteProxy');
91    
92     //class GenericDataSource extends MemoryDataSource {
93     //class GenericDataSource extends DesignPattern_Proxy {
94     //class GenericDataSource extends DesignPattern_RemoteProxy {
95     //class GenericDataSource extends DesignPattern_TransparentProxy {
96    
97     //class GenericDataSource extends MemoryDataSource {
98     //loadModule("DataSource::Proxy::Memory");
99     //class GenericDataSource extends DataSource_Proxy_Memory {
100     //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {
101     //class DataSource_GenericDataSource extends DesignPattern_Proxy {
102     //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {
103    
104     // now independent!!! new class-inheritance-tree possible now!
105     // solved by having an Adapter *and* a Proxy here!
106     //class GenericDataSource {
107    
108     loadModule('DesignPattern::AdapterProxy');
109    
110    
111    
112 joko 1.1 /**
113     * This GenericDataSource child class is *completely* independent
114     * of a specific storage implementation and intended to be a wrapper
115 joko 1.2 * class on the way from phpHtmlLib to Xyz. <br>
116 joko 1.1 * ("Yyz" gets represented by Data::Storage by now.....)
117     *
118     * GenericDataSource interacts with an intermediate "proxy" object
119 joko 1.2 * (e.g. Data::Driver::Proxy) when doing queries. <br>
120     * <pre>
121 joko 1.1 * Don't mix this up with a persistent database handle which gets
122     * reused each and every time for different queries.
123     * Here *is* a new instance of Data::Driver::Proxy for *each* query.
124 joko 1.2 * </pre>
125 joko 1.1 *
126     * But the point is: Caching! The actual *data* isn't read redundant!
127     *
128 joko 1.2 * <pre>
129     * --- snipped into here from above ---
130     * that may use arbitrary code modules as database handlers.
131     * It's aims are to get together:
132     * o phpHtmlLibs "source-handlers"
133     * o PEAR's database handlers
134     * o custom ones (e.g. Data::Driver::Proxy object, which talks to a remote rpc server)
135     * --- snipped into here from above ---
136     * </pre>
137     *
138 joko 1.7 * <p>
139 joko 1.1 * !!!!!! refactor this to Data::Driver::Proxy !!!!!! <-----------------
140     *
141     * Data::Driver::Proxy instantiates "handlers" below itself
142     * which act as encapsulated workers to actually do the stuff to do.
143     * It can cache data for "disconnected mode" using the
144     * php PEAR DB abstraction objects.
145     * One worker already implemented is Data::Driver::RPC::Remote, which
146     * talks to a RPC::XML server (todo: talk SOAP!) using PEAR::XML::RPC.
147     *
148 joko 1.2 * <pre>
149 joko 1.1 * --- refactored here, but: redundant somehow ---
150     * Data::Driver::Proxy uses a PEAR XML::RPC object to actually
151     * talk HTTP and serialize data chunks to and from XML,
152     * but adds some caching to this "process of fetching data from a remote side".
153     * It "proxies" arbitrary data chunks a) inside a native php4 session,
154     * b) by talking to a rdbms (single proxy-table) or c) [TODO] using PEAR::Cache.
155     * --- refactored here, but: redundant somehow ---
156 joko 1.2 * </pre>
157 joko 1.1 *
158     * !!!!!! refactor this to Data::Driver::Proxy !!!!!! <-----------------
159 joko 1.7 * </p>
160 joko 1.1 *
161     *
162 joko 1.7 * <p>
163 joko 1.2 * <b>How to use?</b>
164 joko 1.1 *
165     * Pass an array holding "locator metadata" to the constructor.
166     * GenericDataSource takes care of the rest.
167     *
168 joko 1.7 * <pre>
169 joko 1.1 * Pass an array to the constructor: (e.g.)
170     *
171     * 1. doing rpc-calls....
172 joko 1.2 * <code>
173 joko 1.1 * $locator = array(
174     * type => 'rpc',
175     * metadata => array( Host => 'localhost', Port => '8765' ),
176     * );
177 joko 1.3 * $source = ne w GenericDataSource($locator);
178 joko 1.1 * $this->set_data_source( &$source );
179 joko 1.2 * </code>
180 joko 1.1 *
181     * 2. [proposal] common datahandles....
182 joko 1.2 * <code>
183 joko 1.1 * $locator = array(
184     * type => 'mysql',
185     * dsn => 'known dsn markup',
186     * );
187 joko 1.3 * $source = ne w GenericDataSource($locator);
188 joko 1.1 * $this->set_data_source( &$source );
189 joko 1.2 * </code>
190 joko 1.7 * </pre>
191     * </p>
192     *
193 joko 1.1 *
194 joko 1.2 * @link http://www.netfrag.org/~joko/
195 joko 1.1 * @author Andreas Motl <andreas.motl@ilo.de>
196 joko 1.2 *
197     * @link http://www.netfrag.org/~jonen/
198 joko 1.1 * @author Sebastian Utz <seut@tunemedia.de>
199 joko 1.2 *
200 joko 1.1 * @copyright (c) 2003 - All Rights reserved.
201 joko 1.2 *
202     * @link http://www.gnu.org/licenses/lgpl.txt
203 joko 1.1 * @license GNU LGPL (GNU Lesser General Public License)
204     *
205     *
206 joko 1.2 * @package org.netfrag.glib
207     * @subpackage DataSource
208     * @name DataSource::Generic
209 joko 1.1 *
210 joko 1.4 * @todo this:
211 joko 1.5 * o mungle this to be able to be wrapped around phpHtmlLib's own storage-handles
212     * o implement another Data::Driver::Proxy container
213 joko 1.1 *
214 joko 1.5 * <pre>
215 joko 1.4 * !!!!!!!! THIS IS THE PROBLEM !!!!!!!!
216     * !!!!!!!! here is it where we have to break inheritance again !!!!!!!!
217     *
218     * THE CONFLICT: Beeing in phpHtmlLib *and* DesignPattern::TransparentProxy
219     * inheritance trees at the same time, which is *not* possible at
220     * declare-time. We *do* need some runtime-infrastructure to solve this!
221     *
222     * TODO: move build- and check-locator stuff from ObjectList to this place!!!
223     *
224     * ABOUT:
225     * 1. otherwhere: WebApp - scope:
226     * x handles page vs. block vs. widget; dispatches MVC-View
227     * 2. here: DataSource - scope:
228     * x handles bridge to frameworks (e.g. phpHtmlLib) vs. actual data driver libs (PEAR, etc.))
229     * o clean implementation using a DesignPattern::AdapterProxy
230 joko 1.5 * </pre>
231 joko 1.4 *
232     *
233     */
234 joko 1.1 class DataSource_Generic extends DesignPattern_AdapterProxy {
235    
236     // !!!!!!!! here is it where we have to break inheritance again !!!!!!!!
237     // !!!!!!!! THIS IS THE PROBLEM !!!!!!!!
238    
239    
240    
241     /**
242     * This var holds the locator metadata hash
243     * that is used to feed metadata to a per-query-instance
244     * of an Adapter object.
245     *
246     */
247     //var $_locator = NULL;
248    
249     /**
250     * This var holds the locator metadata hash
251     * which is built from some predefined rules
252     * using metadata from $_options and some
253     * other presets.
254     *
255     * See '_buildLocator' which acts as a dispatcher
256     * depending on $_options[datasource].
257     * (main dispatching level)
258     *
259     * The structure of a full blown locator looks like this:
260     *
261     * $locator = array(
262     * type => '<your type specifying the datasource-type>',
263     * metadata => array(
264     * ... your arbitrary deep metadata structure ...
265     * ),
266     * [dsn => '<your dsn markup>'],
267     * );
268     *
269     * Example 1 - data is inside a rdbms, using a dsn to connect to it:
270     * $locator = array(
271     * type => 'sql',
272     * dsn => 'mysql://username:password@localhost/database',
273     * );
274     *
275     * Example 2 - data is inside an odbms, reachable by doing remote procedure calls (rpc):
276     * $locator = array(
277     * type => 'rpc',
278     * metadata => array(
279     * package => 'Data::Driver::Proxy',
280     * Host => 'localhost',
281     * Port => '8765',
282     * )
283     * );
284     *
285     */
286     var $_locator = NULL;
287    
288    
289     /**
290     * This var holds the module information required to
291     * create instances of a Proxy and an Adapter.
292     * Information might get extracted from a
293     * DataSource::Locator instance.
294     *
295     * --- A skeleton:
296     *
297     * $this->_modules = array(
298     * _proxy => array( _id => '', _module => '', _options = array(), _instance => &$obj),
299     * _adapter => array( _id => '', _module => '', _options = array(), _instance => &$obj),
300     * );
301     *
302     *
303     * --- An example:
304     *
305     * $this->_modules = array(
306     * _proxy => array( _id => 'rpc', _module => 'DesignPattern::RemoteProxy', _instance => &$obj),
307     * _adapter => array( _id => 'phpHtmlLib', _module => 'DataSource::Adapter::phpHtmlLib::DataListSource', _instance => &$obj),
308     * );
309     *
310     *
311     */
312     //var $_modules = NULL;
313    
314    
315     /**
316     * This var holds the query hash
317     * that is used to feed as query to a per-query-instance
318     * of a Data::Driver::Proxy object.
319     *
320     */
321     var $_query = NULL;
322    
323    
324     /**
325     * this holds the query result from the
326     * Data::Driver::Proxy->queryXyz() call
327     *
328     */
329     var $_result = NULL;
330    
331    
332    
333     /**
334     * The constructor is used to pass in the
335     * locator metadata hash.
336     *
337     * @param LocatorMetadataHash array - layout: array( type => '', metadata => '', dsn => '' )
338     * @param Query array - layout: array( type => '', metadata => '', dsn => '' )
339     */
340    
341    
342     function DataSource_Generic( &$locator, $query ) {
343    
344     // copy parameter from query to locator
345     //$this->_locator->merge_to($this->_locator, array( datasource_type => $query[datasource] ), '_');
346     //$this->_locator->_datasource_type = $query[datasource];
347     //$locator[_datasource_type] = $query[datasource];
348    
349 joko 1.3 /**
350     * <!-- Autodia -->
351     * can do: (this is metadata supplied for Autodia, don't delete!)
352     * $this->_locator = new DataSource_Locator()
353     *
354     */
355    
356 joko 1.1 // build master locator
357     $this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[datasource] ) );
358     //exit;
359     //$this->_locator = php::mkComponent('DataSource::Locator');
360    
361     $this->_locator->check();
362    
363     // trace
364     //print "locator-obj: " . Dumper($this->_locator);
365     //print "locator-data: " . Dumper($locator_data);
366     //exit;
367    
368    
369    
370     /*
371     $this->_modules = array(
372     _proxy => array( _id => $locator->_datasource_type ),
373     _adapter => array( _id => $locator->_adapter_type ),
374     );
375     */
376    
377     //$this->set_locator( $locator );
378     $this->set_query( $query );
379    
380    
381    
382     /*
383     // V1:
384     // pre-flight: establish and check locator metadata
385     $this->_buildLocator();
386     $this->_checkLocator();
387     */
388    
389    
390    
391     // pre-flight: check locator metadata
392     //$locator->build();
393     if (!$this->_locator->check()) {
394     user_error("locator-check failed.");
395     exit;
396     //return;
397     }
398    
399     //exit;
400    
401    
402 joko 1.3 /**
403     * <!-- Autodia -->
404     * can do: (this is metadata supplied for Autodia, don't delete!)
405     * $proxy = new DesignPattern_RemoteProxy()
406     *
407     */
408    
409    
410 joko 1.1 // --- Proxy selector/dispatcher ...
411    
412     switch ($this->_locator->_datasource_type) {
413     case 'rpc':
414     //$locator_data = $this->_locator->get_metadata();
415     //$this->_modules[_proxy][_options] = array( locator => $this->_locator, query => $query );
416     //$this->_modules[_proxy][_module] = 'DataSource::Proxy::XMLRPC';
417    
418     //$this->_modules[_proxy][_module] = 'DesignPattern::RemoteProxy';
419     //$this->_modules[_proxy][_options] = $locator_data;
420    
421     //$this->set_component_name('DesignPattern::RemoteProxy');
422     //$this->set_component_options($locator_data);
423    
424     $this->set_component_name('DesignPattern::RemoteProxy');
425    
426     break;
427     default:
428     user_error("Site::GenericPage: no Proxy could be selected!");
429     break;
430     }
431    
432    
433    
434     /*
435     // V1:
436     // make up dummy args by now
437     $args = array(
438     adapter => 'phpHtmlLib',
439     );
440     */
441    
442     // V2: now propagated from caller!
443    
444     //print Dumper(array( locator => $locator, query => $query ));
445     //exit;
446    
447     //$this->create_adapter($this->module, $this->function, $this->arguments);
448     //$this->set_handler( $this->get_adapter() );
449    
450    
451     // --- Adapter selector/dispatcher ...
452     // ... resolves this._modules.adapter._id to this._modules.adapter._module
453    
454     switch ($locator->_adapter_type) {
455     case 'phpHtmlLib':
456     //$adapter_arguments = $args[title];
457    
458     $this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataListSource');
459    
460     // in order to let the Adapter communicate with the Proxy,
461     // instantiate a wrapper method in a third namespace via
462     // Exporter::export_symbol(from, to)
463     $this->set_adapter_options($this);
464    
465    
466     break;
467     default:
468     user_error("DataSource::GenericDataSource: no Adapter could be selected!");
469     break;
470     }
471    
472    
473    
474     // --- module instantiation - Proxy and Adapter
475    
476     //user_error("handle proxy here!");
477     //$this->create_proxy();
478    
479     //print Dumper($this);
480    
481     //print "this: " . Dumper($this);
482    
483     // V1:
484     /*
485     $proxy = php::mkComponent($this->_modules[_proxy][_module], $this->_modules[_proxy][_options]);
486     print "proxy: " . Dumper($proxy);
487     //exit;
488     */
489    
490     // V2:
491     /*
492     $resultHandle = mkObject('DesignPattern::RemoteProxy', $cache_key, array( key => 1, command => $command, query => $query, remote => 1, rpcinfo => $rpcinfo, cache => array( db => 0, session => 1 ) ) );
493     $result = $resultHandle->getAttributes();
494     return $result;
495     */
496    
497     // V3:
498     // $this->set_handler( $proxy );
499    
500     // V4: use _component_name & _component_options (proposal from GenericPage)
501     // $this->_component_name = ...
502     // $this->create_handler();
503    
504 joko 1.3
505     /**
506     * <!-- Autodia -->
507     * can do: (this is metadata supplied for Autodia, don't delete!)
508     * $adapter = new DataSource_Adapter_phpHtmlLib_DataListSource()
509     *
510     */
511 joko 1.1
512     // V1:
513     //$this->create_adapter($adapter_module, $this->function, $this->arguments);
514    
515     // V2: FIXME - better use V1?
516     $adapter = php::mkComponent($this->get_adapter_module(), $this->get_adapter_options());
517     $this->set_adapter($adapter);
518    
519    
520    
521    
522     }
523    
524     function make_adapter_transparent() {
525    
526     // ... known from Site::Adapter::php::Class:
527    
528     // At this place the Adapter becomes a Proxy.
529     // This functionality currently correlates to the
530     // name of our ancestor, DesignPattern::AdapterProxy.
531     // FIXME: move this code to its namespace!!!
532     // FIXME: rename to set_proxy...
533    
534     // The reason this has to occour here is required
535     // by the TransparentProxy to actually make the
536     // _handler (_proxy) transparent later....
537     //$this->set_proxy( $this->get_adapter() );
538     }
539    
540     /**
541     * Set the metadata information
542     * (a DataSource::Locator) we will use
543     * to build encapsulated instances
544     * of both a Proxy and an Adapter.
545     *
546     * @param LocatorMetadataHash array -
547     *
548     */
549     function set_metadata( &$locator ) {
550     $this->_locator = &$locator;
551     }
552    
553     function &get_metadata() {
554     return $this->_locator;
555     }
556    
557    
558     /**
559     * Set the query metadata hash we will feed *completely*
560     * to an encapsulated Proxy instance.
561     *
562     * @param QueryDeclaration array -
563     *
564     */
565     function set_query( $query ) {
566     $this->_query = $query;
567     }
568    
569     /**
570     * Issue remote/proxy call
571     * Stolen from Application_AbstractBackend::_remote_method (RefactoringProposal?)
572     * Tweaked a bit: proxy package now taken from $this->_handler_name
573     *
574     * Create a new instance of a proxy and store it for later reuse.
575     * Read the locator metadata hash and create
576     * the proxy handler instance using passed-in name.
577     *
578     * @param string - $proxy_name (namespaced classname - perl syntax - e.g.: Data::Driver::Proxy)
579     *
580     */
581     function datasource_handler_call() {
582    
583    
584     // 1. read args and build cache key
585    
586     $arg_list = func_get_args();
587     $command = array_shift($arg_list);
588     $cache_key = join("-", array(session_id(), $command, join('_', $arg_list) ));
589     //print "cache_key: $cache_key<br>";
590    
591     // FIXME: what if arg_list still contains more elements after doing this?
592     $query = array_shift($arg_list);
593    
594     // 2. prepare proxy-options (read from locator)
595    
596     //print "this: " . Dumper($this);
597     //exit;
598    
599     // read from locator metadata
600     //$proxy_name = $this->_locator[metadata][package];
601    
602     // V1:
603     //$rpcinfo = array( Host => $this->_locator[metadata][Host], Port => $this->_locator[metadata][Port] );
604    
605     // V2:
606     $rpcinfo = $this->_locator->get_metadata();
607    
608     // FIXME! implement this into Data::Driver::RPC::Remote!
609     //$rpcinfo[to_latin] = 1;
610    
611     // FIXME! patch query
612     if (sizeof($query) == 1) {
613     $query = $query[0];
614     }
615    
616     //print "query: " . Dumper($query);
617    
618     // !!! use DesignPattern::Proxy here !!!
619     // $proxy = new DesignPattern_Proxy($proxy_name, ...)
620     // or:
621     // $proxy = mkObject('DesignPattern::Proxy');
622     // $this->set_handler( $proxy );
623     // or:
624     // $proxy = mkObject('DesignPattern::Proxy');
625     // $proxy->
626     // $this->set_handler( $proxy );
627    
628    
629    
630     //$this->set_component_name( $proxy_name );
631     $this->set_component_options( $cache_key, array( key => 1, command => $command, query => $query, remote => 1, rpcinfo => $rpcinfo, cache => array( db => 0, session => 1 ) ) );
632     //print Dumper($this);
633     //exit;
634    
635     $this->create_proxy();
636    
637     //print Dumper($this);
638     //exit;
639    
640     /*
641     // -------------------- clone this & modify ----------
642     $proxy = mkObject($proxy_name, $cache_key, array( key => 1, command => $command, query => $query, remote => 1, rpcinfo => $rpcinfo, cache => array( db => 0, session => 1 ) ) );
643     $this->set_handler( $proxy );
644     //$result = $resultHandle->getAttributes();
645     //return $result;
646     //$this->_result = $resultHandle->getAttributes();
647     //$this->_result = $this->_handler->getAttributes();
648     // -------------------- clone this & modify ----------
649     */
650    
651     }
652    
653    
654     function datasource_handler_buildoptions() {
655    
656     //print Dumper($this->_query);
657     //exit;
658    
659     // make up a command from metadata
660     // FIXME: abstract this some more (e.g. via a CommandMapper|Registry)
661     switch ($this->_query[metatype]) {
662     case 'data':
663     //$command = 'queryData';
664     $command = 'getObjects'; // FIXME!!!
665     //$this->_locator->set_option('metadata.command', $command);
666     $args = array();
667     switch ($this->_query[vartype]) {
668     case 'object':
669     if (!$this->_query[classname]) {
670     $msg = "_query[vartype] == 'object' requires _query[classname]";
671     user_error("GenericDataSource::query_data() - failed: " . $msg);
672     }
673     array_push($args, $this->_query[classname]);
674     break;
675     }
676     break;
677     case 'schema':
678     $command = 'querySchema';
679     break;
680     }
681    
682    
683     /*
684     $this->_query[rpc_command] = $command;
685     $this->_query[rpc_args] = $command;
686     */
687    
688     // methods!!!
689     $this->_locator->_call[_method] = $command;
690     $this->_locator->_call[_arguments] = $args;
691    
692     //$adapter = $this->get_adapter();
693    
694     // trace
695     /*
696     print Dumper(null, '<b>= = = = = = = = = = = = = = = = = = = = = =</b>');
697     print Dumper('datasource_handler_buildoptions', array(
698     "_locator" => $this->_locator,
699     "_query" => $this->_query,
700     "command" => '<b>' . $command . "</b>",
701     "args" => $args
702     ));
703     */
704    
705     /*
706     $this->_handler_options = array(
707     method => $command,
708     args => $args,
709     );
710     */
711    
712     }
713    
714     function &fetch_result() {
715    
716     $this->datasource_handler_buildoptions();
717    
718     $method = $this->_locator->_call[_method];
719     $args = $this->_locator->_call[_arguments];
720    
721     // pre-flight checks
722     if (!$method) {
723     $msg = "Remote command could not be resolved, please pass in or check configuration.";
724     user_error("GenericDataSource::query_data() - failed: " . $msg);
725     return;
726     }
727    
728     //print "fetch_result: this->_handler=" . Dumper($this->_handler);
729    
730     // do remote call here and get result
731     // FIXME: handle synchronous/asynchronous mode here!!!
732     $this->datasource_handler_call($method, $args);
733    
734    
735     // TODO: ... = $this->poll_handler_result and $this->get_handler_result
736     $proxy = $this->get_proxy();
737     $this->_result = $proxy->getResult();
738     //print "result: " . Dumper($this->_result); exit;
739    
740     $this->_result_count = sizeof($this->_result);
741    
742     // trace
743     if ($this->_debug[notice]) {
744     //print "_result = " . Dumper($this->_result);
745     print "DataSource::Generic->_result_count = " . $this->_result_count . "<br/>";
746     }
747    
748     return $this->_result;
749    
750     }
751    
752    
753     function &query_data() {
754     //print "query!<br/>";
755     return $this->fetch_result();
756     //$this->handle_result();
757     }
758    
759     function query_schema() {
760     user_error("FIXME: query_schema");
761     // $this->datasource_handler_call( ... );
762     }
763    
764     function &get_result() {
765     return $this->_result;
766     }
767    
768     }
769    
770     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed