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

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

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