commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/geas doc/gcd/gcd.txt examples/python/query...


From: Treshna Enterprises
Subject: gnue/geas doc/gcd/gcd.txt examples/python/query...
Date: Thu, 28 Jun 2001 21:08:26 -0700

CVSROOT:        /cvs
Module name:    gnue
Changes by:     Treshna Enterprises <address@hidden>    01/06/28 21:08:26

Modified files:
        geas/doc/gcd   : gcd.txt 
        geas/examples/python: querytest.py 
        geas/lib/classdefs: classdata.c gcdparser.c gcdparser.h 
                            lparser.l yparser.y 
        geas/src       : connection.c query.c 
        geas/src/oql   : oql.c 

Log message:
        new feature: in GCD files, a class's ORDER BY may have an optional
        DESC after the field name, causing sorting to be done in reverse order.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/doc/gcd/gcd.txt.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/examples/python/querytest.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/classdata.c.diff?cvsroot=OldCVS&tr1=1.63&tr2=1.64&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/gcdparser.c.diff?cvsroot=OldCVS&tr1=1.40&tr2=1.41&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/gcdparser.h.diff?cvsroot=OldCVS&tr1=1.27&tr2=1.28&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/lparser.l.diff?cvsroot=OldCVS&tr1=1.26&tr2=1.27&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/yparser.y.diff?cvsroot=OldCVS&tr1=1.33&tr2=1.34&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/connection.c.diff?cvsroot=OldCVS&tr1=1.63&tr2=1.64&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/query.c.diff?cvsroot=OldCVS&tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/oql/oql.c.diff?cvsroot=OldCVS&tr1=1.63&tr2=1.64&r1=text&r2=text

Patches:
Index: gnue/geas/doc/gcd/gcd.txt
diff -u gnue/geas/doc/gcd/gcd.txt:1.2 gnue/geas/doc/gcd/gcd.txt:1.3
--- gnue/geas/doc/gcd/gcd.txt:1.2       Mon Apr  2 06:48:54 2001
+++ gnue/geas/doc/gcd/gcd.txt   Thu Jun 28 21:08:25 2001
@@ -8,7 +8,7 @@
 -----------------
 
 This is a brief summary. If I've gotten something wrong, please email
address@hidden so I can fix this document.
address@hidden so someone can fix this document.
 
 The full official grammar is in geas/lib/classdefs/yparser.y using the
 yacc grammar.
Index: gnue/geas/examples/python/querytest.py
diff -u gnue/geas/examples/python/querytest.py:1.2 
gnue/geas/examples/python/querytest.py:1.3
--- gnue/geas/examples/python/querytest.py:1.2  Mon Apr  2 18:23:10 2001
+++ gnue/geas/examples/python/querytest.py      Thu Jun 28 21:08:25 2001
@@ -9,8 +9,6 @@
 
 try:
     import CORBA
-    CORBA.load_idl("../../idl/geas.idl")
-    # import GEAS
     from GEAS import *
     import GEAS
 except ImportError,ex:
@@ -46,18 +44,18 @@
     print "set logic"
 
     f = GEAS.Query.Field( field="name",test=GEAS.Query.contains,
-        invert=CORBA.FALSE,casesensitive=CORBA.FALSE,value="nItEd" )
+        invert=CORBA.FALSE,casesensitive=CORBA.FALSE,value="a" )
     print "made field"
     q1.addField( f )
-    q2 = q1.newConstraint()
-    q2.logic = GEAS.Query.OR
-    f = GEAS.Query.Field( field="id",test=GEAS.Query.equals,
-        invert=CORBA.FALSE,casesensitive=CORBA.FALSE,value="US" )
-    q2.addField( f )
-    f = GEAS.Query.Field( field="id",test=GEAS.Query.equals,
-        invert=CORBA.FALSE,casesensitive=CORBA.FALSE,value="??" )
-    q2.addField( f )
-    print "added field"
+#    q2 = q1.newConstraint()
+#    q2.logic = GEAS.Query.OR
+#    f = GEAS.Query.Field( field="id",test=GEAS.Query.equals,
+#        invert=CORBA.FALSE,casesensitive=CORBA.FALSE,value="US" )
+#    q2.addField( f )
+#    f = GEAS.Query.Field( field="id",test=GEAS.Query.equals,
+#        invert=CORBA.FALSE,casesensitive=CORBA.FALSE,value="??" )
+#    q2.addField( f )
+#    print "added field"
 
     lst = con.executeQuery(q1)
     print "execution done"
