Commit 20d4ed207e52b9e144580a8c76693925f529006b

Authored by totoro
1 parent 1a0e85ff

add table constraint on model definition

add mobile and url field
calexium_lib @ b3254dcbe86
1   -Subproject commit 07f1bbce4bbd814d97625f59577e98fc4f8eceea
  1 +Subproject commit b3254dcbe8651bb63cc91b71934155fd560bf621
... ...
ds_files/20170524-graphviz.pdf 0 → 100644
No preview for this file type
ds_files/graphviz.pdf 0 → 100644
No preview for this file type
hayamiki_generator.aproj
... ... @@ -37,6 +37,7 @@
37 37 <Compile Include="calexium_lib\database\db_update_fields.anubis" />
38 38 <Compile Include="calexium_lib\database\db_types.anubis" />
39 39 <Compile Include="calexium_lib\database\db_utils.anubis" />
  40 + <Compile Include="calexium_lib\database\db_version.anubis" />
40 41 <Compile Include="calexium_lib\database\migration.anubis" />
41 42 <Compile Include="calexium_lib\database\migration_common.anubis" />
42 43 <Compile Include="calexium_lib\database\migration_common_sqlite3.anubis" />
... ... @@ -68,6 +69,7 @@
68 69 <Compile Include="calexium_lib\net_services_protocols\pkg_updater_protocol.anubis" />
69 70 <Compile Include="calexium_lib\os_tools\freebsd\rc_conf.anubis" />
70 71 <Compile Include="calexium_lib\os_tools\linux\config\network_interface_file.anubis" />
  72 + <Compile Include="calexium_lib\types\version.anubis" />
71 73 <Compile Include="calexium_lib\unit_test\xml_rpc.unit_test.anubis" />
72 74 <Compile Include="calexium_lib\web\counter.anubis" />
73 75 <Compile Include="calexium_lib\web\CXM_common.anubis" />
... ... @@ -712,6 +714,7 @@
712 714 <Folder Include="calexium_lib\os_tools\freebsd" />
713 715 <Folder Include="calexium_lib\os_tools\linux" />
714 716 <Folder Include="calexium_lib\os_tools\linux\config" />
  717 + <Folder Include="calexium_lib\types" />
715 718 <Folder Include="calexium_lib\unit_test" />
716 719 <Folder Include="calexium_lib\web" />
717 720 <Folder Include="calexium_lib\web\jQuery" />
... ...
hayamiki_lib @ c0af45f7cc7
1   -Subproject commit 57345f2acee9ffeb19673b957d0aeb7296dfb742
  1 +Subproject commit c0af45f7cc7c251cbac2837e95cdb7bea2379d95
... ...
src/check.anubis
... ... @@ -164,7 +164,7 @@ define Maybe(List(HK_Table))
164 164 [] then success(reverse(so_far)),
165 165 [h . t] then
166 166 since h is hk_table(name, short_name, model, display),
167   - since model is hk_model(columns, display_string),
  167 + since model is hk_model(columns, constraints, display_string),
168 168 with table_name = if length(app_name) > 0 then app_name +"_"+name else name,
169 169 if resolve_foreign(apps_name, app_name, table_name, columns, []) is
170 170 {
... ... @@ -175,7 +175,7 @@ define Maybe(List(HK_Table))
175 175 {
176 176 failure then failure,
177 177 success(checked_list_edits) then
178   - resolve_foreign(apps_name, app_name, t, [hk_table(table_name, name, hk_model(checked_model, display_string), hk_display(list_views, checked_list_edits)) . so_far])
  178 + resolve_foreign(apps_name, app_name, t, [hk_table(table_name, name, hk_model(checked_model, constraints, display_string), hk_display(list_views, checked_list_edits)) . so_far])
179 179 }
180 180  
181 181 }
... ...
src/generation/SQL_get_all.anubis
... ... @@ -17,7 +17,7 @@ public define Maybe(One)
17 17 HK_Table table
18 18 )=
19 19 since table is hk_table(name, short_name, model, _),
20   - since model is hk_model(columns, _),
  20 + since model is hk_model(columns, constraints, _),
21 21 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
22 22  
23 23 //generate the type of the table that contain all components
... ... @@ -74,7 +74,7 @@ public define Maybe(One)
74 74 HK_Table table
75 75 )=
76 76 since table is hk_table(name, short_name, model, _),
77   - since model is hk_model(columns, _),
  77 + since model is hk_model(columns, constraints, _),
78 78 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
79 79  
80 80 //generate the type of the table that contain all components
... ...
src/generation/SQL_get_count.anubis
... ... @@ -19,7 +19,7 @@ public define Maybe(One)
19 19 HK_Table table
20 20 )=
21 21 since table is hk_table(name, short_name, model, _),
22   - since model is hk_model(columns, _),
  22 + since model is hk_model(columns, constraints, _),
