/[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.15 by joko, Sun Apr 6 04:46:33 2003 UTC revision 1.20 by jonen, Sat Apr 19 16:07:15 2003 UTC
# Line 9  Line 9 
9   */   */
10    
11  /**  /**
12   * <b>Cvs-Log:</b>   * Cvs-Log:
13   *   *
  * <pre>  
14   * $Id$   * $Id$
15   *   *
16   * $Log$   * $Log$
17     * Revision 1.20  2003/04/19 16:07:15  jonen
18     * + added '_query[list_meta]' at 'queryData' needed for meta query args
19     *    (e.g. at UserManagment)
20     *
21     * Revision 1.19  2003/04/18 15:40:51  joko
22     * NEW: tree data handling
23     *   introduced new adapter: DataSource::Adapter::Free
24     *   enhanced datasource_handler_buildoptions: now handles a) case 'tree'  b) _query[filter]
25     *
26     * Revision 1.18  2003/04/11 00:55:49  joko
27     * updated 'datasource_handler_buildoptions': action dispatcher now aware of 'delete'
28     *
29     * Revision 1.17  2003/04/09 02:07:33  joko
30     * CHANGE: renamed key 'classname' through 'nodename'
31     *
32     * Revision 1.16  2003/04/08 17:55:20  joko
33     * CHANGE: renamed property 'datasource' to 'transport'
34     * NEW: new case 'method' in 'function datasource_handler_buildoptions'
35     * minor fixes: updated logging/debugging messages
36     *
37   * Revision 1.15  2003/04/06 04:46:33  joko   * Revision 1.15  2003/04/06 04:46:33  joko
38   * renamed linking function   * renamed linking function
39   * mozilla fixes   * mozilla fixes
# Line 86  Line 105 
105   *   *
106   * Revision 1.1  2003/03/01 03:10:40  joko   * Revision 1.1  2003/03/01 03:10:40  joko
107   * + initial commit   * + initial commit
  * </pre>  
108   *   *
109   */   */
110    
# Line 283  class DataSource_Generic extends DesignP Line 301  class DataSource_Generic extends DesignP
301      * other presets.      * other presets.
302      *      *
303      * See '_buildLocator' which acts as a dispatcher      * See '_buildLocator' which acts as a dispatcher
304      * depending on $_options[datasource].      * depending on $_options[transport].
305      * (main dispatching level)      * (main dispatching level)
306      *      *
307      * The structure of a full blown locator looks like this:      * The structure of a full blown locator looks like this:
# Line 372  class DataSource_Generic extends DesignP Line 390  class DataSource_Generic extends DesignP
390          function DataSource_Generic( &$locator, $query ) {          function DataSource_Generic( &$locator, $query ) {
391    
392                  // copy parameter from query to locator                  // copy parameter from query to locator
393                  //$this->_locator->merge_to($this->_locator, array( datasource_type => $query[datasource] ), '_');                  //$this->_locator->merge_to($this->_locator, array( datasource_type => $query[transport] ), '_');
394                  //$this->_locator->_datasource_type = $query[datasource];                  //$this->_locator->_datasource_type = $query[transport];
395                  //$locator[_datasource_type] = $query[datasource];                  //$locator[_datasource_type] = $query[transport];
396                                    
397        /**        /**
398         * <!-- Autodia -->         * <!-- Autodia -->
# Line 384  class DataSource_Generic extends DesignP Line 402  class DataSource_Generic extends DesignP
402         */         */
403    
404                  // build master locator                  // build master locator
405                  $this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[datasource] ) );                  $this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[transport] ) );
406                  //exit;                  //exit;
407                  //$this->_locator = php::mkComponent('DataSource::Locator');                  //$this->_locator = php::mkComponent('DataSource::Locator');
408                                    
# Line 421  class DataSource_Generic extends DesignP Line 439  class DataSource_Generic extends DesignP
439      // pre-flight: check locator metadata      // pre-flight: check locator metadata
440        //$locator->build();        //$locator->build();
441        if (!$this->_locator->check()) {        if (!$this->_locator->check()) {
442          user_error("locator-check failed.");          user_error("DataSource::Generic: locator-check failed." . "<br/>" . "Locator was: " . Dumper($this->_locator) );
443          exit;          //exit;
444           //return;           return;
445        }        }
446    
447  //exit;  //exit;
# Line 482  class DataSource_Generic extends DesignP Line 500  class DataSource_Generic extends DesignP
500          // ... resolves this._modules.adapter._id to this._modules.adapter._module          // ... resolves this._modules.adapter._id to this._modules.adapter._module
501                    
502          switch ($locator->_adapter_type) {          switch ($locator->_adapter_type) {
503    
504            case 'phpHtmlLib':            case 'phpHtmlLib':
505              //$adapter_arguments = $args[title];              //$adapter_arguments = $args[title];
   
506              $this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataSource');              $this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataSource');
507                            
508              // in order to let the Adapter communicate with the Proxy,              // in order to let the Adapter communicate with the Proxy,
509              // instantiate a wrapper method in a third namespace via              // instantiate a wrapper method in a third namespace via
510              // Exporter::export_symbol(from, to)              // Exporter::export_symbol(from, to)
511              $this->set_adapter_options($this);              $this->set_adapter_options($this);
512                break;
513    
514              // NEW [2003-04-17]: Freedom for the adapter!
515              // phpHtmlLib didn't have a tree widget, but PEAR does.
516              // So: Free us from the phpHtmlLib-adapter in this case.
517              case 'free':
518                $this->set_adapter_module('DataSource::Adapter::Free');
519                $this->set_adapter_options($this);
520              break;              break;
521    
522            default:            default:
523              user_error("DataSource::GenericDataSource: no Adapter could be selected!");              user_error("DataSource::Generic: no Adapter could be selected: \$locator->_adapter_type='$locator->_adapter_type'");
524              break;              break;
525          }          }
526    
# Line 700  class DataSource_Generic extends DesignP Line 725  class DataSource_Generic extends DesignP
725                case 'objects':                case 'objects':
726                  if (!$this->_query[classname]) {                  if (!$this->_query[classname]) {
727                    $msg = "_query[vartype] == 'objects' requires _query[classname]";                    $msg = "_query[vartype] == 'objects' requires _query[classname]";
728                    user_error("GenericDataSource::query_data() - failed: " . $msg);                    user_error("DataSource::Generic: query_data() - failed: " . $msg);
729                  }                  }
730                  array_push($args, $this->_query[classname]);                  array_push($args, $this->_query[classname]);
731                  break;                  break;
732              }              }
733   */   */
734              $query_args = array();              $query_args = array();
735                
736                 $msg_prefix = "DataSource::Generic::datasource_handler_buildoptions failed: ";
737               switch ($this->_query[abstract_type]) {               switch ($this->_query[abstract_type]) {
738                  case 'item':
739                    if (!$this->_query[nodename]) {
740                      $msg = "_query[vartype] == 'objects' requires _query[nodename]";
741                      user_error($msg_prefix . $msg);
742                    }
743                    $query_args[guid] = $this->_query[ident];
744                    $query_args[nodename] = $this->_query[nodename];
745                    break;
746                case 'list':                case 'list':
747                  if (!$this->_query[classname]) {                  if (!$this->_query[nodename]) {
748                    $msg = "_query[vartype] == 'objects' requires _query[classname]";                    $msg = "_query[vartype] == 'objects' requires _query[nodename]";
749                    user_error("GenericDataSource::query_data() - failed: " . $msg);                    user_error($msg_prefix . $msg);
750                  }                  }
751                  //array_push($query_args, $this->_query[classname]);                  //array_push($query_args, $this->_query[nodename]);
752                  $query_args[classname] = $this->_query[classname];                  $query_args[nodename] = $this->_query[nodename];
753                    if($this->_query[list_meta]) { $query_args[list_meta] = $this->_query[list_meta]; }
754                  break;                  break;
755                case 'item':                case 'tree':
756                  if (!$this->_query[classname]) {                  /*
757                    $msg = "_query[vartype] == 'objects' requires _query[classname]";                  if (!$this->_query[nodename]) {
758                    user_error("GenericDataSource::query_data() - failed: " . $msg);                    $msg = "_query[vartype] == 'objects' requires _query[nodename]";
759                      user_error($msg_prefix . $msg);
760                  }                  }
761                    */
762                  $query_args[guid] = $this->_query[ident];                  $query_args[guid] = $this->_query[ident];
763                  $query_args[classname] = $this->_query[classname];                  //$query_args[nodename] = $this->_query[nodename];
764                  break;                                break;
765                  default:
766                    $msg = "\$this->_query[abstract_type] could not be dispatched as 'item', 'list' or 'tree'.";
767                    user_error($msg_prefix . $msg);
768                    break;
769              }              }
770              if($this->_query[action] == 'write') {              
771                // filter???
772                if ($this->_query[filter]) {
773                  $query_args[filter] = $this->_query[filter];
774                }
775                
776                // dispatch action
777                if ($this->_query[action] == 'write') {
778               $query_args[action] = $this->_query[action];               $query_args[action] = $this->_query[action];
779               $query_args[data] = $this->_query[data];               $query_args[data] = $this->_query[data];
780                } elseif ($this->_query[action] == 'delete') {
781                 $query_args[action] = $this->_query[action];
782              }              }
783                
784              $args = array(              $args = array(
785                            'data_type' => $this->_query[abstract_type],                            'data_type' => $this->_query[abstract_type],
786                            'query_args' => $query_args                            'query_args' => $query_args
# Line 741  class DataSource_Generic extends DesignP Line 793  class DataSource_Generic extends DesignP
793              $command = 'querySchema';              $command = 'querySchema';
794              $args = array( $this->_query[filter] );              $args = array( $this->_query[filter] );
795              break;              break;
796                
797              // remoteMethod
798              case 'method':
799                $command = $this->_query[method];
800                $args = $this->_query[args];
801                break;
802    
803          }          }
804                
805          
806            // FIXME: bad behaviour?
807            if (!is_array($args)) { $args = array( $args ); }
808                    
809          /*          /*
810          $this->_query[rpc_command] = $command;          $this->_query[rpc_command] = $command;
# Line 778  class DataSource_Generic extends DesignP Line 840  class DataSource_Generic extends DesignP
840    
841    
842          function &fetch_result() {          function &fetch_result() {
843    
844          //print Dumper($this);
845                
846        $this->datasource_handler_buildoptions();        $this->datasource_handler_buildoptions();
847    
848        $call = $this->_locator->get_call();        $call = $this->_locator->get_call();
849    
850        //print Dumper($call);        //print Dumper($call);
851          //return;
852    
853        // pre-flight checks        // pre-flight checks
854          if (!$call[method]) {          if (!$call[method]) {
855            $msg = "Remote method is empty, please pass in proper metadata or check configuration.";            $msg = "Remote method is empty, please pass in proper metadata or check configuration.";
856                          user_error("GenericDataSource::query_data() - failed: " . $msg);                          user_error("DataSource::Generic: query_data() - failed: " . $msg);
857            return;            return;
858          }          }
859    

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.20

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