Index: gnue/geas/lib/classdefs/classdata.c
diff -u gnue/geas/lib/classdefs/classdata.c:1.63 
gnue/geas/lib/classdefs/classdata.c:1.64
--- gnue/geas/lib/classdefs/classdata.c:1.63    Wed Jun 27 11:46:57 2001
+++ gnue/geas/lib/classdefs/classdata.c Thu Jun 28 21:08:25 2001
@@ -22,7 +22,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
 
-   $Id: classdata.c,v 1.63 2001/06/27 18:46:57 ntiffin Exp $
+   $Id: classdata.c,v 1.64 2001/06/29 04:08:25 treshna Exp $
    
 */
 
@@ -95,7 +95,8 @@
     {
       fprintf (out, "           istype: false\n");
     }
-  fprintf (out, "         order by: %s\n", container->orderby);
+  fprintf (out, "         order by: %s%s\n", container->orderby ,
+          (container->desc?" (descending)":"hello") );
   contents = container->contents;
   while (contents)
     {
@@ -2519,7 +2520,9 @@
             {
               fprintf (out, " ");
             }
-          fprintf (out, "ORDER BY %s", ((odl_container *) item)->orderby);
+          fprintf (out, "ORDER BY %s%s", ((odl_container *) item)->orderby ,
+                  ((odl_container *) item)->desc ? " (descending)" : "" );
+                  
           fprintf (out, "\n");
         }
       l = item->contents;
Index: gnue/geas/lib/classdefs/gcdparser.c
diff -u gnue/geas/lib/classdefs/gcdparser.c:1.40 
gnue/geas/lib/classdefs/gcdparser.c:1.41
--- gnue/geas/lib/classdefs/gcdparser.c:1.40    Wed Jun 27 11:46:57 2001
+++ gnue/geas/lib/classdefs/gcdparser.c Thu Jun 28 21:08:25 2001
@@ -22,7 +22,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
 
-   $Id: gcdparser.c,v 1.40 2001/06/27 18:46:57 ntiffin Exp $
+   $Id: gcdparser.c,v 1.41 2001/06/29 04:08:25 treshna Exp $
    
 */
 
@@ -115,6 +115,7 @@
       o->indexes = NULL;
       o->orderby = NULL;
       o->filename = NULL;
+      o->desc = FALSE;
     }
   return (o);
 }
Index: gnue/geas/lib/classdefs/gcdparser.h
diff -u gnue/geas/lib/classdefs/gcdparser.h:1.27 
gnue/geas/lib/classdefs/gcdparser.h:1.28
--- gnue/geas/lib/classdefs/gcdparser.h:1.27    Tue Jun  5 14:42:07 2001
+++ gnue/geas/lib/classdefs/gcdparser.h Thu Jun 28 21:08:25 2001
@@ -21,7 +21,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
 
-   $Id: gcdparser.h,v 1.27 2001/06/05 21:42:07 ntiffin Exp $
+   $Id: gcdparser.h,v 1.28 2001/06/29 04:08:25 treshna Exp $
    
 */
 
@@ -75,6 +75,7 @@
   GList                *parents;    /* list of (char *)                        
*/
   GList                *indexes;    /* list of (struct _odl_index *)           
*/
   char                 *filename;   /* filename that defined this container    
*/
+  gboolean              desc;       /* ORDER BY uses descending order          
*/
 };
 
 /** \struct _odl_item
Index: gnue/geas/lib/classdefs/lparser.l
diff -u gnue/geas/lib/classdefs/lparser.l:1.26 
gnue/geas/lib/classdefs/lparser.l:1.27
--- gnue/geas/lib/classdefs/lparser.l:1.26      Sat Jun  9 08:20:36 2001
+++ gnue/geas/lib/classdefs/lparser.l   Thu Jun 28 21:08:25 2001
@@ -24,7 +24,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    
-   $Id: lparser.l,v 1.26 2001/06/09 15:20:36 ntiffin Exp $
+   $Id: lparser.l,v 1.27 2001/06/29 04:08:25 treshna Exp $
 
 */
 #include "config.h"
