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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Wed Mar 5 12:04:00 2003 UTC revision 1.25 by jonen, Mon Nov 17 18:01:03 2003 UTC
# Line 1  Line 1 
1  <?php  <?php
2  /**  /**
3   * This file contains the GenericDataSource child class   * This file contains the GenericDataSource child class
  * that may use arbitrary code modules as database handlers.  
  * It's aims are to get together:  
  *   o phpHtmlLibs "source-handlers"  
  *   o PEAR's database handlers  
  *   o custom ones (e.g. Data::Driver::Proxy object, which talks to a remote rpc server)  
4   *   *
5   * @author Andreas Motl <andreas.motl@ilo.de>   * @author Andreas Motl <andreas.motl@ilo.de>
6   * @package phpHtmlLib   * @package org.netfrag.glib
7   * @module GenericDataSource   * @name DataSource::Generic
8   *   *
9   */   */
10    
11  /**  /**
12     * Cvs-Log:
13     *
14   * $Id$   * $Id$
15   *   *
16   * $Log$   * $Log$
17     * Revision 1.25  2003/11/17 18:01:03  jonen
18     * bugfix: php cannot use perl-syntax!! ;-)
19     *
20     * Revision 1.23  2003/07/14 10:02:32  jonen
21     * removed debug dumper
22     *
23     * Revision 1.22  2003/06/06 04:25:45  joko
24     * fix: query args get encapsulated once more
25     *
26     * Revision 1.21  2003/05/10 18:14:50  jonen
27     * + implements 'create' of item (query mapping part)
28     *
29     * Revision 1.20  2003/04/19 16:07:15  jonen
30     * + added '_query[list_meta]' at 'queryData' needed for meta query args
31     *    (e.g. at UserManagment)
32     *
33     * Revision 1.19  2003/04/18 15:40:51  joko
34     * NEW: tree data handling
35     *   introduced new adapter: DataSource::Adapter::Free
36     *   enhanced datasource_handler_buildoptions: now handles a) case 'tree'  b) _query[filter]
37     *
38     * Revision 1.18  2003/04/11 00:55:49  joko
39     * updated 'datasource_handler_buildoptions': action dispatcher now aware of 'delete'
40     *
41     * Revision 1.17  2003/04/09 02:07:33  joko
42     * CHANGE: renamed key 'classname' through 'nodename'
43     *
44     * Revision 1.16  2003/04/08 17:55:20  joko
45     * CHANGE: renamed property 'datasource' to 'transport'
46     * NEW: new case 'method' in 'function datasource_handler_buildoptions'
47     * minor fixes: updated logging/debugging messages
48     *
49     * Revision 1.15  2003/04/06 04:46:33  joko
50     * renamed linking function
51     * mozilla fixes
52     *
53     * Revision 1.14  2003/04/04 21:19:21  joko
54     * modified exception handling (enhanced, purged redundant code)
55     *
56     * Revision 1.13  2003/04/04 02:37:14  jonen
57     * _query[action] == write
58     *
59     * Revision 1.12  2003/03/29 08:00:48  joko
60     * modified ErrorBoxing
61     *
62     * Revision 1.11  2003/03/28 06:45:26  joko
63     * VERBOSE mode
64     *
65     * Revision 1.10  2003/03/28 03:01:02  joko
66     * more fancy debugging-output
67     *
68     * Revision 1.9  2003/03/27 16:24:26  jonen
69     * + mugled namespace
70     * + added enhanced 'queryData'
71     *
72     * Revision 1.8  2003/03/20 07:22:14  jonen
73     * + modified case 'object' to 'objects'
74     *   (cause its loads all *objects* of a given classname)
75     *
76     * Revision 1.7  2003/03/11 01:43:00  joko
77     * + fixed metadata for phpDocumentor
78     *
79     * Revision 1.6  2003/03/11 01:22:25  joko
80     * + fixed metadata for phpDocumentor
81     *
82     * Revision 1.5  2003/03/11 00:12:49  joko
83     * + fixed metadata for phpDocumentor
84     *
85     * Revision 1.4  2003/03/10 23:25:03  joko
86     * + fixed metadata for phpDocumentor
87     *
88     * Revision 1.3  2003/03/09 15:50:36  joko
89     * + additional metadata for Autodia
90     *
91     * Revision 1.2  2003/03/05 17:28:43  joko
92     * updated docu (phpDocumentor testing....)
93     *
94   * Revision 1.1  2003/03/05 12:04:00  joko   * Revision 1.1  2003/03/05 12:04:00  joko
95   * + initial commit, from GenericDataSource   * + initial commit, from GenericDataSource
96   *   *
# Line 44  Line 118 
118   * Revision 1.1  2003/03/01 03:10:40  joko   * Revision 1.1  2003/03/01 03:10:40  joko
119   * + initial commit   * + initial commit
120   *   *
  *  
121   */   */
122    
123  /**  /**
# Line 71  Line 144 
144    // require_once("PEAR.php");   // FIXME: what about PEAR::XML::RPC?    // require_once("PEAR.php");   // FIXME: what about PEAR::XML::RPC?
145    // require_once("DB.php");    // require_once("DB.php");
146    
147    
148    loadModule('DesignPattern::Proxy');
149    loadModule('DesignPattern::TransparentProxy');
150    loadModule('DesignPattern::RemoteProxy');
151    
152    //class GenericDataSource extends MemoryDataSource {
153    //class GenericDataSource extends DesignPattern_Proxy {
154    //class GenericDataSource extends DesignPattern_RemoteProxy {
155    //class GenericDataSource extends DesignPattern_TransparentProxy {
156    
157    //class GenericDataSource extends MemoryDataSource {
158    //loadModule("DataSource::Proxy::Memory");
159    //class GenericDataSource extends DataSource_Proxy_Memory {
160    //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {
161    //class DataSource_GenericDataSource extends DesignPattern_Proxy {
162    //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {
163    
164    // now independent!!! new class-inheritance-tree possible now!
165    // solved by having an Adapter *and* a Proxy here!
166    //class GenericDataSource {
167    
168    loadModule('DesignPattern::AdapterProxy');
169    
170    
171    
172  /**  /**
173   * This GenericDataSource child class is *completely* independent   * This GenericDataSource child class is *completely* independent
174   * of a specific storage implementation and intended to be a wrapper   * of a specific storage implementation and intended to be a wrapper
175   * class on the way from phpHtmlLib to Xyz.   * class on the way from phpHtmlLib to Xyz. <br>
176   *    ("Yyz" gets represented by Data::Storage by now.....)   *    ("Yyz" gets represented by Data::Storage by now.....)
177   *   *
178   * GenericDataSource interacts with an intermediate "proxy" object   * GenericDataSource interacts with an intermediate "proxy" object
179   * (e.g. Data::Driver::Proxy) when doing queries.   * (e.g. Data::Driver::Proxy) when doing queries. <br>
180     * <pre>
181   *    Don't mix this up with a persistent database handle which gets   *    Don't mix this up with a persistent database handle which gets
182   *    reused each and every time for different queries.   *    reused each and every time for different queries.
183   *    Here *is* a new instance of Data::Driver::Proxy for *each* query.   *    Here *is* a new instance of Data::Driver::Proxy for *each* query.
184     * </pre>
185   *   *
186   * But the point is: Caching! The actual *data* isn't read redundant!   * But the point is: Caching! The actual *data* isn't read redundant!
187   *   *
188     * <pre>
189     * --- snipped into here from above ---
190     * that may use arbitrary code modules as database handlers.
191     * It's aims are to get together:
192     *   o phpHtmlLibs "source-handlers"
193     *   o PEAR's database handlers
194     *   o custom ones (e.g. Data::Driver::Proxy object, which talks to a remote rpc server)
195     * --- snipped into here from above ---
196     * </pre>
197   *   *
198     * <p>
199   * !!!!!!  refactor this to Data::Driver::Proxy  !!!!!!     <-----------------   * !!!!!!  refactor this to Data::Driver::Proxy  !!!!!!     <-----------------
200   *   *
201   * Data::Driver::Proxy instantiates "handlers" below itself   * Data::Driver::Proxy instantiates "handlers" below itself
# Line 95  Line 205 
205   * One worker already implemented is Data::Driver::RPC::Remote, which   * One worker already implemented is Data::Driver::RPC::Remote, which
206   * talks to a RPC::XML server (todo: talk SOAP!) using PEAR::XML::RPC.   * talks to a RPC::XML server (todo: talk SOAP!) using PEAR::XML::RPC.
207   *   *
208     * <pre>
209   * ---  refactored here, but: redundant somehow  ---   * ---  refactored here, but: redundant somehow  ---
210   * Data::Driver::Proxy uses a PEAR XML::RPC object to actually   * Data::Driver::Proxy uses a PEAR XML::RPC object to actually
211   * talk HTTP and serialize data chunks to and from XML,   * talk HTTP and serialize data chunks to and from XML,
# Line 102  Line 213 
213   * It "proxies" arbitrary data chunks a) inside a native php4 session,   * It "proxies" arbitrary data chunks a) inside a native php4 session,
214   * b) by talking to a rdbms (single proxy-table) or c) [TODO] using PEAR::Cache.   * b) by talking to a rdbms (single proxy-table) or c) [TODO] using PEAR::Cache.
215   * ---  refactored here, but: redundant somehow  ---   * ---  refactored here, but: redundant somehow  ---
216     * </pre>
217   *   *
218   * !!!!!!  refactor this to Data::Driver::Proxy  !!!!!!     <-----------------   * !!!!!!  refactor this to Data::Driver::Proxy  !!!!!!     <-----------------
219     * </p>
220   *   *
221   *   *
222   * How to use?   * <p>
223     * <b>How to use?</b>
224   *   *
225   * Pass an array holding "locator metadata" to the constructor.   * Pass an array holding "locator metadata" to the constructor.
226   * GenericDataSource takes care of the rest.   * GenericDataSource takes care of the rest.
227   *   *
228     * <pre>
229   * Pass an array to the constructor: (e.g.)   * Pass an array to the constructor: (e.g.)
230   *   *
231   *  1. doing rpc-calls....   *  1. doing rpc-calls....
232     *    <code>
233   *    $locator = array(   *    $locator = array(
234   *      type => 'rpc',   *      type => 'rpc',
235   *      metadata => array( Host => 'localhost', Port => '8765' ),   *      metadata => array( Host => 'localhost', Port => '8765' ),
236   *    );   *    );
237   *    $source = new GenericDataSource($locator);   *    $source = ne w GenericDataSource($locator);
238   *    $this->set_data_source( &$source );   *    $this->set_data_source( &$source );
239     *    </code>
240   *   *
241   *  2. [proposal] common datahandles....   *  2. [proposal] common datahandles....
242     *    <code>
243   *    $locator = array(   *    $locator = array(
244   *      type => 'mysql',   *      type => 'mysql',
245   *      dsn => 'known dsn markup',   *      dsn => 'known dsn markup',
246   *    );   *    );
247   *    $source = new GenericDataSource($locator);   *    $source = ne w GenericDataSource($locator);
248   *    $this->set_data_source( &$source );   *    $this->set_data_source( &$source );
249     *    </code>
250     * </pre>
251     * </p>
252     *
253   *   *
254     * @link http://www.netfrag.org/~joko/
255   * @author Andreas Motl <andreas.motl@ilo.de>   * @author Andreas Motl <andreas.motl@ilo.de>
256     *
257     * @link http://www.netfrag.org/~jonen/
258   * @author Sebastian Utz <seut@tunemedia.de>   * @author Sebastian Utz <seut@tunemedia.de>
259     *
260   * @copyright (c) 2003 - All Rights reserved.   * @copyright (c) 2003 - All Rights reserved.
  * @license GNU LGPL (GNU Lesser General Public License)  
261   *   *
262   * @author-url http://www.netfrag.org/~joko/   * @link http://www.gnu.org/licenses/lgpl.txt
263   * @author-url http://www.netfrag.org/~jonen/   * @license GNU LGPL (GNU Lesser General Public License)
  * @license-url http://www.gnu.org/licenses/lgpl.txt  
264   *   *
  * @package phpHtmlLib  
  * @module GenericDataSource  
265   *   *
266   */   * @package org.netfrag.glib
267     * @subpackage DataSource
268  /**   * @name DataSource::Generic
269   * Todo:   *
270     * @todo this:
271     * o mungle this to be able to be wrapped around phpHtmlLib's own storage-handles
272     * o implement another Data::Driver::Proxy container
273     *
274     * <pre>
275     *              !!!!!!!!          THIS IS THE PROBLEM          !!!!!!!!
276     *    !!!!!!!!   here is it where we have to break inheritance again   !!!!!!!!
277     *
278     *    THE CONFLICT: Beeing in phpHtmlLib *and* DesignPattern::TransparentProxy
279     *    inheritance trees at the same time, which is *not* possible at
280     *    declare-time. We *do* need some runtime-infrastructure to solve this!
281     *
282     *    TODO: move build- and check-locator stuff from ObjectList to this place!!!
283     *
284     *    ABOUT:
285     *      1. otherwhere: WebApp - scope:
286     *          x handles page vs. block vs. widget; dispatches MVC-View
287     *      2. here: DataSource - scope:
288     *          x handles bridge to frameworks (e.g. phpHtmlLib) vs. actual data driver libs (PEAR, etc.))
289     *          o clean implementation using a DesignPattern::AdapterProxy
290     * </pre>
291   *   *
  *  o mungle this to be able to be wrapped around phpHtmlLib's own storage-handles  
  *  o implement another Data::Driver::Proxy container  
292   *   *
293   */   */
   
   
 //              !!!!!!!!          THIS IS THE PROBLEM          !!!!!!!!  
 //    !!!!!!!!   here is it where we have to break inheritance again   !!!!!!!!  
 //  
 //    THE CONFLICT: Beeing in phpHtmlLib *and* DesignPattern::TransparentProxy  
 //    inheritance trees at the same time, which is *not* possible at  
 //    declare-time. We *do* need some runtime-infrastructure to solve this!  
 //  
 //    TODO: move build- and check-locator stuff from ObjectList to this place!!!  
 //  
 //    ABOUT:  
 //      1. otherwhere: WebApp - scope:  
 //          x handles page vs. block vs. widget; dispatches MVC-View  
 //      2. here: DataSource - scope:  
 //          x handles bridge to frameworks (e.g. phpHtmlLib) vs. actual data driver libs (PEAR, etc.))  
 //          o clean implementation using a DesignPattern::AdapterProxy  
 //  
   
 loadModule('DesignPattern::Proxy');  
 loadModule('DesignPattern::TransparentProxy');  
 loadModule('DesignPattern::RemoteProxy');  
   
 //class GenericDataSource extends MemoryDataSource {  
 //class GenericDataSource extends DesignPattern_Proxy {  
 //class GenericDataSource extends DesignPattern_RemoteProxy {  
 //class GenericDataSource extends DesignPattern_TransparentProxy {  
   
 //class GenericDataSource extends MemoryDataSource {  
 //loadModule("DataSource::Proxy::Memory");  
 //class GenericDataSource extends DataSource_Proxy_Memory {  
 //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {  
 //class DataSource_GenericDataSource extends DesignPattern_Proxy {  
 //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {  
   
 // now independent!!! new class-inheritance-tree possible now!  
 // solved by having an Adapter *and* a Proxy here!  
 //class GenericDataSource {  
   
 loadModule('DesignPattern::AdapterProxy');  
