commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r7611 - in trunk/gnue-appserver: share src/gcd


From: johannes
Subject: [gnue] r7611 - in trunk/gnue-appserver: share src/gcd
Date: Fri, 17 Jun 2005 07:33:22 -0500 (CDT)

Author: johannes
Date: 2005-06-17 07:33:21 -0500 (Fri, 17 Jun 2005)
New Revision: 7611

Modified:
   trunk/gnue-appserver/share/gnue.gsd
   trunk/gnue-appserver/src/gcd/readgcd.py
Log:
Changed gnue-readgcd to use new writeSchema ()


Modified: trunk/gnue-appserver/share/gnue.gsd
===================================================================
--- trunk/gnue-appserver/share/gnue.gsd 2005-06-17 12:32:33 UTC (rev 7610)
+++ trunk/gnue-appserver/share/gnue.gsd 2005-06-17 12:33:21 UTC (rev 7611)
@@ -3,7 +3,7 @@
 <!--
   GNU Enterprise Application Server - Database Schema and Base Classes
  
-  Copyright 2001-2004 Free Software Foundation
+  Copyright 2001-2005 Free Software Foundation
  
   This file is part of GNU Enterprise
  
@@ -70,14 +70,12 @@
       </fields>
       <indexes/>
       <constraints>
-        <constraint name="fk_gnue_class_gnue_module" type="foreignkey">
-          <constraintfield name="gnue_module"/>
-          <constraintref name="gnue_id" table="gnue_module"/>
-        </constraint>
-        <constraint name="fk_gnue_class_gnue_filter" type="foreignkey">
-          <constraintfield name="gnue_filter"/>
-          <constraintref name="gnue_id" table="gnue_class"/>
-        </constraint>
+        <foreignkey name="fk_gnue_class_gnue_module" references="gnue_module">
+          <fkfield name="gnue_module" references="gnue_id"/>
+        </foreignkey>
+        <foreignkey name="fk_gnue_class_gnue_filter" references="gnue_class">
+          <fkfield name="gnue_filter" references="gnue_id"/>
+        </foreignkey>
       </constraints>
       <primarykey name="pk_gnue_class">
         <pkfield name="gnue_id"/>
@@ -111,14 +109,13 @@
       </fields>
       <indexes/>
       <constraints>
-        <constraint name="fk_gnue_property_gnue_class" type="foreignkey">
-          <constraintfield name="gnue_class"/>
-          <constraintref name="gnue_id" table="gnue_class"/>
-        </constraint>
-        <constraint name="fk_gnue_property_gnue_module" type="foreignkey">
-          <constraintfield name="gnue_module"/>
-          <constraintref name="gnue_id" table="gnue_module"/>
-        </constraint>
+        <foreignkey name="fk_gnue_property_gnue_class" references="gnue_class">
+          <fkfield name="gnue_class" references="gnue_id"/>
+        </foreignkey>
+        <foreignkey name="fk_gnue_property_gnue_module"
+                    references="gnue_module">
+          <fkfield name="gnue_module" references="gnue_id"/>
+        </foreignkey>
       </constraints>
       <primarykey name="pk_gnue_property">
         <pkfield name="gnue_id"/>
@@ -156,14 +153,13 @@
       </fields>
       <indexes/>
       <constraints>
-        <constraint name="fk_gnue_procedure_gnue_class" type="foreignkey">
-          <constraintfield name="gnue_class"/>
-          <constraintref name="gnue_id" table="gnue_class"/>
-        </constraint>
-        <constraint name="fk_gnue_procedure_gnue_module" type="foreignkey">
-          <constraintfield name="gnue_module"/>
-          <constraintref name="gnue_id" table="gnue_module"/>
-        </constraint>
+        <foreignkey name="fk_gnue_procedure_gnue_class" 
references="gnue_class">
+          <fkfield name="gnue_class" references="gnue_id"/>
+        </foreignkey>
+        <foreignkey name="fk_gnue_procedure_gnue_module"
+                    references="gnue_module">
+          <fkfield name="gnue_module" references="gnue_id"/>
+        </foreignkey>
       </constraints>
       <primarykey name="pk_gnue_procedure">
         <pkfield name="gnue_id"/>
@@ -193,10 +189,10 @@
       </fields>
       <indexes/>
       <constraints>
-        <constraint name="fk_gnue_parameter_gnue_procedure" type="foreignkey">
-          <constraintfield name="gnue_procedure"/>
-          <constraintref name="gnue_id" table="gnue_procedure"/>
-        </constraint>
+        <foreignkey name="fk_gnue_parameter_gnue_procedure"
+                    references="gnue_procedure">
+          <fkfield name="gnue_procedure" references="gnue_id"/>
+        </foreignkey>
       </constraints>
       <primarykey name="pk_gnue_parameter">
         <pkfield name="gnue_id"/>
@@ -230,10 +226,10 @@
       </fields>
       <indexes/>
       <constraints>