23 23 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
24 24  
25 25 //generate the type of the table that contain all components
... ...
src/generation/choices_selector.anubis
... ... @@ -80,7 +80,7 @@ public define Maybe(One)
80 80 HK_Table table
81 81 )=
82 82 since table is hk_table(table_name, short_name, model, _),
83   - since model is hk_model( columns, show_string),
  83 + since model is hk_model( columns, constraints, show_string),
84 84  
85 85 map_forget((HK_Model_Column column) |->
86 86 since column is hk_column(column_name, field_type, _, _),
... ...
src/generation/columns.anubis
... ... @@ -109,8 +109,8 @@ public define List(String)
109 109 {
110 110 [] then reverse(so_far),
111 111 [h . t ] then
112   - since h is hk_column(name, col_type, _, _),
113   - with result = to_Bind(col_type, type_name, name, insert),
  112 + since h is hk_column(name, col_type, attributes, _),
  113 + with result = to_Bind(col_type, attributes, type_name, name, insert),
114 114 //we eliminate the empty string because during the join it will have an empty line
115 115 if result = "" then
116 116 to_Bind_list(t, type_name, so_far, insert)
... ... @@ -164,6 +164,8 @@ public define Maybe(String)
164 164 text_field(_) then success(name),
165 165 color_field then success(name),
166 166 phone_field then success(name),
  167 + mobile_field then success(name),
  168 + url_field then success(name),
167 169 email_field then success(name)
168 170 }.
169 171  
... ... @@ -287,6 +289,8 @@ public define Maybe(String)
287 289 text_field(txt_attr) then success("text_area(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", "+to_Anubis_source(txt_attr)+", "+to_Anubis_source(help)+")"),
288 290 color_field then success("color(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", "+to_Anubis_source(help)+")"),
289 291 phone_field then success("phone(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", "+to_Anubis_source(help)+")"),
  292 + mobile_field then success("mobile_phone(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", "+to_Anubis_source(help)+")"),
  293 + url_field then success("url(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", "+to_Anubis_source(help)+")"),
290 294 email_field then success("email(\""+to_upper(col_name)+"\", \""+col_name+"\", "+type_name+"."+col_name+", "+to_Anubis_source(help)+")"),
291 295 }.
292 296  
... ... @@ -336,9 +340,11 @@ public define String
336 340 float_field then "float_to_string("+current_type_name+"."+name+",5)",
337 341 char_field(_,_) then current_type_name+"."+name,
338 342 password_field(_) then current_type_name+"."+name,
339   - text_field(_) then current_type_name+"."+name
340   - color_field then current_type_name+"."+name
341   - phone_field then current_type_name+"."+name
  343 + text_field(_) then current_type_name+"."+name,
  344 + color_field then current_type_name+"."+name,
  345 + phone_field then current_type_name+"."+name,
  346 + mobile_field then current_type_name+"."+name,
  347 + url_field then current_type_name+"."+name,
342 348 email_field then current_type_name+"."+name
343 349 }.
344 350  
... ...
src/generation/create_table.anubis
... ... @@ -65,12 +65,50 @@ define String
65 65 .
66 66  
67 67 define String
  68 + to_String
  69 + (
  70 + HK_On_Conflict on_conflict
  71 + )=
  72 + if on_conflict is
  73 + {
  74 + rollback then "ROLLBACK",
  75 + abort then "ABORT",
  76 + fail then "FAIL",
  77 + ignore then "IGNORE",
  78 + replace then "REPLACE"
  79 + }
  80 +.
  81 +
  82 +define String
  83 + create_table_generate_one_constraint
  84 + (
  85 + HK_Constraint constraint,
  86 + String indent
  87 + )=
  88 + since constraint is unique(_name, columns, _on_conflict),
  89 + with name = if _name = "" then "" else "CONSTRAINT "+_name+" ",
  90 + indent+name+"UNIQUE ("+
  91 + indent+indent+join(",\n"+indent+indent, columns)+"\n"+
  92 + indent+")"+
  93 + indent+"ON CONFLICT "+to_String(_on_conflict)
  94 +.
  95 +
  96 +define String
  97 + create_table_generate_constraints
  98 + (
  99 + List(HK_Constraint) constraints,
  100 + String indent
  101 + )=
  102 + join(",\n"+indent, map((HK_Constraint constraint) |-> create_table_generate_one_constraint(constraint, indent), constraints))
  103 +.
  104 +
  105 +define String
