/[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.8 - (hide annotations)
Thu Mar 20 07:22:14 2003 UTC (21 years, 4 months ago) by jonen
Branch: MAIN
Changes since 1.7: +6 -3 lines
+ modified case 'object' to 'objects'
  (cause its loads all *objects* of a given classname)

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

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