@@ -305,6 +305,7 @@
 tooltip             { ST; if( expecting_datatype == 1 ) { expecting_datatype = 
0; return(TOOLTIP);    } else { yylval.string=g_strdup(yytext); return(SYMBOL); 
} }
 order               { ST; if( expecting_datatype == 1 ) { expecting_datatype = 
0; return(ORDER);      } else { yylval.string=g_strdup(yytext); return(SYMBOL); 
} }
 by                  { ST; if( expecting_datatype == 1 ) { expecting_datatype = 
0; return(BY);         } else { yylval.string=g_strdup(yytext); return(SYMBOL); 
} }
+desc                { ST; if( expecting_datatype == 1 ) { expecting_datatype = 
0; return(DESC);       } else { yylval.string=g_strdup(yytext); return(SYMBOL); 
} }
 
 [a-zA-Z][a-zA-Z0-9]*      { enum odl_datatype tmp;
                             ST;
Index: gnue/geas/lib/classdefs/yparser.y
diff -u gnue/geas/lib/classdefs/yparser.y:1.33 
gnue/geas/lib/classdefs/yparser.y:1.34
--- gnue/geas/lib/classdefs/yparser.y:1.33      Sat Jun  9 17:26:03 2001
+++ gnue/geas/lib/classdefs/yparser.y   Thu Jun 28 21:08:25 2001
@@ -60,7 +60,7 @@
 %token UNSIGNED TRIGGERTYPE ENUM HELP TOOLTIP
 %token LOOKUP LIST REFERENCE CALCULATED TRIGGER UNIQUE INDEX SINGLETON
 %token CTYPE MODULE CLASS EXTEND PUBLIC PROTECTED PRIVATE FINAL ABSTRACT
-%token NOT NUL READONLY ORDER BY
+%token NOT NUL READONLY ORDER BY DESC
 
 %token <string>   SYMBOL DATATYPE STRING
 %token <integer>  INTEGER
@@ -83,6 +83,7 @@
 %type <datasource> reference_data_source list_data_source lookup_data_source
 %type <string>     opt_help_fieldname help_fieldname stringlist language
 %type <uint>       opt_properties property properties
+%type <boolean>    optdesc
 
 %%
 
@@ -384,21 +385,21 @@
   |              body_item ';' dt_on      { $$ = $1; }
   ;
 
-body_item: opt_access class              { $$ = NULL; /* already handled */ }
-  |        opt_access type               { $$ = NULL; /* already handled */ }
-  |        opt_unique INDEX index        { $$ = NULL; /* already handled */ }
-  |        datatype new_field_list       { $$ = odl_reprocess_fields($1,$2); }
-  |        datatype method               { $$ = 
g_list_append(NULL,set_method_datatype($1,$2));  }
-  |        LOOKUP lookup                 { $$ = g_list_append(NULL,$2); }
-  |        LIST list                     { $$ = g_list_append(NULL,$2); }
-  |        REFERENCE reference           { $$ = g_list_append(NULL,$2); }
-  |        CALCULATED calculated         { $$ = NULL; /* TODO */ }
-  |        TRIGGER trigger               { $$ = NULL; /* TODO */ }
-  |        READONLY readonly             { $$ = NULL; /* TODO */ }
-  |        ENUM enum                     { $$ = NULL; /* already handled */ }
-  |        HELP help                     { $$ = NULL; /* already handled */ }
-  |        TOOLTIP tooltip               { $$ = NULL; /* already handled */ }
-  |        ORDER dt_on BY orderby        { $$ = NULL; /* already handled */ }
+body_item: opt_access class               { $$ = NULL; /* already handled */ }
+  |        opt_access type                { $$ = NULL; /* already handled */ }
+  |        opt_unique INDEX index         { $$ = NULL; /* already handled */ }
+  |        datatype new_field_list        { $$ = odl_reprocess_fields($1,$2); }
+  |        datatype method                { $$ = 
g_list_append(NULL,set_method_datatype($1,$2));  }
+  |        LOOKUP lookup                  { $$ = g_list_append(NULL,$2); }
+  |        LIST list                      { $$ = g_list_append(NULL,$2); }
+  |        REFERENCE reference            { $$ = g_list_append(NULL,$2); }
+  |        CALCULATED calculated          { $$ = NULL; /* TODO */ }
+  |        TRIGGER trigger                { $$ = NULL; /* TODO */ }
+  |        READONLY readonly              { $$ = NULL; /* TODO */ }
+  |        ENUM enum                      { $$ = NULL; /* already handled */ }
+  |        HELP help                      { $$ = NULL; /* already handled */ }
+  |        TOOLTIP tooltip                { $$ = NULL; /* already handled */ }
+  |        ORDER dt_on BY orderby         { $$ = NULL; /* already handled */ }
   ;
 
 index: '(' index_item_list ')' { if(current_pass == 2)
@@ -678,7 +679,12 @@
                                          }
   ;
 
-orderby: SYMBOL    { if( yycurrent_container->orderby )
-                         g_free( yycurrent_container->orderby );
-                     yycurrent_container->orderby = $1;
-                   }
+optdesc: /* */ { $$ = FALSE; }
+  |      DESC  { $$ = TRUE;  }
+  ;
+
+orderby: SYMBOL dt_on optdesc dt_off  { if( yycurrent_container->orderby )
+                                            g_free( 
yycurrent_container->orderby );
+                                        yycurrent_container->orderby = $1;
+                                       yycurrent_container->desc = $3;
+                                      }
Index: gnue/geas/src/connection.c
diff -u gnue/geas/src/connection.c:1.63 gnue/geas/src/connection.c:1.64
--- gnue/geas/src/connection.c:1.63     Mon Jun 25 20:01:26 2001
+++ gnue/geas/src/connection.c  Thu Jun 28 21:08:25 2001
@@ -19,7 +19,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
    
-   $Id: connection.c,v 1.63 2001/06/26 03:01:26 treshna Exp $
+   $Id: connection.c,v 1.64 2001/06/29 04:08:25 treshna Exp $
  
 */
 
@@ -869,6 +869,9 @@
   else
     reverse = FALSE;
   g_free (temp);
+
+  /* nasty, but hey, it should work */
+  if( c->desc ) reverse = !reverse;
 
   temp = oc_get_object_field (ob, "logic");
   if (temp[0] == '1')
Index: gnue/geas/src/oql/oql.c
diff -u gnue/geas/src/oql/oql.c:1.63 gnue/geas/src/oql/oql.c:1.64
--- gnue/geas/src/oql/oql.c:1.63        Tue Jun 12 21:28:21 2001
+++ gnue/geas/src/oql/oql.c     Thu Jun 28 21:08:25 2001
@@ -19,7 +19,7 @@
   along with GEAS; if not, write to the Free Software Foundation, Inc.,
   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-  $Id: oql.c,v 1.63 2001/06/13 04:28:21 treshna Exp $
+  $Id: oql.c,v 1.64 2001/06/29 04:08:25 treshna Exp $
 */
 
 #include "config.h"
@@ -534,6 +534,7 @@
   GList *tmp;
   char *loadclass = NULL;
   char *quoted;
+  odl_class *cl;
 
   if (q->classes)
     loadclass = q->classes->data;
@@ -587,7 +588,12 @@
       quoted = oql_quote_column (loadclass, q->orderby, db);
       g_string_append (buf, quoted);
       g_free (quoted);
-      if (q->reversesearch)
+    
+      /* if reverse : if descending, then sort in ascending order
+       * else       : if descending, then sort in descending order
+       */
+      cl = odl_find_class( all_classes , loadclass , NULL );
+      if ( (q->reversesearch && !cl->desc) || (!q->reversesearch && cl->desc) )
         g_string_append (buf, " DESC");
     }
 
Index: gnue/geas/src/query.c
diff -u gnue/geas/src/query.c:1.11 gnue/geas/src/query.c:1.12
--- gnue/geas/src/query.c:1.11  Tue Jun 12 12:12:30 2001
+++ gnue/geas/src/query.c       Thu Jun 28 21:08:25 2001
@@ -19,7 +19,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
    
-   $Id: query.c,v 1.11 2001/06/12 19:12:30 reinhard Exp $
+   $Id: query.c,v 1.12 2001/06/29 04:08:25 treshna Exp $
  
 */
 
@@ -401,6 +401,7 @@
       return;
     }
   GEAS_DataObject_setField (q, "classname", value, ev);
+
   CORBA_Object_release (q, ev);
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]