Commit d4dc7034443cfc7ede68c842cecc4965ecf30412

Authored by totoro
1 parent 64adc833

add generation of create table

add checking of the model
rename almost all db_ to hk_
calexium_lib @ eba0f762de0
1   -Subproject commit 6cf67b09e781c09f8475c678ba69991772066a76
  1 +Subproject commit eba0f762de01ad8cd7c4aa41ea78c9f641d74e03
... ...
hayamiki.aproj
... ... @@ -468,6 +468,8 @@
468 468 <Compile Include="library\widgets4\window_test.anubis" />
469 469 <Compile Include="library\xml\basic_xml_parser.anubis" />
470 470 <Compile Include="library\xml\xml_parser.apg.anubis" />
  471 + <Compile Include="src\check.anubis" />
  472 + <Compile Include="src\generation\create_table.anubis" />
471 473 <Compile Include="src\generation\files.anubis" />
472 474 <Compile Include="src\generation\header.anubis" />
473 475 <Compile Include="src\generation\types.anubis" />
... ... @@ -694,6 +696,5 @@
694 696 <Folder Include="library\xml" />
695 697 <Folder Include="src" />
696 698 <Folder Include="src\generation" />
697   - <Folder Include="src\types" />
698 699 </ItemGroup>
699 700 </Project>
700 701 \ No newline at end of file
... ...
src/check.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ
  4 + * Date: 04/02/2016
  5 + * Time: 22:34
  6 + * © Calexium
  7 + */
  8 +
  9 +read calexium_lib/database/model/db_model.anubis
  10 +read system/string.anubis
  11 +read tools/list.anubis
  12 +read tools/basis.anubis
  13 +
  14 +public define Maybe(List(String))
  15 + get_all_apps_name
  16 + (
  17 + List(HK_App) apps,
  18 + List(String) so_far
  19 + )=
  20 + if apps is
  21 + {
  22 + [] then success(so_far),
  23 + [h . t] then
  24 + since h is hk_app(name, _),
  25 + if name:so_far then
  26 + println("The app name "+name+" already exists"); failure
  27 + //'this' is not allowed as app name because the
  28 + //else name = "this" then
  29 + // prinln("error: 'this' is forbidden app name "); failure
  30 + else
  31 + get_all_apps_name(t, [name. so_far])
  32 + }.
  33 +
  34 +
  35 +define Maybe(HK_Model_Column)
  36 + resolve_foreign
  37 + (
  38 + List(String) apps_name,
  39 + String current_app_name,
  40 + String table_name,
  41 + HK_Model_Column col
  42 + )=
  43 + since col is hk_column(name, type, attrib, help),
  44 + if type is foreign_key(fk_app, fk_table) then
  45 + with mb_fk_app = if (fk_app) is
  46 + {
  47 + this then println("this found replaced by "+current_app_name+" in app '"+current_app_name+"' table '"+table_name+"' column '"+name+"'");
  48 + success(current_app_name),
  49 + app_name(_name) then
  50 + if _name:apps_name then
  51 + success(_name)
  52 + else
  53 + println("foreign key app '"+_name+"' doesn't exists in app '"+current_app_name+"' table '"+table_name+"' column '"+_name+"'");failure,
  54 + none then
  55 + success("")
  56 + },
  57 + if mb_fk_app is
  58 + {
  59 + failure then failure,
  60 + success(n_fk_app) then success(hk_column(name, foreign_key(if (fk_app) is app_name(_) then app_name(n_fk_app) else fk_app, (if length(n_fk_app)>0 then n_fk_app+"_"else "")+fk_table), attrib, help))
  61 + }
  62 + else
  63 + success(col).
  64 +
  65 +define Maybe(List(HK_Model_Column))
  66 + resolve_foreign
  67 + (
  68 + List(String) apps_name,
  69 + String app_name,
  70 + String table_name,
  71 + List(HK_Model_Column) columns,
  72 + List(HK_Model_Column) so_far
  73 + )=
  74 + if columns is
  75 + {
  76 + [] then success(reverse(so_far)),
  77 + [h . t] then
  78 + if resolve_foreign(apps_name, app_name, table_name, h) is
  79 + {
  80 + failure then failure,
  81 + success(col) then resolve_foreign(apps_name, app_name, table_name, t, [col. so_far])
  82 + }
  83 + }.
  84 +
  85 +define Maybe(List(HK_Table))
  86 + resolve_foreign
  87 + (
  88 + List(String) apps_name,
  89 + String app_name,
  90 + List(HK_Table) tables,
  91 + List(HK_Table) so_far
  92 + )=
  93 + if tables is
  94 + {
  95 + [] then success(reverse(so_far)),
  96 + [h . t] then
  97 + since h is hk_table(name, model, display),
  98 + since model is hk_model(columns, display_string),
  99 + with table_name = if length(app_name) > 0 then app_name +"_"+name else name,
  100 + if resolve_foreign(apps_name, app_name, table_name, columns, []) is
  101 + {
  102 + failure then failure,
  103 + success(checked_model) then resolve_foreign(apps_name, app_name, t, [hk_table(table_name, hk_model(checked_model, display_string), display) . so_far])
  104 + }
  105 + }.
  106 +
  107 +define Maybe(HK_App)
  108 + resolve_foreign
  109 + (
  110 + List(String) apps_name,
  111 + HK_App app
  112 + )=
  113 + since app is hk_app(name, tables),
  114 + if resolve_foreign(apps_name, name, tables, []) is
  115 + {
  116 + failure then failure,
  117 + success(resolved_tables) then success(hk_app(name, resolved_tables))
  118 + }.
  119 +
  120 +define Maybe(List(HK_App))
  121 + resolve_foreign
  122 + (
  123 + List(String) apps_name,
  124 + List(HK_App) apps,
  125 + List(HK_App) so_far
  126 + )=
  127 + if apps is
  128 + {
  129 + [] then success(reverse(so_far)),
  130 + [h . t] then
  131 + if resolve_foreign(apps_name, h) is
  132 + {
  133 + failure then failure,
  134 + success(app) then resolve_foreign(apps_name, t, [app . so_far])
  135 + }
  136 + }.
  137 +
  138 +public define Maybe(HK_Database)
  139 + check_database
  140 + (
  141 + HK_Database current_db //database model description
  142 + )=
  143 + since current_db is hk_database(name, apps),
  144 +
  145 + if get_all_apps_name(apps, []) is
  146 + {
  147 + failure then failure,
  148 + success(chk_apps) then
  149 + if resolve_foreign(chk_apps, apps, []) is
  150 + {
  151 + failure then failure,
  152 + success(resolved_apps) then
  153 + //with checked_db = current_db,
  154 + success(hk_database(name, resolved_apps))
  155 +
  156 + }
  157 + }.
  158 +