68 106 create_table_generate_one_table
69 107 (
70 108 HK_Table table
71 109 )=
72 110 since table is hk_table(name, short_name, model, display),
73   - since model is hk_model( columns, _),
  111 + since model is hk_model( columns, constraints, _),
74 112  
75 113 "\n"+
76 114 " // "+to_upper(name)+"\n"+
... ... @@ -78,6 +116,7 @@ define String
78 116 "\"CREATE TABLE "+name+" (\n"+
79 117 //columns
80 118 " "+create_table_generate_columns([hk_column("id",p_key) . columns], " ")+
  119 + create_table_generate_constraints(constraints, " ")+
81 120 "\n)\".\n"
82 121 .
83 122  
... ... @@ -124,23 +163,24 @@ define String
124 163 public define Maybe(One)
125 164 generate_create_table
126 165 (
127   - List(HK_App) apps, //list of the table model description
128   - String dest_dir
  166 + List(HK_App) apps, //list of the table model description
  167 + String dest_dir,
  168 + String version,
  169 + String _sha1
129 170 )=
130   - //TODO manage version
131   - with version = "1.0.0.0",
132   - version_str = find_and_replace(version,".","_"), //replace the dot by underscore because dot is not allowed in function name by Anubis language
  171 +
  172 + with version_str = find_and_replace(version,".","_"), //replace the dot by underscore because dot is not allowed in function name by Anubis language
133 173  
134 174 with file_name = dest_dir+"database/generated/migration/to_"+version+".anubis",
135   - with script_file_name = dest_dir+"database/generated/migration/to_"+version+"_scripts.anubis",
136   -
  175 + with create_file_name = dest_dir+"database/generated/migration/to_"+version+"_create.anubis",
  176 + //with script_file_name = dest_dir+"database/generated/migration/to_"+version+"_SQL.anubis",
137 177 //create all necessary directories if doesn't exist.
138 178 make_directories(file_name);
139 179  
140 180 //create script file name as new file. Previous file with same name will be erased
141   - if file(script_file_name, new) is
  181 + if file(create_file_name, new) is