294  class DataSource_Generic extends DesignPattern_AdapterProxy {  class DataSource_Generic extends DesignPattern_AdapterProxy {
295    
296  //    !!!!!!!!   here is it where we have to break inheritance again   !!!!!!!!  //    !!!!!!!!   here is it where we have to break inheritance again   !!!!!!!!
# Line 212  class DataSource_Generic extends DesignP Line 313  class DataSource_Generic extends DesignP
313      * other presets.      * other presets.
314      *      *
315      * See '_buildLocator' which acts as a dispatcher      * See '_buildLocator' which acts as a dispatcher
316      * depending on $_options[datasource].      * depending on $_options[transport].
317      * (main dispatching level)      * (main dispatching level)
318      *      *
319      * The structure of a full blown locator looks like this:      * The structure of a full blown locator looks like this:
# Line 301  class DataSource_Generic extends DesignP Line 402  class DataSource_Generic extends DesignP
402          function DataSource_Generic( &$locator, $query ) {          function DataSource_Generic( &$locator, $query ) {
403    
404                  // copy parameter from query to locator                  // copy parameter from query to locator
405                  //$this->_locator->merge_to($this->_locator, array( datasource_type => $query[datasource] ), '_');                  //$this->_locator->merge_to($this->_locator, array( datasource_type => $query[transport] ), '_');
406                  //$this->_locator->_datasource_type = $query[datasource];                  //$this->_locator->_datasource_type = $query[transport];
407                  //$locator[_datasource_type] = $query[datasource];                  //$locator[_datasource_type] = $query[transport];
408                                    
409          /**
410           * <!-- Autodia -->
411           * can do: (this is metadata supplied for Autodia, don't delete!)
412           *  $this->_locator = new DataSource_Locator()
413           *
414           */
415    
416                  // build master locator                  // build master locator
417                  $this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[datasource] ) );                  $this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[transport] ) );
418                  //exit;                  //exit;
419                  //$this->_locator = php::mkComponent('DataSource::Locator');                  //$this->_locator = php::mkComponent('DataSource::Locator');
420                                    
# Line 343  class DataSource_Generic extends DesignP Line 451  class DataSource_Generic extends DesignP
451      // pre-flight: check locator metadata      // pre-flight: check locator metadata
452        //$locator->build();        //$locator->build();
453        if (!$this->_locator->check()) {        if (!$this->_locator->check()) {
454          user_error("locator-check failed.");          user_error("DataSource::Generic: locator-check failed." . "<br/>" . "Locator was: " . Dumper($this->_locator) );
455          exit;          //exit;
456           //return;           return;
457        }        }
458    
459  //exit;  //exit;
460    
461    
462        /**
463         * <!-- Autodia -->
464         * can do: (this is metadata supplied for Autodia, don't delete!)
465         *  $proxy = new DesignPattern_RemoteProxy()
466         *
467         */
468    
469    
470      // --- Proxy selector/dispatcher ...      // --- Proxy selector/dispatcher ...
471            
472      switch ($this->_locator->_datasource_type) {      switch ($this->_locator->_datasource_type) {
# Line 396  class DataSource_Generic extends DesignP Line 512  class DataSource_Generic extends DesignP
512          // ... resolves this._modules.adapter._id to this._modules.adapter._module          // ... resolves this._modules.adapter._id to this._modules.adapter._module
513                    
514          switch ($locator->_adapter_type) {          switch ($locator->_adapter_type) {
515    
516            case 'phpHtmlLib':            case 'phpHtmlLib':
517              //$adapter_arguments = $args[title];              //$adapter_arguments = $args[title];
518                $this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataSource');
             $this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataListSource');  
519                            
520              // in order to let the Adapter communicate with the Proxy,              // in order to let the Adapter communicate with the Proxy,
521              // instantiate a wrapper method in a third namespace via              // instantiate a wrapper method in a third namespace via
522              // Exporter::export_symbol(from, to)              // Exporter::export_symbol(from, to)
523              $this->set_adapter_options($this);              $this->set_adapter_options($this);
524                break;
525    
526              // NEW [2003-04-17]: Freedom for the adapter!
527              // phpHtmlLib didn't have a tree widget, but PEAR does.
528              // So: Free us from the phpHtmlLib-adapter in this case.
529              case 'free':
530                $this->set_adapter_module('DataSource::Adapter::Free');
531                $this->set_adapter_options($this);
532              break;              break;
533    
534            default:            default:
535              user_error("DataSource::GenericDataSource: no Adapter could be selected!");              user_error("DataSource::Generic: no Adapter could be selected: \$locator->_adapter_type='$locator->_adapter_type'");
536              break;              break;
537          }          }
538    
# Line 446  class DataSource_Generic extends DesignP Line 569  class DataSource_Generic extends DesignP
569        // $this->create_handler();        // $this->create_handler();
570    
571    
572          /**
573           * <!-- Autodia -->
574           * can do: (this is metadata supplied for Autodia, don't delete!)
575           *  $adapter = new DataSource_Adapter_phpHtmlLib_DataListSource()
576           *
577           */
578    
579        // V1:        // V1:
580        //$this->create_adapter($adapter_module, $this->function, $this->arguments);        //$this->create_adapter($adapter_module, $this->function, $this->arguments);
581    
# Line 597  class DataSource_Generic extends DesignP Line 727  class DataSource_Generic extends DesignP
727        // FIXME: abstract this some more (e.g. via a CommandMapper|Registry)        // FIXME: abstract this some more (e.g. via a CommandMapper|Registry)
728          switch ($this->_query[metatype]) {          switch ($this->_query[metatype]) {
729            case 'data':            case 'data':
730              //$command = 'queryData';              $command = 'queryData';
731              $command = 'getObjects';   // FIXME!!!              
732                //$command = 'getObjects';   // FIXME!!!
733              //$this->_locator->set_option('metadata.command', $command);              //$this->_locator->set_option('metadata.command', $command);
734    /*
735              $args = array();              $args = array();
736              switch ($this->_query[vartype]) {              switch ($this->_query[vartype]) {
737                case 'object':                case 'objects':
738                  if (!$this->_query[classname]) {                  if (!$this->_query[classname]) {
739                    $msg = "_query[vartype] == 'object' requires _query[classname]";                    $msg = "_query[vartype] == 'objects' requires _query[classname]";
740                    user_error("GenericDataSource::query_data() - failed: " . $msg);                    user_error("DataSource::Generic: query_data() - failed: " . $msg);
741                  }                  }
742                  array_push($args, $this->_query[classname]);                  array_push($args, $this->_query[classname]);
743                  break;                  break;
744              }              }
745              break;   */
746                $query_args = array();
747                
748                 $msg_prefix = "DataSource::Generic::datasource_handler_buildoptions failed: ";
749                 switch ($this->_query[abstract_type]) {
750                  case 'item':
751                    if (!$this->_query[nodename] && $this->_query[action] != 'create') {
752                      $msg = "_query[vartype] == 'objects' requires _query[nodename]";
753                      user_error($msg_prefix . $msg);
754                    } elseif($this->_query[action] == 'create' && $this->_query[parent]) {
755                      if($this->_query[nodename]) { $query_args[node_class] = $this->_query[nodename]; }
756                      if($this->_query['hash_key']) { $query_args['hash_key'] = $this->_query['hash_key']; }
757                      $query_args[nodename] = $this->_query[ident];
758                      $query_args[parent][guid] = $this->_query[parent][guid];
759                      $query_args[parent][nodename] = $this->_query[parent][nodename];
760                    } else {
761                      $query_args[guid] = $this->_query[ident];
762                      $query_args[nodename] = $this->_query[nodename];
763                      // 2003-11-17 NEW: use expand flag for real obj expand at backend
764                      if ($this->_query[expand]) {$query_args[expand] = 1; }
765                    }
766                    break;
767                  case 'list':
768                    if (!$this->_query[nodename]) {
769                      $msg = "_query[vartype] == 'objects' requires _query[nodename]";
770                      user_error($msg_prefix . $msg);
771                    }
772                    //array_push($query_args, $this->_query[nodename]);
773                    $query_args[nodename] = $this->_query[nodename];
774                    if($this->_query[list_meta]) { $query_args[list_meta] = $this->_query[list_meta]; }
775                    break;
776                  case 'tree':
777                    /*
778                    if (!$this->_query[nodename]) {
779                      $msg = "_query[vartype] == 'objects' requires _query[nodename]";
780                      user_error($msg_prefix . $msg);
781                    }
782                    */
783                    $query_args[guid] = $this->_query[ident];
784                    //$query_args[nodename] = $this->_query[nodename];
785                    break;
786                  default:
787                    $msg = "\$this->_query[abstract_type] could not be dispatched as 'item', 'list' or 'tree'.";
788                    user_error($msg_prefix . $msg);
789                    break;
790                }
791                
792                // filter???
793                //print "Filter: " . Dumper($this->_query[filter]) . "<br>";
794                if ($this->_query[filter]) {
795                  $query_args[filter] = $this->_query[filter];
796                }
797                
798                // dispatch action
799                //print "Action: " . $this->_query[action] . "<br>";
800                if ($this->_query[action] == 'write') {
801                 $query_args[action] = $this->_query[action];
802                 $query_args[data] = $this->_query[data];
803                } elseif ($this->_query[action] == 'delete') {
804                 $query_args[action] = $this->_query[action];
805                } elseif ($this->_query[action] == 'create') {
806                   $query_args[action] = $this->_query[action];
807                }
808                
809                $args = array(
810                              'data_type' => $this->_query[abstract_type],
811                              'query_args' => $query_args
812                              );
813               break;
814    
815              // querySchema
816            case 'schema':            case 'schema':
817                //print "Testing schema:" . "<br>";
818              $command = 'querySchema';              $command = 'querySchema';
819                $args = array( $this->_query[filter] );
820              break;              break;
821                
822              // remoteMethod
823              case 'method':
824                $command = $this->_query[method];
825                //$args = $this->_query[args];
826                // FIX
827                $args = array( $this->_query[args] );
828                break;
829    
830          }          }
831                
832          
833            // FIXME: bad behaviour?
834            if (!is_array($args)) { $args = array( $args ); }
835            
836            //print Dumper($args);
837                    
838          /*          /*
839          $this->_query[rpc_command] = $command;          $this->_query[rpc_command] = $command;
# Line 648  class DataSource_Generic extends DesignP Line 866  class DataSource_Generic extends DesignP
866                
867    }    }
868    
869    
870    
871          function &fetch_result() {          function &fetch_result() {
872    
873          //print Dumper($this);
874                
875        $this->datasource_handler_buildoptions();        $this->datasource_handler_buildoptions();
876    
877        $method = $this->_locator->_call[_method];        $call = $this->_locator->get_call();
878        $args = $this->_locator->_call[_arguments];  
879                //print Dumper($call);
880          //return;
881    
882        // pre-flight checks        // pre-flight checks
883          if (!$method) {          if (!$call[method]) {
884            $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.";
885                          user_error("GenericDataSource::query_data() - failed: " . $msg);                          user_error("DataSource::Generic: query_data() - failed: " . $msg);
886            return;            return;
887          }          }
888    
# Line 666  class DataSource_Generic extends DesignP Line 890  class DataSource_Generic extends DesignP
890    
891        // do remote call here and get result        // do remote call here and get result
892        // FIXME: handle synchronous/asynchronous mode here!!!        // FIXME: handle synchronous/asynchronous mode here!!!
893          $this->datasource_handler_call($method, $args);          $this->datasource_handler_call($call[method], $call[args]);
894                    
895                    
896          // TODO: ... = $this->poll_handler_result  and  $this->get_handler_result          // TODO: ... = $this->poll_handler_result  and  $this->get_handler_result
# Line 677  class DataSource_Generic extends DesignP Line 901  class DataSource_Generic extends DesignP
901          $this->_result_count = sizeof($this->_result);          $this->_result_count = sizeof($this->_result);
902    
903        // trace        // trace
904          if ($this->_debug[notice]) {          //if (constants::get('VERBOSE') && $this->_debug[notice]) {
905            if (constants::get('VERBOSE') or constants::get('ERRORS_ONLY')) {
906            //print "_result = " . Dumper($this->_result);            //print "_result = " . Dumper($this->_result);
907            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>";
908              $this->draw_status_box();
909          }          }
910            
911          return $this->_result;          return $this->_result;
912    
913          }          }
914    
915      function draw_status_box() {
916    
917        static $boxcount;
918        
919        $boxcount++;
920    
921        $box = container();
922    
923        // box style
924        $style = container(
925          html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'),
926          html_style("text/css", '.box_dsg { background: #20ab39; color: white; border: 2px black groove; width:640px; padding:10px; margin:40px; }')
927        );
928        $box->add( $style );
929        
930        // box content
931        $statusbox = html_div('box_dsg');
932        $statusbox->add( html_b("DataSource::Generic"), html_br() );
933        $locatorbox = html_div('box_dsg');
934        $locatorbox->set_id("locatorbox_$boxcount");
935        $locatorbox->add( Dumper($this->_locator) );
936        
937        // FIXME: ie/mozilla?
938        //$locatorbox->set_style('display:none;');
939        //$locatorbox->set_style('visibility:hidden;');
940        // already duplicate inside Tracer!!!
941        $locatorbox->set_style('visibility:hidden; position:absolute; z-index:1; margin-top:30px; padding:5px;');
942        
943        $statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), link::js_function( 'toggleVisibility', array("locatorbox_$boxcount"), '[show]'), $locatorbox, html_br() );
944        $call = $this->_locator->get_call();
945        $statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() );
946        if (sizeof($call[args])) {
947          $statusbox->add( html_span('boxlabel_darkgreen', "Arguments:"), Dumper($call[args]), html_br() );
948        }
949        $statusbox->add( html_span('boxlabel_darkgreen', "Count:"), $this->get_result_count(), html_br() );
950        $box->add( $statusbox );
951    
952        //print $box->render();
953        trace( $box );
954    
955      }
956    
957    
958    function &query_data() {    function &query_data() {
959      //print "query!<br/>";      //print "query!<br/>";
# Line 701  class DataSource_Generic extends DesignP Line 969  class DataSource_Generic extends DesignP
969    function &get_result() {    function &get_result() {
970      return $this->_result;      return $this->_result;
971    }    }
972      
973      function get_result_count() {
974        return $this->_result_count;
975      }
976                    
977  }  }
978    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.25

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