... ...
src/generation/create_table.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 24/01/2016
  5 + * Time: 18:13
  6 + * © Calexium
  7 + */
  8 +
  9 +
  10 +read calexium_lib/database/model/db_model.anubis
  11 +read tools/basis.anubis
  12 +read tools/int.anubis
  13 +read system/string.anubis
  14 +read tools/streams.anubis
  15 +read tools/ISO-8601.anubis
  16 +
  17 +define String
  18 + create_table_generate_one_column
  19 + (
  20 + HK_Model_Column column,
  21 + Int fill_size
  22 + )=
  23 + since column is hk_column(name, col_type, attributes, _),
  24 + fill(name, fill_size)+ to_SQL_CREATE(col_type, attributes)
  25 + .
  26 +
  27 +define String
  28 + create_table_generate_columns
  29 + (
  30 + List(HK_Model_Column) columns,
  31 + String indent
  32 + )=
  33 + with column_max_size = max(columns),
  34 + join(",\n"+indent, map((HK_Model_Column column) |-> create_table_generate_one_column(column, column_max_size+1), columns))
  35 + .
  36 +
  37 +define String
  38 + create_table_generate_one_table
  39 + (
  40 + HK_Table table
  41 + )=
  42 + since table is hk_table(name, model, display),
  43 + since model is hk_model( columns, _),
  44 +
  45 + "\n"+
  46 + " // "+to_upper(name)+"\n"+
  47 + "public define String create_table_"+name+" =\n"+
  48 + "\"CREATE TABLE "+name+" (\n"+
  49 + //columns
  50 + " "+create_table_generate_columns([hk_column("id",p_key) . columns], " ")+
  51 + "\n);\".\n"
  52 + .
  53 +
  54 +define String
  55 + create_table_generate_all_tables
  56 + (
  57 + List(HK_App) apps, //
  58 + List(HK_Table) tables, //list of the table model description
  59 + String so_far
  60 + )=
  61 + if tables is
  62 + {
  63 + [] then
  64 + if apps is
  65 + {
  66 + [] then so_far,
  67 + [app. t_apps] then
  68 + since app is hk_app(name, app_tables),
  69 + create_table_generate_all_tables(t_apps, app_tables, so_far + "\n /************ TABLES for Application '"+name+"' ***************/")
  70 + },
  71 +
  72 + [table . t] then
  73 + create_table_generate_all_tables(apps, t, so_far + create_table_generate_one_table(table))
  74 + }.
  75 +
  76 +define Int
  77 + longest_table_name_size
  78 + (
  79 + List(HK_App) apps,
  80 + Int current_size
  81 + )=
  82 + if apps is
  83 + {
  84 + [] then current_size,
  85 + [app . t_apps] then
  86 + since app is hk_app(_, tables),
  87 + with max_size = max(map((HK_Table table) |-> length(table.name), tables), current_size),
  88 + longest_table_name_size(t_apps, max_size)
  89 + }.
  90 +
  91 +define String
  92 + generate_all_tables_list
  93 + (
  94 + List(HK_App) apps,
  95 + List(HK_Table) tables, //list of the table model description
  96 + String indent
  97 + )=
  98 + //calculate then longest table name and add 4 for enclosed quote + coma + final space
  99 + //hence we can make a beautiful formatting
  100 + with max_space = longest_table_name_size(apps, 0) + 4,
  101 + join(",\n",map((HK_Table table) |-> indent+"table("+fill("\""+table.name+"\",", max_space)+"create_table_"+table.name+")", tables)).
  102 +
  103 +public define Maybe(One)
  104 + generate_create_table
  105 + (
  106 + List(HK_App) apps //list of the table model description
  107 + )=
  108 + //TODO manage version
  109 + with version = "1.0.0",
  110 + version_str = find_and_replace(version,".","_"), //replace the dot by underscore because dot is not allowed in function name by Anubis language
  111 +
  112 + with file_name = "to_"+version+".anubis",
  113 + with script_file_name = "to_"+version+"_script.anubis",
  114 +
  115 + //create script file name
  116 + if file(script_file_name, new) is
  117 + {
  118 + failure then println("Can't create script "+script_file_name);failure,
  119 + success(fd_script) then
  120 + with script_stream = make_stream(fd_script),
  121 + //write into script file the generated create table
  122 + if write_string(script_stream,
  123 +"/*
  124 + * Created by 早見木 (Hayamiki).
  125 + * User: Automat
  126 + * Date: "+_Int_to_ISO_8601_date(now)+"
  127 + * Time: "+_Int_to_ISO_8601_time(now)+"
  128 + *
  129 + */
  130 +read data_base/alter_table.anubis
  131 +read data_base/db_types.anubis\n"+
  132 + //call the generation of all tables
  133 + create_table_generate_all_tables(apps, [], "")+
  134 + //TODO make indexes
  135 + "\npublic define List(String) db_indexes = [].\n"
  136 + ) is
  137 + {
  138 + failure then println ("Can't generate script "+script_file_name);failure,
  139 + success(_) then
  140 + //create file with create table management (alter_table, etc...)
  141 + if file(file_name, new) is
  142 + {
  143 + failure then println("can't create file "+file_name);failure,
  144 + success(fd) then
  145 + with stream = make_stream(fd),
  146 + write_string(stream,
  147 +"/*
  148 + * Created by 早見木 (Hayamiki).
  149 + * User: Automat
  150 + * Date: "+_Int_to_ISO_8601_date(now)+"
  151 + * Time: "+_Int_to_ISO_8601_time(now)+"
  152 + *
  153 + */
  154 + *
  155 +read tools/basis.anubis
  156 +read system/files.anubis
  157 +read system/logger.anubis
  158 +read data_base/db_tools.anubis
  159 +
  160 +read calexium_lib/database/db_utils.anubis
  161 +read calexium_lib/database/migration_common_sqlite3.anubis
  162 +read calexium_lib/net_services_protocols/logger_service.anubis
  163 +read data_base/alter_table.anubis
  164 +
  165 +read types/app_types.anubis
  166 +read app/app_constants.anubis
  167 +read app/app_loggers.anubis
  168 +
  169 +read database/generated/migration/to_"+version_str+"_scripts.anubis
  170 +
  171 +define String _version = \""+version+"\".
  172 +
  173 +public define Maybe(One)
  174 + create_v"+version_str+"_tables
  175 + (
  176 + SQLite3DataBase db,
  177 + Logger logger_debug
  178 + )=
  179 + if drop_all_triggers(db, logger_debug) is failure then failure else
  180 +
  181 + with tables = (List(DbTable)) [
  182 +"+generate_all_tables_list(apps, [], " ")+"
  183 + ],
  184 + if create_tables(db, logger_debug, tables, _version) is
  185 + {
  186 + failure then failure,
  187 + success(_) then
  188 + if make_foreign_keys(db, logger_debug, db_relations, _version) is failure then failure else
  189 + success(unique)
  190 + }.
  191 +
  192 +public define Maybe(One)
  193 + create_v"+version_str+"_indexes
  194 + (
  195 + SQLite3DataBase db,
  196 + Logger logger
  197 + )=
  198 + if create_indexes(db, logger, db_indexes, _version) is failure then failure else
  199 + success(unique)
  200 + .
  201 +
  202 +define Maybe(One)
  203 + to_v"+version_str+"_pre
  204 + (
  205 + SQLite3DataBase db,
  206 + Logger logger
  207 + )=success(unique).
  208 +
  209 +define Maybe(One)
  210 + to_v"+version_str+"_post
  211 + (
  212 + SQLite3DataBase db,
  213 + Logger logger
  214 + )=success(unique).
  215 +
  216 +public define Maybe(One)
  217 + migrate_to_v"+version_str+"
  218 + (
  219 + SQLite3DataBase db,
  220 + Logger logger,
  221 + )=
  222 + if to_v"+version_str+"_pre(db, logger) is failure then failure
  223 + else if create_v"+version_str+"_tables(db, logger) is failure then failure
  224 + else if to_v"+version_str+"_post(db, logger) is failure then failure
  225 + else create_v"+version_str+"_indexes(db, logger).
  226 +
  227 +
  228 + ")
  229 + }}}
  230 + .
  231 +
  232 +
... ...
src/generation/files.anubis
... ... @@ -14,19 +14,21 @@ read tools/streams.anubis
14 14 read tools/ISO-8601.anubis
15 15 read generation/header.anubis
16 16 read generation/types.anubis
  17 +read generation/create_table.anubis
  18 +read check.anubis
17 19  
18 20 define Maybe(One)
19 21 generate_table
20 22 (
21   - DB_Table org_table
  23 + HK_Table org_table
22 24 )
23 25 =
24   - since org_table is db_table(name, old_model, display),
25   - since old_model is db_model(columns, show_string),
  26 + since org_table is hk_table(name, old_model, display),
  27 + since old_model is hk_model(columns, show_string),
26 28 since display is db_display(list_view, list_edit),
27 29  
28   - with model = db_model([db_column("id", p_key, []). columns], show_string ),
29   - with table = db_table(name, model, display),
  30 + with model = hk_model([hk_column("id", p_key, []). columns], show_string ),
  31 + with table = hk_table(name, model, display),
30 32 println("Generating file for table ["+name+"]");
31 33 with file_name = name+".anubis",
32 34 if file(file_name, new) is
... ... @@ -48,11 +50,11 @@ define Maybe(One)
48 50 if generate_VT_edit(strm, table) is { failure then failure, success(_) then
49 51 success(unique)}}}}}}}}}}}}
50 52 }.
51   -
  53 +
52 54 define One
53 55 make_all_tables
54 56 (
55   - List(DB_Table) tables //list of the table model description
  57 + List(HK_Table) tables //list of the table model description
56 58 )
57 59 =
58 60 if tables is
... ... @@ -65,6 +67,16 @@ define One
65 67 success(_) then make_all_tables(t)
66 68 }
67 69 }.
  70 +
  71 +define One
  72 + make_all_tables
  73 + (
  74 + List(HK_App) apps
  75 + )=
  76 + map_forget((HK_App app) |-> since app is hk_app(app_name, tables),
  77 + println("generating tables for App ["+app_name+"]");
  78 + make_all_tables(tables), apps).
  79 +