142 182 {
143   - failure then println("Can't create script "+script_file_name);failure,
  183 + failure then println("Can't create script "+create_file_name);failure,
144 184 success(fd_script) then
145 185 with script_stream = make_stream(fd_script),
146 186 //write into script file the generated create table
... ... @@ -150,6 +190,10 @@ public define Maybe(One)
150 190 * Date: "+_Int_to_ISO_8601_date(now)+"
151 191 * Time: "+_Int_to_ISO_8601_time(now)+"
152 192 */
  193 +
  194 +read system/logger.anubis
  195 +read calexium_lib/net_services_protocols/logger_service.anubis
  196 +read calexium_lib/database/migration_common_sqlite3.anubis
153 197 read data_base/sqlite_foreign_key.anubis
154 198 read data_base/db_types.anubis\n"+
155 199 //call the generation of all tables
... ... @@ -158,12 +202,40 @@ read data_base/db_types.anubis\n&quot;+
158 202 "\npublic define List(String) db_indexes = [].\n"+
159 203 "// ///////////////////////////////\n"+
160 204 "// Foreign keys \n"+
161   - "public define List((String, String, String, String, FK_Null, FK_Cascade)) db_relations = [].\n"
  205 + "public define List((String, String, String, String, FK_Null, FK_Cascade)) db_relations = [].\n\n\n
  206 +define String _version = \""+version+"\".
  207 +
  208 +public define Maybe(One)
  209 + create_v"+version_str+"_tables
  210 + (
  211 + SQLite3DataBase db,
  212 + Logger logger_debug
  213 + )=
  214 + if drop_all_triggers(db, logger_debug) is failure then failure else
  215 +
  216 + with tables = (List(DbTable)) [
  217 +"+generate_all_tables_list(apps, " ")+"
  218 + ],
  219 + if create_tables(db, logger_debug, tables, _version) is
  220 + {
  221 + failure then failure,
  222 + success(_) then
  223 + if make_foreign_keys(db, logger_debug, db_relations, _version) is failure then failure else
  224 + success(unique)
  225 + }
  226 +.
  227 +
  228 +public define DB_Version db_model_version = db_version(\""+version+"\", \""+_sha1+"\").
  229 +\n\n"
  230 +
162 231 ) is
163 232 {
164   - failure then println ("Can't generate script "+script_file_name);failure,
  233 + failure then println ("Can't generate script "+create_file_name);failure,
165 234 success(_) then
166 235 //create file with create table management (alter_table, etc...)
  236 + if file_exists(file_name) then
  237 + success(println("Skip creation of "+file_name+" because it's already exists and preventing to erase custom migration stuff"))
  238 + else
167 239 if file(file_name, new) is
168 240 {
169 241 failure then println("can't create file "+file_name);failure,
... ... @@ -183,6 +255,7 @@ read data_base/db_tools.anubis
183 255  
184 256 read calexium_lib/database/db_utils.anubis
185 257 read calexium_lib/database/migration_common_sqlite3.anubis
  258 +read calexium_lib/database/migration_sqlite3.anubis
186 259 read calexium_lib/net_services_protocols/logger_service.anubis
187 260 read data_base/alter_table.anubis
188 261  
... ... @@ -190,28 +263,9 @@ read types/app_types.anubis
190 263 read app/app_constants.anubis
191 264 read app/app_loggers.anubis
192 265  
193   -read database/generated/migration/to_"+version+"_scripts.anubis
  266 +read database/generated/migration/to_"+version+"_create.anubis
194 267  
195 268 define String _version = \""+version+"\".
196   -
197   -public define Maybe(One)
198   - create_v"+version_str+"_tables
199   - (
200   - SQLite3DataBase db,
201   - Logger logger_debug
202   - )=
203   - if drop_all_triggers(db, logger_debug) is failure then failure else
204   -
205   - with tables = (List(DbTable)) [
206   -"+generate_all_tables_list(apps, " ")+"
207   - ],
208   - if create_tables(db, logger_debug, tables, _version) is
209   - {
210   - failure then failure,
211   - success(_) then
212   - if make_foreign_keys(db, logger_debug, db_relations, _version) is failure then failure else
213   - success(unique)
214   - }.
215 269  
216 270 public define Maybe(One)
217 271 create_v"+version_str+"_indexes
... ... @@ -243,12 +297,17 @@ public define Maybe(One)
243 297 SQLite3DataBase db,
244 298 Logger logger,
245 299 )=
246   - if to_v"+version_str+"_pre(db, logger) is failure then failure
  300 + if to_v"+version_str+"_pre(db, logger) is failure then failure
247 301 else if create_v"+version_str+"_tables(db, logger) is failure then failure
248   - else if to_v"+version_str+"_post(db, logger) is failure then failure
249   - else create_v"+version_str+"_indexes(db, logger).
  302 + else if to_v"+version_str+"_post(db, logger) is failure then failure
  303 + else create_v"+version_str+"_indexes(db, logger)
  304 +.
250 305  
251   -
  306 +global define Migration
  307 + migration_to_v"+version_str+"
  308 + =
  309 + migration(db_model_version, migrate_to_v"+version_str+", create_v"+version_str+"_tables, create_v"+version_str+"_indexes)
  310 +.
252 311 ")
253 312 }}}
254 313 .
... ...
src/generation/densaku.anubis
... ... @@ -37,7 +37,7 @@ public define Maybe(One)
37 37 HK_Table table
38 38 )=
39 39 since table is hk_table(name, short_name, model, display),
40   - since model is hk_model(columns, show_string),
  40 + since model is hk_model(columns, constraints, show_string),
41 41 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
42 42  
43 43 //generate the type of the HK_Table that contain all components
... ...
src/generation/edit_view_list_form.anubis
... ... @@ -43,7 +43,7 @@ public define Maybe(One)
43 43 List(HK_FK_View) l_fk_view //List of foreign key view to display
44 44 )=
45 45 since table is hk_table(table_name, short_name, model, display),
46   - since model is hk_model( columns, _),
  46 + since model is hk_model( columns, constraints, _),
47 47 with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type.
48 48  
49 49 if write_string(stream,
... ...
src/generation/edit_view_table_form.anubis
... ... @@ -129,7 +129,7 @@ public define Maybe(One)
129 129 HK_Editor_Table form_in_table //edit view to generate
130 130 )=
131 131 since table is hk_table(table_name, short_name, model, display),
132   - since model is hk_model( columns, _),
  132 + since model is hk_model( columns, constraints, _),
133 133 with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type.
134 134  
135 135 //generate the type of the table that contain all components
... ...
src/generation/extractor.anubis
... ... @@ -33,6 +33,8 @@ public define String
33 33 text_field(_) then "text"+cursor_index,
34 34 color_field then "text"+cursor_index,
35 35 phone_field then "text"+cursor_index,
  36 + mobile_field then "text"+cursor_index,
  37 + url_field then "text"+cursor_index,
36 38 email_field then "text"+cursor_index
37 39 }.
38 40  
... ... @@ -73,7 +75,7 @@ public define Maybe(One)
73 75 HK_Table table
74 76 )=
75 77 since table is hk_table(name, short_name, model, display),
76   - since model is hk_model(columns, _),
  78 + since model is hk_model(columns, constraint, _),
