/[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.10 by joko, Fri Mar 28 03:01:02 2003 UTC revision 1.16 by joko, Tue Apr 8 17:55:20 2003 UTC
# Line 15  Line 15 
15   * $Id$   * $Id$
16   *   *
17   * $Log$   * $Log$
18     * Revision 1.16  2003/04/08 17:55:20  joko
19     * CHANGE: renamed property 'datasource' to 'transport'
20     * NEW: new case 'method' in 'function datasource_handler_buildoptions'
21     * minor fixes: updated logging/debugging messages
22     *
23     * Revision 1.15  2003/04/06 04:46:33  joko
24     * renamed linking function
25     * mozilla fixes
26     *
27     * Revision 1.14  2003/04/04 21:19:21  joko
28     * modified exception handling (enhanced, purged redundant code)
29     *
30     * Revision 1.13  2003/04/04 02:37:14  jonen
31     * _query[action] == write
32     *
33     * Revision 1.12  2003/03/29 08:00:48  joko
34     * modified ErrorBoxing
35     *
36     * Revision 1.11  2003/03/28 06:45:26  joko
37     * VERBOSE mode
38     *
39   * Revision 1.10  2003/03/28 03:01:02  joko   * Revision 1.10  2003/03/28 03:01:02  joko
40   * more fancy debugging-output   * more fancy debugging-output
41   *   *
# Line 267  class DataSource_Generic extends DesignP Line 288  class DataSource_Generic extends DesignP
288      * other presets.      * other presets.
289      *      *
290      * See '_buildLocator' which acts as a dispatcher      * See '_buildLocator' which acts as a dispatcher
291      * depending on $_options[datasource].      * depending on $_options[transport].
292      * (main dispatching level)      * (main dispatching level)
293      *      *
294      * The structure of a full blown locator looks like this:      * The structure of a full blown locator looks like this:
# Line 356  class DataSource_Generic extends DesignP Line 377  class DataSource_Generic extends DesignP
377          function DataSource_Generic( &$locator, $query ) {          function DataSource_Generic( &$locator, $query ) {
378    
379                  // copy parameter from query to locator                  // copy parameter from query to locator
380                  //$this->_locator->merge_to($this->_locator, array( datasource_type => $query[datasource] ), '_');                  //$this->_locator->merge_to($this->_locator, array( datasource_type => $query[transport] ), '_');
381                  //$this->_locator->_datasource_type = $query[datasource];                  //$this->_locator->_datasource_type = $query[transport];
382                  //$locator[_datasource_type] = $query[datasource];                  //$locator[_datasource_type] = $query[transport];
383                                    
384        /**        /**
385         * <!-- Autodia -->         * <!-- Autodia -->
# Line 368  class DataSource_Generic extends DesignP Line 389  class DataSource_Generic extends DesignP
389         */         */
390    
391                  // build master locator                  // build master locator
392                  $this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[datasource] ) );                  $this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[transport] ) );
393                  //exit;                  //exit;
394                  //$this->_locator = php::mkComponent('DataSource::Locator');                  //$this->_locator = php::mkComponent('DataSource::Locator');
395                                    
# Line 405  class DataSource_Generic extends DesignP Line 426  class DataSource_Generic extends DesignP
426      // pre-flight: check locator metadata      // pre-flight: check locator metadata
427        //$locator->build();        //$locator->build();
428        if (!$this->_locator->check()) {        if (!$this->_locator->check()) {
429          user_error("locator-check failed.");          user_error("DataSource::Generic: locator-check failed." . "<br/>" . "Locator was: " . Dumper($this->_locator) );
430          exit;          //exit;
431           //return;           return;
432        }        }
433    
434  //exit;  //exit;
# Line 479  class DataSource_Generic extends DesignP Line 500  class DataSource_Generic extends DesignP
500    
501              break;              break;
502            default:            default:
503              user_error("DataSource::GenericDataSource: no Adapter could be selected!");              user_error("DataSource::Generic: no Adapter could be selected!");
504              break;              break;
505          }          }
506    
# Line 675  class DataSource_Generic extends DesignP Line 696  class DataSource_Generic extends DesignP
696          switch ($this->_query[metatype]) {          switch ($this->_query[metatype]) {
697            case 'data':            case 'data':
698              $command = 'queryData';              $command = 'queryData';
699                
700              //$command = 'getObjects';   // FIXME!!!              //$command = 'getObjects';   // FIXME!!!
701              //$this->_locator->set_option('metadata.command', $command);              //$this->_locator->set_option('metadata.command', $command);
702  /*  /*
# Line 683  class DataSource_Generic extends DesignP Line 705  class DataSource_Generic extends DesignP
705                case 'objects':                case 'objects':
706                  if (!$this->_query[classname]) {                  if (!$this->_query[classname]) {
707                    $msg = "_query[vartype] == 'objects' requires _query[classname]";                    $msg = "_query[vartype] == 'objects' requires _query[classname]";
708                    user_error("GenericDataSource::query_data() - failed: " . $msg);                    user_error("DataSource::Generic: query_data() - failed: " . $msg);
709                  }                  }
710                  array_push($args, $this->_query[classname]);                  array_push($args, $this->_query[classname]);
711                  break;                  break;
# Line 694  class DataSource_Generic extends DesignP Line 716  class DataSource_Generic extends DesignP
716                case 'list':                case 'list':
717                  if (!$this->_query[classname]) {                  if (!$this->_query[classname]) {
718                    $msg = "_query[vartype] == 'objects' requires _query[classname]";                    $msg = "_query[vartype] == 'objects' requires _query[classname]";
719                    user_error("GenericDataSource::query_data() - failed: " . $msg);                    user_error("DataSource::Generic: query_data() - failed: " . $msg);
720                  }                  }
721                  //array_push($query_args, $this->_query[classname]);                  //array_push($query_args, $this->_query[classname]);
722                  $query_args[classname] = $this->_query[classname];                  $query_args[classname] = $this->_query[classname];
# Line 702  class DataSource_Generic extends DesignP Line 724  class DataSource_Generic extends DesignP
724                case 'item':                case 'item':
725                  if (!$this->_query[classname]) {                  if (!$this->_query[classname]) {
726                    $msg = "_query[vartype] == 'objects' requires _query[classname]";                    $msg = "_query[vartype] == 'objects' requires _query[classname]";
727                    user_error("GenericDataSource::query_data() - failed: " . $msg);                    user_error("DataSource::Generic: query_data() - failed: " . $msg);
728                  }                  }
729                  $query_args[guid] = $this->_query[ident];                  $query_args[guid] = $this->_query[ident];
730                  $query_args[classname] = $this->_query[classname];                  $query_args[classname] = $this->_query[classname];
731                  break;                                break;              
732              }              }
733                if($this->_query[action] == 'write') {
734                 $query_args[action] = $this->_query[action];
735                 $query_args[data] = $this->_query[data];
736                }
737              $args = array(              $args = array(
738                            'data_type' => $this->_query[abstract_type],                            'data_type' => $this->_query[abstract_type],
739                            'query_args' => $query_args                            'query_args' => $query_args
# Line 718  class DataSource_Generic extends DesignP Line 744  class DataSource_Generic extends DesignP
744            case 'schema':            case 'schema':
745              //print "Testing schema:" . "<br>";              //print "Testing schema:" . "<br>";
746              $command = 'querySchema';              $command = 'querySchema';
747                $args = array( $this->_query[filter] );
748                break;
749                
750              // remoteMethod
751              case 'method':
752                $command = $this->_query[method];
753                $args = $this->_query[args];
754              break;              break;
755    
756          }          }
757                
758          
759            // FIXME: bad behaviour?
760            if (!is_array($args)) { $args = array( $args ); }
761                    
762          /*          /*
763          $this->_query[rpc_command] = $command;          $this->_query[rpc_command] = $command;
# Line 753  class DataSource_Generic extends DesignP Line 790  class DataSource_Generic extends DesignP
790                
791    }    }
792    
793    
794    
795          function &fetch_result() {          function &fetch_result() {
796                
797        $this->datasource_handler_buildoptions();        $this->datasource_handler_buildoptions();
798    
799        $method = $this->_locator->_call[_method];        $call = $this->_locator->get_call();
800        $args = $this->_locator->_call[_arguments];        //print Dumper($call);
801          
802        // pre-flight checks        // pre-flight checks
803          if (!$method) {          if (!$call[method]) {
804            $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.";
805                          user_error("GenericDataSource::query_data() - failed: " . $msg);                          user_error("DataSource::Generic: query_data() - failed: " . $msg);
806            return;            return;
807          }          }
808    
# Line 771  class DataSource_Generic extends DesignP Line 810  class DataSource_Generic extends DesignP
810    
811        // do remote call here and get result        // do remote call here and get result
812        // FIXME: handle synchronous/asynchronous mode here!!!        // FIXME: handle synchronous/asynchronous mode here!!!
813          $this->datasource_handler_call($method, $args);          $this->datasource_handler_call($call[method], $call[args]);
814                    
815                    
816          // TODO: ... = $this->poll_handler_result  and  $this->get_handler_result          // TODO: ... = $this->poll_handler_result  and  $this->get_handler_result
# Line 782  class DataSource_Generic extends DesignP Line 821  class DataSource_Generic extends DesignP
821          $this->_result_count = sizeof($this->_result);          $this->_result_count = sizeof($this->_result);
822    
823        // trace        // trace
824          if ($this->_debug[notice]) {          //if (constants::get('VERBOSE') && $this->_debug[notice]) {
825            if (constants::get('VERBOSE') or constants::get('ERRORS_ONLY')) {
826            //print "_result = " . Dumper($this->_result);            //print "_result = " . Dumper($this->_result);
827            print "<div><b><font color=\"darkgreen\">Debug:</font></b> DataSource::Generic->_result_count = <b>" . $this->_result_count . "</b></div>";            //print "<div><b><font color=\"darkgreen\">Debug:</font></b> DataSource::Generic->_result_count = <b>" . $this->_result_count . "</b></div>";
828              $this->draw_status_box();
829          }          }
830            
831          return $this->_result;          return $this->_result;
832    
833          }          }
834    
835      function draw_status_box() {
836    
837        static $boxcount;
838        
839        $boxcount++;
840    
841        $box = container();
842    
843        // box style
844        $style = container(
845          html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'),
846          html_style("text/css", '.box_dsg { background: #20ab39; color: white; border: 2px black groove; width:640px; padding:10px; margin:40px; }')
847        );
848        $box->add( $style );
849        
850        // box content
851        $statusbox = html_div('box_dsg');
852        $statusbox->add( html_b("DataSource::Generic"), html_br() );
853        $locatorbox = html_div('box_dsg');
854        $locatorbox->set_id("locatorbox_$boxcount");
855        $locatorbox->add( Dumper($this->_locator) );
856        
857        // FIXME: ie/mozilla?
858        //$locatorbox->set_style('display:none;');
859        //$locatorbox->set_style('visibility:hidden;');
860        // already duplicate inside Tracer!!!
861        $locatorbox->set_style('visibility:hidden; position:absolute; z-index:1; margin-top:30px; padding:5px;');
862        
863        $statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), link::js_function( 'toggleVisibility', array("locatorbox_$boxcount"), '[show]'), $locatorbox, html_br() );
864        $call = $this->_locator->get_call();
865        $statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() );
866        if (sizeof($call[args])) {
867          $statusbox->add( html_span('boxlabel_darkgreen', "Arguments:"), Dumper($call[args]), html_br() );
868        }
869        $statusbox->add( html_span('boxlabel_darkgreen', "Count:"), $this->get_result_count(), html_br() );
870        $box->add( $statusbox );
871    
872        //print $box->render();
873        trace( $box );
874    
875      }
876    
877    
878    function &query_data() {    function &query_data() {
879      //print "query!<br/>";      //print "query!<br/>";
# Line 806  class DataSource_Generic extends DesignP Line 889  class DataSource_Generic extends DesignP
889    function &get_result() {    function &get_result() {
890      return $this->_result;      return $this->_result;
891    }    }
892      
893      function get_result_count() {
894        return $this->_result_count;
895      }
896                    
897  }  }
898    

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.16

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