/[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.8 by jonen, Thu Mar 20 07:22:14 2003 UTC revision 1.14 by joko, Fri Apr 4 21:19:21 2003 UTC
# Line 15  Line 15 
15   * $Id$   * $Id$
16   *   *
17   * $Log$   * $Log$
18     * Revision 1.14  2003/04/04 21:19:21  joko
19     * modified exception handling (enhanced, purged redundant code)
20     *
21     * Revision 1.13  2003/04/04 02:37:14  jonen
22     * _query[action] == write
23     *
24     * Revision 1.12  2003/03/29 08:00:48  joko
25     * modified ErrorBoxing
26     *
27     * Revision 1.11  2003/03/28 06:45:26  joko
28     * VERBOSE mode
29     *
30     * Revision 1.10  2003/03/28 03:01:02  joko
31     * more fancy debugging-output
32     *
33     * Revision 1.9  2003/03/27 16:24:26  jonen
34     * + mugled namespace
35     * + added enhanced 'queryData'
36     *
37   * Revision 1.8  2003/03/20 07:22:14  jonen   * Revision 1.8  2003/03/20 07:22:14  jonen
38   * + modified case 'object' to 'objects'   * + modified case 'object' to 'objects'
39   *   (cause its loads all *objects* of a given classname)   *   (cause its loads all *objects* of a given classname)
# Line 462  class DataSource_Generic extends DesignP Line 481  class DataSource_Generic extends DesignP
481            case 'phpHtmlLib':            case 'phpHtmlLib':
482              //$adapter_arguments = $args[title];              //$adapter_arguments = $args[title];
483    
484              $this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataListSource');              $this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataSource');
485                            
486              // in order to let the Adapter communicate with the Proxy,              // in order to let the Adapter communicate with the Proxy,
487              // instantiate a wrapper method in a third namespace via              // instantiate a wrapper method in a third namespace via
# Line 667  class DataSource_Generic extends DesignP Line 686  class DataSource_Generic extends DesignP
686        // FIXME: abstract this some more (e.g. via a CommandMapper|Registry)        // FIXME: abstract this some more (e.g. via a CommandMapper|Registry)
687          switch ($this->_query[metatype]) {          switch ($this->_query[metatype]) {
688            case 'data':            case 'data':
689              //$command = 'queryData';              $command = 'queryData';
690              $command = 'getObjects';   // FIXME!!!              
691                //$command = 'getObjects';   // FIXME!!!
692              //$this->_locator->set_option('metadata.command', $command);              //$this->_locator->set_option('metadata.command', $command);
693    /*
694              $args = array();              $args = array();
695              switch ($this->_query[vartype]) {              switch ($this->_query[vartype]) {
696                case 'objects':                case 'objects':
# Line 680  class DataSource_Generic extends DesignP Line 701  class DataSource_Generic extends DesignP
701                  array_push($args, $this->_query[classname]);                  array_push($args, $this->_query[classname]);
702                  break;                  break;
703              }              }
704              break;   */
705                $query_args = array();
706                 switch ($this->_query[abstract_type]) {
707                  case 'list':
708                    if (!$this->_query[classname]) {
709                      $msg = "_query[vartype] == 'objects' requires _query[classname]";
710                      user_error("GenericDataSource::query_data() - failed: " . $msg);
711                    }
712                    //array_push($query_args, $this->_query[classname]);
713                    $query_args[classname] = $this->_query[classname];
714                    break;
715                  case 'item':
716                    if (!$this->_query[classname]) {
717                      $msg = "_query[vartype] == 'objects' requires _query[classname]";
718                      user_error("GenericDataSource::query_data() - failed: " . $msg);
719                    }
720                    $query_args[guid] = $this->_query[ident];
721                    $query_args[classname] = $this->_query[classname];
722                    break;              
723                }
724                if($this->_query[action] == 'write') {
725                 $query_args[action] = $this->_query[action];
726                 $query_args[data] = $this->_query[data];
727                }
728                $args = array(
729                              'data_type' => $this->_query[abstract_type],
730                              'query_args' => $query_args
731                              );
732               break;
733    
734              // querySchema
735            case 'schema':            case 'schema':
736                //print "Testing schema:" . "<br>";
737              $command = 'querySchema';              $command = 'querySchema';
738                $args = array( $this->_query[filter] );
739              break;              break;
740          }          }
741                
# Line 718  class DataSource_Generic extends DesignP Line 771  class DataSource_Generic extends DesignP
771                
772    }    }
773    
774    
775    
776          function &fetch_result() {          function &fetch_result() {
777                
778        $this->datasource_handler_buildoptions();        $this->datasource_handler_buildoptions();
779    
780        $method = $this->_locator->_call[_method];        $call = $this->_locator->get_call();
781        $args = $this->_locator->_call[_arguments];        //print Dumper($call);
782          
783        // pre-flight checks        // pre-flight checks
784          if (!$method) {          if (!$call[method]) {
785            $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.";
786                          user_error("GenericDataSource::query_data() - failed: " . $msg);                          user_error("GenericDataSource::query_data() - failed: " . $msg);
787            return;            return;
788          }          }
# Line 736  class DataSource_Generic extends DesignP Line 791  class DataSource_Generic extends DesignP
791    
792        // do remote call here and get result        // do remote call here and get result
793        // FIXME: handle synchronous/asynchronous mode here!!!        // FIXME: handle synchronous/asynchronous mode here!!!
794          $this->datasource_handler_call($method, $args);          $this->datasource_handler_call($call[method], $call[args]);
795                    
796                    
797          // TODO: ... = $this->poll_handler_result  and  $this->get_handler_result          // TODO: ... = $this->poll_handler_result  and  $this->get_handler_result
# Line 747  class DataSource_Generic extends DesignP Line 802  class DataSource_Generic extends DesignP
802          $this->_result_count = sizeof($this->_result);          $this->_result_count = sizeof($this->_result);
803    
804        // trace        // trace
805          if ($this->_debug[notice]) {          //if (constants::get('VERBOSE') && $this->_debug[notice]) {
806            if (constants::get('VERBOSE') or constants::get('ERRORS_ONLY')) {
807            //print "_result = " . Dumper($this->_result);            //print "_result = " . Dumper($this->_result);
808            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>";
809              $this->draw_status_box();
810          }          }
811            
812          return $this->_result;          return $this->_result;
813    
814          }          }
815    
816      function draw_status_box() {
817    
818        static $boxcount;
819        
820        $boxcount++;
821    
822        $box = container();
823    
824        // box style
825        $style = container(
826          html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'),
827          html_style("text/css", '.box_dsg { background: #20ab39; color: white; border: 2px black groove; width:640px; padding:10px; margin:40px; }')
828        );
829        $box->add( $style );
830        
831        // box content
832        $statusbox = html_div('box_dsg');
833        $statusbox->add( html_b("DataSource::Generic"), html_br() );
834        $locatorbox = html_div('box_dsg');
835        $locatorbox->set_id("locatorbox_$boxcount");
836        $locatorbox->add( Dumper($this->_locator) );
837        
838        // FIXME: ie/mozilla?
839        //$locatorbox->set_style('visibility:false;');
840        $locatorbox->set_style('display:none;');
841        
842        $statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), jsAnchor( 'toggle_vis', array("locatorbox_$boxcount"), '[show]'), $locatorbox, html_br() );
843        $call = $this->_locator->get_call();
844        $statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() );
845        if (sizeof($call[args])) {
846          $statusbox->add( html_span('boxlabel_darkgreen', "Arguments:"), Dumper($call[args]), html_br() );
847        }
848        $statusbox->add( html_span('boxlabel_darkgreen', "Count:"), $this->get_result_count(), html_br() );
849        $box->add( $statusbox );
850    
851        //print $box->render();
852        trace( $box );
853    
854      }
855    
856    
857    function &query_data() {    function &query_data() {
858      //print "query!<br/>";      //print "query!<br/>";
# Line 771  class DataSource_Generic extends DesignP Line 868  class DataSource_Generic extends DesignP
868    function &get_result() {    function &get_result() {
869      return $this->_result;      return $this->_result;
870    }    }
871      
872      function get_result_count() {
873        return $this->_result_count;
874      }
875                    
876  }  }
877    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.14

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