77 79 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
78 80  
79 81 //generate the type of the table that contain all components
... ... @@ -168,7 +170,7 @@ public define Maybe(One)
168 170 HK_Table table
169 171 )=
170 172 since table is hk_table(name, short_name, model, display),
171   - since model is hk_model(columns, _),
  173 + since model is hk_model(columns, constraints, _),
172 174 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
173 175  
174 176 //generate the type of the table that contain all components
... ... @@ -204,8 +206,9 @@ public define Maybe(One)
204 206 " json_object(\n"+
205 207 " map(((Int -> SQLite3Datum) -> JsonMember extractor) |-> extractor(cursor) , extractors)\n"+
206 208 " ))\n"+
207   - " }\n.\n"+
  209 + " }\n.\n\n"+
208 210  
  211 +"public define String get_"+name+"_show_string(SQLite3DataBase db, DB_id _idx).\n\n"+
209 212 "define (Int -> SQLite3Datum) -> JsonMember\n"+
210 213 " get_extractor\n"+
211 214 " (\n"+
... ...
src/generation/fields.anubis
... ... @@ -38,6 +38,8 @@ public define String
38 38 text_field(_) then "String",
39 39 color_field then "String",
40 40 phone_field then "String",
  41 + mobile_field then "String",
  42 + url_field then "String",
41 43 email_field then "String"
42 44 }.
43 45  
... ... @@ -62,7 +64,9 @@ public define String
62 64 password_field(_) then "string",
63 65 text_field(_) then "string",
64 66 color_field then "string",
65   - phone_field then "string"
  67 + phone_field then "string",
  68 + mobile_field then "String",
  69 + url_field then "String",
66 70 email_field then "string"
67 71 }.
68 72  
... ... @@ -95,6 +99,8 @@ public define String
95 99 text_field(_) then fill("TEXT", 15) + format_attributes(attributes),
96 100 color_field then fill("VARCHAR(8)",15)+ format_attributes(attributes),
97 101 phone_field then fill("VARCHAR(20)", 15) + format_attributes(attributes),
  102 + mobile_field then fill("VARCHAR(20)", 15) + format_attributes(attributes),
  103 + url_field then fill("VARCHAR(2048)", 15) + format_attributes(attributes),
98 104 email_field then fill("VARCHAR(254)", 15) + format_attributes(attributes),
99 105 }.
100 106  
... ... @@ -120,7 +126,9 @@ public define String
120 126 text_field(_) then "\"\"",
121 127 color_field then "\"#DDD\"",
122 128 phone_field then "\"\"",
123   - email_field then "\"\""
  129 + mobile_field then "\"\"",
  130 + url_field then "\"\"",
  131 + email_field then "\"\""
124 132 }.
125 133  
126 134  
... ... @@ -130,11 +138,13 @@ public define String
130 138 public define String
131 139 to_Bind
132 140 (
133   - HK_Model_Field t,
134   - String type_name, //name of the type
135   - String name, //name of component into the type
136   - Bool insert //true if insert time else false for update
  141 + HK_Model_Field t,
  142 + List(HK_Model_Attr) attributes,
  143 + String type_name, //name of the type
  144 + String name, //name of component into the type
  145 + Bool insert //true if insert time else false for update
137 146 ) =
  147 + with or_null = if not_null:attributes then "" else "_or_NULL", //check if not_null is member of the list of column's attributes