68 80  
69 81 define Maybe(One)
70 82 generate_vtm_file
... ... @@ -113,7 +125,8 @@ join(&quot;\n&quot;, transmit)+&quot;\n\n&quot;+
113 125 define One
114 126 _make_vtm
115 127 (
116   - List(DB_Table) tables, //list of the table model description
  128 + List(HK_App) apps, //list of application
  129 + List(HK_Table) tables, //list of the table model description
117 130 List(String) so_far_transmit,
118 131 List(String) so_far_view,
119 132 List(String) so_far_edit,
... ... @@ -121,34 +134,51 @@ define One
121 134 )=
122 135 if tables is
123 136 {
124   - [] then forget(generate_vtm_file(so_far_transmit, so_far_view, so_far_edit, so_far_writer));println("Generation finished"),
  137 + [] then
  138 + if apps is
  139 + {
  140 + [] then forget(generate_vtm_file(so_far_transmit, so_far_view, so_far_edit, so_far_writer));println("Generation finished"),
  141 + [app . apps_t] then
  142 + _make_vtm(apps_t, app.hk_tables, so_far_transmit, so_far_view, so_far_edit, so_far_writer)
  143 +
  144 + },
  145 +
125 146 [table . t] then
126   - since table is db_table(name, _, _),
  147 + since table is hk_table(name, _, _),
127 148 with transmit = "transmit "+name+".anubis",
128 149 with view = "vtm_view(\""+name+"\", get_viewable_"+name+")",
129 150 with edit = "vtm_edit(\""+name+"\", get_editable_"+name+")",
130 151 with writer = "tm_writer(\""+name+"\", update_"+name+")",
131 152  
132   - _make_vtm(t, [transmit . so_far_transmit], [view . so_far_view], [edit . so_far_edit], [writer . so_far_writer])
  153 + _make_vtm(apps, t, [transmit . so_far_transmit], [view . so_far_view], [edit . so_far_edit], [writer . so_far_writer])
133 154 }.
134 155  
135 156 define One
136 157 make_vtm
137 158 (
138   - List(DB_Table) tables //list of the table model description
  159 + List(HK_App) apps //list of the applications
139 160 )
140 161 =
141   - _make_vtm(tables, [], [], [], []).
142   -
  162 + _make_vtm(apps, [], [], [], [], []).
  163 +
143 164  
144 165 public define One
145 166 generate_model_files
146 167 (
147   - DB_Database database //database model description
  168 + HK_Database db //database model description
148 169 )=
149   - since database is db_database(name, tables),
150   - println("Generating models for Database "+name);
151   - make_all_tables(tables);
152   - println("Generating VTM for Database "+name);
153   - make_vtm(tables).
  170 +
  171 + if check_database(db) is
  172 + {
  173 + failure then println("Check database error"),
  174 + success(database) then
  175 + since database is hk_database(name, apps),
  176 + println("Generating models for Database "+name);
  177 + make_all_tables(apps);
  178 + println("Generating VTM for Database "+name);
  179 + make_vtm(apps);
  180 + println("Generating create for Database "+name);
  181 + if generate_create_table(apps) is failure then println("failure") else
  182 + unique
  183 + }.
