From 5982fb919cc198b09154cab6aca30f83eadb5ef7 Mon Sep 17 00:00:00 2001 From: totoro Date: Sat, 13 Feb 2016 12:03:59 +0100 Subject: [PATCH] move and explode calexium_lib/database/db_model into hayamiki_lib --- hk_generator.anubis | 33 +++++++++++++++++++++++++++++++++ types/hayamiki.anubis | 11 +++++++++++ types/model/app.anubis | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ types/model/columns.anubis | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ types/model/database.anubis | 14 ++++++++++++++ types/model/display.anubis | 21 +++++++++++++++++++++ types/model/fields.anubis | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ types/model/help.anubis | 27 +++++++++++++++++++++++++++ types/model/icons.anubis | 38 ++++++++++++++++++++++++++++++++++++++ types/model/model.anubis | 15 +++++++++++++++ types/model/tables.anubis | 25 +++++++++++++++++++++++++ 11 files changed, 342 insertions(+), 0 deletions(-) create mode 100644 hk_generator.anubis create mode 100644 types/hayamiki.anubis create mode 100644 types/model/app.anubis create mode 100644 types/model/columns.anubis create mode 100644 types/model/database.anubis create mode 100644 types/model/display.anubis create mode 100644 types/model/fields.anubis create mode 100644 types/model/help.anubis create mode 100644 types/model/icons.anubis create mode 100644 types/model/model.anubis create mode 100644 types/model/tables.anubis diff --git a/hk_generator.anubis b/hk_generator.anubis new file mode 100644 index 0000000..e15640a --- /dev/null +++ b/hk_generator.anubis @@ -0,0 +1,33 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:23 + * © Calexium + */ + +read tools/basis.anubis +transmit types/hayamiki.anubis + +public type HK_Generator_API: + hk_api( + ((HK_Database, String) -> Maybe(One)) generate_model_files). + + +public define Maybe(HK_Generator_API) + load_hk_generator + = + with file_name = "hk_gen.adm", + if (LoadAdm(HK_Generator_API))load_adm(file_name) is + { + file_not_found then print("File '"+file_name+"' not found.\n\n");failure, + read_error then print("Error reading file '"+file_name+"'.\n\n");failure, + timeout then print("Timeout when loading '"+file_name+"'.\n\n");failure, + file_damaged then print("File '"+file_name+"' is damaged.\n\n");failure, + bad_version(expected,found) then print("Secondary module '"+file_name+"' doesn't have the same\n"+ + " version ("+found+") as primary module ("+expected+").\n\n");failure, + wrong_type(expected,found) then print("Secondary module '"+file_name+"' has type:\n"+ + found+" while primary module expected:\n"+ + expected+"\n\n");failure, + ok(hk_gen_api) then println("Hayamiki generator loaded ");success(hk_gen_api) + }. diff --git a/types/hayamiki.anubis b/types/hayamiki.anubis new file mode 100644 index 0000000..a610768 --- /dev/null +++ b/types/hayamiki.anubis @@ -0,0 +1,11 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 09:45 + * © Calexium + */ + + +transmit model/fields.anubis +transmit model/database.anubis diff --git a/types/model/app.anubis b/types/model/app.anubis new file mode 100644 index 0000000..1bff755 --- /dev/null +++ b/types/model/app.anubis @@ -0,0 +1,49 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:06 + * © Calexium + */ + +transmit help.anubis +transmit tables.anubis +transmit icons.anubis + + + +public type HK_App: + hk_app( + String app_name, + HK_Icon icon, + HK_Help_Text help, + List(HK_Table) hk_tables + ). + + /* Default constructor for HK_App*/ +public define HK_App + hk_app + ( + String app_name, + HK_Help_Text help, + List(HK_Table) hk_tables + )= + hk_app(app_name, no_icon, help, hk_tables). + +public define HK_App + hk_app + ( + String app_name, + HK_Icon icon, + List(HK_Table) hk_tables + )= + hk_app(app_name, icon, no_help_text, hk_tables). + + +public define HK_App + hk_app + ( + String app_name, + List(HK_Table) hk_tables + )= + hk_app(app_name, no_icon, no_help_text, hk_tables). diff --git a/types/model/columns.anubis b/types/model/columns.anubis new file mode 100644 index 0000000..f71ee84 --- /dev/null +++ b/types/model/columns.anubis @@ -0,0 +1,52 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:07 + * © Calexium + */ + +transmit help.anubis +transmit fields.anubis + +public type HK_Model_Attr: + unique, // by default, the values in a column are not required to be all different + indexed, // by default, a column is not indexed + default(String), // default value (used in case of creation of a NON NULL column + // in a table which already contains some rows) + not_null. + + *** (1.4) 'HK_Model_Column' (describing a column in a table). + + Description of a column: + +public type HK_Model_Column: + hk_column (String name, // name of ordinary column (i.e. all but 'id') + HK_Model_Field type, + List(HK_Model_Attr) attributes, + HK_Help_Text help + ). + + /****** DEFAULT CONSTRUCTOR HELPER - part *******/ + +public define HK_Model_Column +/* Constructor helper for hk_column without help attribute. + the real type constructor will be called with the attribute no_help_text +*/ + hk_column + ( + String name, + HK_Model_Field type, + List(HK_Model_Attr) attributes, + )= + hk_column(name, type, attributes, no_help_text). + +public define HK_Model_Column + hk_column + ( + String name, + HK_Model_Field type + )= + hk_column(name, type, [], no_help_text). + + diff --git a/types/model/database.anubis b/types/model/database.anubis new file mode 100644 index 0000000..6f3cd7a --- /dev/null +++ b/types/model/database.anubis @@ -0,0 +1,14 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:38 + * © Calexium + */ + +transmit app.anubis + +public type HK_Database: + hk_database (String name, // name of the database + List(HK_App) apps //list of applications + ). diff --git a/types/model/display.anubis b/types/model/display.anubis new file mode 100644 index 0000000..f8cc7e3 --- /dev/null +++ b/types/model/display.anubis @@ -0,0 +1,21 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:36 + * © Calexium + */ + + +public type HK_List_View: + list_view_all, + list_view(String view_name, List(String) columns). + +public type HK_Edit_View: + edit_view_all, + edit_view(String view_name, List(String) columns). + +public type HK_Display: + hk_display(List(HK_List_View) list_views, + //List(HK_Edit_View) edit_views + List(String)). diff --git a/types/model/fields.anubis b/types/model/fields.anubis new file mode 100644 index 0000000..3fb532e --- /dev/null +++ b/types/model/fields.anubis @@ -0,0 +1,57 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 09:42 + * © Calexium + */ + + + + *** 'HK_Model_Field' (data types of table columns). + + From the point of view of your Anubis program, these data will be of types: + + Name | Anubis type | Type within the database + ----------------+-------------------+-------------------------------------------------- + p_key | DB_id | primary key (integer) automatically add in 1st + position in every model table + boolean_field | Bool | boolean + date_field | DB_date | text (date in ISO-8601 format: yyyy-mm-dd) + time_field | DB_time | text (date in ISO-8601 format: hh:mm:ss) + datetime_field | DB_datetime | text (date in ISO-8601 format: yyyy-mm-dd hh:mm:ss) + foreign_key | Int | integer + integer_field | Int | arbitrary size integer (numeric) + char_field | String | max size text + text_field | String | arbitrary size text + + +public type HK_App_Name: + this, + app_name(String name), + none. + +public type HK_Datetime_Field_Attr: + none, //Nothing special, normal behaviour + auto_now, //Always update datetime at SQL update + auto_now_add. //Set current datetime when row is created and can't be edited anymore + + + +public type HK_Model_Field: + p_key, + boolean_field, // true or false + date_field (HK_Datetime_Field_Attr), // date with the precision of the day + time_field (HK_Datetime_Field_Attr), // time with the precision of the second + datetime_field(HK_Datetime_Field_Attr), // datetime with the precision of the second + foreign_key (HK_App_Name app_name, String table_name), // foreign key to 'id' in another (or same) table and column_name for choice selector. + integer_field, // integer of arbitrary size + char_field (Int size), // text of maximal size 'size' (number of characters) + text_field. // text of variable size + +public define HK_Model_Field + foreign_key + ( + String table_name + )= + foreign_key(this, table_name). diff --git a/types/model/help.anubis b/types/model/help.anubis new file mode 100644 index 0000000..ab5f05e --- /dev/null +++ b/types/model/help.anubis @@ -0,0 +1,27 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:12 + * © Calexium + */ + + +public type HK_Help_Text: + no_help_text, //no help text available + help_text_TAG(String), //TAG use with Anubis translation tool /locale/L3.anubis + help_text(String). //pure text to show + +public define String +/* Return the Anubis source of the type component +*/ + to_Anubis_source + ( + HK_Help_Text help + )= + if help is + { + no_help_text then "no_help_text", + help_text_TAG(tag) then "help_text_TAG(\""+tag+"\")", + help_text(str) then "help_text(\""+str+"\")" + }. diff --git a/types/model/icons.anubis b/types/model/icons.anubis new file mode 100644 index 0000000..b74c104 --- /dev/null +++ b/types/model/icons.anubis @@ -0,0 +1,38 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:31 + * © Calexium + */ + + +public type HK_Icon: + no_icon, + icon16(String name). + +public define String +/* Return the Anubis source of the type component +*/ + to_Anubis_source + ( + HK_Icon icon + )= + if icon is + { + no_icon then "no_icon", + icon16(icn_str) then "icon16(\""+icn_str+"\")" + }. + +public define String +/* Return the Anubis source of the type component +*/ + to_String + ( + HK_Icon icon + )= + if icon is + { + no_icon then "\"\"", + icon16(icn_str) then "\""+icn_str+"_icon\"" + }. diff --git a/types/model/model.anubis b/types/model/model.anubis new file mode 100644 index 0000000..4e1e071 --- /dev/null +++ b/types/model/model.anubis @@ -0,0 +1,15 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:41 + * © Calexium + */ + +transmit columns.anubis + +public type HK_Model: + hk_model( List(HK_Model_Column) columns, // columns other than the primary key column (if any) + String show_string). + + diff --git a/types/model/tables.anubis b/types/model/tables.anubis new file mode 100644 index 0000000..a3d0c0c --- /dev/null +++ b/types/model/tables.anubis @@ -0,0 +1,25 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:20 + * © Calexium + */ + +transmit display.anubis +transmit model.anubis + +public type HK_Table: + hk_table ( String name, //name of the table + String short_name, //table name without app_name in prefix + HK_Model model, + HK_Display display). + +public define HK_Table + hk_table + ( + String name, //name of the table + HK_Model model, + HK_Display display + )= + hk_table(name, "", model, display). -- libgit2 0.21.4