Santiago Payà Miralta avatar Santiago Payà Miralta committed b1bfbf4

More weekendWork.

Comments (0)

Files changed (5)

control/genet_creator.py

 from model.class_edge import edge
 from model.class_node import node
 from model.db_connection import db
-from model.db_schema import *
+from model import db_schema
+from control import genet_global
 
 ################################################################################
 # Create tables.
 def createLevel(description):
     """
     Create one level in the network data model. The level primary key is
-    created here with the sequence number padded on the left with zeros.
+    used to tag the table.
 
     @param description of the level.
+    @returns queries statements and results.
     """
     st = "INSERT INTO gn____levels(description) " \
         "VALUES ('" + description + "') " \
         "RETURNING id;"
     level = db.query(st).getresult()[0][0]
-    level = str(level).zfill(2)
+    tag_level = genet_global.tagName(level)
     
     # This should not be necessary.
-    ret = dropLevelTables(level)
+    ret = db_schema.dropLevelTables(tag_level)
 
     # Create the layer tables.
-    ret = ret, createLevelTables(level)
+    ret = ret, db_schema.createLevelTables(tag_level)
     return ret
 
 def createEdgeType(level, description):
     """
-    Create one edge type. Gets the number of types in the 'edge_types'
-    table and adds one padding on the left with zeros. Construct the 
-    new tablename of type with the new type.
+    Create one edge type. Construct the new tablename of type with the new type.
 
     @param level in which the new type is added.
     @param description of the type.
     """
-    st= "SELECT count(type) FROM gn____edge_types;"
-    n = db.query(st).getresult()[0][0]
-    new_type = str(n + 1).zfill(2)
-    new_tablename = "gn_" + level + "_edge_type_" + new_type
+    st = "INSERT INTO gn____edge_types(level, description) " \
+        "VALUES (" + level + ", '" + description + "') " \
+        "RETURNING ID;"
+    id = db.query(st).getresult()[0][0]
+    ret = st, id
 
-    st = "INSERT INTO gn____edge_types(type, level, tablename, description) " \
-        "VALUES ('" \
-        + new_type + "', '" \
-        + level + "', '" \
-        + new_tablename + "', '" \
-        + description + "');"
-    return st, db.query(st)
+    # Update tablename with the level and id.
+    tag_level = genet_global.tagName(level)
+    tag_id = genet_global.tagName(id)
+    tablename = "gn_" + tag_level + "_edges_type_" + tag_id
 
+    st = "UPDATE gn____edge_types " \
+        "SET tablename = '" + tablename + "' " \
+        "WHERE id = " + str(id) + ";"
+    ret = ret, st, db.query(st)
+
+    # Create the table.
+    ret = ret, db_schema.createEdgeTypeTable(tag_level, tablename)
+    
+    return ret
+    
+def createNodeType(level, description):
+    """
+    Create one edge type. Construct the new tablename of type with the new type.
+
+    @param level in which the new type is added.
+    @param description of the type.
+    """
+    st = "INSERT INTO gn____node_types(level, description) " \
+        "VALUES (" + level + ", '" + description + "') " \
+        "RETURNING ID;"
+    id = db.query(st).getresult()[0][0]
+    ret = st, id
+
+    # Update tablename with the level and id.
+    tag_level = genet_global.tagName(level)
+    tag_id = genet_global.tagName(id)
+    tablename = "gn_" + tag_level + "_nodes_type_" + tag_id
+
+    st = "UPDATE gn____node_types " \
+        "SET tablename = '" + tablename + "' " \
+        "WHERE id = " + str(id) + ";"
+    ret = ret, st, db.query(st)
+
+    # Create the table.
+    ret = ret, db_schema.createNodeTypeTable(tag_level, tablename)
+    
+    return ret
+    
 def connectNodes(level, idnA, idnB):
     """
     TODO

control/genet_global.py

 """
 """
 
+from model.db_connection import db
 from model import db_schema
 
 #GN_DEBUG = True
 
 ##
-# *** DANGER ***
-# startSchema() deletes db schema.
+# *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** 
+# Deletes db schema.
+# *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** 
 def restartSchema():
     """
-    *** DANGER ***
-    Deletes all the database.
+    *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** 
+    Restarts all the database sequences and schema tables.
+    *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** 
+
     """
     db_schema.dropSchema()
     db_schema.startSchema()
 
+##
+# *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** 
+# Deletes all the database data tables.
+# *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** 
+def restartDatabase():
+    """
+    *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** 
+    Restarts all the database.
+    *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** *** DANGER *** 
+
+    """
+    st = "DROP SCHEMA public CASCADE;" \
+        "CREATE SCHEMA public;"
+    ret = st, db.query(st)
+    ret = ret, db_schema.startSchema()
+    return ret
+
+def tagName(input):
+    """
+    Tags uniformly database elements. Padded on the left with zeros.
+
+    """
+    return str(input).zfill(2)

model/db_schema.py

 
 from db_connection import db
 
+################################################################################
+# Schema tables.
+#
 def startSchema():
     """
     Start the db schema. Must be ran only once because restarts the master
     """
     return st, db.query(st)
 
+################################################################################
+# Level tables.
+#
 def createLevelTables(level):
     """
     Tables schema. Create one level in datastore.
     DROP TABLE IF EXISTS "gn_""" + level + """_edges" CASCADE;
     """
     return st, db.query(st)