138 148 if t is
139 149 {
140 150 //anubis(_T) then "constant_byte_array(0,0)",
... ... @@ -156,10 +166,12 @@ public define String
156 166 foreign_key(_,_,_) then "bind_DB_id_or_NULL(\":v_"+name+"\", "+type_name+"."+name+")",
157 167 integer_field(_) then "bind_Int(\":v_"+name+"\", "+type_name+"."+name+")",
158 168 float_field then "bind_Float(\":v_"+name+"\", "+type_name+"."+name+")",
159   - char_field(_,_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")",
  169 + char_field(_,_) then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")",
160 170 password_field(_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")",
161   - text_field(_) then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")",
162   - color_field then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")",
163   - phone_field then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")",
164   - email_field then "bind_String(\":v_"+name+"\", "+type_name+"."+name+")",
  171 + text_field(_) then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")",
  172 + color_field then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")",
  173 + phone_field then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")",
  174 + mobile_field then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")",
  175 + url_field then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")",
  176 + email_field then "bind_String"+or_null+"(\":v_"+name+"\", "+type_name+"."+name+")",
165 177 }.
... ...
src/generation/files.anubis
... ... @@ -41,10 +41,10 @@ define Maybe(One)
41 41 )
42 42 =
43 43 since org_table is hk_table(name, short_name, old_model, display),
44   - since old_model is hk_model(columns, show_string),
  44 + since old_model is hk_model(columns, constraints, show_string),
45 45 since display is hk_display(list_view, list_edit),
46 46  
47   - with model = hk_model([hk_column("id", p_key, []). columns], show_string ),
  47 + with model = hk_model([hk_column("id", p_key, []). columns], constraints, show_string ),
48 48 with table = hk_table(name, short_name, model, display),
49 49 println("Generating file for table ["+name+"]");
50 50 with file_name = dest_dir+"database/generated/"+name+".anubis",
... ... @@ -221,7 +221,7 @@ define One
221 221 //view interface
222 222 //selector
223 223 get_selector_"+name+",
224   - hk_trigger_set(var([]), var([])) //initialize the triggers list as empty
  224 + hk_trigger_set(var([]), var([]), var([]), var([]), var([]), var([])) //initialize the triggers list as empty
225 225 )",
226 226  
227 227 _make_vtm(apps, t, [transmit . so_far_transmit], [view . so_far_view], [edit . so_far_edit], [controller . so_far_controllers], dest_dir)
... ... @@ -256,6 +256,7 @@ define Maybe(One)
256 256 with ini = loadIniFile(destination_dir+"/hayamiki.ini"),
257 257  
258 258 with db_SHA1 = readString(ini, "DB_MODEL", "SHA1", "N/A"),
  259 + with version = readString(ini, "DB_MODEL", "Version", "0.0.0.0"),
259 260 println("Saved DB model SHA1 = "+db_SHA1);
260 261 with current_db_SHA1 = to_ascii(sha1(serialize(db))),
261 262 println("Current DB model SHA1 = "+current_db_SHA1);
... ... @@ -272,12 +273,14 @@ define Maybe(One)
272 273 println("Generating VTM for Database "+name);
273 274 make_vtm(apps, destination_dir);
274 275 println("Generating create for Database "+name);
275   - if generate_create_table(apps, destination_dir) is failure then println("failure");failure else
  276 + if generate_create_table(apps, destination_dir, version, current_db_SHA1) is failure then println("failure");failure else
276 277 println("Generating menu for Database "+name);
277 278 if generate_hk_menus(apps, destination_dir) is failure then println("failure");failure else
278 279 if generate_cxm_lib_menus(apps, destination_dir) is failure then println("failure");failure else
279 280 writeString(ini, "DB_MODEL", "SHA1", current_db_SHA1);
  281 + writeString(ini, "DB_MODEL", "Version", version);
280 282 writeIniInfo(ini);
  283 + sleep(3000);
281 284 success(unique)
282 285 }.
283 286  
... ...
src/generation/fn_delete.anubis
... ... @@ -21,7 +21,7 @@ public define Maybe(One)
21 21 HK_Table table
22 22 )=
23 23 since table is hk_table(name, short_name, model, _),
24   - since model is hk_model( columns, _),
  24 + since model is hk_model( columns, constraints, _),
25 25 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
26 26  
27 27 //generate the type of the table that contain all components
... ...
src/generation/html.anubis
... ... @@ -108,6 +108,8 @@ public define String
108 108 text_field(attrs) then to_HTML_cell_text(column, data_name, general_type_name),
109 109 color_field then to_HTML_cell_text(column, data_name, general_type_name),
110 110 phone_field then to_HTML_cell_text(column, data_name, general_type_name),
  111 + mobile_field then to_HTML_cell_text(column, data_name, general_type_name),
  112 + url_field then to_HTML_cell_text(column, data_name, general_type_name),
111 113 email_field then to_HTML_cell_text(column, data_name, general_type_name)
112 114 }
113 115 }.
... ... @@ -121,7 +123,7 @@ public define String
121 123 HK_Viewer list_view //list view to generate
122 124 )=
123 125 since table is hk_table(table_name, short, model, _), //get name and model of the table
124   - since model is hk_model( columns, _), //get all columns of table
  126 + since model is hk_model( columns, _, _), //get all columns of table
125 127 // since display is db_display(views, _), //
126 128 with current_list_column = if list_view is
127 129 {
... ...
src/generation/icons.anubis
... ... @@ -36,6 +36,8 @@ public define String
36 36 text_field(_) then icn16_question,
37 37 color_field then icn16_question,
38 38 phone_field then icn16_phone,
  39 + mobile_field then icn16_question,
  40 + url_field then icn16_question,
39 41 email_field then icn16_email
40 42 }.
41 43  
... ...
src/generation/json.anubis
... ... @@ -36,6 +36,8 @@ public define String
36 36 text_field(_) then "to_JSON_String("+current_type_name+"."+name+")",
37 37 color_field then "to_JSON_String("+current_type_name+"."+name+")",
38 38 phone_field then "to_JSON_String("+current_type_name+"."+name+")",
  39 + mobile_field then "to_JSON_String("+current_type_name+"."+name+")",
  40 + url_field then "to_JSON_String("+current_type_name+"."+name+")",