-        <constraint name="fk_gnue_label_gnue_property" type="foreignkey">
-          <constraintfield name="gnue_property"/>
-          <constraintref name="gnue_id" table="gnue_property"/>
-        </constraint>
+        <foreignkey name="fk_gnue_label_gnue_property"
+                    references="gnue_property">
+          <fkfield name="gnue_property" references="gnue_id"/>
+        </foreignkey>
       </constraints>
       <primarykey name="pk_gnue_label">
         <pkfield name="gnue_id"/>
@@ -258,10 +254,9 @@
       </fields>
       <indexes/>
       <constraints>
-        <constraint name="fk_gnue_message_gnue_module" type="foreignkey">
-          <constraintfield name="gnue_module"/>
-          <constraintref name="gnue_id" table="gnue_module"/>
-        </constraint>
+        <foreignkey name="fk_gnue_message_gnue_module" 
references="gnue_module">
+          <fkfield name="gnue_module" references="gnue_id"/>
+        </foreignkey>
       </constraints>
       <primarykey name="pk_gnue_message">
         <pkfield name="gnue_id"/>
@@ -276,11 +271,9 @@
     <!-- ================================================================= -->
 
     <tabledata name="gnue_module_dump" tablename="gnue_module">
-      <definition>
-        <column field="gnue_comment" type="string(70)"/>
-        <column field="gnue_id" type="string(32)"/>
-        <column field="gnue_name" type="string(35)"/>
-      </definition>
+      <primarykey name="pk_gnue_module">
+        <pkfield name="gnue_id"/>
+      </primarykey>
       <rows>
         <row>
           <value field="gnue_comment">GNU Enterprise System Management</value>
@@ -295,12 +288,9 @@
     <!-- ================================================================= -->
 
     <tabledata name="gnue_class_dump" tablename="gnue_class">
-      <definition>
-        <column field="gnue_comment" type="string(70)"/>
-        <column field="gnue_id" type="string(32)"/>
-        <column field="gnue_module" type="string(32)"/>
-        <column field="gnue_name" type="string(35)"/>
-      </definition>
+      <primarykey name="pk_gnue_class">
+        <pkfield name="gnue_id"/>
+      </primarykey>
       <rows>
         <row>
           <value field="gnue_comment">GNU Enterprise Business Object 
Class</value>
@@ -352,17 +342,9 @@
     <!-- ================================================================= -->
 
     <tabledata name="gnue_property_dump" tablename="gnue_property">
-      <definition>
-        <column field="gnue_class" type="string(32)"/>
-        <column field="gnue_comment" type="string(70)"/>
-        <column field="gnue_id" type="string(32)"/>
-        <column field="gnue_length" type="number(6)"/>
-        <column field="gnue_module" type="string(32)"/>
-        <column field="gnue_name" type="string(35)"/>
-        <column field="gnue_nullable" type="boolean"/>
-        <column field="gnue_scale" type="number(4)"/>
-        <column field="gnue_type" type="string(35)"/>
-      </definition>
+      <primarykey name="pk_gnue_property">
+        <pkfield name="gnue_id"/>
+      </primarykey>
       <rows>
 
         <!-- ============================================================ -->
@@ -869,19 +851,9 @@
     <!-- DATA: Procedures                                             -->
     <!-- ============================================================ -->
     <tabledata name="gnue_procedure_dump" tablename="gnue_procedure">
-      <definition>
-        <column field="gnue_class" type="string(32)"/>
-        <column field="gnue_code" type="string"/>
-        <column field="gnue_comment" type="string(70)"/>
-        <column field="gnue_id" type="string(32)"/>
-        <column field="gnue_language" type="string(10)"/>
-        <column field="gnue_length" type="number(6)"/>
-        <column field="gnue_module" type="string(32)"/>
-        <column field="gnue_name" type="string(35)"/>
-        <column field="gnue_nullable" type="boolean"/>
-        <column field="gnue_scale" type="number(4)"/>
-        <column field="gnue_type" type="string(35)"/>
-      </definition>
+      <primarykey name="pk_gnue_procedure">
+        <pkfield name="gnue_id"/>
+      </primarykey>
       <rows>
         <row>
           <value field="gnue_class">00000000000000000000000000000020</value>
@@ -907,15 +879,9 @@
     <!-- ================================================================= -->
 
     <tabledata name="gnue_parameter_dump" tablename="gnue_parameter">
-      <definition>
-        <column field="gnue_comment" type="string(70)"/>
-        <column field="gnue_id" type="string(32)"/>
-        <column field="gnue_length" type="number(6)"/>
-        <column field="gnue_name" type="string(35)"/>
-        <column field="gnue_procedure" type="string(32)"/>
-        <column field="gnue_scale" type="number(4)"/>
-        <column field="gnue_type" type="string(35)"/>
-      </definition>
+      <primarykey name="pk_gnue_parameter">
+        <pkfield name="gnue_id"/>
+      </primarykey>
       <rows>
         <row>
           <value 
field="gnue_procedure">00000000000000000000000000007001</value>

Modified: trunk/gnue-appserver/src/gcd/readgcd.py
===================================================================
--- trunk/gnue-appserver/src/gcd/readgcd.py     2005-06-17 12:32:33 UTC (rev 
7610)
+++ trunk/gnue-appserver/src/gcd/readgcd.py     2005-06-17 12:33:21 UTC (rev 
7611)
@@ -29,7 +29,7 @@
 from gnue.common.apps.i18n import translate as _        # for epydoc
 from gnue.common.apps.GClientApp import *
 from gnue.common.utils.FileUtils import openResource