+
+def createNodeTypeTable(level, tablename):
+    """
+    TODO
+    """
+    st = """
+    CREATE TABLE """ + tablename + """ (
+        "idnode" integer,
+        "atribute01" varchar(32)
+    ) WITH (OIDS = FALSE);
+    ALTER TABLE """ + tablename + """ 
+        ADD CONSTRAINT """ + tablename + """_id 
+        PRIMARY KEY("idnode");
+    ALTER TABLE """ + tablename + """
+        ADD CONSTRAINT """ + tablename + """_fkey_type 
+        FOREIGN KEY ("idnode")
+        REFERENCES gn_""" + level + """_nodes("id") 
+        ON UPDATE RESTRICT ON DELETE RESTRICT;
+    """
+    return st, db.query(st)
+    
+def createEdgeTypeTable(level, tablename):
+    """
+    TODO
+    """
+    st = """
+    CREATE TABLE """ + tablename + """ (
+        "idedge" integer,
+        "atribute01" varchar(32)
+    ) WITH (OIDS = FALSE);
+    ALTER TABLE """ + tablename + """ 
+        ADD CONSTRAINT """ + tablename + """_id 
+        PRIMARY KEY("idedge");
+    ALTER TABLE """ + tablename + """
+        ADD CONSTRAINT """ + tablename + """_fkey_type 
+        FOREIGN KEY ("idedge")
+        REFERENCES gn_""" + level + """_nodes("id") 
+        ON UPDATE RESTRICT ON DELETE RESTRICT;
+    """
+    return st, db.query(st)
+
   <widget class="GtkWindow" id="genet">
     <property name="visible">True</property>
     <property name="title" translatable="yes">genet</property>
-    <property name="resizable">False</property>
     <signal name="destroy" handler="on_genet_destroy"/>
     <child>
       <widget class="GtkVBox" id="vbox">
           <widget class="GtkNotebook" id="notebook">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
+            <property name="scrollable">True</property>
+            <property name="enable_popup">True</property>
+            <property name="homogeneous">True</property>
             <child>
               <widget class="GtkTable" id="table_browser">
                 <property name="visible">True</property>
                   <widget class="GtkComboBoxEntry" id="comboboxentry_browser_level">
                     <property name="visible">True</property>
                     <child internal-child="entry">
-                      <widget class="GtkEntry" id="comboboxentry-entry_browser_level">
+                      <widget class="GtkEntry" id="comboboxentry-entry6">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                       </widget>
                   <widget class="GtkComboBoxEntry" id="comboboxentry_browser_nA">
                     <property name="visible">True</property>
                     <child internal-child="entry">
-                      <widget class="GtkEntry" id="comboboxentry-entry_browser_nA">
+                      <widget class="GtkEntry" id="comboboxentry-entry5">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                       </widget>
                   <widget class="GtkComboBoxEntry" id="comboboxentry_browser_nB">
                     <property name="visible">True</property>
                     <child internal-child="entry">
-                      <widget class="GtkEntry" id="comboboxentry-entry_browser_nB">
+                      <widget class="GtkEntry" id="comboboxentry-entry4">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                       </widget>
               </packing>
             </child>
             <child>
-              <widget class="GtkTable" id="table_creator">
+              <widget class="GtkTable" id="table1">
                 <property name="visible">True</property>
                 <property name="n_rows">5</property>
                 <property name="n_columns">5</property>
                 <child>
-                  <widget class="GtkButton" id="button_creator_levels_refresh">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Refresh</property>
-                    <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_creator_levels_refresh_clicked"/>
-                  </widget>
-                  <packing>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkButton" id="button_drop_level">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Delete</property>
-                    <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_drop_level_clicked"/>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkComboBox" id="combobox_creator_levels">
-                    <property name="visible">True</property>
-                    <property name="items" translatable="yes"></property>
-                    <signal name="changed" handler="on_combobox_creator_levels_changed"/>
-                    <signal name="move_active" handler="on_combobox_creator_levels_move_active"/>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <widget class="GtkButton" id="button_create_level">
+                  <widget class="GtkButton" id="button_create_node">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
                     <property name="label" translatable="yes">Create</property>
                     <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_create_level_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">3</property>
+                    <property name="right_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="combobox_creator_node_type">
+                    <property name="visible">True</property>
                   </widget>
                   <packing>
                     <property name="left_attach">2</property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkEntry" id="entry_creator_level">
+                  <widget class="GtkComboBox" id="combobox_creator_level">
                     <property name="visible">True</property>
-                    <property name="can_focus">True</property>
                   </widget>
                   <packing>
                     <property name="left_attach">1</property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="label_creator_level">