39 41 email_field then "to_JSON_String("+current_type_name+"."+name+")",
40 42 }
41 43 .
... ... @@ -68,6 +70,8 @@ public define String
68 70 text_field(_) then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))",
69 71 color_field then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))",
70 72 phone_field then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))",
  73 + mobile_field then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))",
  74 + url_field then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))",
71 75 email_field then "json_member(\""+name+"\", json_string("+current_type_name+"."+name+"))",
72 76 }
73 77 .
... ... @@ -100,6 +104,8 @@ public define String
100 104 text_field(_) then "json_member(\""+name+"\", json_string(text"+cursor_index+"))",
101 105 color_field then "json_member(\""+name+"\", json_string(text"+cursor_index+"))",
102 106 phone_field then "json_member(\""+name+"\", json_string(text"+cursor_index+"))",
  107 + mobile_field then "json_member(\""+name+"\", json_string(text"+cursor_index+"))",
  108 + url_field then "json_member(\""+name+"\", json_string(text"+cursor_index+"))",
103 109 email_field then "json_member(\""+name+"\", json_string(text"+cursor_index+"))"
104 110 }
105 111 .
... ...
src/generation/types.anubis
... ... @@ -38,7 +38,7 @@ public define Maybe(One)
38 38 Bool use_densaku
39 39 )=
40 40 since table is hk_table(name, short_name, model, display),
41   - since model is hk_model(columns, show_string),
  41 + since model is hk_model(columns, constraints, show_string),
42 42 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
43 43  
44 44 //if we use densaku for generating the type, we insert the read of that type after densaku generation
... ... @@ -83,7 +83,7 @@ public define Maybe(One)
83 83 HK_Table table
84 84 )=
85 85 since table is hk_table(name, short_name, model, _),
86   - since model is hk_model(columns, show_string),
  86 + since model is hk_model(columns, constraints, show_string),
87 87 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
88 88  
89 89 //generate the type of the table that contain all components
... ... @@ -104,7 +104,7 @@ public define Maybe(One)
104 104 HK_Table table
105 105 )=
106 106 since table is hk_table(name, short_name, model, _),
107   - since model is hk_model(columns, show_string),
  107 + since model is hk_model(columns, constraints, show_string),
108 108 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
109 109  
110 110 //generate the type of the table that contain all components
... ... @@ -127,7 +127,7 @@ public define Maybe(One)
127 127 HK_Table table
128 128 )=
129 129 since table is hk_table(name, short_name, model, _),
130   - since model is hk_model(columns, show_string),
  130 + since model is hk_model(columns, constraints, show_string),
131 131 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
132 132  
133 133 //generate the type of the table that contain all components
... ... @@ -205,7 +205,7 @@ public define Maybe(One)
205 205 HK_Table table
206 206 )=
207 207 since table is hk_table(name, short_name, model, _),
208   - since model is hk_model(columns, show_string),
  208 + since model is hk_model(columns, constraints, show_string),
209 209 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
210 210  
211 211 //generate the type of the table that contain all components
... ... @@ -259,7 +259,7 @@ public define Maybe(One)
259 259 HK_Table table
260 260 )=
261 261 since table is hk_table(name, short_name, model, _),
262   - since model is hk_model(columns, show_string),
  262 + since model is hk_model(columns, constraints, show_string),
263 263 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
264 264  
265 265 //generate the type of the table that contain all components
... ... @@ -290,7 +290,7 @@ public define Maybe(One)
290 290 HK_Table table
291 291 )=
292 292 since table is hk_table(name, short_name, model, _),
293   - since model is hk_model( columns, _),
  293 + since model is hk_model( columns, constraints, _),
294 294 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
295 295  
296 296 //generate the type of the table that contain all components
... ... @@ -399,7 +399,7 @@ public define Maybe(One)
399 399 HK_Table table
400 400 )=
401 401 since table is hk_table(name, short_name, model, _),
402   - since model is hk_model( columns, show_string),
  402 + since model is hk_model( columns, constraints, show_string),
403 403 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
404 404  
405 405 //generate the type of the table that contain all components
... ... @@ -435,7 +435,7 @@ public define Maybe(One)
435 435 HK_Table table
436 436 )=
437 437 since table is hk_table(name, short_name, model, _),
438   - since model is hk_model( columns, show_string),
  438 + since model is hk_model( columns, constraints, show_string),
