Commit 5982fb919cc198b09154cab6aca30f83eadb5ef7

Authored by totoro
0 parents

move and explode calexium_lib/database/db_model into hayamiki_lib

hk_generator.anubis 0 → 100644
  1 +++ a/hk_generator.anubis
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 13/02/2016
  5 + * Time: 10:23
  6 + * © Calexium
  7 + */
  8 +
  9 +read tools/basis.anubis
  10 +transmit types/hayamiki.anubis
  11 +
  12 +public type HK_Generator_API:
  13 + hk_api(
  14 + ((HK_Database, String) -> Maybe(One)) generate_model_files).
  15 +
  16 +
  17 +public define Maybe(HK_Generator_API)
  18 + load_hk_generator
  19 + =
  20 + with file_name = "hk_gen.adm",
  21 + if (LoadAdm(HK_Generator_API))load_adm(file_name) is
  22 + {
  23 + file_not_found then print("File '"+file_name+"' not found.\n\n");failure,
  24 + read_error then print("Error reading file '"+file_name+"'.\n\n");failure,
  25 + timeout then print("Timeout when loading '"+file_name+"'.\n\n");failure,
  26 + file_damaged then print("File '"+file_name+"' is damaged.\n\n");failure,
  27 + bad_version(expected,found) then print("Secondary module '"+file_name+"' doesn't have the same\n"+
  28 + " version ("+found+") as primary module ("+expected+").\n\n");failure,
  29 + wrong_type(expected,found) then print("Secondary module '"+file_name+"' has type:\n"+
  30 + found+" while primary module expected:\n"+
  31 + expected+"\n\n");failure,
  32 + ok(hk_gen_api) then println("Hayamiki generator loaded ");success(hk_gen_api)
  33 + }.
... ...
types/hayamiki.anubis 0 → 100644
  1 +++ a/types/hayamiki.anubis
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 13/02/2016
  5 + * Time: 09:45
  6 + * © Calexium
  7 + */
  8 +
  9 +
  10 +transmit model/fields.anubis
  11 +transmit model/database.anubis
... ...
types/model/app.anubis 0 → 100644
  1 +++ a/types/model/app.anubis
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 13/02/2016
  5 + * Time: 10:06
  6 + * © Calexium
  7 + */
  8 +
  9 +transmit help.anubis
  10 +transmit tables.anubis
  11 +transmit icons.anubis
  12 +
  13 +
  14 +
  15 +public type HK_App:
  16 + hk_app(
  17 + String app_name,
  18 + HK_Icon icon,
  19 + HK_Help_Text help,
  20 + List(HK_Table) hk_tables
  21 + ).
  22 +
  23 + /* Default constructor for HK_App*/
  24 +public define HK_App
  25 + hk_app
  26 + (
  27 + String app_name,
  28 + HK_Help_Text help,
  29 + List(HK_Table) hk_tables
  30 + )=
  31 + hk_app(app_name, no_icon, help, hk_tables).
  32 +
  33 +public define HK_App
  34 + hk_app
  35 + (
  36 + String app_name,
  37 + HK_Icon icon,
  38 + List(HK_Table) hk_tables
  39 + )=
  40 + hk_app(app_name, icon, no_help_text, hk_tables).
  41 +
  42 +
  43 +public define HK_App
  44 + hk_app
  45 + (
  46 + String app_name,
  47 + List(HK_Table) hk_tables
  48 + )=
  49 + hk_app(app_name, no_icon, no_help_text, hk_tables).