+                  <widget class="GtkLabel" id="label_creator_node">
                     <property name="visible">True</property>
-                    <property name="label" translatable="yes">Level</property>
+                    <property name="label" translatable="yes">Node</property>
                   </widget>
                 </child>
-              </widget>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkLabel" id="label_creator">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">Create</property>
-              </widget>
-              <packing>
-                <property name="type">tab</property>
-                <property name="position">1</property>
-                <property name="tab_fill">False</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkTable" id="table1">
-                <property name="visible">True</property>
-                <property name="n_rows">5</property>
-                <property name="n_columns">5</property>
-                <child>
-                  <widget class="GtkButton" id="button_admin_reset">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">True</property>
-                    <property name="label" translatable="yes">Reset</property>
-                    <property name="response_id">0</property>
-                    <signal name="clicked" handler="on_button_admin_reset_clicked"/>
-                  </widget>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
                 <child>
                   <placeholder/>
                 </child>
                 </child>
               </widget>
               <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label_creator">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Create</property>
+              </widget>
+              <packing>
+                <property name="type">tab</property>
+                <property name="position">1</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkTable" id="table_creator">
+                <property name="visible">True</property>
+                <property name="n_rows">5</property>
+                <property name="n_columns">6</property>
+                <child>
+                  <widget class="GtkComboBox" id="combobox_creator_levels_types">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="items" translatable="yes"></property>
+                    <signal name="focus" handler="on_combobox_creator_levels_types_focus"/>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_admin_reset">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Reset</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_admin_reset_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">4</property>
+                    <property name="bottom_attach">5</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_drop_edge_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Delete</property>
+                    <property name="response_id">0</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">5</property>
+                    <property name="right_attach">6</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_drop_node_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Delete</property>
+                    <property name="response_id">0</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">5</property>
+                    <property name="right_attach">6</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="combobox_creator_edge_types">
+                    <property name="visible">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">4</property>
+                    <property name="right_attach">5</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="combobox_creator_node_types">
+                    <property name="visible">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">4</property>
+                    <property name="right_attach">5</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_creator_edge_types_refresh">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Refresh</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_creator_edge_types_refresh_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">3</property>
+                    <property name="right_attach">4</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_creator_node_types_refresh">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Refresh</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_creator_node_types_refresh_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">3</property>
+                    <property name="right_attach">4</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_drop_level">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Delete</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_drop_level_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">5</property>
+                    <property name="right_attach">6</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkComboBox" id="combobox_creator_levels">
+                    <property name="visible">True</property>
+                    <property name="items" translatable="yes"></property>
+                    <signal name="changed" handler="on_combobox_creator_levels_changed"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">4</property>
+                    <property name="right_attach">5</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_creator_levels_refresh">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Refresh</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_creator_levels_refresh_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">3</property>
+                    <property name="right_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label_creator_node_type">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Node type</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_create_node_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Create</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_create_node_type_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="entry_creator_node_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="entry_creator_edge_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_create_edge_type">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Create</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_create_edge_type_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label_creator_edge_type">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Edge type</property>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label_creator_level">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Level</property>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="entry_creator_level">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="button_create_level">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="label" translatable="yes">Create</property>
+                    <property name="response_id">0</property>
+                    <signal name="clicked" handler="on_button_create_level_clicked"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
                 <property name="position">2</property>
               </packing>
             </child>

view/genet_window.py

             self.combobox_creator_levels_changed,
             "on_button_creator_levels_refresh_clicked" :
             self.button_creator_levels_refresh_clicked,
+            "on_button_create_node_type_clicked" :
+            self.button_create_node_type_clicked,
+            "on_button_create_edge_type_clicked" :
+            self.button_create_edge_type_clicked,
             "on_button_admin_reset_clicked" :
             self.button_admin_reset_clicked,
             "on_genet_destroy" : (gtk.main_quit) }
         cell = gtk.CellRendererText()
         combo.pack_start(cell, True)
 
+    def button_create_node_type_clicked(self, widget):
+        # Get level
+        combo = self.wTree.get_widget("combobox_creator_levels")
+        combo_model = combo.get_model()
+        combo_index = combo.get_active()
+        level = combo_model[combo_index][1]
+
+        # Get description
+        description = self.wTree.get_widget("entry_creator_node_type").get_text()
+
+        # Create type
+        genet_creator.createNodeType(level, description)
+       
+    def button_create_edge_type_clicked(self, widget):
+        # Get level
+        combo = self.wTree.get_widget("combobox_creator_levels")
+        combo_model = combo.get_model()
+        combo_index = combo.get_active()
+        level = combo_model[combo_index][1]
+
+        # Get description
+        description = self.wTree.get_widget("entry_creator_edge_type").get_text()
+
+        # Create type
+        genet_creator.createEdgeType(level, description)
+
     def button_admin_reset_clicked(self, widget):
-        genet_global.restartSchema()
+        genet_global.restartDatabase()
  
     def main(self):
         gtk.main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.