439 439 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
440 440  
441 441 //generate the type of the table that contain all components
... ...
src/generation/vt_edit.anubis
... ... @@ -29,7 +29,7 @@ public define Maybe(One)
29 29 HK_Editor edit_view //edit view to generate
30 30 )=
31 31 since table is hk_table(table_name, short_name, model, display),
32   - since model is hk_model( columns, _),
  32 + since model is hk_model( columns, constraints, _),
33 33 //since display is db_display(list_view, list_edit),
34 34  
35 35 with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type.
... ... @@ -170,7 +170,7 @@ public define Maybe(One)
170 170 HK_Table table
171 171 )=
172 172 since table is hk_table(name, short_name, model, display),
173   - since model is hk_model( columns, _),
  173 + since model is hk_model( columns, constraints, _),
174 174 since display is hk_display(_, list_edit),
175 175  
176 176 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
... ...
src/generation/vt_view.anubis
... ... @@ -79,6 +79,8 @@ define String
79 79 text_field(txt_attr) then "text_area(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")",
80 80 color_field then "color(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")",
81 81 phone_field then "phone(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")",
  82 + mobile_field then "mobile_phone(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")",
  83 + url_field then "url(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")",
82 84 email_field then "email(\""+to_upper(name)+"\", \""+name+"\", "+to_Anubis_source(help)+")"
83 85  
84 86 }.
... ... @@ -113,7 +115,7 @@ public define Maybe(One)
113 115 HK_Viewer list_view //list view to generate
114 116 )=
115 117 since table is hk_table(table_name, short_name, model, display),
116   - since model is hk_model( columns, _),
  118 + since model is hk_model( columns, constraints, _),
117 119 //since display is db_display(list_view, list_edit),
118 120  
119 121 with type_name = to_upper(table_name, 1), //make the first character to upper case and be an Anubis Type.
... ... @@ -351,7 +353,7 @@ public define Maybe(One)
351 353 HK_Table table
352 354 )=
353 355 since table is hk_table(name, short_name, model, display),
354   - since model is hk_model( columns, _),
  356 + since model is hk_model( columns, constraints, _),
355 357 since display is hk_display(list_view, list_edit),
356 358  
357 359 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
... ...
src/generation/web_args.anubis
... ... @@ -34,6 +34,8 @@ public define String
34 34 text_field(_) then "get_String(lwa, __prefix__+\""+name+"\")",
35 35 color_field then "get_String(lwa, __prefix__+\""+name+"\")",
36 36 phone_field then "get_String(lwa, __prefix__+\""+name+"\")",
  37 + mobile_field then "get_String(lwa, __prefix__+\""+name+"\")",
  38 + url_field then "get_String(lwa, __prefix__+\""+name+"\")",
37 39 email_field then "get_String(lwa, __prefix__+\""+name+"\")"
38 40 }.
39 41  
... ... @@ -87,6 +89,8 @@ public define String
87 89 text_field(_) then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),",
88 90 color_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),",
89 91 phone_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),",
  92 + mobile_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),",
  93 + url_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),",
90 94 email_field then "get_String(lwa, __prefix__+\""+name+"\", "+to_Anubis_default(col_type)+"),"
91 95 }.
92 96  
... ... @@ -120,7 +124,7 @@ public define Maybe(One)
120 124 HK_Table table
121 125 )=
122 126 since table is hk_table(name, short_name, model, _),
123   - since model is hk_model(columns, _),
  127 + since model is hk_model(columns, constraint, _),
124 128 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
125 129 since _generate_extract_web_arg_to_type(columns, [], 0) is ((List(String))list_of_web_arg, (Int) nb_closure),
126 130 //generate the type of the table that contain all components
... ... @@ -215,6 +219,10 @@ public define String
215 219 "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }"
216 220 phone_field then
217 221 "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }"
  222 + mobile_field then
  223 + "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }"
  224 + url_field then
  225 + "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }"
218 226 email_field then
219 227 "if get_String(lwa, __prefix__+\""+name+"\") is {failure then [], success("+name+") then [field(\""+name+"\", bind_String(\":v_"+name+"\", "+name+"))] }"
220 228 }.
... ... @@ -245,7 +253,7 @@ public define Maybe(One)
245 253 HK_Table table
246 254 )=
247 255 since table is hk_table(name, short_name, model, _),
248   - since model is hk_model(columns, _),
  256 + since model is hk_model(columns, constraints, _),
249 257 with type_name = to_upper(name, 1), //make the first character to upper case to able to be a Anubis Type.
250 258  
251 259 //generate the type of the table that contain all components
... ...