From 0f97a53e954d365d416021a78dad323610d54da5 Mon Sep 17 00:00:00 2001 From: totoro Date: Wed, 15 Mar 2017 14:13:07 +0100 Subject: [PATCH] generate all types with densaku instead manually. With that auto generation it's faster to make evolution in core. --- ds_files/ds_types.anubis | 199 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/app.anubis | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/columns.anubis | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/database.anubis | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/display.anubis | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/fields.anubis | 345 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/help.anubis | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/icons.anubis | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/model.anubis | 35 +++++++++++++++++++++++++++++++++++ model/tables.anubis | 37 +++++++++++++++++++++++++++++++++++++ model/types/hk_app.anubis | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_app_name.anubis | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_database.anubis | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_datetime_field_attr.anubis | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_display.anubis | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_edit_view.anubis | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_help_text.anubis | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_icon.anubis | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_int_choice.anubis | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_int_choices.anubis | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_list_view.anubis | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_model.anubis | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_model_attr.anubis | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_model_column.anubis | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_model_field.anubis | 232 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_table.anubis | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_text_choice.anubis | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_text_choices.anubis | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ model/types/hk_text_field_attr.anubis | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ types/hayamiki.anubis | 6 +++--- types/model/app.anubis | 118 ---------------------------------------------------------------------------------------------------------------------- types/model/columns.anubis | 171 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- types/model/database.anubis | 91 ------------------------------------------------------------------------------------------- types/model/display.anubis | 209 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- types/model/fields.anubis | 414 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ types/model/help.anubis | 110 -------------------------------------------------------------------------------------------------------------- types/model/icons.anubis | 113 ----------------------------------------------------------------------------------------------------------------- types/model/model.anubis | 66 ------------------------------------------------------------------ types/model/tables.anubis | 84 ------------------------------------------------------------------------------------ view/view_table_types.anubis | 2 +- 40 files changed, 2673 insertions(+), 1380 deletions(-) create mode 100644 ds_files/ds_types.anubis create mode 100644 model/app.anubis create mode 100644 model/columns.anubis create mode 100644 model/database.anubis create mode 100644 model/display.anubis create mode 100644 model/fields.anubis create mode 100644 model/help.anubis create mode 100644 model/icons.anubis create mode 100644 model/model.anubis create mode 100644 model/tables.anubis create mode 100644 model/types/hk_app.anubis create mode 100644 model/types/hk_app_name.anubis create mode 100644 model/types/hk_database.anubis create mode 100644 model/types/hk_datetime_field_attr.anubis create mode 100644 model/types/hk_display.anubis create mode 100644 model/types/hk_edit_view.anubis create mode 100644 model/types/hk_help_text.anubis create mode 100644 model/types/hk_icon.anubis create mode 100644 model/types/hk_int_choice.anubis create mode 100644 model/types/hk_int_choices.anubis create mode 100644 model/types/hk_list_view.anubis create mode 100644 model/types/hk_model.anubis create mode 100644 model/types/hk_model_attr.anubis create mode 100644 model/types/hk_model_column.anubis create mode 100644 model/types/hk_model_field.anubis create mode 100644 model/types/hk_table.anubis create mode 100644 model/types/hk_text_choice.anubis create mode 100644 model/types/hk_text_choices.anubis create mode 100644 model/types/hk_text_field_attr.anubis delete mode 100644 types/model/app.anubis delete mode 100644 types/model/columns.anubis delete mode 100644 types/model/database.anubis delete mode 100644 types/model/display.anubis delete mode 100644 types/model/fields.anubis delete mode 100644 types/model/help.anubis delete mode 100644 types/model/icons.anubis delete mode 100644 types/model/model.anubis delete mode 100644 types/model/tables.anubis diff --git a/ds_files/ds_types.anubis b/ds_files/ds_types.anubis new file mode 100644 index 0000000..b93c0fd --- /dev/null +++ b/ds_files/ds_types.anubis @@ -0,0 +1,199 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 14/03/2017 + * Time: 22:50 + * © Calexium + */ + + +read densaku_lib/types/densaku.anubis + +define String model_types = "hayamiki_lib/model/types/". + +public define List(DS_Type) hayamiki_lib_types_description = + [ + ds_type("HK_Database", [ + alternative("hk_database", [ + component(string, "name", comment("name of the database")), + component(list, extern_type("HK_App", model_types+"hk_app.anubis"), "apps", comment("list of applications")) + ]) + ]), + + ds_type("HK_App", [ + alternative("hk_app", [ + component(string, "app_name"), + component(extern_type("HK_Icon", model_types+"hk_icon.anubis"), "icon"), + component(extern_type("HK_Help_Text", model_types+"hk_help_text.anubis"), "help"), + component(list, extern_type("HK_Table", model_types+"hk_table.anubis"), "hk_tables") + ]) + ]), + + ds_type("HK_Icon", [ + enum("no_icon"), + alternative("icon16", [ + component(string, "name") + ]) + ]), + + ds_type("HK_Help_Text", [ + enum("no_help_text", comment("no help text available")), + alternative("help_text_TAG", [ + component(string, "h_text_tag", comment("TAG use with Anubis translation tool /locale/L3.anubis")) + ]), + alternative("help_text", [ + component(string, "h_text", comment("pure text to show")) + ]) + ]), + + ds_type("HK_Table", [ + alternative("hk_table", [ + component(string, "name", comment("name of the table")), + component(string, "short_name", comment("table name without app_name in prefix")), + component(extern_type("HK_Model", model_types+"hk_model.anubis"), "model"), + component(extern_type("HK_Display", model_types+"hk_display.anubis"), "display") + ]) + ]), + + ds_type("HK_Model", [ + alternative("hk_model", [ + component(list, extern_type("HK_Model_Column", model_types+"hk_model_column.anubis"), "columns", comment("columns other than the primary key column (if any)")), + component(string, "show_string") + ]) + ]), + + ds_type("HK_Model_Column", [ + alternative("hk_column", [ + component( string, "name", comment("name of ordinary column (i.e. all but 'id')")), + component( extern_type("HK_Model_Field", model_types+"hk_model_field.anubis"), "type"), + component(list, extern_type("HK_Model_Attr", model_types+"hk_model_attr.anubis"), "attributes"), + component( extern_type("HK_Help_Text", model_types+"hk_help_text.anubis"), "help") + ]) + ]), + + ds_type("HK_Model_Field", [ + enum("p_key"), + enum("boolean_field", comment("true or false")), + alternative("date_field", [ + component(extern_type("HK_Datetime_Field_Attr", model_types+"hk_datetime_field_attr.anubis"), "hk_dt_f_attr", comment("date with the precision of the day")), + ]), + alternative("time_field", [ + component(extern_type("HK_Datetime_Field_Attr", model_types+"hk_datetime_field_attr.anubis"), "hk_dt_f_attr", comment("time with the precision of the second")), + ]), + alternative("datetime_field", [ + component(extern_type("HK_Datetime_Field_Attr", model_types+"hk_datetime_field_attr.anubis"), "hk_dt_f_attr", comment("datetime with the precision of the second")), + ]), + alternative("foreign_key", comment("foreign key to 'id' in another (or same) table and column_name for choice selector)"), + [ + component(extern_type("HK_App_Name", model_types+"hk_app_name.anubis"), "app_name"), + component(string, "table_name"), + ]), + alternative("integer_field", [ + component(extern_type("HK_Int_Choices", model_types+"hk_int_choices.anubis"), "choices", comment("integer of arbitrary size ")), + ]), + enum("float_field"), + alternative("char_field", [ + component(extern_type("HK_Text_Choices", model_types+"hk_text_choices.anubis"), "choices"), + component(int, "size", comment("text of maximal size 'size' (number of characters)")), + ]), + alternative("password_field", [ + component(int, "min_size", comment("the password field doesn't show the password string or store it in hashed version into database")), + ]), + alternative("text_field", comment("text of variable size"), + [ + component(extern_type("HK_Text_Field_Attr", model_types+"hk_text_field_attr.anubis"), "hk_text_field_attr"), + ]) + ]), + + // + ds_type("HK_Text_Field_Attr", [ + enum("none", comment("Nothing special, normal behaviour")), + enum("rich_editor", comment("Use richt text editor for that area")) + ]), + + ds_type("HK_Int_Choices", [ + enum("no_choice", comment("No list choice is available. Hence the user must enter the value")), + alternative("int_choices", [ + component(list, extern_type("HK_Int_Choice", model_types+"hk_int_choice.anubis"), "hk_int_choice", comment("List of possible choices")) + ]) + ]), + + ds_type("HK_Int_Choice", [ + alternative("hk_int_choice", [ + component(int, "value", comment("value to set in database corresponding to description below")), + component(string, "visible", comment("visible string which help the user to choose teh correct choice")) + ]) + ]), + + ds_type("HK_Text_Choices", [ + enum("no_choice"), + alternative("text_choices", [ + component(list, extern_type("HK_Text_Choice", model_types+"hk_text_choice.anubis"), "hk_text_choice") + ]) + ]), + + ds_type("HK_Text_Choice", [ + alternative("hk_text_choice", [ + component(string, "value"), + component(string, "visible") + ]) + ]), + + ds_type("HK_App_Name", [ + enum("this"), + alternative("app_name", [ + component(string, "name"), + ]), + enum("none"), + ]), + + ds_type("HK_Datetime_Field_Attr", [ + enum("none", comment("Nothing special, normal behaviour")), + enum("auto_now", comment("Always update datetime at SQL update")), + enum("auto_now_add", comment("Set current datetime when row is created and can't be edited anymore")) + ]), + + ds_type("HK_Model_Attr", [ + enum("unique", comment("by default, the values in a column are not required to be all different ")), + alternative("default", [ + component(string, "default_str", comment("default value (used in case of creation of a NON NULL column in a table which already contains some rows)")), + ]), + enum("not_null"), + ]), + + ds_type("HK_Model_Column", [ + alternative("hk_column", [ + component(string, "name", comment("name of ordinary column (i.e. all but 'id')")), + component(extern_type("HK_Model_Field", model_types+"hk_model_field.anubis"), "type"), + component(list, extern_type("HK_Model_Attr", model_types+"hk_model_attr.anubis"), "attributes"), + component(extern_type("HK_Help_Text", model_types+"hk_help_text.anubis"), "help") + ]) + ]), + + //HK_DISPLAY + ds_type("HK_Display", [ + alternative("hk_display", [ + component(list, extern_type("HK_List_View", model_types+"hk_list_view.anubis"), "list_views"), + component(list, extern_type("HK_Edit_View", model_types+"hk_edit_view.anubis"), "list_edits"), + ]) + ]), + + ds_type("HK_List_View", [ + enum("list_view_all"), + alternative("list_view", [ + component(string, "view_name"), + component(list, string, "columns"), + component(extern_type("WEB_Action_Name", "calexium_lib/web/types/web_action_name.anubis"), "link_id_action") + ]) + ]), + + ds_type("HK_Edit_View", [ + enum("edit_view_all"), + alternative("edit_view", [ + component(string, "view_name"), + component(list, string, "columns") + ]) + ]), + + ] +. diff --git a/model/app.anubis b/model/app.anubis new file mode 100644 index 0000000..bc015fc --- /dev/null +++ b/model/app.anubis @@ -0,0 +1,75 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:06 + * © Calexium + */ + +transmit help.anubis +transmit tables.anubis +transmit icons.anubis + +read tools/basis.anubis +transmit system/muscle.anubis +transmit calexium_lib/web/CXM_json.anubis +transmit hayamiki_lib/model/types/hk_app.anubis + + /* 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). + + type HK_App: + hk_app( + String app_name, + HK_Icon icon, + HK_Help_Text help, + List(HK_Table) hk_tables + ). + + _HK_APP: + ======== + +----------+---------------+-------------------------- + | name | type | description + +----------+---------------+-------------------------------- + | "name" | String | Name of the application + | "icon" | Message | Icon description, contained in message id _HK_ICON + | "help" | Message | Help string, contained in message id _HK_HELP_TEXT + | "tables" | List(Message) | List of tables of that application contained in message id _HK_TABLE + +public define JsonValue + to_JSON + ( + HK_App app + )= + json_object("_HK_APP", + [ + json_member("name", json_string(app.app_name)), + json_member("icon", to_JSON(app.icon)), + json_member("help", to_JSON(app.help)), + json_member("tables", json_array(map((HK_Table table) |-> to_JSON(table), app.hk_tables))) + ]). diff --git a/model/columns.anubis b/model/columns.anubis new file mode 100644 index 0000000..5d3229d --- /dev/null +++ b/model/columns.anubis @@ -0,0 +1,90 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:07 + * © Calexium + */ + +read tools/basis.anubis + +transmit help.anubis +transmit fields.anubis +transmit calexium_lib/web/CXM_json.anubis +transmit hayamiki_lib/model/types/hk_model_column.anubis +transmit hayamiki_lib/model/types/hk_model_attr.anubis +transmit hayamiki_lib/model/types/hk_help_text.anubis + +public define JsonValue + to_JSON + ( + HK_Model_Attr hk_model_attr + )= + with members = + if hk_model_attr is + { + unique then [ json_member("hk_column_attr", json_string("unique")) ], + +// indexed then [ json_member("hk_column_attr", json_string("indexed")) ], + + default(value) then [ json_member("hk_column_attr", json_string("default")), + json_member("value", json_string(value)) + ], + + not_null then [ json_member("hk_column_attr", json_string("not_null")) ] + }, + + json_object("_HK_COLUMN_ATTRIBUTES", members). + + 'HK_Model_Column' (describing a column in a table). + Description of a column: + + + /****** 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). + + + _HK_COLUMN message format: + ========================== + + +--------------+---------------+-------------------------- + | name | type | description + +--------------+---------------+-------------------------------- + | "name" | String | Name of the column in table + | "field_type" | Message | computation String to be shown to summarize row content. This string is Anubis source code + | "attributes" | List(Message) | List of attributes of the table Message id is _HK_COLUMN_ATTRIBUTES + | "text" | Message | help text to use during edit screen + + + +public define JsonValue + to_JSON + ( + HK_Model_Column hk_column + )= + json_object("_HK_COLUMN", + [ + json_member("name", json_string(hk_column.name)), + json_member("field_type", to_JSON(hk_column.type)), + json_member("attributes", json_array(map((HK_Model_Attr attribute) |-> to_JSON(attribute), hk_column.attributes))), + json_member("text", to_JSON(hk_column.help)) + ]). diff --git a/model/database.anubis b/model/database.anubis new file mode 100644 index 0000000..a0ac602 --- /dev/null +++ b/model/database.anubis @@ -0,0 +1,57 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:38 + * © Calexium + */ + +transmit app.anubis + +transmit tools/basis.anubis +transmit system/muscle.anubis +transmit calexium_lib/CXM_message_constants.anubis +transmit calexium_lib/web/CXM_json.anubis +transmit hayamiki_lib/model/types/hk_database.anubis + + + + + _HK_DATABASE message format: + ============================ + + +-----------+---------------+-------------------------- + | name | type | description + +-----------+---------------+-------------------------------- + | "name" | String | Name of the database + | "apps" | List(Message) | List of Application of the database the application Message id is _HK_APP + + + + _HK_DATABASE JSON format: + ========================= + + { + "obj_type": "_HK_DATABASE", //_HK_DATABASE object type describe a database + "name": "XXXX", //name of database + "apps": //list of applications + [ + { "obj_type": "_HK_APP", //_HK_APP object type describe an application + "name" : "app_name" //name of the current application + }, + ... //anothers applications + ] + } + +public define JsonValue + to_JSON + ( + HK_Database hk_db + )= + json_object( + [ json_member("obj_type", json_string("_HK_DATABASE")), + json_member("name", json_string(hk_db.name)), + json_member("apps", json_array(map((HK_App app) |-> to_JSON(app), hk_db.apps))) + ]). + + diff --git a/model/display.anubis b/model/display.anubis new file mode 100644 index 0000000..8f612ff --- /dev/null +++ b/model/display.anubis @@ -0,0 +1,76 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:36 + * © Calexium + */ + +transmit system/muscle.anubis +transmit tools/basis.anubis +transmit calexium_lib/CXM_message_constants.anubis +transmit calexium_lib/web/CXM_json.anubis + +transmit hayamiki_lib/model/types/hk_display.anubis +transmit hayamiki_lib/model/types/hk_list_view.anubis +transmit hayamiki_lib/model/types/hk_edit_view.anubis +transmit hayamiki_lib/model/types/hk_icon.anubis + +public define HK_List_View + list_view + ( + String view_name, + List(String) columns + )= + list_view(view_name, columns, no_action). + + + public define JsonValue + to_JSON + ( + HK_List_View list_view + )= + with members = + if list_view is + { + list_view_all then + [ json_member("type", json_string("list_view_all")) ], + + list_view(name, columns, link_id_action) then + [ json_member("type", json_string("list_view")), + json_member("view_name", json_string(name)), + json_member("link_id_action", json_string(link_id_action)), + json_member("columns", json_array(map((String column) |-> json_string(column), columns))) + ] + }, + + json_object("_HK_LIST_VIEW", members). + + + + _HK_MODEL_DISPLAY message format: + ========================= + The message string name is "hk_display" + +--------------+---------------+-------------------------------- + | name | type | description + +--------------+---------------+-------------------------------- + | "list_edits" | List(Message) | List of (edit list) the Message id is _HK_EDIT_VIEW + | "list_views" | List(Message) | List of (view list) the Message id is _HK_LIST_VIEW + + + + + + +public define JsonValue + to_JSON + ( + HK_Display display + )= + since display is hk_display(list_views, list_edits), + json_object("_HK_MODEL_DISPLAY", + [ //json_member("list_views", json_array(map((HK_List_View _view) |-> to_JSON(_view), list_views))), + //json_member("list_edits", json_array(map((HK_Edit_View _edit) |-> to_JSON(_edit), list_edits))) + ] + ). + diff --git a/model/fields.anubis b/model/fields.anubis new file mode 100644 index 0000000..d6a1e8d --- /dev/null +++ b/model/fields.anubis @@ -0,0 +1,345 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 09:42 + * © Calexium + */ + +transmit tools/basis.anubis +transmit system/convert.anubis +transmit system/muscle.anubis +transmit calexium_lib/CXM_message_constants.anubis +transmit calexium_lib/web/CXM_json.anubis +transmit hayamiki_lib/model/types/hk_model_field.anubis +transmit hayamiki_lib/model/types/hk_app_name.anubis +transmit hayamiki_lib/model/types/hk_text_field_attr.anubis +transmit hayamiki_lib/model/types/hk_datetime_field_attr.anubis +transmit hayamiki_lib/model/types/hk_int_choices.anubis +transmit hayamiki_lib/model/types/hk_text_choices.anubis + + *** '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) + float_field | Float | + char_field | String | max size text + text_field | String | arbitrary size text + + + +public define JsonValue + to_JSON + ( + HK_App_Name hk_app_name + )= + with members = + if hk_app_name is + { + this then [ json_member("type", json_string("this")) ], + + app_name(name) then [ json_member("type", json_string("app_name")), + json_member("name", json_string(name)) + ], + + none then [ json_member("type", json_string("none")) ], + }, + + json_object("_HK_APP_NAME", members). + +define String + to_String + ( + HK_Text_Field_Attr attr + )= + if attr is + { + none then "none", + rich_editor then "rich_editor" + }. + +public define String + to_Anubis_source + ( + HK_Text_Field_Attr attr + )= + to_String(attr) +. + +define HK_Text_Field_Attr + to_HK_Text_Field_Attr + ( + String txt_attr_str + )= + if txt_attr_str = "none" then none else + if txt_attr_str = "rich_editor" then rich_editor + else none +. + +define HK_Text_Field_Attr + get_text_attribute + ( + Message msg + )= + if find_string(msg, "text_attribute") is + { + failure then none, + success(text_attrib) then to_HK_Text_Field_Attr(text_attrib) + }. + + + +define String + to_String + ( + HK_Datetime_Field_Attr attr + )= + if attr is + { + none then "none", + auto_now then "auto_now", + auto_now_add then "auto_now_add" + }. + +define HK_Datetime_Field_Attr + to_HK_Datetime_Field_Attr + ( + String dt_attr_str + )= + if dt_attr_str = "none" then none else + if dt_attr_str = "auto_now" then auto_now else + if dt_attr_str = "auto_now_add" then auto_now_add + else none. + +define HK_Datetime_Field_Attr + get_dt_attribute + ( + Message msg + )= + if find_string(msg, "dt_attribute") is + { + failure then none, + success(dt_attrib) then to_HK_Datetime_Field_Attr(dt_attrib) + }. + + +//default initialization +public define HK_Model_Field + char_field + ( + Int size + )= + char_field(no_choice, size). + +public define HK_Model_Field + integer_field + = + integer_field(no_choice). + +public define HK_Model_Field + foreign_key + ( + String table_name + )= + foreign_key(this, table_name). + +public define HK_Model_Field + text_field + = + text_field(none) +. + + /* * + _HK_FIELD message format: + ============================= + +----------------+-----------+-------------------------------- + | name | type | description + +----------------+-----------+-------------------------------- + | "type" | String | type of the field. It sould be + "p_key" + "boolean_field" + "date_field" __________ + "time_field" ________ | + "datetime_field" __ | | + ________________________________________________|_|_| + | "foreign_key" _________ + | "integer_field" + | "char_field" + | "text_field" + | + --> date_field or time_field or datetime_field: + +-------------+--------+------------------------------------+ + | name | type | description | + |-------------+--------+------------------------------------| + | "attribute" | String | 'none', 'auto_now', 'auto_now_add' | + +-----------------------------------------------------------+ + +*/ + + public define Message + to_Message + ( + HK_Model_Field hk_model_field + )= + with hk_model_field_message = message(_HK_FIELD), + if hk_model_field is + { + p_key then + forget(add_string(hk_model_field_message, "type", "p_key")), + + boolean_field then + forget(add_string(hk_model_field_message, "type", "boolean_field")), + + date_field(attr) then + forget(add_string(hk_model_field_message, "type", "date_field")); + forget(add_string(hk_model_field_message, "dt_attribute", to_String(attr))), + + time_field(attr) then + forget(add_string(hk_model_field_message, "type", "time_field")); + forget(add_string(hk_model_field_message, "dt_attribute", to_String(attr))), + + datetime_field(attr) then + forget(add_string(hk_model_field_message, "type", "datetime_field")); + forget(add_string(hk_model_field_message, "dt_attribute", to_String(attr))), + + foreign_key(app_name, table_name) then // foreign key to 'id' in another (or same) table and column_name for choice selector. + forget(add_string(hk_model_field_message, "type", "foreign_key")); + forget(add_message(hk_model_field_message, "app_name", to_Message(app_name))); + forget(add_string(hk_model_field_message, "table_name", table_name)), + + integer_field(choices) then // integer of arbitrary size + //TODO add choices if need + forget(add_string(hk_model_field_message, "type", "integer_field")), + + float_field then + forget(add_string(hk_model_field_message, "type", "float_field")), + + char_field (choices, size) then // text of maximal size 'size' (number of characters) + //TODO add choices if need + forget(add_string(hk_model_field_message, "type", "char_field")); + forget(add_int32(hk_model_field_message, "size", truncate_to_Word32(size))), + + password_field(size) then + forget(add_string(hk_model_field_message, "type", "password_field")); + forget(add_int32(hk_model_field_message, "size", truncate_to_Word32(size))), + + text_field(text_attr) then // text of variable size + forget(add_string(hk_model_field_message, "type", "text_field")); + forget(add_string(hk_model_field_message, "text_attribute", to_String(text_attr))), + + }; + hk_model_field_message + . + +public define JsonValue + to_JSON + ( + HK_Model_Field hk_model_field + )= + with members = + if hk_model_field is + { + p_key then + [ json_member("type", json_string("p_key")) ], + + boolean_field then + [ json_member("type", json_string("boolean_field")) ], + + date_field(attr) then + [ json_member("type", json_string("date_field")), + json_member("dt_attribute", json_string(to_String(attr))) + ], + + time_field(attr) then + [ json_member("type", json_string("time_field")), + json_member("dt_attribute", json_string(to_String(attr))) + ], + + datetime_field(attr) then + [ json_member("type", json_string("datetime_field")), + json_member("dt_attribute", json_string(to_String(attr))) + ], + + foreign_key(app_name, table_name) then // foreign key to 'id' in another (or same) table and column_name for choice selector. + [ json_member("type", json_string("foreign_key")), + json_member("app_name", to_JSON(app_name)), + json_member("table_name", json_string(table_name)), + ], + + integer_field(choices) then // integer of arbitrary size + //TODO add choices if need + [ json_member("type", json_string("integer_field")) ], + + float_field then //float + [ json_member("type", json_string("float_field"))], + + char_field (choices, size) then // text of maximal size 'size' (number of characters) + //TODO add choices if need + [ json_member("type", json_string("char_field")), + json_member("size", json_int(size)) + ], + + password_field(size) then + [ json_member("type", json_string("password_field")), + json_member("size", json_int(size)) + ], + + text_field(attr) then // text of variable size + [ json_member("type", json_string("text_field")), + json_member("text_attribute", json_string(to_String(attr))) + ] + }, + + json_object("_HK_FIELD", members). + + define Maybe(HK_Model_Field) + get_field + ( + Message hk_model_field_message, + String type + )= + if type = "p_key" then success(p_key) + else if type = "boolean_field" then success(boolean_field) + else if type = "date_field" then success(date_field(get_dt_attribute(hk_model_field_message))) + else if type = "time_field" then success(time_field(get_dt_attribute(hk_model_field_message))) + else if type = "datetime_field" then success(datetime_field(get_dt_attribute(hk_model_field_message))) + else if type = "foreign_key" then + if find_string(hk_model_field_message, "table_name") is {failure then failure, success(table_name) then + if find_message(hk_model_field_message, "app_name") is {failure then failure, success(msg_app_name) then + if from_Message(msg_app_name) is {failure then failure, success(app_name) then + success(foreign_key(app_name, table_name)) + }}} + else if type = "integer_field" then success(integer_field) + else if type = "float_field" then success(float_field) + else if type = "char_field" then + if find_int32(hk_model_field_message, "size") is {failure then failure, success(w32_size) then + success(char_field(to_Int(w32_size)))} + else if type = "password_field" then + if find_int32(hk_model_field_message, "size") is {failure then failure, success(w32_size) then + success(password_field(to_Int(w32_size)))} + else if type = "text_field" then success(text_field(get_text_attribute(hk_model_field_message))) + else failure + . + + public define Maybe(HK_Model_Field) + from_Message + ( + Message hk_model_field_message + )= + if *hk_model_field_message.what = _HK_FIELD then + if find_string(hk_model_field_message, "type") is {failure then failure, success(type) then + get_field(hk_model_field_message, type) + } + else + failure + . diff --git a/model/help.anubis b/model/help.anubis new file mode 100644 index 0000000..b822116 --- /dev/null +++ b/model/help.anubis @@ -0,0 +1,71 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:12 + * © Calexium + */ + +transmit tools/basis.anubis +transmit system/muscle.anubis +transmit calexium_lib/CXM_message_constants.anubis +transmit calexium_lib/web/CXM_json.anubis +transmit hayamiki_lib/model/types/hk_help_text.anubis + + +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+"\")" + }. + + /* * + _HK_HELP_TEXT message format: + ============================= + +----------------+-----------+-------------------------------- + | name | type | description + +----------------+-----------+-------------------------------- + | "hk_help_text" | String | type of the help text. It sould be + "no_help" + "TAG" ____ + "text" __ | + ______________________________________|_| + | + --> TAG or text: + +---------+-----------+-------------------------------- + | name | type | description + +---------+-----------+-------------------------------- + | "value" | String | String name of the 16x16 icon. + +*/ + + + +public define JsonValue + to_JSON + ( + HK_Help_Text hk_help + )= + with members = + if hk_help is + { + no_help_text then [ json_member("hk_help_text", json_string("no_help")) + ], + help_text_TAG(tag) then [ json_member("hk_help_text", json_string("TAG")), + json_member("value", json_string(tag)) + ] + help_text(value) then [ json_member("hk_help_text", json_string("text")), + json_member("value", json_string(value)) + ] + }, + json_object("_HK_HELP_TEXT", members). + + diff --git a/model/icons.anubis b/model/icons.anubis new file mode 100644 index 0000000..a9c16ef --- /dev/null +++ b/model/icons.anubis @@ -0,0 +1,80 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:31 + * © Calexium + */ + +transmit tools/basis.anubis +transmit system/muscle.anubis +transmit calexium_lib/CXM_message_constants.anubis +transmit calexium_lib/web/CXM_json.anubis + +transmit hayamiki_lib/model/types/hk_icon.anubis + +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\"" + }. + + /* * + _HK_ICON message format: + ======================= + +-----------+-----------+-------------------------------- + | name | type | description + +-----------+-----------+-------------------------------- + | "hk_icon" | String | type of the icon. It sould be + "no_icon" + "icon_16" __ + ______________________________________| + | + --> icon_16: + +-----------+-----------+-------------------------------- + | name | type | description + +-----------+-----------+-------------------------------- + | "icn_str" | String | String name of the 16x16 icon. + + */ + + + +public define JsonValue + to_JSON + ( + HK_Icon hk_icon + )= + with members = + if hk_icon is + { + no_icon then [ json_member("hk_icon", json_string("no_icon")) + ], + + icon16(icn_str) then [ json_member("hk_icon", json_string("icon_16")), + json_member("icn_str", json_string(icn_str)) + ] + }, + + json_object("_HK_ICON", members). + diff --git a/model/model.anubis b/model/model.anubis new file mode 100644 index 0000000..c2a401f --- /dev/null +++ b/model/model.anubis @@ -0,0 +1,35 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:41 + * © Calexium + */ + +transmit tools/basis.anubis +transmit columns.anubis +transmit calexium_lib/web/CXM_json.anubis +transmit hayamiki_lib/model/types/hk_model.anubis + + + _HK_MODEL message format: + ======================== + + +------------+---------------+-------------------------- + | name | type | description + +------------+---------------+-------------------------------- + | "columns" | List(Message) | List of columns of the table Message id is _HK_COLUMN + | "show_str" | String | computation String to be shown to summarize row content. This string is Anubis source code + where the row content is in datum, named "obj". + +public define JsonValue + to_JSON + ( + HK_Model hk_model + )= + json_object("_HK_MODEL", + [ + json_member("columns", json_array(map((HK_Model_Column column) |-> to_JSON(column), hk_model.columns))), + json_member("show_str", json_string(hk_model.show_string)) + ]). + diff --git a/model/tables.anubis b/model/tables.anubis new file mode 100644 index 0000000..d6a7242 --- /dev/null +++ b/model/tables.anubis @@ -0,0 +1,37 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 13/02/2016 + * Time: 10:20 + * © Calexium + */ + +read tools/basis.anubis +transmit display.anubis +transmit model.anubis +transmit calexium_lib/web/CXM_json.anubis + +transmit hayamiki_lib/model/types/hk_table.anubis + +public define HK_Table + hk_table + ( + String name, //name of the table + HK_Model model, + HK_Display display + )= + hk_table(name, "", model, display). + +public define JsonValue + to_JSON + ( + HK_Table table + )= + json_object("_HK_TABLE", + [ json_member("name", json_string(table.name)), + json_member("short_name", json_string(table.short_name)), + json_member("model", to_JSON(table.model)), + json_member("hk_display", to_JSON(table.display)) + ] + ). + diff --git a/model/types/hk_app.anubis b/model/types/hk_app.anubis new file mode 100644 index 0000000..7461e8c --- /dev/null +++ b/model/types/hk_app.anubis @@ -0,0 +1,85 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:19 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + +transmit hayamiki_lib/model/types/hk_table.anubis +transmit hayamiki_lib/model/types/hk_help_text.anubis +transmit hayamiki_lib/model/types/hk_icon.anubis + +public type HK_App: + hk_app( + String app_name, + HK_Icon icon, + HK_Help_Text help, + List(HK_Table) hk_tables + ) +. + + HK_App message format + ===================== + + +public define Message + to_Message + ( + HK_App _hk_app + )= + with _hk_app_message = message((Word32)0), // + forget(add_string(_hk_app_message, "__TYPE__", "HK_App")); + if _hk_app is + { + //Alternative hk_app + hk_app(_app_name, _icon, _help, __hk_tables) then + forget(add_string(_hk_app_message, "__TYPE_ALT__", "hk_app")); + // [type = String] hk_app.app_name + forget(add_string(_hk_app_message, "app_name", _app_name)); + // [type = HK_Icon] hk_app.icon + forget(add_message(_hk_app_message, "icon", to_Message(_icon))); + // [type = HK_Help_Text] hk_app.help + forget(add_message(_hk_app_message, "help", to_Message(_help))); + // [type = List(HK_Table)] hk_app.hk_tables + map_forget((HK_Table _hk_tables) |-> add_message(_hk_app_message, "hk_tables", to_Message(_hk_tables)), __hk_tables), + + }; + _hk_app_message +. + +public define Maybe(HK_App) + from_Message + ( + Message _hk_app_message + )= + if find_string(_hk_app_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_app_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_App" then + //Alternative hk_app + if __type_alt__ = "hk_app" then //Alternative hk_app + // [type = String] hk_app.app_name + if find_string(_hk_app_message, "app_name") is {failure then failure, success(app_name) then + // [type = HK_Icon] hk_app.icon + if find_message(_hk_app_message, "icon") is {failure then failure, success(icon_msg) then + if (Maybe(HK_Icon))from_Message(icon_msg) is {failure then failure, success(icon) then + // [type = HK_Help_Text] hk_app.help + if find_message(_hk_app_message, "help") is {failure then failure, success(help_msg) then + if (Maybe(HK_Help_Text))from_Message(help_msg) is {failure then failure, success(help) then + // [type = List(HK_Table)] hk_app.hk_tables + with mb_hk_tables = map_escape(( Message msg ) |-> (Maybe(HK_Table)) from_Message(msg), find_messages(_hk_app_message, "hk_tables")), + if mb_hk_tables is {failure then failure, success(hk_tables) then + + success(hk_app(app_name, icon, help, hk_tables)) + }}}}}} + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_app_name.anubis b/model/types/hk_app_name.anubis new file mode 100644 index 0000000..5cde52c --- /dev/null +++ b/model/types/hk_app_name.anubis @@ -0,0 +1,80 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:20 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + + +public type HK_App_Name: + this, + app_name( + String name + ), + none +. + + HK_App_Name message format + ========================== + + +public define Message + to_Message + ( + HK_App_Name _hk_app_name + )= + with _hk_app_name_message = message((Word32)0), // + forget(add_string(_hk_app_name_message, "__TYPE__", "HK_App_Name")); + if _hk_app_name is + { + //Alternative this (NO TYPE) + this then + forget(add_string(_hk_app_name_message, "__TYPE_ALT__", "this")), + + //Alternative app_name + app_name(_name) then + forget(add_string(_hk_app_name_message, "__TYPE_ALT__", "app_name")); + // [type = String] app_name.name + forget(add_string(_hk_app_name_message, "name", _name)), + + //Alternative none (NO TYPE) + none then + forget(add_string(_hk_app_name_message, "__TYPE_ALT__", "none")), + + }; + _hk_app_name_message +. + +public define Maybe(HK_App_Name) + from_Message + ( + Message _hk_app_name_message + )= + if find_string(_hk_app_name_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_app_name_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_App_Name" then + //Alternative this (NO TYPE) + if __type_alt__ = "this" then + success(this) + else //Alternative app_name + if __type_alt__ = "app_name" then //Alternative app_name + // [type = String] app_name.name + if find_string(_hk_app_name_message, "name") is {failure then failure, success(name) then + + success(app_name(name)) + } + else //Alternative none (NO TYPE) + if __type_alt__ = "none" then + success(none) + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_database.anubis b/model/types/hk_database.anubis new file mode 100644 index 0000000..3b84ebe --- /dev/null +++ b/model/types/hk_database.anubis @@ -0,0 +1,71 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:19 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + +transmit hayamiki_lib/model/types/hk_app.anubis + +public type HK_Database: + hk_database( + String name, //name of the database + List(HK_App) apps //list of applications + ) +. + + HK_Database message format + ========================== + + +public define Message + to_Message + ( + HK_Database _hk_database + )= + with _hk_database_message = message((Word32)0), // + forget(add_string(_hk_database_message, "__TYPE__", "HK_Database")); + if _hk_database is + { + //Alternative hk_database + hk_database(_name, __apps) then + forget(add_string(_hk_database_message, "__TYPE_ALT__", "hk_database")); + // [type = String] hk_database.name + forget(add_string(_hk_database_message, "name", _name)); + // [type = List(HK_App)] hk_database.apps + map_forget((HK_App _apps) |-> add_message(_hk_database_message, "apps", to_Message(_apps)), __apps), + + }; + _hk_database_message +. + +public define Maybe(HK_Database) + from_Message + ( + Message _hk_database_message + )= + if find_string(_hk_database_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_database_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Database" then + //Alternative hk_database + if __type_alt__ = "hk_database" then //Alternative hk_database + // [type = String] hk_database.name + if find_string(_hk_database_message, "name") is {failure then failure, success(name) then + // [type = List(HK_App)] hk_database.apps + with mb_apps = map_escape(( Message msg ) |-> (Maybe(HK_App)) from_Message(msg), find_messages(_hk_database_message, "apps")), + if mb_apps is {failure then failure, success(apps) then + + success(hk_database(name, apps)) + }} + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_datetime_field_attr.anubis b/model/types/hk_datetime_field_attr.anubis new file mode 100644 index 0000000..37c45a2 --- /dev/null +++ b/model/types/hk_datetime_field_attr.anubis @@ -0,0 +1,72 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:20 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + + +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 +. + + HK_Datetime_Field_Attr message format + ===================================== + + +public define Message + to_Message + ( + HK_Datetime_Field_Attr _hk_datetime_field_attr + )= + with _hk_datetime_field_attr_message = message((Word32)0), // + forget(add_string(_hk_datetime_field_attr_message, "__TYPE__", "HK_Datetime_Field_Attr")); + if _hk_datetime_field_attr is + { + //Alternative none (NO TYPE) + none then + forget(add_string(_hk_datetime_field_attr_message, "__TYPE_ALT__", "none")), + + //Alternative auto_now (NO TYPE) + auto_now then + forget(add_string(_hk_datetime_field_attr_message, "__TYPE_ALT__", "auto_now")), + + //Alternative auto_now_add (NO TYPE) + auto_now_add then + forget(add_string(_hk_datetime_field_attr_message, "__TYPE_ALT__", "auto_now_add")), + + }; + _hk_datetime_field_attr_message +. + +public define Maybe(HK_Datetime_Field_Attr) + from_Message + ( + Message _hk_datetime_field_attr_message + )= + if find_string(_hk_datetime_field_attr_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_datetime_field_attr_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Datetime_Field_Attr" then + //Alternative none (NO TYPE) + if __type_alt__ = "none" then + success(none) + else //Alternative auto_now (NO TYPE) + if __type_alt__ = "auto_now" then + success(auto_now) + else //Alternative auto_now_add (NO TYPE) + if __type_alt__ = "auto_now_add" then + success(auto_now_add) + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_display.anubis b/model/types/hk_display.anubis new file mode 100644 index 0000000..a7f25d1 --- /dev/null +++ b/model/types/hk_display.anubis @@ -0,0 +1,73 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:20 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + +transmit hayamiki_lib/model/types/hk_edit_view.anubis +transmit hayamiki_lib/model/types/hk_list_view.anubis + +public type HK_Display: + hk_display( + List(HK_List_View) list_views, + List(HK_Edit_View) list_edits + ) +. + + HK_Display message format + ========================= + + +public define Message + to_Message + ( + HK_Display _hk_display + )= + with _hk_display_message = message((Word32)0), // + forget(add_string(_hk_display_message, "__TYPE__", "HK_Display")); + if _hk_display is + { + //Alternative hk_display + hk_display(__list_views, __list_edits) then + forget(add_string(_hk_display_message, "__TYPE_ALT__", "hk_display")); + // [type = List(HK_List_View)] hk_display.list_views + map_forget((HK_List_View _list_views) |-> add_message(_hk_display_message, "list_views", to_Message(_list_views)), __list_views); + // [type = List(HK_Edit_View)] hk_display.list_edits + map_forget((HK_Edit_View _list_edits) |-> add_message(_hk_display_message, "list_edits", to_Message(_list_edits)), __list_edits), + + }; + _hk_display_message +. + +public define Maybe(HK_Display) + from_Message + ( + Message _hk_display_message + )= + if find_string(_hk_display_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_display_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Display" then + //Alternative hk_display + if __type_alt__ = "hk_display" then //Alternative hk_display + // [type = List(HK_List_View)] hk_display.list_views + with mb_list_views = map_escape(( Message msg ) |-> (Maybe(HK_List_View)) from_Message(msg), find_messages(_hk_display_message, "list_views")), + if mb_list_views is {failure then failure, success(list_views) then + // [type = List(HK_Edit_View)] hk_display.list_edits + with mb_list_edits = map_escape(( Message msg ) |-> (Maybe(HK_Edit_View)) from_Message(msg), find_messages(_hk_display_message, "list_edits")), + if mb_list_edits is {failure then failure, success(list_edits) then + + success(hk_display(list_views, list_edits)) + }} + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_edit_view.anubis b/model/types/hk_edit_view.anubis new file mode 100644 index 0000000..267e047 --- /dev/null +++ b/model/types/hk_edit_view.anubis @@ -0,0 +1,77 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:20 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + + +public type HK_Edit_View: + edit_view_all, + edit_view( + String view_name, + List(String) columns + ) +. + + HK_Edit_View message format + =========================== + + +public define Message + to_Message + ( + HK_Edit_View _hk_edit_view + )= + with _hk_edit_view_message = message((Word32)0), // + forget(add_string(_hk_edit_view_message, "__TYPE__", "HK_Edit_View")); + if _hk_edit_view is + { + //Alternative edit_view_all (NO TYPE) + edit_view_all then + forget(add_string(_hk_edit_view_message, "__TYPE_ALT__", "edit_view_all")), + + //Alternative edit_view + edit_view(_view_name, __columns) then + forget(add_string(_hk_edit_view_message, "__TYPE_ALT__", "edit_view")); + // [type = String] edit_view.view_name + forget(add_string(_hk_edit_view_message, "view_name", _view_name)); + // [type = List(String)] edit_view.columns + map_forget((String _columns) |-> add_string(_hk_edit_view_message, "columns", _columns), __columns), + + }; + _hk_edit_view_message +. + +public define Maybe(HK_Edit_View) + from_Message + ( + Message _hk_edit_view_message + )= + if find_string(_hk_edit_view_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_edit_view_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Edit_View" then + //Alternative edit_view_all (NO TYPE) + if __type_alt__ = "edit_view_all" then + success(edit_view_all) + else //Alternative edit_view + if __type_alt__ = "edit_view" then //Alternative edit_view + // [type = String] edit_view.view_name + if find_string(_hk_edit_view_message, "view_name") is {failure then failure, success(view_name) then + // [type = List(String)] edit_view.columns + with columns = find_string_list(_hk_edit_view_message, "columns"), + + success(edit_view(view_name, columns)) + } + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_help_text.anubis b/model/types/hk_help_text.anubis new file mode 100644 index 0000000..e27c2f1 --- /dev/null +++ b/model/types/hk_help_text.anubis @@ -0,0 +1,88 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:19 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + + +public type HK_Help_Text: + no_help_text, //no help text available + help_text_TAG( + String h_text_tag //TAG use with Anubis translation tool /locale/L3.anubis + ), + help_text( + String h_text //pure text to show + ) +. + + HK_Help_Text message format + =========================== + + +public define Message + to_Message + ( + HK_Help_Text _hk_help_text + )= + with _hk_help_text_message = message((Word32)0), // + forget(add_string(_hk_help_text_message, "__TYPE__", "HK_Help_Text")); + if _hk_help_text is + { + //Alternative no_help_text (NO TYPE) + no_help_text then + forget(add_string(_hk_help_text_message, "__TYPE_ALT__", "no_help_text")), + + //Alternative help_text_TAG + help_text_TAG(_h_text_tag) then + forget(add_string(_hk_help_text_message, "__TYPE_ALT__", "help_text_TAG")); + // [type = String] help_text_TAG.h_text_tag + forget(add_string(_hk_help_text_message, "h_text_tag", _h_text_tag)), + + //Alternative help_text + help_text(_h_text) then + forget(add_string(_hk_help_text_message, "__TYPE_ALT__", "help_text")); + // [type = String] help_text.h_text + forget(add_string(_hk_help_text_message, "h_text", _h_text)), + + }; + _hk_help_text_message +. + +public define Maybe(HK_Help_Text) + from_Message + ( + Message _hk_help_text_message + )= + if find_string(_hk_help_text_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_help_text_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Help_Text" then + //Alternative no_help_text (NO TYPE) + if __type_alt__ = "no_help_text" then + success(no_help_text) + else //Alternative help_text_TAG + if __type_alt__ = "help_text_TAG" then //Alternative help_text_TAG + // [type = String] help_text_TAG.h_text_tag + if find_string(_hk_help_text_message, "h_text_tag") is {failure then failure, success(h_text_tag) then + + success(help_text_TAG(h_text_tag)) + } + else //Alternative help_text + if __type_alt__ = "help_text" then //Alternative help_text + // [type = String] help_text.h_text + if find_string(_hk_help_text_message, "h_text") is {failure then failure, success(h_text) then + + success(help_text(h_text)) + } + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_icon.anubis b/model/types/hk_icon.anubis new file mode 100644 index 0000000..30c7a8b --- /dev/null +++ b/model/types/hk_icon.anubis @@ -0,0 +1,72 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:19 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + + +public type HK_Icon: + no_icon, + icon16( + String name + ) +. + + HK_Icon message format + ====================== + + +public define Message + to_Message + ( + HK_Icon _hk_icon + )= + with _hk_icon_message = message((Word32)0), // + forget(add_string(_hk_icon_message, "__TYPE__", "HK_Icon")); + if _hk_icon is + { + //Alternative no_icon (NO TYPE) + no_icon then + forget(add_string(_hk_icon_message, "__TYPE_ALT__", "no_icon")), + + //Alternative icon16 + icon16(_name) then + forget(add_string(_hk_icon_message, "__TYPE_ALT__", "icon16")); + // [type = String] icon16.name + forget(add_string(_hk_icon_message, "name", _name)), + + }; + _hk_icon_message +. + +public define Maybe(HK_Icon) + from_Message + ( + Message _hk_icon_message + )= + if find_string(_hk_icon_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_icon_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Icon" then + //Alternative no_icon (NO TYPE) + if __type_alt__ = "no_icon" then + success(no_icon) + else //Alternative icon16 + if __type_alt__ = "icon16" then //Alternative icon16 + // [type = String] icon16.name + if find_string(_hk_icon_message, "name") is {failure then failure, success(name) then + + success(icon16(name)) + } + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_int_choice.anubis b/model/types/hk_int_choice.anubis new file mode 100644 index 0000000..46323f2 --- /dev/null +++ b/model/types/hk_int_choice.anubis @@ -0,0 +1,70 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:20 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + + +public type HK_Int_Choice: + hk_int_choice( + Int value, //value to set in database corresponding to description below + String visible //visible string which help the user to choose teh correct choice + ) +. + + HK_Int_Choice message format + ============================ + + +public define Message + to_Message + ( + HK_Int_Choice _hk_int_choice + )= + with _hk_int_choice_message = message((Word32)0), // + forget(add_string(_hk_int_choice_message, "__TYPE__", "HK_Int_Choice")); + if _hk_int_choice is + { + //Alternative hk_int_choice + hk_int_choice(_value, _visible) then + forget(add_string(_hk_int_choice_message, "__TYPE_ALT__", "hk_int_choice")); + // [type = Int] hk_int_choice.value + forget(add_string(_hk_int_choice_message, "value", to_String(_value))); + // [type = String] hk_int_choice.visible + forget(add_string(_hk_int_choice_message, "visible", _visible)), + + }; + _hk_int_choice_message +. + +public define Maybe(HK_Int_Choice) + from_Message + ( + Message _hk_int_choice_message + )= + if find_string(_hk_int_choice_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_int_choice_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Int_Choice" then + //Alternative hk_int_choice + if __type_alt__ = "hk_int_choice" then //Alternative hk_int_choice + // [type = Int] hk_int_choice.value + if find_string(_hk_int_choice_message, "value") is {failure then failure, success(_value) then + if decimal_scan(_value) is { failure then failure, success(value) then + // [type = String] hk_int_choice.visible + if find_string(_hk_int_choice_message, "visible") is {failure then failure, success(visible) then + + success(hk_int_choice(value, visible)) + }}} + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_int_choices.anubis b/model/types/hk_int_choices.anubis new file mode 100644 index 0000000..8b99810 --- /dev/null +++ b/model/types/hk_int_choices.anubis @@ -0,0 +1,74 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:20 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + +transmit hayamiki_lib/model/types/hk_int_choice.anubis + +public type HK_Int_Choices: + no_choice, //No list choice is available. Hence the user must enter the value + int_choices( + List(HK_Int_Choice) hk_int_choice //List of possible choices + ) +. + + HK_Int_Choices message format + ============================= + + +public define Message + to_Message + ( + HK_Int_Choices _hk_int_choices + )= + with _hk_int_choices_message = message((Word32)0), // + forget(add_string(_hk_int_choices_message, "__TYPE__", "HK_Int_Choices")); + if _hk_int_choices is + { + //Alternative no_choice (NO TYPE) + no_choice then + forget(add_string(_hk_int_choices_message, "__TYPE_ALT__", "no_choice")), + + //Alternative int_choices + int_choices(__hk_int_choice) then + forget(add_string(_hk_int_choices_message, "__TYPE_ALT__", "int_choices")); + // [type = List(HK_Int_Choice)] int_choices.hk_int_choice + map_forget((HK_Int_Choice _hk_int_choice) |-> add_message(_hk_int_choices_message, "hk_int_choice", to_Message(_hk_int_choice)), __hk_int_choice), + + }; + _hk_int_choices_message +. + +public define Maybe(HK_Int_Choices) + from_Message + ( + Message _hk_int_choices_message + )= + if find_string(_hk_int_choices_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_int_choices_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Int_Choices" then + //Alternative no_choice (NO TYPE) + if __type_alt__ = "no_choice" then + success(no_choice) + else //Alternative int_choices + if __type_alt__ = "int_choices" then //Alternative int_choices + // [type = List(HK_Int_Choice)] int_choices.hk_int_choice + with mb_hk_int_choice = map_escape(( Message msg ) |-> (Maybe(HK_Int_Choice)) from_Message(msg), find_messages(_hk_int_choices_message, "hk_int_choice")), + if mb_hk_int_choice is {failure then failure, success(hk_int_choice) then + + success(int_choices(hk_int_choice)) + } + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_list_view.anubis b/model/types/hk_list_view.anubis new file mode 100644 index 0000000..3510be9 --- /dev/null +++ b/model/types/hk_list_view.anubis @@ -0,0 +1,84 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:20 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + +transmit calexium_lib/web/types/web_action_name.anubis + +public type HK_List_View: + list_view_all, + list_view( + String view_name, + List(String) columns, + WEB_Action_Name link_id_action + ) +. + + HK_List_View message format + =========================== + + +public define Message + to_Message + ( + HK_List_View _hk_list_view + )= + with _hk_list_view_message = message((Word32)0), // + forget(add_string(_hk_list_view_message, "__TYPE__", "HK_List_View")); + if _hk_list_view is + { + //Alternative list_view_all (NO TYPE) + list_view_all then + forget(add_string(_hk_list_view_message, "__TYPE_ALT__", "list_view_all")), + + //Alternative list_view + list_view(_view_name, __columns, _link_id_action) then + forget(add_string(_hk_list_view_message, "__TYPE_ALT__", "list_view")); + // [type = String] list_view.view_name + forget(add_string(_hk_list_view_message, "view_name", _view_name)); + // [type = List(String)] list_view.columns + map_forget((String _columns) |-> add_string(_hk_list_view_message, "columns", _columns), __columns); + // [type = WEB_Action_Name] list_view.link_id_action + forget(add_message(_hk_list_view_message, "link_id_action", to_Message(_link_id_action))), + + }; + _hk_list_view_message +. + +public define Maybe(HK_List_View) + from_Message + ( + Message _hk_list_view_message + )= + if find_string(_hk_list_view_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_list_view_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_List_View" then + //Alternative list_view_all (NO TYPE) + if __type_alt__ = "list_view_all" then + success(list_view_all) + else //Alternative list_view + if __type_alt__ = "list_view" then //Alternative list_view + // [type = String] list_view.view_name + if find_string(_hk_list_view_message, "view_name") is {failure then failure, success(view_name) then + // [type = List(String)] list_view.columns + with columns = find_string_list(_hk_list_view_message, "columns"), + // [type = WEB_Action_Name] list_view.link_id_action + if find_message(_hk_list_view_message, "link_id_action") is {failure then failure, success(link_id_action_msg) then + if (Maybe(WEB_Action_Name))from_Message(link_id_action_msg) is {failure then failure, success(link_id_action) then + + success(list_view(view_name, columns, link_id_action)) + }}} + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_model.anubis b/model/types/hk_model.anubis new file mode 100644 index 0000000..8544309 --- /dev/null +++ b/model/types/hk_model.anubis @@ -0,0 +1,71 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:19 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + +transmit hayamiki_lib/model/types/hk_model_column.anubis + +public type HK_Model: + hk_model( + List(HK_Model_Column) columns, //columns other than the primary key column (if any) + String show_string + ) +. + + HK_Model message format + ======================= + + +public define Message + to_Message + ( + HK_Model _hk_model + )= + with _hk_model_message = message((Word32)0), // + forget(add_string(_hk_model_message, "__TYPE__", "HK_Model")); + if _hk_model is + { + //Alternative hk_model + hk_model(__columns, _show_string) then + forget(add_string(_hk_model_message, "__TYPE_ALT__", "hk_model")); + // [type = List(HK_Model_Column)] hk_model.columns + map_forget((HK_Model_Column _columns) |-> add_message(_hk_model_message, "columns", to_Message(_columns)), __columns); + // [type = String] hk_model.show_string + forget(add_string(_hk_model_message, "show_string", _show_string)), + + }; + _hk_model_message +. + +public define Maybe(HK_Model) + from_Message + ( + Message _hk_model_message + )= + if find_string(_hk_model_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_model_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Model" then + //Alternative hk_model + if __type_alt__ = "hk_model" then //Alternative hk_model + // [type = List(HK_Model_Column)] hk_model.columns + with mb_columns = map_escape(( Message msg ) |-> (Maybe(HK_Model_Column)) from_Message(msg), find_messages(_hk_model_message, "columns")), + if mb_columns is {failure then failure, success(columns) then + // [type = String] hk_model.show_string + if find_string(_hk_model_message, "show_string") is {failure then failure, success(show_string) then + + success(hk_model(columns, show_string)) + }} + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_model_attr.anubis b/model/types/hk_model_attr.anubis new file mode 100644 index 0000000..0ce0e10 --- /dev/null +++ b/model/types/hk_model_attr.anubis @@ -0,0 +1,80 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:20 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + + +public type HK_Model_Attr: + unique, //by default, the values in a column are not required to be all different + default( + String default_str //default value (used in case of creation of a NON NULL column in a table which already contains some rows) + ), + not_null +. + + HK_Model_Attr message format + ============================ + + +public define Message + to_Message + ( + HK_Model_Attr _hk_model_attr + )= + with _hk_model_attr_message = message((Word32)0), // + forget(add_string(_hk_model_attr_message, "__TYPE__", "HK_Model_Attr")); + if _hk_model_attr is + { + //Alternative unique (NO TYPE) + unique then + forget(add_string(_hk_model_attr_message, "__TYPE_ALT__", "unique")), + + //Alternative default + default(_default_str) then + forget(add_string(_hk_model_attr_message, "__TYPE_ALT__", "default")); + // [type = String] default.default_str + forget(add_string(_hk_model_attr_message, "default_str", _default_str)), + + //Alternative not_null (NO TYPE) + not_null then + forget(add_string(_hk_model_attr_message, "__TYPE_ALT__", "not_null")), + + }; + _hk_model_attr_message +. + +public define Maybe(HK_Model_Attr) + from_Message + ( + Message _hk_model_attr_message + )= + if find_string(_hk_model_attr_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_model_attr_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Model_Attr" then + //Alternative unique (NO TYPE) + if __type_alt__ = "unique" then + success(unique) + else //Alternative default + if __type_alt__ = "default" then //Alternative default + // [type = String] default.default_str + if find_string(_hk_model_attr_message, "default_str") is {failure then failure, success(default_str) then + + success(default(default_str)) + } + else //Alternative not_null (NO TYPE) + if __type_alt__ = "not_null" then + success(not_null) + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_model_column.anubis b/model/types/hk_model_column.anubis new file mode 100644 index 0000000..02ee585 --- /dev/null +++ b/model/types/hk_model_column.anubis @@ -0,0 +1,85 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:20 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + +transmit hayamiki_lib/model/types/hk_help_text.anubis +transmit hayamiki_lib/model/types/hk_model_attr.anubis +transmit hayamiki_lib/model/types/hk_model_field.anubis + +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 + ) +. + + HK_Model_Column message format + ============================== + + +public define Message + to_Message + ( + HK_Model_Column _hk_model_column + )= + with _hk_model_column_message = message((Word32)0), // + forget(add_string(_hk_model_column_message, "__TYPE__", "HK_Model_Column")); + if _hk_model_column is + { + //Alternative hk_column + hk_column(_name, _type, __attributes, _help) then + forget(add_string(_hk_model_column_message, "__TYPE_ALT__", "hk_column")); + // [type = String] hk_column.name + forget(add_string(_hk_model_column_message, "name", _name)); + // [type = HK_Model_Field] hk_column.type + forget(add_message(_hk_model_column_message, "type", to_Message(_type))); + // [type = List(HK_Model_Attr)] hk_column.attributes + map_forget((HK_Model_Attr _attributes) |-> add_message(_hk_model_column_message, "attributes", to_Message(_attributes)), __attributes); + // [type = HK_Help_Text] hk_column.help + forget(add_message(_hk_model_column_message, "help", to_Message(_help))), + + }; + _hk_model_column_message +. + +public define Maybe(HK_Model_Column) + from_Message + ( + Message _hk_model_column_message + )= + if find_string(_hk_model_column_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_model_column_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Model_Column" then + //Alternative hk_column + if __type_alt__ = "hk_column" then //Alternative hk_column + // [type = String] hk_column.name + if find_string(_hk_model_column_message, "name") is {failure then failure, success(name) then + // [type = HK_Model_Field] hk_column.type + if find_message(_hk_model_column_message, "type") is {failure then failure, success(type_msg) then + if (Maybe(HK_Model_Field))from_Message(type_msg) is {failure then failure, success(type) then + // [type = List(HK_Model_Attr)] hk_column.attributes + with mb_attributes = map_escape(( Message msg ) |-> (Maybe(HK_Model_Attr)) from_Message(msg), find_messages(_hk_model_column_message, "attributes")), + if mb_attributes is {failure then failure, success(attributes) then + // [type = HK_Help_Text] hk_column.help + if find_message(_hk_model_column_message, "help") is {failure then failure, success(help_msg) then + if (Maybe(HK_Help_Text))from_Message(help_msg) is {failure then failure, success(help) then + + success(hk_column(name, type, attributes, help)) + }}}}}} + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_model_field.anubis b/model/types/hk_model_field.anubis new file mode 100644 index 0000000..ed35260 --- /dev/null +++ b/model/types/hk_model_field.anubis @@ -0,0 +1,232 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:19 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + +transmit hayamiki_lib/model/types/hk_text_field_attr.anubis +transmit hayamiki_lib/model/types/hk_text_choices.anubis +transmit hayamiki_lib/model/types/hk_int_choices.anubis +transmit hayamiki_lib/model/types/hk_app_name.anubis +transmit hayamiki_lib/model/types/hk_datetime_field_attr.anubis + +public type HK_Model_Field: + p_key, + boolean_field, //true or false + date_field( + HK_Datetime_Field_Attr hk_dt_f_attr //date with the precision of the day + ), + time_field( + HK_Datetime_Field_Attr hk_dt_f_attr //time with the precision of the second + ), + datetime_field( + HK_Datetime_Field_Attr hk_dt_f_attr //datetime with the precision of the second + ), + //foreign key to 'id' in another (or same) table and column_name for choice selector) + + foreign_key( + HK_App_Name app_name, + String table_name + ), + integer_field( + HK_Int_Choices choices //integer of arbitrary size + ), + float_field, + char_field( + HK_Text_Choices choices, + Int size //text of maximal size 'size' (number of characters) + ), + password_field( + Int min_size //the password field doesn't show the password string or store it in hashed version into database + ), + //text of variable size + + text_field( + HK_Text_Field_Attr hk_text_field_attr + ) +. + + HK_Model_Field message format + ============================= + + +public define Message + to_Message + ( + HK_Model_Field _hk_model_field + )= + with _hk_model_field_message = message((Word32)0), // + forget(add_string(_hk_model_field_message, "__TYPE__", "HK_Model_Field")); + if _hk_model_field is + { + //Alternative p_key (NO TYPE) + p_key then + forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "p_key")), + + //Alternative boolean_field (NO TYPE) + boolean_field then + forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "boolean_field")), + + //Alternative date_field + date_field(_hk_dt_f_attr) then + forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "date_field")); + // [type = HK_Datetime_Field_Attr] date_field.hk_dt_f_attr + forget(add_message(_hk_model_field_message, "hk_dt_f_attr", to_Message(_hk_dt_f_attr))), + + //Alternative time_field + time_field(_hk_dt_f_attr) then + forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "time_field")); + // [type = HK_Datetime_Field_Attr] time_field.hk_dt_f_attr + forget(add_message(_hk_model_field_message, "hk_dt_f_attr", to_Message(_hk_dt_f_attr))), + + //Alternative datetime_field + datetime_field(_hk_dt_f_attr) then + forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "datetime_field")); + // [type = HK_Datetime_Field_Attr] datetime_field.hk_dt_f_attr + forget(add_message(_hk_model_field_message, "hk_dt_f_attr", to_Message(_hk_dt_f_attr))), + + //Alternative foreign_key + //foreign key to 'id' in another (or same) table and column_name for choice selector) + foreign_key(_app_name, _table_name) then + forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "foreign_key")); + // [type = HK_App_Name] foreign_key.app_name + forget(add_message(_hk_model_field_message, "app_name", to_Message(_app_name))); + // [type = String] foreign_key.table_name + forget(add_string(_hk_model_field_message, "table_name", _table_name)), + + //Alternative integer_field + integer_field(_choices) then + forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "integer_field")); + // [type = HK_Int_Choices] integer_field.choices + forget(add_message(_hk_model_field_message, "choices", to_Message(_choices))), + + //Alternative float_field (NO TYPE) + float_field then + forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "float_field")), + + //Alternative char_field + char_field(_choices, _size) then + forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "char_field")); + // [type = HK_Text_Choices] char_field.choices + forget(add_message(_hk_model_field_message, "choices", to_Message(_choices))); + // [type = Int] char_field.size + forget(add_string(_hk_model_field_message, "size", to_String(_size))), + + //Alternative password_field + password_field(_min_size) then + forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "password_field")); + // [type = Int] password_field.min_size + forget(add_string(_hk_model_field_message, "min_size", to_String(_min_size))), + + //Alternative text_field + //text of variable size + text_field(_hk_text_field_attr) then + forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "text_field")); + // [type = HK_Text_Field_Attr] text_field.hk_text_field_attr + forget(add_message(_hk_model_field_message, "hk_text_field_attr", to_Message(_hk_text_field_attr))), + + }; + _hk_model_field_message +. + +public define Maybe(HK_Model_Field) + from_Message + ( + Message _hk_model_field_message + )= + if find_string(_hk_model_field_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_model_field_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Model_Field" then + //Alternative p_key (NO TYPE) + if __type_alt__ = "p_key" then + success(p_key) + else //Alternative boolean_field (NO TYPE) + if __type_alt__ = "boolean_field" then + success(boolean_field) + else //Alternative date_field + if __type_alt__ = "date_field" then //Alternative date_field + // [type = HK_Datetime_Field_Attr] date_field.hk_dt_f_attr + if find_message(_hk_model_field_message, "hk_dt_f_attr") is {failure then failure, success(hk_dt_f_attr_msg) then + if (Maybe(HK_Datetime_Field_Attr))from_Message(hk_dt_f_attr_msg) is {failure then failure, success(hk_dt_f_attr) then + + success(date_field(hk_dt_f_attr)) + }} + else //Alternative time_field + if __type_alt__ = "time_field" then //Alternative time_field + // [type = HK_Datetime_Field_Attr] time_field.hk_dt_f_attr + if find_message(_hk_model_field_message, "hk_dt_f_attr") is {failure then failure, success(hk_dt_f_attr_msg) then + if (Maybe(HK_Datetime_Field_Attr))from_Message(hk_dt_f_attr_msg) is {failure then failure, success(hk_dt_f_attr) then + + success(time_field(hk_dt_f_attr)) + }} + else //Alternative datetime_field + if __type_alt__ = "datetime_field" then //Alternative datetime_field + // [type = HK_Datetime_Field_Attr] datetime_field.hk_dt_f_attr + if find_message(_hk_model_field_message, "hk_dt_f_attr") is {failure then failure, success(hk_dt_f_attr_msg) then + if (Maybe(HK_Datetime_Field_Attr))from_Message(hk_dt_f_attr_msg) is {failure then failure, success(hk_dt_f_attr) then + + success(datetime_field(hk_dt_f_attr)) + }} + else //Alternative foreign_key + //foreign key to 'id' in another (or same) table and column_name for choice selector) + if __type_alt__ = "foreign_key" then //Alternative foreign_key + // [type = HK_App_Name] foreign_key.app_name + if find_message(_hk_model_field_message, "app_name") is {failure then failure, success(app_name_msg) then + if (Maybe(HK_App_Name))from_Message(app_name_msg) is {failure then failure, success(app_name) then + // [type = String] foreign_key.table_name + if find_string(_hk_model_field_message, "table_name") is {failure then failure, success(table_name) then + + success(foreign_key(app_name, table_name)) + }}} + else //Alternative integer_field + if __type_alt__ = "integer_field" then //Alternative integer_field + // [type = HK_Int_Choices] integer_field.choices + if find_message(_hk_model_field_message, "choices") is {failure then failure, success(choices_msg) then + if (Maybe(HK_Int_Choices))from_Message(choices_msg) is {failure then failure, success(choices) then + + success(integer_field(choices)) + }} + else //Alternative float_field (NO TYPE) + if __type_alt__ = "float_field" then + success(float_field) + else //Alternative char_field + if __type_alt__ = "char_field" then //Alternative char_field + // [type = HK_Text_Choices] char_field.choices + if find_message(_hk_model_field_message, "choices") is {failure then failure, success(choices_msg) then + if (Maybe(HK_Text_Choices))from_Message(choices_msg) is {failure then failure, success(choices) then + // [type = Int] char_field.size + if find_string(_hk_model_field_message, "size") is {failure then failure, success(_size) then + if decimal_scan(_size) is { failure then failure, success(size) then + + success(char_field(choices, size)) + }}}} + else //Alternative password_field + if __type_alt__ = "password_field" then //Alternative password_field + // [type = Int] password_field.min_size + if find_string(_hk_model_field_message, "min_size") is {failure then failure, success(_min_size) then + if decimal_scan(_min_size) is { failure then failure, success(min_size) then + + success(password_field(min_size)) + }} + else //Alternative text_field + //text of variable size + if __type_alt__ = "text_field" then //Alternative text_field + // [type = HK_Text_Field_Attr] text_field.hk_text_field_attr + if find_message(_hk_model_field_message, "hk_text_field_attr") is {failure then failure, success(hk_text_field_attr_msg) then + if (Maybe(HK_Text_Field_Attr))from_Message(hk_text_field_attr_msg) is {failure then failure, success(hk_text_field_attr) then + + success(text_field(hk_text_field_attr)) + }} + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_table.anubis b/model/types/hk_table.anubis new file mode 100644 index 0000000..25b2ce2 --- /dev/null +++ b/model/types/hk_table.anubis @@ -0,0 +1,83 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:19 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + +transmit hayamiki_lib/model/types/hk_display.anubis +transmit hayamiki_lib/model/types/hk_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 + ) +. + + HK_Table message format + ======================= + + +public define Message + to_Message + ( + HK_Table _hk_table + )= + with _hk_table_message = message((Word32)0), // + forget(add_string(_hk_table_message, "__TYPE__", "HK_Table")); + if _hk_table is + { + //Alternative hk_table + hk_table(_name, _short_name, _model, _display) then + forget(add_string(_hk_table_message, "__TYPE_ALT__", "hk_table")); + // [type = String] hk_table.name + forget(add_string(_hk_table_message, "name", _name)); + // [type = String] hk_table.short_name + forget(add_string(_hk_table_message, "short_name", _short_name)); + // [type = HK_Model] hk_table.model + forget(add_message(_hk_table_message, "model", to_Message(_model))); + // [type = HK_Display] hk_table.display + forget(add_message(_hk_table_message, "display", to_Message(_display))), + + }; + _hk_table_message +. + +public define Maybe(HK_Table) + from_Message + ( + Message _hk_table_message + )= + if find_string(_hk_table_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_table_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Table" then + //Alternative hk_table + if __type_alt__ = "hk_table" then //Alternative hk_table + // [type = String] hk_table.name + if find_string(_hk_table_message, "name") is {failure then failure, success(name) then + // [type = String] hk_table.short_name + if find_string(_hk_table_message, "short_name") is {failure then failure, success(short_name) then + // [type = HK_Model] hk_table.model + if find_message(_hk_table_message, "model") is {failure then failure, success(model_msg) then + if (Maybe(HK_Model))from_Message(model_msg) is {failure then failure, success(model) then + // [type = HK_Display] hk_table.display + if find_message(_hk_table_message, "display") is {failure then failure, success(display_msg) then + if (Maybe(HK_Display))from_Message(display_msg) is {failure then failure, success(display) then + + success(hk_table(name, short_name, model, display)) + }}}}}} + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_text_choice.anubis b/model/types/hk_text_choice.anubis new file mode 100644 index 0000000..10abdee --- /dev/null +++ b/model/types/hk_text_choice.anubis @@ -0,0 +1,69 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:20 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + + +public type HK_Text_Choice: + hk_text_choice( + String value, + String visible + ) +. + + HK_Text_Choice message format + ============================= + + +public define Message + to_Message + ( + HK_Text_Choice _hk_text_choice + )= + with _hk_text_choice_message = message((Word32)0), // + forget(add_string(_hk_text_choice_message, "__TYPE__", "HK_Text_Choice")); + if _hk_text_choice is + { + //Alternative hk_text_choice + hk_text_choice(_value, _visible) then + forget(add_string(_hk_text_choice_message, "__TYPE_ALT__", "hk_text_choice")); + // [type = String] hk_text_choice.value + forget(add_string(_hk_text_choice_message, "value", _value)); + // [type = String] hk_text_choice.visible + forget(add_string(_hk_text_choice_message, "visible", _visible)), + + }; + _hk_text_choice_message +. + +public define Maybe(HK_Text_Choice) + from_Message + ( + Message _hk_text_choice_message + )= + if find_string(_hk_text_choice_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_text_choice_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Text_Choice" then + //Alternative hk_text_choice + if __type_alt__ = "hk_text_choice" then //Alternative hk_text_choice + // [type = String] hk_text_choice.value + if find_string(_hk_text_choice_message, "value") is {failure then failure, success(value) then + // [type = String] hk_text_choice.visible + if find_string(_hk_text_choice_message, "visible") is {failure then failure, success(visible) then + + success(hk_text_choice(value, visible)) + }} + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_text_choices.anubis b/model/types/hk_text_choices.anubis new file mode 100644 index 0000000..85e9c48 --- /dev/null +++ b/model/types/hk_text_choices.anubis @@ -0,0 +1,74 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:20 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + +transmit hayamiki_lib/model/types/hk_text_choice.anubis + +public type HK_Text_Choices: + no_choice, + text_choices( + List(HK_Text_Choice) hk_text_choice + ) +. + + HK_Text_Choices message format + ============================== + + +public define Message + to_Message + ( + HK_Text_Choices _hk_text_choices + )= + with _hk_text_choices_message = message((Word32)0), // + forget(add_string(_hk_text_choices_message, "__TYPE__", "HK_Text_Choices")); + if _hk_text_choices is + { + //Alternative no_choice (NO TYPE) + no_choice then + forget(add_string(_hk_text_choices_message, "__TYPE_ALT__", "no_choice")), + + //Alternative text_choices + text_choices(__hk_text_choice) then + forget(add_string(_hk_text_choices_message, "__TYPE_ALT__", "text_choices")); + // [type = List(HK_Text_Choice)] text_choices.hk_text_choice + map_forget((HK_Text_Choice _hk_text_choice) |-> add_message(_hk_text_choices_message, "hk_text_choice", to_Message(_hk_text_choice)), __hk_text_choice), + + }; + _hk_text_choices_message +. + +public define Maybe(HK_Text_Choices) + from_Message + ( + Message _hk_text_choices_message + )= + if find_string(_hk_text_choices_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_text_choices_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Text_Choices" then + //Alternative no_choice (NO TYPE) + if __type_alt__ = "no_choice" then + success(no_choice) + else //Alternative text_choices + if __type_alt__ = "text_choices" then //Alternative text_choices + // [type = List(HK_Text_Choice)] text_choices.hk_text_choice + with mb_hk_text_choice = map_escape(( Message msg ) |-> (Maybe(HK_Text_Choice)) from_Message(msg), find_messages(_hk_text_choices_message, "hk_text_choice")), + if mb_hk_text_choice is {failure then failure, success(hk_text_choice) then + + success(text_choices(hk_text_choice)) + } + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/model/types/hk_text_field_attr.anubis b/model/types/hk_text_field_attr.anubis new file mode 100644 index 0000000..6e15b3b --- /dev/null +++ b/model/types/hk_text_field_attr.anubis @@ -0,0 +1,64 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-15 + * Time: 02:24:20 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + + +public type HK_Text_Field_Attr: + none, //Nothing special, normal behaviour + rich_editor //Use richt text editor for that area +. + + HK_Text_Field_Attr message format + ================================= + + +public define Message + to_Message + ( + HK_Text_Field_Attr _hk_text_field_attr + )= + with _hk_text_field_attr_message = message((Word32)0), // + forget(add_string(_hk_text_field_attr_message, "__TYPE__", "HK_Text_Field_Attr")); + if _hk_text_field_attr is + { + //Alternative none (NO TYPE) + none then + forget(add_string(_hk_text_field_attr_message, "__TYPE_ALT__", "none")), + + //Alternative rich_editor (NO TYPE) + rich_editor then + forget(add_string(_hk_text_field_attr_message, "__TYPE_ALT__", "rich_editor")), + + }; + _hk_text_field_attr_message +. + +public define Maybe(HK_Text_Field_Attr) + from_Message + ( + Message _hk_text_field_attr_message + )= + if find_string(_hk_text_field_attr_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_text_field_attr_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Text_Field_Attr" then + //Alternative none (NO TYPE) + if __type_alt__ = "none" then + success(none) + else //Alternative rich_editor (NO TYPE) + if __type_alt__ = "rich_editor" then + success(rich_editor) + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/types/hayamiki.anubis b/types/hayamiki.anubis index 3d90bee..2b0cdd6 100644 --- a/types/hayamiki.anubis +++ b/types/hayamiki.anubis @@ -7,6 +7,6 @@ */ -transmit model/fields.anubis -transmit model/database.anubis -transmit model/columns.anubis +transmit hayamiki_lib/model/fields.anubis +transmit hayamiki_lib/model/database.anubis +transmit hayamiki_lib/model/columns.anubis diff --git a/types/model/app.anubis b/types/model/app.anubis deleted file mode 100644 index 832075b..0000000 --- a/types/model/app.anubis +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Created by PyramIDE. - * User: フランスのトトロ aka (David RENÉ) - * Date: 13/02/2016 - * Time: 10:06 - * © Calexium - */ - -transmit help.anubis -transmit tables.anubis -transmit icons.anubis - -read tools/basis.anubis -transmit system/muscle.anubis -transmit calexium_lib/web/CXM_json.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). - - type HK_App: - hk_app( - String app_name, - HK_Icon icon, - HK_Help_Text help, - List(HK_Table) hk_tables - ). - - _HK_APP: - ======== - +----------+---------------+-------------------------- - | name | type | description - +----------+---------------+-------------------------------- - | "name" | String | Name of the application - | "icon" | Message | Icon description, contained in message id _HK_ICON - | "help" | Message | Help string, contained in message id _HK_HELP_TEXT - | "tables" | List(Message) | List of tables of that application contained in message id _HK_TABLE - -public define Message - to_Message - ( - HK_App app - )= - with hk_app_message = message(_HK_APP), - forget(add_string(hk_app_message, "name", app.app_name)); - forget(add_message(hk_app_message, "icon", to_Message(app.icon))); - forget(add_message(hk_app_message, "help", to_Message(app.help))); - map_forget((HK_Table table) |-> add_message(hk_app_message, "tables", to_Message(table)), app.hk_tables); - //print_to_stream(hk_app_message); - hk_app_message - . - -public define JsonValue - to_JSON - ( - HK_App app - )= - json_object("_HK_APP", - [ - json_member("name", json_string(app.app_name)), - json_member("icon", to_JSON(app.icon)), - json_member("help", to_JSON(app.help)), - json_member("tables", json_array(map((HK_Table table) |-> to_JSON(table), app.hk_tables))) - ]). - - -public define Maybe(HK_App) - from_Message - ( - Message hk_app_message - )= - if *hk_app_message.what = _HK_APP then - if find_string(hk_app_message, "name") is {failure then failure, success(name) then - if find_message(hk_app_message, "icon") is {failure then failure, success(icon_msg) then - if (Maybe(HK_Icon))from_Message(icon_msg) is {failure then failure, success(icon) then - if find_message(hk_app_message, "help") is {failure then failure, success(help_msg) then - if (Maybe(HK_Help_Text))from_Message(help_msg) is {failure then failure, success(help) then - - with tables = map_escape((Message msg_app) |-> (Maybe(HK_Table))from_Message(msg_app), find_messages(hk_app_message, "tables")), - if tables is {failure then failure, success(table_list) then - //return the application - success(hk_app(name, icon, help, table_list)) - }}}}}} - else - failure - . diff --git a/types/model/columns.anubis b/types/model/columns.anubis deleted file mode 100644 index 0580101..0000000 --- a/types/model/columns.anubis +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Created by PyramIDE. - * User: フランスのトトロ aka (David RENÉ) - * Date: 13/02/2016 - * Time: 10:07 - * © Calexium - */ - -read tools/basis.anubis - -transmit help.anubis -transmit fields.anubis -transmit calexium_lib/web/CXM_json.anubis - -public type HK_Model_Attr: - unique, // by default, the values in a column are not required to be all different - default(String), // default value (used in case of creation of a NON NULL column - // in a table which already contains some rows) - not_null. - -public define Message - to_Message - ( - HK_Model_Attr hk_model_attr - )= - with hk_model_attr_message = message(_HK_COLUMN_ATTRIBUTES), - if hk_model_attr is - { - unique then forget(add_string(hk_model_attr_message, "hk_column_attr", "unique")), -// indexed then forget(add_string(hk_model_attr_message, "hk_column_attr", "indexed")), - default(value) then forget(add_string(hk_model_attr_message, "hk_column_attr", "default")); - forget(add_string(hk_model_attr_message, "value", value)), - not_null then forget(add_string(hk_model_attr_message, "hk_column_attr", "not_null")) - }; - hk_model_attr_message - . - -public define JsonValue - to_JSON - ( - HK_Model_Attr hk_model_attr - )= - with members = - if hk_model_attr is - { - unique then [ json_member("hk_column_attr", json_string("unique")) ], - -// indexed then [ json_member("hk_column_attr", json_string("indexed")) ], - - default(value) then [ json_member("hk_column_attr", json_string("default")), - json_member("value", json_string(value)) - ], - - not_null then [ json_member("hk_column_attr", json_string("not_null")) ] - }, - - json_object("_HK_COLUMN_ATTRIBUTES", members). - -public define Maybe(HK_Model_Attr) - from_Message - ( - Message hk_model_attr_message - )= - if *hk_model_attr_message.what = _HK_COLUMN_ATTRIBUTES then - if find_string(hk_model_attr_message, "hk_column_attr") is {failure then failure, success(col_attr) then - if col_attr = "unique" then success(unique) -// else if col_attr = "indexed" then success(indexed) - else if col_attr = "default" then - if find_string(hk_model_attr_message, "value") is {failure then failure, success(value) then - success(default(value)) - } - else if col_attr = "not_null" then success(not_null) - else failure - } - else - failure - . - - '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). - - - _HK_COLUMN message format: - ========================== - - +--------------+---------------+-------------------------- - | name | type | description - +--------------+---------------+-------------------------------- - | "name" | String | Name of the column in table - | "field_type" | Message | computation String to be shown to summarize row content. This string is Anubis source code - | "attributes" | List(Message) | List of attributes of the table Message id is _HK_COLUMN_ATTRIBUTES - | "text" | Message | help text to use during edit screen - -public define Message - to_Message - ( - HK_Model_Column hk_column - )= - with hk_model_column = message(_HK_COLUMN), - forget(add_string(hk_model_column, "name", hk_column.name)); - forget(add_message(hk_model_column, "field_type", to_Message(hk_column.type))); - map_forget((HK_Model_Attr attribute) |-> add_message(hk_model_column, "attributes", to_Message(attribute)), hk_column.attributes); - forget(add_message(hk_model_column, "text", to_Message(hk_column.help))); - - //print_to_stream(hk_model_column); - hk_model_column - . - -public define JsonValue - to_JSON - ( - HK_Model_Column hk_column - )= - json_object("_HK_COLUMN", - [ - json_member("name", json_string(hk_column.name)), - json_member("field_type", to_JSON(hk_column.type)), - json_member("attributes", json_array(map((HK_Model_Attr attribute) |-> to_JSON(attribute), hk_column.attributes))), - json_member("text", to_JSON(hk_column.help)) - ]). - - -public define Maybe(HK_Model_Column) - from_Message - ( - Message msg_hk_column - )= - if *msg_hk_column.what = _HK_COLUMN then - if find_string(msg_hk_column, "name") is {failure then failure, success(name) then - if find_message(msg_hk_column, "field_type") is {failure then failure, success(field_type_msg) then - if (Maybe(HK_Model_Field))from_Message(field_type_msg) is {failure then failure, success(field_type) then - if find_message(msg_hk_column, "text") is {failure then failure, success(help_msg) then - if (Maybe(HK_Help_Text))from_Message(help_msg) is {failure then failure, success(help) then - - with mb_attribs = map_escape((Message msg_col) |-> (Maybe(HK_Model_Attr))from_Message(msg_col), find_messages(msg_hk_column, "attributes")), - if mb_attribs is {failure then failure, success(attributes_list) then - //return the application - success(hk_column(name, field_type, attributes_list, help)) - }}}}}} - else - failure - . diff --git a/types/model/database.anubis b/types/model/database.anubis deleted file mode 100644 index 4c40d4d..0000000 --- a/types/model/database.anubis +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Created by PyramIDE. - * User: フランスのトトロ aka (David RENÉ) - * Date: 13/02/2016 - * Time: 10:38 - * © Calexium - */ - -transmit app.anubis - -transmit tools/basis.anubis -transmit system/muscle.anubis -transmit calexium_lib/CXM_message_constants.anubis -transmit calexium_lib/web/CXM_json.anubis - - -public type HK_Database: - hk_database (String name, // name of the database - List(HK_App) apps //list of applications - ). - - - _HK_DATABASE message format: - ============================ - - +-----------+---------------+-------------------------- - | name | type | description - +-----------+---------------+-------------------------------- - | "name" | String | Name of the database - | "apps" | List(Message) | List of Application of the database the application Message id is _HK_APP - -public define Message - to_Message - ( - HK_Database hk_db - )= - with hk_db_message = message(_HK_DATABASE), - forget(add_string(hk_db_message, "name", hk_db.name)); - map_forget((HK_App app) |-> add_message(hk_db_message, "apps", to_Message(app)), hk_db.apps); - - //print_to_stream(hk_db_message); - hk_db_message - . - - _HK_DATABASE JSON format: - ========================= - - { - "obj_type": "_HK_DATABASE", //_HK_DATABASE object type describe a database - "name": "XXXX", //name of database - "apps": //list of applications - [ - { "obj_type": "_HK_APP", //_HK_APP object type describe an application - "name" : "app_name" //name of the current application - }, - ... //anothers applications - ] - } - -public define JsonValue - to_JSON - ( - HK_Database hk_db - )= - json_object( - [ json_member("obj_type", json_string("_HK_DATABASE")), - json_member("name", json_string(hk_db.name)), - json_member("apps", json_array(map((HK_App app) |-> to_JSON(app), hk_db.apps))) - ]). - -public define Maybe(HK_Database) - from_Message - ( - Message hk_db_message - )= - if *hk_db_message.what = _HK_DATABASE then - if find_string(hk_db_message, "name") is - { - failure then failure, - success(name) then - with app_list = map_escape((Message msg_app) |-> (Maybe(HK_App))from_Message(msg_app), find_messages(hk_db_message, "apps")), - if app_list is - { - failure then failure, - success(apps) then success(hk_database(name, apps)) - } - } - else - failure - . - diff --git a/types/model/display.anubis b/types/model/display.anubis deleted file mode 100644 index a640aa3..0000000 --- a/types/model/display.anubis +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Created by PyramIDE. - * User: フランスのトトロ aka (David RENÉ) - * Date: 13/02/2016 - * Time: 10:36 - * © Calexium - */ - -transmit system/muscle.anubis -transmit tools/basis.anubis -transmit calexium_lib/CXM_message_constants.anubis -transmit calexium_lib/web/CXM_json.anubis - -public type HK_List_View: - list_view_all, - list_view(String view_name, List(String) columns, String link_id_action). - -public define HK_List_View - list_view - ( - String view_name, - List(String) columns - )= - list_view(view_name, columns, ""). - -public define Message - to_Message - ( - HK_List_View list_view - )= - with _msg = message(_HK_LIST_VIEW), - if list_view is - { - list_view_all then forget(add_string(_msg, "type", "list_view_all")), - list_view(name, columns, link_id_action) then - forget(add_string(_msg, "type", "list_view")); - forget(add_string(_msg, "view_name", name)); - forget(add_string(_msg, "link_id_action", link_id_action)); - map_forget((String column) |-> forget(add_string(_msg, "columns", column)), columns) - }; - _msg - . - - -public define JsonValue - to_JSON - ( - HK_List_View list_view - )= - with members = - if list_view is - { - list_view_all then - [ json_member("type", json_string("list_view_all")) ], - - list_view(name, columns, link_id_action) then - [ json_member("type", json_string("list_view")), - json_member("view_name", json_string(name)), - json_member("link_id_action", json_string(link_id_action)), - json_member("columns", json_array(map((String column) |-> json_string(column), columns))) - ] - }, - - json_object("_HK_LIST_VIEW", members). - -public define Maybe(HK_List_View) - from_Message - ( - Message msg - )= - if *msg.what = _HK_LIST_VIEW then - if find_string(msg, "type") is {failure then failure, success(type) then - if type = "list_view_all" then success(list_view_all) else - if type = "list_view" then - if find_string(msg, "view_name") is {failure then failure, success(view_name) then - with columns = find_strings(msg, "columns"), - success(list_view(view_name, columns))} - else - failure - } - else - failure - . - -public type HK_Edit_View: - edit_view_all, - edit_view(String view_name, List(String) columns). - -public define Message - to_Message - ( - HK_Edit_View edit_view - )= - with _msg = message(_HK_EDIT_VIEW), - if edit_view is - { - edit_view_all then forget(add_string(_msg, "type", "edit_view_all")), - edit_view(name, columns) then - forget(add_string(_msg, "type", "edit_view")); - forget(add_string(_msg, "view_name", name)); - map_forget((String column) |-> forget(add_string(_msg, "columns", column)), columns) - }; - _msg - . - -public define JsonValue - to_JSON - ( - HK_Edit_View edit_view - )= - with members = - if edit_view is - { - edit_view_all then - [ json_member("type", json_string("edit_view_all")) ], - - edit_view(name, columns) then - [ json_member("type", json_string("edit_view")), - json_member("view_name", json_string(name)), - json_member("columns", json_array(map((String column) |-> json_string(column), columns))) - ] - }, - - json_object("_HK_EDIT_VIEW", members). - -public define Maybe(HK_Edit_View) - from_Message - ( - Message msg - )= - if *msg.what = _HK_EDIT_VIEW then - if find_string(msg, "type") is {failure then failure, success(type) then - if type = "edit_view_all" then success(edit_view_all) else - if type = "edit_view" then - if find_string(msg, "view_name") is {failure then failure, success(view_name) then - with columns = find_strings(msg, "columns"), - success(edit_view(view_name, columns))} - else - failure - } - else - failure - . - - _HK_MODEL_DISPLAY message format: - ========================= - The message string name is "hk_display" - +--------------+---------------+-------------------------------- - | name | type | description - +--------------+---------------+-------------------------------- - | "list_edits" | List(Message) | List of (edit list) the Message id is _HK_EDIT_VIEW - | "list_views" | List(Message) | List of (view list) the Message id is _HK_LIST_VIEW - - -public type HK_Display: - hk_display(List(HK_List_View) list_views, - List(HK_Edit_View) list_edits - //List(String) - ). - -public define Message - to_Message - ( - HK_Display display - )= - with hk_display_msg = message(_HK_MODEL_DISPLAY), - since display is hk_display(list_views, list_edits), - map_forget((HK_List_View _view) |-> add_message(hk_display_msg, "list_views", to_Message(_view)), list_views); - map_forget((HK_Edit_View _edit) |-> add_message(hk_display_msg, "list_edits", to_Message(_edit)), list_edits); -// map_forget((String _str) |-> add_string(hk_display_msg, "edits", _str), list_edit); - hk_display_msg - . - -public define JsonValue - to_JSON - ( - HK_Display display - )= - since display is hk_display(list_views, list_edits), - json_object("_HK_MODEL_DISPLAY", - [ json_member("list_views", json_array(map((HK_List_View _view) |-> to_JSON(_view), list_views))), - json_member("list_edits", json_array(map((HK_Edit_View _edit) |-> to_JSON(_edit), list_edits))) - ] - ). - -public define Maybe(HK_Display) - get_hk_display - ( - Message msg - )= - if find_message(msg, "hk_display") is { failure then failure, success(msg_hk_display) then - if *msg_hk_display.what = _HK_MODEL_DISPLAY then - with view_list = map_escape((Message _msg) |-> (Maybe(HK_List_View))from_Message(_msg), find_messages(msg_hk_display, "list_views")), - with edit_list = map_escape((Message _msg) |-> (Maybe(HK_Edit_View))from_Message(_msg), find_messages(msg_hk_display, "list_edits")), - if view_list is - { - failure then failure, - success(list_views) then - if edit_list is - { - failure then failure, - success(list_edits) then - success(hk_display(list_views, list_edits)) - } - } - else - failure - }. - diff --git a/types/model/fields.anubis b/types/model/fields.anubis deleted file mode 100644 index 5a39d1d..0000000 --- a/types/model/fields.anubis +++ /dev/null @@ -1,414 +0,0 @@ -/* - * Created by PyramIDE. - * User: フランスのトトロ aka (David RENÉ) - * Date: 13/02/2016 - * Time: 09:42 - * © Calexium - */ - -transmit tools/basis.anubis -transmit system/convert.anubis -transmit system/muscle.anubis -transmit calexium_lib/CXM_message_constants.anubis -transmit calexium_lib/web/CXM_json.anubis - - *** '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) - float_field | Float | - char_field | String | max size text - text_field | String | arbitrary size text - - -public type HK_App_Name: - this, - app_name(String name), - none. - -public define Message - to_Message - ( - HK_App_Name hk_app_name - )= - with hk_app_name_message = message(_HK_APP_NAME), - if hk_app_name is - { - this then forget(add_string(hk_app_name_message, "type", "this")), - app_name(name)then forget(add_string(hk_app_name_message, "type", "app_name")); - forget(add_string(hk_app_name_message, "name", name)), - none then forget(add_string(hk_app_name_message, "type", "none")) - }; - hk_app_name_message - . - -public define JsonValue - to_JSON - ( - HK_App_Name hk_app_name - )= - with members = - if hk_app_name is - { - this then [ json_member("type", json_string("this")) ], - - app_name(name) then [ json_member("type", json_string("app_name")), - json_member("name", json_string(name)) - ], - - none then [ json_member("type", json_string("none")) ], - }, - - json_object("_HK_APP_NAME", members). - -public define Maybe(HK_App_Name) - from_Message - ( - Message hk_app_name_message - )= - if *hk_app_name_message.what = _HK_APP_NAME then - if find_string(hk_app_name_message, "type") is {failure then failure, success(type) then - if type = "this" then success(this) - else if type = "app_name" then - if find_string(hk_app_name_message, "name") is {failure then failure, success(name) then - success(app_name(name)) - } - else if type = "none" then success(none) - else failure - } - else - failure - . - -public type HK_Text_Choice: - hk_text_choice(String value, String visible). - -public type HK_Text_Choices: - no_choice, - text_choices(List(HK_Text_Choice)). - -public type HK_Int_Choice: - hk_int_choice( - Int value, //value to set in database corresponding to description below - String visible //visible string which help the user to choose teh correct choice - ). - -public type HK_Int_Choices: - no_choice, //No list choice is available. Hence the user must enter the value - int_choices(List(HK_Int_Choice)). //List of possible choices - -public type HK_Text_Field_Attr: - none, //Nothing special, normal behaviour - rich_editor. //Use richt text editor for that area - -define String - to_String - ( - HK_Text_Field_Attr attr - )= - if attr is - { - none then "none", - rich_editor then "rich_editor" - }. - -public define String - to_Anubis_source - ( - HK_Text_Field_Attr attr - )= - to_String(attr) -. - -define HK_Text_Field_Attr - to_HK_Text_Field_Attr - ( - String txt_attr_str - )= - if txt_attr_str = "none" then none else - if txt_attr_str = "rich_editor" then rich_editor - else none -. - -define HK_Text_Field_Attr - get_text_attribute - ( - Message msg - )= - if find_string(msg, "text_attribute") is - { - failure then none, - success(text_attrib) then to_HK_Text_Field_Attr(text_attrib) - }. - -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 - -define String - to_String - ( - HK_Datetime_Field_Attr attr - )= - if attr is - { - none then "none", - auto_now then "auto_now", - auto_now_add then "auto_now_add" - }. - -define HK_Datetime_Field_Attr - to_HK_Datetime_Field_Attr - ( - String dt_attr_str - )= - if dt_attr_str = "none" then none else - if dt_attr_str = "auto_now" then auto_now else - if dt_attr_str = "auto_now_add" then auto_now_add - else none. - -define HK_Datetime_Field_Attr - get_dt_attribute - ( - Message msg - )= - if find_string(msg, "dt_attribute") is - { - failure then none, - success(dt_attrib) then to_HK_Datetime_Field_Attr(dt_attrib) - }. - -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 (HK_Int_Choices choices), // integer of arbitrary size - float_field , - char_field (HK_Text_Choices choices, Int size), // text of maximal size 'size' (number of characters) - password_field(Int min_size), // the password field doesn't show the password string or store it in hashed version into database - text_field (HK_Text_Field_Attr). // text of variable size - -//default initialization -public define HK_Model_Field - char_field - ( - Int size - )= - char_field(no_choice, size). - -public define HK_Model_Field - integer_field - = - integer_field(no_choice). - -public define HK_Model_Field - foreign_key - ( - String table_name - )= - foreign_key(this, table_name). - -public define HK_Model_Field - text_field - = - text_field(none) -. - - /* * - _HK_FIELD message format: - ============================= - +----------------+-----------+-------------------------------- - | name | type | description - +----------------+-----------+-------------------------------- - | "type" | String | type of the field. It sould be - "p_key" - "boolean_field" - "date_field" __________ - "time_field" ________ | - "datetime_field" __ | | - ________________________________________________|_|_| - | "foreign_key" _________ - | "integer_field" - | "char_field" - | "text_field" - | - --> date_field or time_field or datetime_field: - +-------------+--------+------------------------------------+ - | name | type | description | - |-------------+--------+------------------------------------| - | "attribute" | String | 'none', 'auto_now', 'auto_now_add' | - +-----------------------------------------------------------+ - -*/ - -public define Message - to_Message - ( - HK_Model_Field hk_model_field - )= - with hk_model_field_message = message(_HK_FIELD), - if hk_model_field is - { - p_key then - forget(add_string(hk_model_field_message, "type", "p_key")), - - boolean_field then - forget(add_string(hk_model_field_message, "type", "boolean_field")), - - date_field(attr) then - forget(add_string(hk_model_field_message, "type", "date_field")); - forget(add_string(hk_model_field_message, "dt_attribute", to_String(attr))), - - time_field(attr) then - forget(add_string(hk_model_field_message, "type", "time_field")); - forget(add_string(hk_model_field_message, "dt_attribute", to_String(attr))), - - datetime_field(attr) then - forget(add_string(hk_model_field_message, "type", "datetime_field")); - forget(add_string(hk_model_field_message, "dt_attribute", to_String(attr))), - - foreign_key(app_name, table_name) then // foreign key to 'id' in another (or same) table and column_name for choice selector. - forget(add_string(hk_model_field_message, "type", "foreign_key")); - forget(add_message(hk_model_field_message, "app_name", to_Message(app_name))); - forget(add_string(hk_model_field_message, "table_name", table_name)), - - integer_field(choices) then // integer of arbitrary size - //TODO add choices if need - forget(add_string(hk_model_field_message, "type", "integer_field")), - - float_field then - forget(add_string(hk_model_field_message, "type", "float_field")), - - char_field (choices, size) then // text of maximal size 'size' (number of characters) - //TODO add choices if need - forget(add_string(hk_model_field_message, "type", "char_field")); - forget(add_int32(hk_model_field_message, "size", truncate_to_Word32(size))), - - password_field(size) then - forget(add_string(hk_model_field_message, "type", "password_field")); - forget(add_int32(hk_model_field_message, "size", truncate_to_Word32(size))), - - text_field(text_attr) then // text of variable size - forget(add_string(hk_model_field_message, "type", "text_field")); - forget(add_string(hk_model_field_message, "text_attribute", to_String(text_attr))), - - }; - hk_model_field_message - . - -public define JsonValue - to_JSON - ( - HK_Model_Field hk_model_field - )= - with members = - if hk_model_field is - { - p_key then - [ json_member("type", json_string("p_key")) ], - - boolean_field then - [ json_member("type", json_string("boolean_field")) ], - - date_field(attr) then - [ json_member("type", json_string("date_field")), - json_member("dt_attribute", json_string(to_String(attr))) - ], - - time_field(attr) then - [ json_member("type", json_string("time_field")), - json_member("dt_attribute", json_string(to_String(attr))) - ], - - datetime_field(attr) then - [ json_member("type", json_string("datetime_field")), - json_member("dt_attribute", json_string(to_String(attr))) - ], - - foreign_key(app_name, table_name) then // foreign key to 'id' in another (or same) table and column_name for choice selector. - [ json_member("type", json_string("foreign_key")), - json_member("app_name", to_JSON(app_name)), - json_member("table_name", json_string(table_name)), - ], - - integer_field(choices) then // integer of arbitrary size - //TODO add choices if need - [ json_member("type", json_string("integer_field")) ], - - float_field then //float - [ json_member("type", json_string("float_field"))], - - char_field (choices, size) then // text of maximal size 'size' (number of characters) - //TODO add choices if need - [ json_member("type", json_string("char_field")), - json_member("size", json_int(size)) - ], - - password_field(size) then - [ json_member("type", json_string("password_field")), - json_member("size", json_int(size)) - ], - - text_field(attr) then // text of variable size - [ json_member("type", json_string("text_field")), - json_member("text_attribute", json_string(to_String(attr))) - ] - }, - - json_object("_HK_FIELD", members). - -define Maybe(HK_Model_Field) - get_field - ( - Message hk_model_field_message, - String type - )= - if type = "p_key" then success(p_key) - else if type = "boolean_field" then success(boolean_field) - else if type = "date_field" then success(date_field(get_dt_attribute(hk_model_field_message))) - else if type = "time_field" then success(time_field(get_dt_attribute(hk_model_field_message))) - else if type = "datetime_field" then success(datetime_field(get_dt_attribute(hk_model_field_message))) - else if type = "foreign_key" then - if find_string(hk_model_field_message, "table_name") is {failure then failure, success(table_name) then - if find_message(hk_model_field_message, "app_name") is {failure then failure, success(msg_app_name) then - if from_Message(msg_app_name) is {failure then failure, success(app_name) then - success(foreign_key(app_name, table_name)) - }}} - else if type = "integer_field" then success(integer_field) - else if type = "float_field" then success(float_field) - else if type = "char_field" then - if find_int32(hk_model_field_message, "size") is {failure then failure, success(w32_size) then - success(char_field(to_Int(w32_size)))} - else if type = "password_field" then - if find_int32(hk_model_field_message, "size") is {failure then failure, success(w32_size) then - success(password_field(to_Int(w32_size)))} - else if type = "text_field" then success(text_field(get_text_attribute(hk_model_field_message))) - else failure - . - -public define Maybe(HK_Model_Field) - from_Message - ( - Message hk_model_field_message - )= - if *hk_model_field_message.what = _HK_FIELD then - if find_string(hk_model_field_message, "type") is {failure then failure, success(type) then - get_field(hk_model_field_message, type) - } - else - failure - . diff --git a/types/model/help.anubis b/types/model/help.anubis deleted file mode 100644 index fc85cb8..0000000 --- a/types/model/help.anubis +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Created by PyramIDE. - * User: フランスのトトロ aka (David RENÉ) - * Date: 13/02/2016 - * Time: 10:12 - * © Calexium - */ - -transmit tools/basis.anubis -transmit system/muscle.anubis -transmit calexium_lib/CXM_message_constants.anubis -transmit calexium_lib/web/CXM_json.anubis - -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+"\")" - }. - - /* * - _HK_HELP_TEXT message format: - ============================= - +----------------+-----------+-------------------------------- - | name | type | description - +----------------+-----------+-------------------------------- - | "hk_help_text" | String | type of the help text. It sould be - "no_help" - "TAG" ____ - "text" __ | - ______________________________________|_| - | - --> TAG or text: - +---------+-----------+-------------------------------- - | name | type | description - +---------+-----------+-------------------------------- - | "value" | String | String name of the 16x16 icon. - -*/ - -public define Message - to_Message - ( - HK_Help_Text hk_help - )= - with hk_help_message = message(_HK_HELP_TEXT), - if hk_help is - { - no_help_text then forget(add_string(hk_help_message, "hk_help_text", "no_help")), - help_text_TAG(tag) then forget(add_string(hk_help_message, "hk_help_text", "TAG")); - forget(add_string(hk_help_message, "value", tag)), - help_text(value) then forget(add_string(hk_help_message, "hk_help_text", "text")); - forget(add_string(hk_help_message, "value", value)) - }; - hk_help_message - . - -public define JsonValue - to_JSON - ( - HK_Help_Text hk_help - )= - with members = - if hk_help is - { - no_help_text then [ json_member("hk_help_text", json_string("no_help")) - ], - help_text_TAG(tag) then [ json_member("hk_help_text", json_string("TAG")), - json_member("value", json_string(tag)) - ] - help_text(value) then [ json_member("hk_help_text", json_string("text")), - json_member("value", json_string(value)) - ] - }, - json_object("_HK_HELP_TEXT", members). - -public define Maybe(HK_Help_Text) - from_Message - ( - Message hk_help_message - )= - if *hk_help_message.what = _HK_HELP_TEXT then - if find_string(hk_help_message, "hk_help_text") is {failure then failure, success(help_type) then - if help_type = "no_help" then success(no_help_text) - else if help_type = "TAG" then - if find_string(hk_help_message, "value") is {failure then failure, success(value) then - success(help_text_TAG(value)) - } - else if help_type = "text" then - if find_string(hk_help_message, "value") is {failure then failure, success(value) then - success(help_text(value)) - } - else failure - } - else - failure - . - diff --git a/types/model/icons.anubis b/types/model/icons.anubis deleted file mode 100644 index 14591bc..0000000 --- a/types/model/icons.anubis +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Created by PyramIDE. - * User: フランスのトトロ aka (David RENÉ) - * Date: 13/02/2016 - * Time: 10:31 - * © Calexium - */ - -transmit tools/basis.anubis -transmit system/muscle.anubis -transmit calexium_lib/CXM_message_constants.anubis -transmit calexium_lib/web/CXM_json.anubis - -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\"" - }. - - /* * - _HK_ICON message format: - ======================= - +-----------+-----------+-------------------------------- - | name | type | description - +-----------+-----------+-------------------------------- - | "hk_icon" | String | type of the icon. It sould be - "no_icon" - "icon_16" __ - ______________________________________| - | - --> icon_16: - +-----------+-----------+-------------------------------- - | name | type | description - +-----------+-----------+-------------------------------- - | "icn_str" | String | String name of the 16x16 icon. - - */ - -public define Message - to_Message - ( - HK_Icon hk_icon - )= - with hk_icon_message = message(_HK_ICON), - if hk_icon is - { - no_icon then forget(add_string(hk_icon_message, "hk_icon", "no_icon")); - hk_icon_message, - icon16(icn_str) then forget(add_string(hk_icon_message, "hk_icon", "icon_16")); - forget(add_string(hk_icon_message, "icn_str", icn_str)); - hk_icon_message - }. - -public define JsonValue - to_JSON - ( - HK_Icon hk_icon - )= - with members = - if hk_icon is - { - no_icon then [ json_member("hk_icon", json_string("no_icon")) - ], - - icon16(icn_str) then [ json_member("hk_icon", json_string("icon_16")), - json_member("icn_str", json_string(icn_str)) - ] - }, - - json_object("_HK_ICON", members). - -public define Maybe(HK_Icon) - from_Message - ( - Message hk_icon_message - )= - if *hk_icon_message.what = _HK_ICON then - if find_string(hk_icon_message, "hk_icon") is {failure then failure, success(hk_icon) then - if hk_icon = "no_icon" then success(no_icon) - else if hk_icon = "icon_16" then - if find_string(hk_icon_message, "icn_str") is {failure then failure, success(icn_str) then - success(icon16(icn_str)) - } - else failure - } - else - failure - . - diff --git a/types/model/model.anubis b/types/model/model.anubis deleted file mode 100644 index 1e75d1d..0000000 --- a/types/model/model.anubis +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Created by PyramIDE. - * User: フランスのトトロ aka (David RENÉ) - * Date: 13/02/2016 - * Time: 10:41 - * © Calexium - */ - -transmit tools/basis.anubis -transmit columns.anubis -transmit calexium_lib/web/CXM_json.anubis - -public type HK_Model: - hk_model( List(HK_Model_Column) columns, // columns other than the primary key column (if any) - String show_string). - - _HK_MODEL message format: - ======================== - - +------------+---------------+-------------------------- - | name | type | description - +------------+---------------+-------------------------------- - | "columns" | List(Message) | List of columns of the table Message id is _HK_COLUMN - | "show_str" | String | computation String to be shown to summarize row content. This string is Anubis source code - where the row content is in datum, named "obj". - - -public define Message - to_Message - ( - HK_Model hk_model - )= - with hk_model_message = message(_HK_MODEL), - map_forget((HK_Model_Column column) |-> add_message(hk_model_message, "columns", to_Message(column)), hk_model.columns); - forget(add_string(hk_model_message, "show_str", hk_model.show_string)); - - //print_to_stream(hk_model_message); - hk_model_message - . - -public define JsonValue - to_JSON - ( - HK_Model hk_model - )= - json_object("_HK_MODEL", - [ - json_member("columns", json_array(map((HK_Model_Column column) |-> to_JSON(column), hk_model.columns))), - json_member("show_str", json_string(hk_model.show_string)) - ]). - -public define Maybe(HK_Model) - from_Message - ( - Message hk_model_msg - )= - if *hk_model_msg.what = _HK_MODEL then - if find_string(hk_model_msg, "show_str") is {failure then failure, success(show_str) then - with mb_columns = map_escape((Message column_msg) |-> (Maybe(HK_Model_Column))from_Message(column_msg), find_messages(hk_model_msg, "columns")), - if mb_columns is {failure then failure, success(columns_list) then - //return the model - success(hk_model(columns_list, show_str)) - }} - else - failure - . diff --git a/types/model/tables.anubis b/types/model/tables.anubis deleted file mode 100644 index 69d79db..0000000 --- a/types/model/tables.anubis +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Created by PyramIDE. - * User: フランスのトトロ aka (David RENÉ) - * Date: 13/02/2016 - * Time: 10:20 - * © Calexium - */ - -read tools/basis.anubis -transmit display.anubis -transmit model.anubis -transmit calexium_lib/web/CXM_json.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). - - - _HK_TABLE message format: - ========================= - +--------------+-----------+-------------------------- - | name | type | description - +--------------+-----------+-------------------------------- - | "name" | String | Name of the table - | "short_name" | String | Name of the table without app_name prefix - | "model" | Message | Model description, contained in message id _HK_MODEL - | "hk_display" | Message | Help string, contained in message id _HK_MODEL_DISPLAY - - -public define Message - to_Message - ( - HK_Table table - )= - with hk_table_message = message(_HK_TABLE), - forget(add_string(hk_table_message, "name", table.name)); - forget(add_string(hk_table_message, "short_name", table.name)); - forget(add_message(hk_table_message, "model", to_Message(table.model))); - forget(add_message(hk_table_message, "hk_display", to_Message(table.display))); - //print_to_stream(hk_table_message); - hk_table_message. - -public define JsonValue - to_JSON - ( - HK_Table table - )= - json_object("_HK_TABLE", - [ json_member("name", json_string(table.name)), - json_member("short_name", json_string(table.name)), - json_member("model", to_JSON(table.model)), - json_member("hk_display", to_JSON(table.display)) - ] - ). - -public define Maybe(HK_Table) - from_Message - ( - Message table_message - )= - if *table_message.what = _HK_TABLE then - if find_string(table_message, "name") is {failure then failure, success(name) then - if find_string(table_message, "short_name") is {failure then failure, success(short_name) then - if find_message(table_message, "model") is {failure then failure, success(model_msg) then - if (Maybe(HK_Model))from_Message(model_msg) is {failure then failure, success(model) then - if get_hk_display(table_message) is {failure then failure, success(display) then - //return the table - success(hk_table(name, "", model, display)) - }}}}} - else - failure - . - diff --git a/view/view_table_types.anubis b/view/view_table_types.anubis index 4b9526a..4961cdb 100644 --- a/view/view_table_types.anubis +++ b/view/view_table_types.anubis @@ -45,7 +45,7 @@ public type VT_edit: public type VT_view_entry: text(String text), link(String id, String text), - link_id_action(String id, String text, String link_id_action), + link_id_action(String id, String text, WEB_Action_Name link_id_action), icon(String icon_path). public type VT_view_row_header: -- libgit2 0.21.4