-from gnue.common.datasources import GDataSource
+from gnue.common.datasources import GDataSource, GSchema
 from gnue.common.utils.uuid import UUID
 
 from gnue.appserver import VERSION
@@ -243,9 +243,10 @@
     self.lpProcedure  = {}        # class-name.module-name_name -> gnue_id
     self.__lpFilter   = {}        # fqName -> gnue_id
     self.__duplos     = {}        # fqName
+    self.__tables     = {}        # tablename -> GSTable instance
 
     # Data from gcd files
-    self.schema     = {}
+    self.schema     = GSchema.GSSchema ()
     self.modules    = {}
     self.classes    = {}
     self.properties = {}
@@ -333,14 +334,13 @@
     self._connections.loginToConnection (connection)
 
     print _("Updating schema ...")
-    code = connection.updateSchema (self.schema.values (), self._fileonly)
+    code = connection.writeSchema (self.schema, self._fileonly)
 
     if self._dump is not None:
       dest = open (self._dump, 'w')
 
-      for item in code:
-        for line in item:
-          dest.write (line + os.linesep)
+      for line in code:
+        dest.write (line + os.linesep)
 
       dest.close ()
 
@@ -561,21 +561,21 @@
     """
 
     ckey = item.fullName.lower ()
-    if not self.schema.has_key (ckey):
-      self.schema [ckey] = {'name': item.fullName, 'fields': []}
+    if not ckey in self.__tables:
+      parent = self.schema.findChildOfType ('GSTables') or \
+          GSchema.GSTables (self.schema, type = "table")
+      self.__tables [ckey] = GSchema.GSTable (parent, name = item.fullName)
+      pk = GSchema.GSPrimaryKey (self.__tables [ckey],
+                                                name = "pk_%s" % item.fullName)
+      GSchema.GSPKField (pk, name = u"gnue_id")
 
-    if item.action == 'create':
-      self.schema [ckey] ['primarykey'] = { \
-          'name'  : 'pk_%s' % item.fullName,
-          'fields': ['gnue_id']}
+    if item.action == "create" and ckey in self.__duplos:
+      raise DuplicateClassError, \
+          (item.fullName, self.__currentFile, self.__duplos [ckey])
 
-      if self.__duplos.has_key (ckey):
-        raise DuplicateClassError, \
-            (item.fullName, self.__currentFile, self.__duplos [ckey])
+    self.__duplos [ckey] = self.__currentFile
 
-      self.__duplos [ckey] = self.__currentFile
 
-
   # ---------------------------------------------------------------------------
   # Add an index to the schema definition
   # ---------------------------------------------------------------------------
@@ -587,13 +587,12 @@
     @param item: GCIndex instance with the index to be added
     """
 
-    classDef = self.schema [self.__currentClass.fullName.lower ()]
-    if not classDef.has_key ('indices'):
-      classDef ['indices'] = []
+    table  = self.__tables [self.__currentClass.fullName.lower ()]
+    parent = table.findChildOfType ('GSIndexes') or GSchema.GSIndexes (table)
 
-    classDef ['indices'].append ({'name'  : item.fullName,
-                                  'unique': item.unique,
-                                  'fields': item.fieldNames})
+    ix = GSchema.GSIndex (parent, name = item.fullName, unique = item.unique)
+    for field in item.fieldNames:
+      GSchema.GSIndexField (ix, name = field)
 
 
   # ---------------------------------------------------------------------------
@@ -632,7 +631,8 @@
     """
 
     parent = item.getParent ()
-    classDef = self.schema [parent.fullName.lower ()]
+    table  = self.__tables [parent.fullName.lower ()]
+    master = table.findChildOfType ('GSFields') or GSchema.GSFields (table)
 
     pDef = {'name'    : item.fullName,
             'type'    : item.datatype,
@@ -641,19 +641,18 @@
     if item.length: pDef ['length']    = item.length
     if item.scale:  pDef ['precision'] = item.scale
 
-    classDef ['fields'].append (pDef)
+    GSchema.GSField (master, **pDef)
 
     # If the property is a reference to another class, add a constraint to the
     # class definition
     if item.isReference:
-      if not classDef.has_key ('constraints'):
-        classDef ['constraints'] = []
+      master = table.findChildOfType ('GSConstraints') or \
+                                                  GSchema.GSConstraints (table)
+      fkey = GSchema.GSForeignKey (master,
+          name = "fk_%s_%s" % (parent.fullName, item.fullName),
+          references = item.type)
 
-      classDef ['constraints'].append ( \
-          {'name'     : "fk_%s_%s" % (parent.fullName, item.fullName),
-           'fields'   : [item.fullName],
-           'reftable' : item.type,
-           'reffields': ['gnue_id']})
+      GSchema.GSFKField (fkey, name = item.fullName, references = u"gnue_id")
 
 
   # ---------------------------------------------------------------------------





reply via email to

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