154 184  
... ...
src/generation/header.anubis
... ... @@ -15,14 +15,14 @@ define Maybe(One)
15 15 foreign_table_header
16 16 (
17 17 Stream stream,
18   - List(DB_Model_Column) columns
  18 + List(HK_Model_Column) columns
19 19 )=
20 20 if columns is
21 21 {
22 22 [] then success(unique),
23 23 [h . t] then
24   - since h is db_column(_, type, _, _),
25   - if type is foreign_key(table_name) then
  24 + since h is hk_column(_, type, _, _),
  25 + if type is foreign_key(app, table_name) then
26 26 if write_string(stream, "\nread database/generated/"+table_name+".anubis") is
27 27 {
28 28 failure then failure,
... ... @@ -39,7 +39,7 @@ public define Maybe(One)
39 39 generate_header
40 40 (
41 41 Stream stream,
42   - List(DB_Model_Column) columns
  42 + List(HK_Model_Column) columns
43 43  
44 44 )=
45 45 if write_string(stream,
... ...
src/generation/types.anubis
... ... @@ -17,14 +17,14 @@ define List(String)
17 17 */
18 18 _generate_type
19 19 (
20   - List(DB_Model_Column) columns,
  20 + List(HK_Model_Column) columns,
21 21 List(String) so_far
22 22 )=
23 23 if columns is
24 24 {
25 25 [] then reverse(so_far),
26 26 [h . t ] then
27   - since h is db_column(name, col_type, _, _),
  27 + since h is hk_column(name, col_type, _, _),
28 28 _generate_type(t, [ " "+fill(to_Anubis_type(col_type), 12) + " " + name . so_far])
29 29 }.
30 30  
... ... @@ -32,13 +32,13 @@ public define Maybe(One)
32 32 generate_type
33 33 (
34 34 Stream stream,
35   - DB_Table table
  35 + HK_Table table
36 36 )=
37   - since table is db_table(name, model, display),
38   - since model is db_model(columns, show_string),
  37 + since table is hk_table(name, model, display),
  38 + since model is hk_model(columns, show_string),
39 39 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
40 40  
41   - //generate the type of the db_table that contain all components
  41 + //generate the type of the HK_Table that contain all components
42 42 if write_string(stream,
43 43 "\n\npublic type "+type_name+":\n "+name+"\n (\n"+ //head of the type declaration
44 44 join(",\n",_generate_type(columns, []))+ //all components of the type
... ... @@ -53,24 +53,24 @@ define List(String)
53 53 */
54 54 _generate_get_default
55 55 (
56   - List(DB_Model_Column) columns,
  56 + List(HK_Model_Column) columns,
57 57 List(String) so_far
58 58 )=
59 59 if columns is
60 60 {
61 61 [] then reverse(so_far),
62 62 [h . t ] then
63   - since h is db_column(name, col_type, _, _),
  63 + since h is hk_column(name, col_type, _, _),
64 64 _generate_get_default(t, [ to_Anubis_default(col_type) . so_far])
65 65 }.
66 66 public define Maybe(One)
67 67 generate_get_default
68 68 (
69 69 Stream stream,
70   - DB_Table table
  70 + HK_Table table
71 71 )=
72   - since table is db_table(name, model, _),
73   - since model is db_model(columns, show_string),
  72 + since table is hk_table(name, model, _),
  73 + since model is hk_model(columns, show_string),
74 74 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
75 75  
76 76 //generate the type of the table that contain all components
... ... @@ -88,7 +88,7 @@ define (List(String), Int)
88 88 */
89 89 _generate_extract_web_arg
90 90 (
91   - List(DB_Model_Column) columns,
  91 + List(HK_Model_Column) columns,
92 92 List(String) so_far,
93 93 Int closure
94 94 )=
... ... @@ -96,7 +96,7 @@ define (List(String), Int)
96 96 {
97 97 [] then (reverse(so_far), closure),
98 98 [h . t ] then
99   - since h is db_column(name, col_type, _, _),
  99 + since h is hk_column(name, col_type, _, _),
100 100 with result = from_web_arg(col_type, name),
101 101 //If the field is not editable no need to get it from the web
102 102 if result = "" then
... ... @@ -112,11 +112,11 @@ define (List(String), Int)
112 112 public define Maybe(One)
113 113 generate_extract_web_arg
114 114 (
115   - Stream stream,
116   - DB_Table table
  115 + Stream stream,
  116 + HK_Table table
117 117 )=
118   - since table is db_table(name, model, _),
119   - since model is db_model(columns, _),
  118 + since table is hk_table(name, model, _),
  119 + since model is hk_model(columns, _),
120 120 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
121 121 since _generate_extract_web_arg(columns, [], 0) is ((List(String))list_of_web_arg, (Int) nb_closure),
122 122 //generate the type of the table that contain all components
... ... @@ -135,10 +135,10 @@ public define Maybe(One)
135 135 generate_extract_db_cursor
136 136 (
137 137 Stream stream,
138   - DB_Table table
  138 + HK_Table table
139 139 )=
140   - since table is db_table(name, model, display),
141   - since model is db_model(columns, _),
  140 + since table is hk_table(name, model, display),
  141 + since model is hk_model(columns, _),
142 142 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
143 143  
144 144 //generate the type of the table that contain all components
... ... @@ -165,11 +165,11 @@ public define Maybe(One)
165 165 public define Maybe(One)
166 166 generate_get_all
167 167 (
168   - Stream stream,
169   - DB_Table table
  168 + Stream stream,
  169 + HK_Table table
170 170 )=
171   - since table is db_table(name, model, _),
172   - since model is db_model(columns, _),
  171 + since table is hk_table(name, model, _),
  172 + since model is hk_model(columns, _),
173 173 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
174 174  
175 175 //generate the type of the table that contain all components
... ... @@ -208,11 +208,11 @@ public define Maybe(One)
208 208 public define Maybe(One)
209 209 generate_get_one
210 210 (
211   - Stream stream,
212   - DB_Table table
  211 + Stream stream,
  212 + HK_Table table
213 213 )=
214   - since table is db_table(name, model, _),
215   - since model is db_model(columns, show_string),
  214 + since table is hk_table(name, model, _),
  215 + since model is hk_model(columns, show_string),
216 216 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
217 217  
218 218 //generate the type of the table that contain all components
... ... @@ -249,10 +249,10 @@ public define Maybe(One)
249 249 generate_update
250 250 (
251 251 Stream stream,
252   - DB_Table table
  252 + HK_Table table
253 253 )=
254   - since table is db_table(name, model, _),
255   - since model is db_model( columns, _),
  254 + since table is hk_table(name, model, _),
  255 + since model is hk_model( columns, _),
256 256 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
257 257  
258 258 //generate the type of the table that contain all components
... ... @@ -305,10 +305,10 @@ public define Maybe(One)
305 305 generate_show_string
306 306 (
307 307 Stream stream,
308   - DB_Table table
  308 + HK_Table table
309 309 )=
310   - since table is db_table(name, model, _),
311   - since model is db_model( columns, show_string),
  310 + since table is hk_table(name, model, _),
  311 + since model is hk_model( columns, show_string),
312 312 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
313 313  
314 314 //generate the type of the table that contain all components
... ... @@ -336,10 +336,10 @@ public define Maybe(One)
336 336 generate_selector
337 337 (
338 338 Stream stream,
339   - DB_Table table
  339 + HK_Table table
340 340 )=
341   - since table is db_table(name, model, _),
342   - since model is db_model( columns, show_string),
  341 + since table is hk_table(name, model, _),
  342 + since model is hk_model( columns, show_string),
343 343 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
344 344  
345 345 //generate the type of the table that contain all components
... ... @@ -381,11 +381,11 @@ public define Maybe(One)
381 381 generate_VT_view
382 382 (
383 383 Stream stream, //stream file where to write
384   - DB_Table table, //
  384 + HK_Table table, //
385 385 HK_List_View list_view //list view to generate
386 386 )=
387   - since table is db_table(table_name, model, display),
388   - since model is db_model( columns, _),
  387 + since table is hk_table(table_name, model, display),
  388 + since model is hk_model( columns, _),
389 389 //since display is db_display(list_view, list_edit),
390 390  
391 391 with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type.
... ... @@ -444,7 +444,7 @@ public define Maybe(One)
444 444 _generate_VT_view
445 445 (
446 446 Stream stream, //stream file where to write
447   - DB_Table table, //
  447 + HK_Table table, //
448 448 List(HK_List_View) list_view, //list view to generate
449 449 Bool has_default //set to true if a default view was encountered.
450 450 )=
... ... @@ -512,10 +512,10 @@ public define Maybe(One)
512 512 generate_get_viewable
513 513 (
514 514 Stream stream, //stream file where to write
515   - DB_Table table, //
  515 + HK_Table table, //
516 516 List(HK_List_View) list_view //list view to generate
517 517 )=
518   - since table is db_table(table_name, model, display),
  518 + since table is hk_table(table_name, model, display),
519 519 if write_string(stream,
520 520 "public define VT_view\n"+
521 521 " get_viewable_"+table_name+"\n"+
... ... @@ -535,10 +535,10 @@ public define Maybe(One)
535 535 generate_VT_all_view
536 536 (
537 537 Stream stream,
538   - DB_Table table
  538 + HK_Table table
539 539 )=
540   - since table is db_table(name, model, display),
541   - since model is db_model( columns, _),
  540 + since table is hk_table(name, model, display),
  541 + since model is hk_model( columns, _),
542 542 since display is db_display(list_view, list_edit),
543 543  
544 544 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
... ... @@ -553,10 +553,10 @@ public define Maybe(One)
553 553 generate_VT_edit
554 554 (
555 555 Stream stream,
556   - DB_Table table
  556 + HK_Table table
557 557 )=
558   - since table is db_table(name, model, display),
559   - since model is db_model( columns, _),
  558 + since table is hk_table(name, model, display),
  559 + since model is hk_model( columns, _),
560 560 since display is db_display(list_view, list_edit),
561 561 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
562 562  
... ...
src/model.3.0.0.anubis
... ... @@ -2,40 +2,40 @@
2 2 read calexium_lib/database/model/db_model.anubis
3 3  
4 4  
5   -public define DB_Table mf_serial_table =
6   - db_table("mf_serial",
7   - db_model(
  5 +public define HK_Table mf_serial_table =
  6 + hk_table("mf_serial",
  7 + hk_model(
8 8 [
9 9  
10   - db_column("serial", char_field(30), []),
11   - db_column("mac", char_field(30), []),
12   - db_column("app_id", char_field(50), []),
13   - db_column("enabled", boolean_field, [], help_text("Is enabled?")),
14   - db_column("free_domain", boolean_field, [], help_text("Free domain available?")),
15   - db_column("max_domains", integer_field, [], help_text("Maximum number of domains")),
16   - db_column("is_demo", boolean_field, [], help_text("Is demo?")),
17   - db_column("is_test", boolean_field, [], help_text("Is test?")),
18   - db_column("date_created", datetime_field(auto_now_add), []),
19   - db_column("last_updated", datetime_field(none), []),
20   - db_column("last_ping", datetime_field(none), []),
21   - db_column("current_ip", char_field(20), []),
22   - db_column("mf_version", char_field(20), [], help_text("MF version")),
23   - db_column("vm_version", char_field(20), [], help_text_TAG("ANUBIS_VM_VER")),
24   - db_column("os_version", char_field(20), [], help_text("OS version")),
25   - db_column("ipkg_list", text_field, []),
26   - db_column("ifconfig", text_field, []),
27   - db_column("dmesg", text_field, []),
28   - db_column("memory", text_field, []),
29   - db_column("vm_memory", text_field, []),
30   - db_column("status", text_field, []),
31   - db_column("disks", text_field, []),
32   - db_column("isp_smtp", text_field, []),
33   - db_column("description", text_field, []),
34   - db_column("comments", text_field, []),
35   - db_column("alert_received", boolean_field, [], help_text("Alert received?")),
36   - db_column("alert_date", datetime_field(none), []),
37   - db_column("alert_msg", text_field, []),
38   - db_column("alert_mf_version", char_field(20), []),
  10 + hk_column("serial", char_field(30), []),
  11 + hk_column("mac", char_field(30), []),
  12 + hk_column("app_id", char_field(50), []),
  13 + hk_column("enabled", boolean_field, [], help_text("Is enabled?")),
  14 + hk_column("free_domain", boolean_field, [], help_text("Free domain available?")),
  15 + hk_column("max_domains", integer_field, [], help_text("Maximum number of domains")),
  16 + hk_column("is_demo", boolean_field, [], help_text("Is demo?")),
  17 + hk_column("is_test", boolean_field, [], help_text("Is test?")),
  18 + hk_column("date_created", datetime_field(auto_now_add), []),
  19 + hk_column("last_updated", datetime_field(none), []),
  20 + hk_column("last_ping", datetime_field(none), []),
  21 + hk_column("current_ip", char_field(20), []),
  22 + hk_column("mf_version", char_field(20), [], help_text("MF version")),
  23 + hk_column("vm_version", char_field(20), [], help_text_TAG("ANUBIS_VM_VER")),
  24 + hk_column("os_version", char_field(20), [], help_text("OS version")),
  25 + hk_column("ipkg_list", text_field, []),
  26 + hk_column("ifconfig", text_field, []),
  27 + hk_column("dmesg", text_field, []),
  28 + hk_column("memory", text_field, []),
  29 + hk_column("vm_memory", text_field, []),
  30 + hk_column("status", text_field, []),
  31 + hk_column("disks", text_field, []),
  32 + hk_column("isp_smtp", text_field, []),
  33 + hk_column("description", text_field, []),
  34 + hk_column("comments", text_field, []),
  35 + hk_column("alert_received", boolean_field, [], help_text("Alert received?")),
  36 + hk_column("alert_date", datetime_field(none), []),
  37 + hk_column("alert_msg", text_field, []),
  38 + hk_column("alert_mf_version", char_field(20), []),
39 39 ],
40 40 "obj.serial"
41 41 ),
... ... @@ -55,13 +55,13 @@ public define DB_Table mf_serial_table =
55 55 )
56 56 ).
57 57  
58   -public define DB_Table settings_table =
59   - db_table("settings",
60   - db_model(
  58 +public define HK_Table settings_table =
  59 + hk_table("settings",
  60 + hk_model(
61 61 [
62 62  
63   - db_column("var_name", char_field(20), []),
64   - db_column("var_value", char_field(20), []),
  63 + hk_column("var_name", char_field(20), []),
  64 + hk_column("var_value", char_field(20), []),
65 65 ],
66 66 "obj.var_name+\" = \"+obj.var_value"
67 67 ),
... ... @@ -73,20 +73,20 @@ public define DB_Table settings_table =
73 73 )
74 74 ).
75 75  
76   -public define DB_Table django_admin_log_table =
77   - db_table("django_admin_log",
78   - db_model(
  76 +public define HK_Table django_admin_log_table =
  77 + hk_table("django_admin_log",
  78 + hk_model(
79 79 [
80 80  
81   - db_column("action_time", datetime_field(auto_now_add), []),
82   -// db_column("user_id", foreign_key("auth_user"), [indexed]),
83   -// db_column("content_type_id", foreign_key("django_content_type"), [indexed]),
84   - db_column("user_id", integer_field, []),
85   - db_column("content_type_id", integer_field, []),
86   - db_column("object_id", text_field, []),
87   - db_column("object_repr", char_field(200), []),
88   - db_column("action_flag", integer_field, []),
89   - db_column("change_message", text_field, []),
  81 + hk_column("action_time", datetime_field(auto_now_add), []),
  82 +// hk_column("user_id", foreign_key("auth_user"), [indexed]),
  83 +// hk_column("content_type_id", foreign_key("django_content_type"), [indexed]),
  84 + hk_column("user_id", integer_field, []),
  85 + hk_column("content_type_id", integer_field, []),
  86 + hk_column("object_id", text_field, []),
  87 + hk_column("object_repr", char_field(200), []),
  88 + hk_column("action_flag", integer_field, []),
  89 + hk_column("change_message", text_field, []),
90 90 ],
91 91 "obj.object_repr"
92 92 ),
... ... @@ -98,14 +98,14 @@ public define DB_Table django_admin_log_table =
98 98 )
99 99 ).
100 100  
101   -public define DB_Table production_macaddress_table =
102   - db_table("production_macaddress",
103   - db_model(
  101 +public define HK_Table production_macaddress_table =
  102 + hk_table("macaddress",
  103 + hk_model(
104 104 [
105 105  
106   - db_column("mac", char_field(20), []),
107   - db_column("index", integer_field, []),
108   - db_column("mailfountain_id", integer_field, []),
  106 + hk_column("mac", char_field(20), []),
  107 + hk_column("index", integer_field, []),
  108 + hk_column("mailfountain_id", integer_field, []),
109 109 ],
110 110 "obj.mac+\" = MailFountain[\"+obj.mailfountain_id+\"]\""
111 111 ),
... ... @@ -117,12 +117,12 @@ public define DB_Table production_macaddress_table =
117 117 )
118 118 ).
119 119  
120   -public define DB_Table production_mass_storage_type_table =
121   - db_table("production_mass_storage_type",
122   - db_model(
  120 +public define HK_Table production_mass_storage_type_table =
  121 + hk_table("mass_storage_type",
  122 + hk_model(
123 123 [
124 124  
125   - db_column("type", char_field(20), []),
  125 + hk_column("type", char_field(20), []),
126 126 ],
127 127 "to_String(obj.id)+\":\"+obj.type"
128 128 ),
... ... @@ -136,18 +136,18 @@ public define DB_Table production_mass_storage_type_table =
136 136  
137 137  
138 138  
139   -public define DB_Table production_mass_storage_table =
140   - db_table("production_mass_storage",
141   - db_model(
  139 +public define HK_Table production_mass_storage_table =
  140 + hk_table("mass_storage",
  141 + hk_model(
142 142 [
143 143  
144   - db_column("purchase_id", foreign_key("production_purchase"), [indexed]),
145   - db_column("model_id", foreign_key("production_mass_storage_model"), [indexed]),
146   - db_column("serial", char_field(40), []), //
147   - db_column("status", char_field(10), []), //
148   - db_column("date_created", datetime_field(auto_now_add), []),
149   - db_column("last_modified", datetime_field(auto_now), []),
150   - db_column("comments", text_field, []) // whatever the user wants to keep
  144 + hk_column("purchase_id", foreign_key("purchase"), [indexed]),
  145 + hk_column("model_id", foreign_key("mass_storage_model"), [indexed]),
  146 + hk_column("serial", char_field(40), []), //
  147 + hk_column("status", char_field(10), []), //
  148 + hk_column("date_created", datetime_field(auto_now_add), []),
  149 + hk_column("last_modified", datetime_field(auto_now), []),
  150 + hk_column("comments", text_field, []) // whatever the user wants to keep
151 151 ],
152 152 "obj.serial"
153 153 ),
... ... @@ -175,18 +175,18 @@ public define DB_Table production_mass_storage_table =
175 175  
176 176  
177 177  
178   -public define DB_Table production_mass_storage_model_table =
179   - db_table("production_mass_storage_model",
180   - db_model(
  178 +public define HK_Table production_mass_storage_model_table =
  179 + hk_table("mass_storage_model",
  180 + hk_model(
181 181 [
182 182  
183   - db_column("manufacturer", char_field(20), []),
184   - db_column("type_id", foreign_key("production_mass_storage_type"), [indexed]),
185   - db_column("capacity", integer_field, []), //
186   - db_column("tr_min", integer_field, []), //
187   - db_column("date_created", datetime_field(auto_now_add), []),
188   - db_column("last_modified", datetime_field(auto_now), []),
189   - db_column("comments", text_field, []) // whatever the user wants to keep
  183 + hk_column("manufacturer", char_field(20), []),
  184 + hk_column("type_id", foreign_key("mass_storage_type"), [indexed]),
  185 + hk_column("capacity", integer_field, []), //
  186 + hk_column("tr_min", integer_field, []), //
  187 + hk_column("date_created", datetime_field(auto_now_add), []),
  188 + hk_column("last_modified", datetime_field(auto_now), []),
  189 + hk_column("comments", text_field, []) // whatever the user wants to keep
190 190 ],
191 191 "obj.manufacturer"
192 192 ),
... ... @@ -200,18 +200,18 @@ public define DB_Table production_mass_storage_model_table =
200 200 )
201 201 ).
202 202  
203   -public define DB_Table production_memory_table =
204   - db_table("production_memory",
205   - db_model(
  203 +public define HK_Table production_memory_table =
  204 + hk_table("memory",
  205 + hk_model(
206 206 [
207 207  
208   - db_column("purchase_id", foreign_key("production_purchase"), [indexed]),
209   - db_column("model_id", foreign_key("production_memory_model"), [indexed]),
210   - db_column("serial", char_field(40), []), //
211   - db_column("status", char_field(10), []), //
212   - db_column("date_created", datetime_field(auto_now_add), []),
213   - db_column("last_modified", datetime_field(auto_now), []),
214   - db_column("comments", text_field, []) // whatever the user wants to keep
  208 + hk_column("purchase_id", foreign_key("purchase"), [indexed]),
  209 + hk_column("model_id", foreign_key("memory_model"), [indexed]),
  210 + hk_column("serial", char_field(40), []), //
  211 + hk_column("status", char_field(10), []), //
  212 + hk_column("date_created", datetime_field(auto_now_add), []),
  213 + hk_column("last_modified", datetime_field(auto_now), []),
  214 + hk_column("comments", text_field, []) // whatever the user wants to keep
215 215 ],
216 216 "obj.serial"
217 217 ),
... ... @@ -225,14 +225,14 @@ public define DB_Table production_memory_table =
225 225 )
226 226 ).
227 227  
228   -public define DB_Table production_memory_model_table =
229   - db_table("production_memory_model",
230   - db_model(
  228 +public define HK_Table production_memory_model_table =
  229 + hk_table("memory_model",
  230 + hk_model(
231 231 [
232 232  
233   - db_column("type_id", foreign_key("production_memory_type"), [indexed]),
234   - db_column("manufacturer", char_field(20), []), //
235   - db_column("capacity", integer_field, []) //
  233 + hk_column("type_id", foreign_key("memory_type"), [indexed]),
  234 + hk_column("manufacturer", char_field(20), []), //
  235 + hk_column("capacity", integer_field, []) //
236 236 ],
237 237 "obj.manufacturer"
238 238 ),
... ... @@ -244,12 +244,12 @@ public define DB_Table production_memory_model_table =
244 244 )
245 245 ).
246 246  
247   -public define DB_Table production_memory_type_table =
248   - db_table("production_memory_type",
249   - db_model(
  247 +public define HK_Table production_memory_type_table =
  248 + hk_table("memory_type",
  249 + hk_model(
250 250 [
251 251  
252   - db_column("type", char_field(20), []),
  252 + hk_column("type", char_field(20), []),
253 253 ],
254 254 "to_String(obj.id)+\":\"+obj.type"
255 255 ),
... ... @@ -261,19 +261,19 @@ public define DB_Table production_memory_type_table =
261 261 )
262 262 ).
263 263  
264   -public define DB_Table production_motherboard_table =
265   - db_table("production_motherboard",
266   - db_model(
  264 +public define HK_Table production_motherboard_table =
  265 + hk_table("motherboard",
  266 + hk_model(
267 267 [
268 268  
269   - db_column("purchase_id", foreign_key("production_purchase"), [indexed]),
270   - db_column("model_id", foreign_key("production_motherboard_model"), [indexed]),
271   - db_column("serial", char_field(40), []), //
272   - db_column("week_fab", char_field(10), []), //
273   - db_column("status", char_field(10), []), //
274   - db_column("date_created", datetime_field(auto_now_add), []),
275   - db_column("last_modified", datetime_field(auto_now), []),
276   - db_column("comments", text_field, []) // whatever the user wants to keep
  269 + hk_column("purchase_id", foreign_key("purchase"), [indexed]),
  270 + hk_column("model_id", foreign_key("motherboard_model"), [indexed]),
  271 + hk_column("serial", char_field(40), []), //
  272 + hk_column("week_fab", char_field(10), []), //
  273 + hk_column("status", char_field(10), []), //
  274 + hk_column("date_created", datetime_field(auto_now_add), []),
  275 + hk_column("last_modified", datetime_field(auto_now), []),
  276 + hk_column("comments", text_field, []) // whatever the user wants to keep
277 277 ],
278 278 "obj.serial"
279 279 ),
... ... @@ -287,19 +287,19 @@ public define DB_Table production_motherboard_table =
287 287 )
288 288 ).
289 289  
290   -public define DB_Table production_motherboard_model_table =
291   - db_table("production_motherboard_model",
292   - db_model(
  290 +public define HK_Table production_motherboard_model_table =
  291 + hk_table("motherboard_model",
  292 + hk_model(
293 293 [
294 294  
295   - db_column("name", char_field(30), []),
296   - db_column("manufacturer", char_field(20), []),
297   - db_column("has_nand", boolean_field, []),
298   - db_column("nand_capacity", integer_field, []), //
299   - db_column("memory", integer_field, []), //
300   - db_column("cpu_freq", integer_field, []), //
301   - db_column("cpu_model", char_field(30), []),
302   - db_column("endian", char_field(1), []) // whatever the user wants to keep
  295 + hk_column("name", char_field(30), []),
  296 + hk_column("manufacturer", char_field(20), []),
  297 + hk_column("has_nand", boolean_field, []),
  298 + hk_column("nand_capacity", integer_field, []), //
  299 + hk_column("memory", integer_field, []), //
  300 + hk_column("cpu_freq", integer_field, []), //
  301 + hk_column("cpu_model", char_field(30), []),
  302 + hk_column("endian", char_field(1), []) // whatever the user wants to keep
303 303 ],
304 304 "obj.name"
305 305 ),
... ... @@ -313,18 +313,18 @@ public define DB_Table production_motherboard_model_table =
313 313 )
314 314 ).
315 315  
316   -public define DB_Table production_power_supply_table =
317   - db_table("production_power_supply",
318   - db_model(
  316 +public define HK_Table production_power_supply_table =
  317 + hk_table("power_supply",
  318 + hk_model(
319 319 [
320 320  
321   - db_column("purchase_id", foreign_key("production_purchase"), [indexed]),
322   - db_column("model_id", foreign_key("production_power_supply_model"), [indexed]),
323   - db_column("serial", char_field(40), []), //
324   - db_column("status", char_field(10), []), //
325   - db_column("date_created", datetime_field(auto_now_add), []),
326   - db_column("last_modified", datetime_field(auto_now), []),
327   - db_column("comments", text_field, []) // whatever the user wants to keep
  321 + hk_column("purchase_id", foreign_key("purchase"), [indexed]),
  322 + hk_column("model_id", foreign_key("power_supply_model"), [indexed]),
  323 + hk_column("serial", char_field(40), []), //
  324 + hk_column("status", char_field(10), []), //
  325 + hk_column("date_created", datetime_field(auto_now_add), []),
  326 + hk_column("last_modified", datetime_field(auto_now), []),
  327 + hk_column("comments", text_field, []) // whatever the user wants to keep
328 328 ],
329 329 "obj.serial"
330 330 ),
... ... @@ -338,14 +338,14 @@ public define DB_Table production_power_supply_table =
338 338 )
339 339 ).
340 340  
341   -public define DB_Table production_power_supply_model_table =
342   - db_table("production_power_supply_model",
343   - db_model(
  341 +public define HK_Table production_power_supply_model_table =
  342 + hk_table("power_supply_model",
  343 + hk_model(
344 344 [
345 345  
346   - db_column("name", char_field(30), []),
347   - db_column("manufacturer", char_field(20), []),
348   - db_column("power", integer_field, [])
  346 + hk_column("name", char_field(30), []),
  347 + hk_column("manufacturer", char_field(20), []),
  348 + hk_column("power", integer_field, [])
349 349 ],
350 350 "obj.name"
351 351 ),
... ... @@ -359,23 +359,23 @@ public define DB_Table production_power_supply_model_table =
359 359 )
360 360 ).
361 361  
362   -public define DB_Table production_product_reference_table =
363   - db_table("production_product_reference",
364   - db_model(
  362 +public define HK_Table production_product_reference_table =
  363 + hk_table("product_reference",
  364 + hk_model(
365 365 [
366 366  
367   - db_column("type_ref_id", foreign_key("production_type_number"), [indexed]),
368   - db_column("product_ref", char_field(4), []),
369   - db_column("product_name", char_field(30), []), //
370   - db_column("description", char_field(200), []), //
371   - db_column("need_memory", boolean_field, []), //
372   - db_column("need_power_supply", boolean_field, []), //
373   - db_column("need_additional_storage", boolean_field, []), //
374   - db_column("min_additional_storage", integer_field, []), //
375   - db_column("max_additional_storage", integer_field, []), //
376   - db_column("date_created", datetime_field(auto_now_add), []),
377   - db_column("last_modified", datetime_field(auto_now), []),
378   - db_column("comments", text_field, []) // whatever the user wants to keep
  367 + hk_column("type_ref_id", foreign_key("type_number"), [indexed]),
  368 + hk_column("product_ref", char_field(4), []),
  369 + hk_column("product_name", char_field(30), []), //
  370 + hk_column("description", char_field(200), []), //
  371 + hk_column("need_memory", boolean_field, []), //
  372 + hk_column("need_power_supply", boolean_field, []), //
  373 + hk_column("need_additional_storage", boolean_field, []), //
  374 + hk_column("min_additional_storage", integer_field, []), //
  375 + hk_column("max_additional_storage", integer_field, []), //
  376 + hk_column("date_created", datetime_field(auto_now_add), []),
  377 + hk_column("last_modified", datetime_field(auto_now), []),
  378 + hk_column("comments", text_field, []) // whatever the user wants to keep
379 379 ],
380 380 "obj.product_ref+\":\"+obj.product_name"
381 381 ),
... ... @@ -390,29 +390,29 @@ public define DB_Table production_product_reference_table =
390 390 )
391 391 ).
392 392  
393   -public define DB_Table production_products_table =
394   - db_table("production_products",
395   - db_model(
  393 +public define HK_Table production_products_table =
  394 + hk_table("products",
  395 + hk_model(
396 396 [
397   - db_column("production_id", foreign_key("production_production"), []),
398   - db_column("produced", boolean_field, []), //
399   - db_column("date", date_field(none), []),
400   - db_column("serial", char_field(50), []), //
401   - db_column("security_code", char_field(50), []), //
402   - db_column("motherboard_id", foreign_key("production_motherboard"), []),
403   - db_column("storage_id", foreign_key("production_mass_storage"), []),
404   - db_column("memory_id", foreign_key("production_memory"), []),
405   - db_column("power_supply_id", foreign_key("production_power_supply"), []),
406   - db_column("wifi", boolean_field, []), //
407   - db_column("mac", char_field(20), []),
408   - db_column("app_id", char_field(100), []),
409   - db_column("os_version", char_field(20), []),
410   - db_column("published", boolean_field, []),
411   - db_column("publish_date", datetime_field(none), []), //
412   - db_column("status", char_field(10), []),
413   - db_column("date_created", datetime_field(auto_now_add), []),
414   - db_column("last_modified", datetime_field(auto_now), []),
415   - db_column("comments", text_field, []) // whatever the user wants to keep
  397 + hk_column("production_id", foreign_key("production"), []),
  398 + hk_column("produced", boolean_field, []), //
  399 + hk_column("date", date_field(none), []),
  400 + hk_column("serial", char_field(50), []), //
  401 + hk_column("security_code", char_field(50), []), //
  402 + hk_column("motherboard_id", foreign_key("motherboard"), []),
  403 + hk_column("storage_id", foreign_key("mass_storage"), []),
  404 + hk_column("memory_id", foreign_key("memory"), []),
  405 + hk_column("power_supply_id", foreign_key("power_supply"), []),
  406 + hk_column("wifi", boolean_field, []), //
  407 + hk_column("mac", char_field(20), []),
  408 + hk_column("app_id", char_field(100), []),
  409 + hk_column("os_version", char_field(20), []),
  410 + hk_column("published", boolean_field, []),
  411 + hk_column("publish_date", datetime_field(none), []), //
  412 + hk_column("status", char_field(10), []),
  413 + hk_column("date_created", datetime_field(auto_now_add), []),
  414 + hk_column("last_modified", datetime_field(auto_now), []),
  415 + hk_column("comments", text_field, []) // whatever the user wants to keep
416 416 ],
417 417 "obj.serial"
418 418 ),
... ... @@ -427,26 +427,26 @@ public define DB_Table production_products_table =
427 427 )
428 428 ).
429 429  
430   -public define DB_Table production_production_table =
431   - db_table("production_production",
432   - db_model(
  430 +public define HK_Table production_production_table =
  431 + hk_table("production",
  432 + hk_model(
433 433 [
434 434  
435   - db_column("date", date_field(none), []),
436   - db_column("assembler_id", foreign_key("staff_staff"), []),
437   - db_column("type_ref_id", foreign_key("production_type_number"), []),
438   - db_column("product_ref_id", foreign_key("production_product_reference"), []),
439   - db_column("site_id", foreign_key("production_production_site"), []),
440   - db_column("serial_prefix_id", foreign_key("production_serial_prefix"), []),
441   - db_column("sticker_tpl_id", foreign_key("production_type_number"), []),
442   - db_column("starting_index", integer_field, []), //
443   - db_column("product_count", integer_field, []), //
444   - db_column("produced_count", integer_field, []), //
445   - db_column("completed", boolean_field, []), //
446   - db_column("active", boolean_field, []), //
447   - db_column("date_created", datetime_field(auto_now_add), []),
448   - db_column("last_modified", datetime_field(auto_now), []),
449   - db_column("comments", text_field, []) // whatever the user wants to keep
  435 + hk_column("date", date_field(none), []),
  436 + hk_column("assembler_id", foreign_key(app_name("staff"),"staff"), []),
  437 + hk_column("type_ref_id", foreign_key("type_number"), []),
  438 + hk_column("product_ref_id", foreign_key("product_reference"), []),
  439 + hk_column("site_id", foreign_key("production_site"), []),
  440 + hk_column("serial_prefix_id", foreign_key("serial_prefix"), []),
  441 + hk_column("sticker_tpl_id", foreign_key("type_number"), []),
  442 + hk_column("starting_index", integer_field, []), //
  443 + hk_column("product_count", integer_field, []), //
  444 + hk_column("produced_count", integer_field, []), //
  445 + hk_column("completed", boolean_field, []), //
  446 + hk_column("active", boolean_field, []), //
  447 + hk_column("date_created", datetime_field(auto_now_add), []),
  448 + hk_column("last_modified", datetime_field(auto_now), []),
  449 + hk_column("comments", text_field, []) // whatever the user wants to keep
450 450 ],
451 451 "date(obj.date)"
452 452 ),
... ... @@ -461,18 +461,18 @@ public define DB_Table production_production_table =
461 461 )
462 462 ).
463 463  
464   -public define DB_Table production_production_site_table =
465   - db_table("production_production_site",
466   - db_model(
  464 +public define HK_Table production_production_site_table =
  465 + hk_table("production_site",
  466 + hk_model(
467 467 [
468   - db_column("ref", char_field(3), []),
469   - db_column("name", char_field(50), []),
470   - db_column("city", char_field(30), []),
471   - db_column("country", char_field(30), []),
472   - db_column("next_serial", integer_field, []),
473   - db_column("date_created", datetime_field(auto_now_add), []),
474   - db_column("last_modified", datetime_field(auto_now), []),
475   - db_column("comments", text_field, []) // whatever the user wants to keep
  468 + hk_column("ref", char_field(3), []),
  469 + hk_column("name", char_field(50), []),
  470 + hk_column("city", char_field(30), []),
  471 + hk_column("country", char_field(30), []),
  472 + hk_column("next_serial", integer_field, []),
  473 + hk_column("date_created", datetime_field(auto_now_add), []),
  474 + hk_column("last_modified", datetime_field(auto_now), []),
  475 + hk_column("comments", text_field, []) // whatever the user wants to keep
476 476 ],
477 477 "obj.ref+\":\"+obj.name"
478 478 ),
... ... @@ -486,18 +486,18 @@ public define DB_Table production_production_site_table =
486 486 )
487 487 ).
488 488  
489   -public define DB_Table production_purchase_table =
490   - db_table("production_purchase",
491   - db_model(
  489 +public define HK_Table production_purchase_table =
  490 + hk_table("purchase",
  491 + hk_model(
492 492 [
493   - db_column("date", date_field(none), []),
494   - db_column("buyer_id", foreign_key("staff_staff"), [indexed]),
495   - db_column("supplier_id", foreign_key("production_supplier"), [indexed]),
496   - db_column("order_ref", char_field(50), []), //
497   - db_column("description", char_field(200), []), // description of the purchase
498   - db_column("date_created", datetime_field(auto_now_add), []),
499   - db_column("last_modified", datetime_field(auto_now), []),
500   - db_column("comments", text_field, []), // whatever the user wants to keep
  493 + hk_column("date", date_field(none), []),
  494 + hk_column("buyer_id", foreign_key(app_name("staff"),"staff"), [indexed]),
  495 + hk_column("supplier_id", foreign_key("supplier"), [indexed]),
  496 + hk_column("order_ref", char_field(50), []), //
  497 + hk_column("description", char_field(200), []), // description of the purchase
  498 + hk_column("date_created", datetime_field(auto_now_add), []),
  499 + hk_column("last_modified", datetime_field(auto_now), []),
  500 + hk_column("comments", text_field, []), // whatever the user wants to keep
501 501 ],
502 502 "date(obj.date)"
503 503 ),
... ... @@ -511,13 +511,13 @@ public define DB_Table production_purchase_table =
511 511 )
512 512 ).
513 513  
514   -public define DB_Table production_serial_prefix_table =
515   - db_table("production_serial_prefix",
516   - db_model(
  514 +public define HK_Table production_serial_prefix_table =
  515 + hk_table("serial_prefix",
  516 + hk_model(
517 517 [
518 518  
519   - db_column("prefix", char_field(3), []),
520   - db_column("next_start", integer_field, [])
  519 + hk_column("prefix", char_field(3), []),
  520 + hk_column("next_start", integer_field, [])
521 521 ],
522 522 "obj.prefix"
523 523 ),
... ... @@ -529,16 +529,16 @@ public define DB_Table production_serial_prefix_table =
529 529 )
530 530 ).
531 531  
532   -public define DB_Table production_type_number_table =
533   - db_table("production_type_number",
534   - db_model(
  532 +public define HK_Table production_type_number_table =
  533 + hk_table("type_number",
  534 + hk_model(
535 535 [
536 536  
537   - db_column("type_ref", char_field(3), []),
538   - db_column("description", text_field, []),
539   - db_column("date_created", datetime_field(auto_now_add), []),
540   - db_column("last_modified", datetime_field(auto_now), []),
541   - db_column("comments", text_field, []) // whatever the user wants to keep
  537 + hk_column("type_ref", char_field(3), []),
  538 + hk_column("description", text_field, []),
  539 + hk_column("date_created", datetime_field(auto_now_add), []),
  540 + hk_column("last_modified", datetime_field(auto_now), []),
  541 + hk_column("comments", text_field, []) // whatever the user wants to keep
542 542 ],
543 543 "obj.type_ref+\":\"+obj.description"
544 544 ),
... ... @@ -552,28 +552,28 @@ public define DB_Table production_type_number_table =
552 552 )
553 553 ).
554 554  
555   -public define DB_Table production_supplier_table =
556   - db_table("production_supplier",
557   - db_model(
  555 +public define HK_Table production_supplier_table =
  556 + hk_table("supplier",
  557 + hk_model(
558 558 [
559 559  
560   - db_column("company", char_field(100), []),
561   - db_column("contact_id", foreign_key("address_book_contact"), []),
562   - db_column("address1", char_field(100), []),
563   - db_column("address2", char_field(100), []),
564   - db_column("zipcode", char_field(10), []),
565   - db_column("city", char_field(50), []),
566   - db_column("country", char_field(50), []),
567   - db_column("email", char_field(75), []),
568   - db_column("url", char_field(200), []),
569   - db_column("phone", char_field(20), []),
570   - db_column("fax", char_field(20), []),
571   - db_column("mobile", char_field(20), []),
572   - db_column("siret", char_field(50), []),
573   - db_column("tva_number", char_field(50), []),
574   - db_column("date_created", datetime_field(auto_now_add), []),
575   - db_column("last_modified", datetime_field(auto_now), []),
576   - db_column("comments", text_field, []) // whatever the user wants to keep
  560 + hk_column("company", char_field(100), []),
  561 + hk_column("contact_id", foreign_key(none, "address_book_contact"), []),
  562 + hk_column("address1", char_field(100), []),
  563 + hk_column("address2", char_field(100), []),
  564 + hk_column("zipcode", char_field(10), []),
  565 + hk_column("city", char_field(50), []),
  566 + hk_column("country", char_field(50), []),
  567 + hk_column("email", char_field(75), []),
  568 + hk_column("url", char_field(200), []),
  569 + hk_column("phone", char_field(20), []),
  570 + hk_column("fax", char_field(20), []),
  571 + hk_column("mobile", char_field(20), []),
  572 + hk_column("siret", char_field(50), []),
  573 + hk_column("tva_number", char_field(50), []),
  574 + hk_column("date_created", datetime_field(auto_now_add), []),
  575 + hk_column("last_modified", datetime_field(auto_now), []),
  576 + hk_column("comments", text_field, []) // whatever the user wants to keep
577 577 ],
578 578 "obj.company"
579 579 ),
... ... @@ -589,16 +589,16 @@ public define DB_Table production_supplier_table =
589 589 ).
590 590  
591 591  
592   -public define DB_Table staff_department_table =
593   - db_table("staff_department",
594   - db_model(
  592 +public define HK_Table department_table =
  593 + hk_table("department",
  594 + hk_model(
595 595 [
596 596  
597   - db_column("name", char_field(50), []),
598   - db_column("description", text_field, []),
599   - db_column("date_created", datetime_field(auto_now_add), []),
600   - db_column("last_modified", datetime_field(auto_now), []),
601   - db_column("comments", text_field, []) // whatever the user wants to keep
  597 + hk_column("name", char_field(50), []),
  598 + hk_column("description", text_field, []),
  599 + hk_column("date_created", datetime_field(auto_now_add), []),
  600 + hk_column("last_modified", datetime_field(auto_now), []),
  601 + hk_column("comments", text_field, []) // whatever the user wants to keep
602 602 ],
603 603 "obj.name"
604 604 ),
... ... @@ -613,15 +613,15 @@ public define DB_Table staff_department_table =
613 613 ).
614 614  
615 615  
616   -public define DB_Table staff_role_table =
617   - db_table("staff_role",
618   - db_model(
  616 +public define HK_Table role_table =
  617 + hk_table("role",
  618 + hk_model(
619 619 [
620   - db_column("role_name", char_field(50), []),
621   - db_column("description", text_field, []),
622   - db_column("date_created", datetime_field(auto_now_add), []),
623   - db_column("last_modified", datetime_field(auto_now), []),
624   - db_column("comments", text_field, []) // whatever the user wants to keep
  620 + hk_column("role_name", char_field(50), []),
  621 + hk_column("description", text_field, []),
  622 + hk_column("date_created", datetime_field(auto_now_add), []),
  623 + hk_column("last_modified", datetime_field(auto_now), []),
  624 + hk_column("comments", text_field, []) // whatever the user wants to keep
625 625 ],
626 626 "obj.role_name"
627 627 ),
... ... @@ -635,21 +635,21 @@ public define DB_Table staff_role_table =
635 635 )
636 636 ).
637 637  
638   -public define DB_Table staff_staff_table =
639   - db_table("staff_staff",
640   - db_model(
  638 +public define HK_Table staff_table =
  639 + hk_table("staff",
  640 + hk_model(
641 641 [
642 642  
643   - db_column("contact_id", foreign_key("address_book_contact"), [indexed]),
644   - db_column("department_id", foreign_key("staff_department"), [indexed]),
645   - db_column("role_id", foreign_key("staff_role"), [indexed]),
646   - db_column("email", char_field(75), []),
647   - db_column("incoming_date", date_field(none), []), //
648   - db_column("outgoing_date", date_field(none), [], help_text("if not still present in company. The date of official outgoing")), //
649   - db_column("still_present", boolean_field, [], help_text("Still working for the company")),
650   - db_column("date_created", datetime_field(auto_now_add), []),
651   - db_column("last_modified", datetime_field(auto_now), []),
652   - db_column("comments", text_field, []) // whatever the user wants to keep
  643 + hk_column("contact_id", foreign_key(none, "address_book_contact"), [indexed]),
  644 + hk_column("department_id", foreign_key("department"), [indexed]),
  645 + hk_column("role_id", foreign_key("role"), [indexed]),
  646 + hk_column("email", char_field(75), []),
  647 + hk_column("incoming_date", date_field(none), []), //
  648 + hk_column("outgoing_date", date_field(none), [], help_text("if not still present in company. The date of official outgoing")), //
  649 + hk_column("still_present", boolean_field, [], help_text("Still working for the company")),
  650 + hk_column("date_created", datetime_field(auto_now_add), []),
  651 + hk_column("last_modified", datetime_field(auto_now), []),
  652 + hk_column("comments", text_field, []) // whatever the user wants to keep
653 653 ],
654 654 "obj.email"
655 655 ),
... ... @@ -665,28 +665,28 @@ public define DB_Table staff_staff_table =
665 665 )
666 666 ).
667 667  
668   -public define DB_Table address_book_contact_table =
669   - db_table("address_book_contact",
670   - db_model(
  668 +public define HK_Table address_book_contact_table =
  669 + hk_table("address_book_contact",
  670 + hk_model(
671 671 [
672 672  
673   - db_column("first_name", char_field(50), []),
674   - db_column("last_name", char_field(50), []),
675   - db_column("company", char_field(100), []),
676   - db_column("role", char_field(50), []),
677   - db_column("address1", char_field(100), []),
678   - db_column("address2", char_field(100), []),
679   - db_column("zipcode", char_field(10), []),
680   - db_column("city", char_field(50), []),
681   - db_column("country", char_field(50), []),
682   - db_column("email", char_field(75), []),
683   - db_column("url", char_field(200), []),
684   - db_column("phone", char_field(20), []),
685   - db_column("fax", char_field(20), []),
686   - db_column("mobile", char_field(20), []),
687   - db_column("date_created", datetime_field(auto_now_add), []),
688   - db_column("last_modified", datetime_field(auto_now), []),
689   - db_column("comments", text_field, []) // whatever the user wants to keep
  673 + hk_column("first_name", char_field(50), []),
  674 + hk_column("last_name", char_field(50), []),
  675 + hk_column("company", char_field(100), []),
  676 + hk_column("role", char_field(50), []),
  677 + hk_column("address1", char_field(100), []),
  678 + hk_column("address2", char_field(100), []),
  679 + hk_column("zipcode", char_field(10), []),
  680 + hk_column("city", char_field(50), []),
  681 + hk_column("country", char_field(50), []),
  682 + hk_column("email", char_field(75), []),
  683 + hk_column("url", char_field(200), []),
  684 + hk_column("phone", char_field(20), []),
  685 + hk_column("fax", char_field(20), []),
  686 + hk_column("mobile", char_field(20), []),
  687 + hk_column("date_created", datetime_field(auto_now_add), []),
  688 + hk_column("last_modified", datetime_field(auto_now), []),
  689 + hk_column("comments", text_field, []) // whatever the user wants to keep
690 690 ],
691 691 "obj.first_name +\" \"+obj.last_name "
692 692 ),
... ... @@ -702,36 +702,48 @@ public define DB_Table address_book_contact_table =
702 702 )
703 703 ).
704 704  
705   -public define DB_Database
  705 +public define HK_Database
706 706 the_database_description
707 707 =
708   - db_database("prod_manager",
  708 + hk_database("prod_manager",
709 709 [
710 710 //domain manager
711 711 //mf_serial_table
712   - settings_table,
713   - production_mass_storage_table,
714   - production_mass_storage_type_table,
715   - production_mass_storage_model_table,
716   - production_memory_table,
717   - production_memory_model_table,
718   - production_memory_type_table,
719   - production_macaddress_table,
720   - production_motherboard_table,
721   - production_motherboard_model_table,
722   - production_power_supply_table,
723   - production_power_supply_model_table,
724   - production_product_reference_table,
725   - production_production_table,
726   - production_production_site_table,
727   - production_products_table,
728   - production_purchase_table,
729   - production_serial_prefix_table,
730   - production_type_number_table,
731   - production_supplier_table,
732   - staff_department_table,
733   - staff_staff_table,
734   - staff_role_table,
735   - django_admin_log_table,
736   - address_book_contact_table
  712 + hk_app("base",
  713 + [
  714 + settings_table,
  715 + ]),
  716 + hk_app("production",
  717 + [
  718 + production_mass_storage_table,
  719 + production_mass_storage_type_table,
  720 + production_mass_storage_model_table,
  721 + production_memory_table,
  722 + production_memory_model_table,
  723 + production_memory_type_table,
  724 + production_macaddress_table,
  725 + production_motherboard_table,
  726 + production_motherboard_model_table,
  727 + production_power_supply_table,
  728 + production_power_supply_model_table,
  729 + production_product_reference_table,
  730 + production_production_table,
  731 + production_production_site_table,
  732 + production_products_table,
  733 + production_purchase_table,
  734 + production_serial_prefix_table,
  735 + production_type_number_table,
  736 + production_supplier_table
  737 + ]),
  738 + hk_app("staff",
  739 + [
  740 + department_table,
  741 + staff_table,
  742 + role_table,
  743 + ]),
  744 + hk_app("",
  745 + [
  746 + django_admin_log_table,
  747 + address_book_contact_table
  748 + ])
737 749 ]).
... ...