/[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.23 by jonen, Mon Jul 14 10:02:32 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.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   * Revision 1.15  2003/04/06 04:46:33  joko
47   * renamed linking function   * renamed linking function
48   * mozilla fixes   * mozilla fixes
# Line 86  Line 114 
114   *   *
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
  * </pre>  
117   *   *
118   */   */
119    
# Line 283  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 372  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 -->         * <!-- Autodia -->
# Line 384  class DataSource_Generic extends DesignP Line 411  class DataSource_Generic extends DesignP
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 421  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;
# Line 482  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::DataSource');
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 700  class DataSource_Generic extends DesignP Line 734  class DataSource_Generic extends DesignP
734                case 'objects':                case 'objects':
735                  if (!$this->_query[classname]) {                  if (!$this->_query[classname]) {
736                    $msg = "_query[vartype] == 'objects' 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   */   */
743              $query_args = array();              $query_args = array();
744                
745                 $msg_prefix = "DataSource::Generic::datasource_handler_buildoptions failed: ";
746               switch ($this->_query[abstract_type]) {               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':                case 'list':
763                  if (!$this->_query[classname]) {                  if (!$this->_query[nodename]) {
764                    $msg = "_query[vartype] == 'objects' requires _query[classname]";                    $msg = "_query[vartype] == 'objects' requires _query[nodename]";
765                    user_error("GenericDataSource::query_data() - failed: " . $msg);                    user_error($msg_prefix . $msg);
766                  }                  }
767                  //array_push($query_args, $this->_query[classname]);                  //array_push($query_args, $this->_query[nodename]);
768                  $query_args[classname] = $this->_query[classname];                  $query_args[nodename] = $this->_query[nodename];
769                    if($this->_query[list_meta]) { $query_args[list_meta] = $this->_query[list_meta]; }
770                  break;                  break;
771                case 'item':                case 'tree':
772                  if (!$this->_query[classname]) {                  /*
773                    $msg = "_query[vartype] == 'objects' requires _query[classname]";                  if (!$this->_query[nodename]) {
774                    user_error("GenericDataSource::query_data() - failed: " . $msg);                    $msg = "_query[vartype] == 'objects' requires _query[nodename]";
775                      user_error($msg_prefix . $msg);
776                  }                  }
777                    */
778                  $query_args[guid] = $this->_query[ident];                  $query_args[guid] = $this->_query[ident];
779                  $query_args[classname] = $this->_query[classname];                  //$query_args[nodename] = $this->_query[nodename];
780                  break;                                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              if($this->_query[action] == 'write') {              
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];               $query_args[action] = $this->_query[action];
797               $query_args[data] = $this->_query[data];               $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(              $args = array(
805                            'data_type' => $this->_query[abstract_type],                            'data_type' => $this->_query[abstract_type],
806                            'query_args' => $query_args                            'query_args' => $query_args
# Line 741  class DataSource_Generic extends DesignP Line 813  class DataSource_Generic extends DesignP
813              $command = 'querySchema';              $command = 'querySchema';
814              $args = array( $this->_query[filter] );              $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 778  class DataSource_Generic extends DesignP Line 864  class DataSource_Generic extends DesignP
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        $call = $this->_locator->get_call();        $call = $this->_locator->get_call();
873    
874        //print Dumper($call);        //print Dumper($call);
875          //return;
876    
877        // pre-flight checks        // pre-flight checks
878          if (!$call[method]) {          if (!$call[method]) {
879            $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.";
880                          user_error("GenericDataSource::query_data() - failed: " . $msg);                          user_error("DataSource::Generic: query_data() - failed: " . $msg);
881            return;            return;
882          }          }
883    

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

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