... ...
types/model/columns.anubis 0 → 100644
  1 +++ a/types/model/columns.anubis
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 13/02/2016
  5 + * Time: 10:07
  6 + * © Calexium
  7 + */
  8 +
  9 +transmit help.anubis
  10 +transmit fields.anubis
  11 +
  12 +public type HK_Model_Attr:
  13 + unique, // by default, the values in a column are not required to be all different
  14 + indexed, // by default, a column is not indexed
  15 + default(String), // default value (used in case of creation of a NON NULL column
  16 + // in a table which already contains some rows)
  17 + not_null.
  18 +
  19 + *** (1.4) 'HK_Model_Column' (describing a column in a table).
  20 +
  21 + Description of a column:
  22 +
  23 +public type HK_Model_Column:
  24 + hk_column (String name, // name of ordinary column (i.e. all but 'id')
  25 + HK_Model_Field type,
  26 + List(HK_Model_Attr) attributes,
  27 + HK_Help_Text help
  28 + ).
  29 +
  30 + /****** DEFAULT CONSTRUCTOR HELPER - part *******/
  31 +
  32 +public define HK_Model_Column
  33 +/* Constructor helper for hk_column without help attribute.
  34 + the real type constructor will be called with the attribute no_help_text
  35 +*/
  36 + hk_column
  37 + (
  38 + String name,
  39 + HK_Model_Field type,
  40 + List(HK_Model_Attr) attributes,
  41 + )=
  42 + hk_column(name, type, attributes, no_help_text).
  43 +
  44 +public define HK_Model_Column
  45 + hk_column
  46 + (
  47 + String name,
  48 + HK_Model_Field type
  49 + )=
  50 + hk_column(name, type, [], no_help_text).
  51 +
  52 +
... ...
types/model/database.anubis 0 → 100644
  1 +++ a/types/model/database.anubis
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 13/02/2016
  5 + * Time: 10:38
  6 + * © Calexium
  7 + */
  8 +
  9 +transmit app.anubis
  10 +
  11 +public type HK_Database:
  12 + hk_database (String name, // name of the database
  13 + List(HK_App) apps //list of applications
  14 + ).
... ...
types/model/display.anubis 0 → 100644
  1 +++ a/types/model/display.anubis
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 13/02/2016
  5 + * Time: 10:36
  6 + * © Calexium
  7 + */
  8 +
  9 +
  10 +public type HK_List_View:
  11 + list_view_all,
  12 + list_view(String view_name, List(String) columns).
  13 +
  14 +public type HK_Edit_View:
  15 + edit_view_all,
  16 + edit_view(String view_name, List(String) columns).
  17 +
  18 +public type HK_Display:
  19 + hk_display(List(HK_List_View) list_views,
  20 + //List(HK_Edit_View) edit_views
  21 + List(String)).
... ...
types/model/fields.anubis 0 → 100644
  1 +++ a/types/model/fields.anubis
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 13/02/2016
  5 + * Time: 09:42
  6 + * © Calexium
  7 + */
  8 +
  9 +
  10 +
  11 + *** 'HK_Model_Field' (data types of table columns).
  12 +
  13 + From the point of view of your Anubis program, these data will be of types:
  14 +
  15 + Name | Anubis type | Type within the database
  16 + ----------------+-------------------+--------------------------------------------------
  17 + p_key | DB_id | primary key (integer) automatically add in 1st
  18 + position in every model table
  19 + boolean_field | Bool | boolean
  20 + date_field | DB_date | text (date in ISO-8601 format: yyyy-mm-dd)
  21 + time_field | DB_time | text (date in ISO-8601 format: hh:mm:ss)
  22 + datetime_field | DB_datetime | text (date in ISO-8601 format: yyyy-mm-dd hh:mm:ss)
  23 + foreign_key | Int | integer
  24 + integer_field | Int | arbitrary size integer (numeric)
  25 + char_field | String | max size text
  26 + text_field | String | arbitrary size text
  27 +
  28 +
  29 +public type HK_App_Name:
  30 + this,
  31 + app_name(String name),
  32 + none.
  33 +
  34 +public type HK_Datetime_Field_Attr:
  35 + none, //Nothing special, normal behaviour
  36 + auto_now, //Always update datetime at SQL update
  37 + auto_now_add. //Set current datetime when row is created and can't be edited anymore
  38 +
  39 +
  40 +
  41 +public type HK_Model_Field:
  42 + p_key,
  43 + boolean_field, // true or false
  44 + date_field (HK_Datetime_Field_Attr), // date with the precision of the day
  45 + time_field (HK_Datetime_Field_Attr), // time with the precision of the second
  46 + datetime_field(HK_Datetime_Field_Attr), // datetime with the precision of the second
  47 + 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.
  48 + integer_field, // integer of arbitrary size
  49 + char_field (Int size), // text of maximal size 'size' (number of characters)
  50 + text_field. // text of variable size
  51 +
  52 +public define HK_Model_Field
  53 + foreign_key
  54 + (
  55 + String table_name
  56 + )=
  57 + foreign_key(this, table_name).
