/[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.13 by jonen, Fri Apr 4 02:37:14 2003 UTC
# Line 15  Line 15 
15   * $Id$   * $Id$
16   *   *
17   * $Log$   * $Log$
18     * Revision 1.13  2003/04/04 02:37:14  jonen
19     * _query[action] == write
20     *
21     * Revision 1.12  2003/03/29 08:00:48  joko
22     * modified ErrorBoxing
23     *
24     * Revision 1.11  2003/03/28 06:45:26  joko
25     * VERBOSE mode
26     *
27     * Revision 1.10  2003/03/28 03:01:02  joko
28     * more fancy debugging-output
29     *
30     * Revision 1.9  2003/03/27 16:24:26  jonen
31     * + mugled namespace
32     * + added enhanced 'queryData'
33     *
34   * Revision 1.8  2003/03/20 07:22:14  jonen   * Revision 1.8  2003/03/20 07:22:14  jonen
35   * + modified case 'object' to 'objects'   * + modified case 'object' to 'objects'
36   *   (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 478  class DataSource_Generic extends DesignP
478            case 'phpHtmlLib':            case 'phpHtmlLib':
479              //$adapter_arguments = $args[title];              //$adapter_arguments = $args[title];
480    
481              $this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataListSource');              $this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataSource');
482                            
483              // in order to let the Adapter communicate with the Proxy,              // in order to let the Adapter communicate with the Proxy,
484              // 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 683  class DataSource_Generic extends DesignP
683        // FIXME: abstract this some more (e.g. via a CommandMapper|Registry)        // FIXME: abstract this some more (e.g. via a CommandMapper|Registry)
684          switch ($this->_query[metatype]) {          switch ($this->_query[metatype]) {
685            case 'data':            case 'data':
686              //$command = 'queryData';              $command = 'queryData';
687              $command = 'getObjects';   // FIXME!!!              
688                //$command = 'getObjects';   // FIXME!!!
689              //$this->_locator->set_option('metadata.command', $command);              //$this->_locator->set_option('metadata.command', $command);
690    /*
691              $args = array();              $args = array();
692              switch ($this->_query[vartype]) {              switch ($this->_query[vartype]) {
693                case 'objects':                case 'objects':
# Line 680  class DataSource_Generic extends DesignP Line 698  class DataSource_Generic extends DesignP
698                  array_push($args, $this->_query[classname]);                  array_push($args, $this->_query[classname]);
699                  break;                  break;
700              }              }
701              break;   */
702                $query_args = array();
703                 switch ($this->_query[abstract_type]) {
704                  case 'list':
705                    if (!$this->_query[classname]) {
706                      $msg = "_query[vartype] == 'objects' requires _query[classname]";
707                      user_error("GenericDataSource::query_data() - failed: " . $msg);
708                    }
709                    //array_push($query_args, $this->_query[classname]);
710                    $query_args[classname] = $this->_query[classname];
711                    break;
712                  case 'item':
713                    if (!$this->_query[classname]) {
714                      $msg = "_query[vartype] == 'objects' requires _query[classname]";
715                      user_error("GenericDataSource::query_data() - failed: " . $msg);
716                    }
717                    $query_args[guid] = $this->_query[ident];
718                    $query_args[classname] = $this->_query[classname];
719                    break;              
720                }
721                if($this->_query[action] == 'write') {
722                 $query_args[action] = $this->_query[action];
723                 $query_args[data] = $this->_query[data];
724                }
725                $args = array(
726                              'data_type' => $this->_query[abstract_type],
727                              'query_args' => $query_args
728                              );
729               break;
730    
731              // querySchema
732            case 'schema':            case 'schema':
733                //print "Testing schema:" . "<br>";
734              $command = 'querySchema';              $command = 'querySchema';
735              break;              break;
736          }          }
# Line 718  class DataSource_Generic extends DesignP Line 767  class DataSource_Generic extends DesignP
767                
768    }    }
769    
770    
771    
772          function &fetch_result() {          function &fetch_result() {
773                
774        $this->datasource_handler_buildoptions();        $this->datasource_handler_buildoptions();
775    
776        $method = $this->_locator->_call[_method];        $call = $this->_locator->get_call();
777        $args = $this->_locator->_call[_arguments];        //print Dumper($call);
778          
779        // pre-flight checks        // pre-flight checks
780          if (!$method) {          if (!$call[method]) {
781            $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.";
782                          user_error("GenericDataSource::query_data() - failed: " . $msg);                          user_error("GenericDataSource::query_data() - failed: " . $msg);
783            return;            return;
784          }          }
# Line 736  class DataSource_Generic extends DesignP Line 787  class DataSource_Generic extends DesignP
787    
788        // do remote call here and get result        // do remote call here and get result
789        // FIXME: handle synchronous/asynchronous mode here!!!        // FIXME: handle synchronous/asynchronous mode here!!!
790          $this->datasource_handler_call($method, $args);          $this->datasource_handler_call($call[method], $call[args]);
791                    
792                    
793          // 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 798  class DataSource_Generic extends DesignP
798          $this->_result_count = sizeof($this->_result);          $this->_result_count = sizeof($this->_result);
799    
800        // trace        // trace
801          if ($this->_debug[notice]) {          //if (constants::get('VERBOSE') && $this->_debug[notice]) {
802            if (constants::get('VERBOSE') or constants::get('ERRORS_ONLY')) {
803            //print "_result = " . Dumper($this->_result);            //print "_result = " . Dumper($this->_result);
804            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>";
805              $this->draw_status_box();
806          }          }
807            
808          return $this->_result;          return $this->_result;
809    
810          }          }
811    
812      function draw_status_box() {
813    
814        static $boxcount;
815        
816        $boxcount++;
817    
818        $box = container();
819    
820        // box client code (javascript)
821        $code_js = "
822        <script language=\"javascript\">
823        function toggle_vis(id) {
824          elem = eval('document.all.' + id);
825          status = elem.style.getAttribute('display');
826          if (status == 'none') {
827            elem.style.setAttribute('display', 'block');
828          } else {
829            elem.style.setAttribute('display', 'none');
830          }
831        }
832        </script>
833        ";
834        //$script = html_script($code_js);
835        //print $script->render();
836        $box->add( $code_js );
837        
838        // box style
839        $style = container(
840          html_style("text/css", '.boxlabel_darkgreen { color: darkgreen; font-weight:bold; }'),
841          html_style("text/css", '.box_dsg { background: #20ab39; color: white; border: 2px black groove; width:640px; padding:10px; margin:40px; }')
842        );
843        $box->add( $style );
844        
845        // box content
846        $statusbox = html_div('box_dsg');
847        $statusbox->add( html_b("DataSource::Generic"), html_br() );
848        $locatorbox = html_div('box_dsg');
849        $locatorbox->set_id("locatorbox_$boxcount");
850        $locatorbox->add( Dumper($this->_locator) );
851        //$locatorbox->set_style('visibility:false;');
852        $locatorbox->set_style('display:none;');
853        
854        $statusbox->add( html_span('boxlabel_darkgreen', "Locator:"), html_a("javascript:toggle_vis('locatorbox_$boxcount');", '[show]'), $locatorbox, html_br() );
855        $call = $this->_locator->get_call();
856        $statusbox->add( html_span('boxlabel_darkgreen', "Method:"), $call[method], html_br() );
857        if (sizeof($call[args])) {
858          $statusbox->add( html_span('boxlabel_darkgreen', "Arguments:"), Dumper($call[args]), html_br() );
859        }
860        $statusbox->add( html_span('boxlabel_darkgreen', "Count:"), $this->get_result_count(), html_br() );
861        $box->add( $statusbox );
862    
863        print $box->render();
864    
865      }
866    
867    
868    function &query_data() {    function &query_data() {
869      //print "query!<br/>";      //print "query!<br/>";
# Line 771  class DataSource_Generic extends DesignP Line 879  class DataSource_Generic extends DesignP
879    function &get_result() {    function &get_result() {
880      return $this->_result;      return $this->_result;
881    }    }
882      
883      function get_result_count() {
884        return $this->_result_count;
885      }
886                    
887  }  }
888    

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

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