... ...
types/model/help.anubis 0 → 100644
  1 +++ a/types/model/help.anubis
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 13/02/2016
  5 + * Time: 10:12
  6 + * © Calexium
  7 + */
  8 +
  9 +
  10 +public type HK_Help_Text:
  11 + no_help_text, //no help text available
  12 + help_text_TAG(String), //TAG use with Anubis translation tool /locale/L3.anubis
  13 + help_text(String). //pure text to show
  14 +
  15 +public define String
  16 +/* Return the Anubis source of the type component
  17 +*/
  18 + to_Anubis_source
  19 + (
  20 + HK_Help_Text help
  21 + )=
  22 + if help is
  23 + {
  24 + no_help_text then "no_help_text",
  25 + help_text_TAG(tag) then "help_text_TAG(\""+tag+"\")",
  26 + help_text(str) then "help_text(\""+str+"\")"
  27 + }.
... ...
types/model/icons.anubis 0 → 100644
  1 +++ a/types/model/icons.anubis
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 13/02/2016
  5 + * Time: 10:31
  6 + * © Calexium
  7 + */
  8 +
  9 +
  10 +public type HK_Icon:
  11 + no_icon,
  12 + icon16(String name).
  13 +
  14 +public define String
  15 +/* Return the Anubis source of the type component
  16 +*/
  17 + to_Anubis_source
  18 + (
  19 + HK_Icon icon
  20 + )=
  21 + if icon is
  22 + {
  23 + no_icon then "no_icon",
  24 + icon16(icn_str) then "icon16(\""+icn_str+"\")"
  25 + }.
  26 +
  27 +public define String
  28 +/* Return the Anubis source of the type component
  29 +*/
  30 + to_String
  31 + (
  32 + HK_Icon icon
  33 + )=
  34 + if icon is
  35 + {
  36 + no_icon then "\"\"",
  37 + icon16(icn_str) then "\""+icn_str+"_icon\""
  38 + }.
... ...
types/model/model.anubis 0 → 100644
  1 +++ a/types/model/model.anubis
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 13/02/2016
  5 + * Time: 10:41
  6 + * © Calexium
  7 + */
  8 +
  9 +transmit columns.anubis
  10 +
  11 +public type HK_Model:
  12 + hk_model( List(HK_Model_Column) columns, // columns other than the primary key column (if any)
  13 + String show_string).
  14 +
  15 +
... ...
types/model/tables.anubis 0 → 100644
  1 +++ a/types/model/tables.anubis
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 13/02/2016
  5 + * Time: 10:20
  6 + * © Calexium
  7 + */
  8 +
  9 +transmit display.anubis
  10 +transmit model.anubis
  11 +
  12 +public type HK_Table:
  13 + hk_table ( String name, //name of the table
  14 + String short_name, //table name without app_name in prefix
  15 + HK_Model model,
  16 + HK_Display display).
  17 +
  18 +public define HK_Table
  19 + hk_table
  20 + (
  21 + String name, //name of the table
  22 + HK_Model model,
  23 + HK_Display display
  24 + )=
  25 + hk_table(name, "", model, display).
... ...