Commit 647c64d2796d0c141d54b63c306ed534256acd46

Authored by totoro
1 parent 3a2758b6

add DB_id in WEB_Session type

Showing 1 changed file with 72 additions and 3 deletions   Show diff stats
web/CXM_web_session.anubis
... ... @@ -8,6 +8,7 @@
8 8  
9 9 read system/convert.anubis
10 10 read system/muscle.anubis
  11 +read calexium_lib/database/db_types.anubis
11 12 read CXM_common.anubis
12 13 read CXM_web_dump.anubis
13 14  
... ... @@ -16,6 +17,7 @@ public type WEB_Session_Field_Datum:
16 17 string(String), //fully implented
17 18 bool(Bool), //fully implented
18 19 int(Int), //fully implented
  20 + db_id(DB_id),
19 21 message(Message), //fully implented
20 22 byte_array(ByteArray),
21 23 float(Float),
... ... @@ -31,6 +33,7 @@ public type WEB_Session_Field_Type:
31 33 string_t,
32 34 bool_t,
33 35 int_t,
  36 + db_id_t,
34 37 message_t,
35 38 byte_array_t,
36 39 float_t,
... ... @@ -214,7 +217,7 @@ define One
214 217 /*************** String *****************/
215 218  
216 219 Maybe(String) get_String(fields, _field_name)
217   - String get_String(fiels, _field_name, default_value)
  220 + String get_String(fields, _field_name, default_value)
218 221  
219 222 public define Maybe(String)
220 223 get_String
... ... @@ -279,7 +282,7 @@ public define One
279 282 /*************** Bool *****************/
280 283  
281 284 Maybe(Bool) get_Bool(fields, _field_name)
282   - Bool get_Bool(fiels, _field_name, default_value)
  285 + Bool get_Bool(fields, _field_name, default_value)
283 286  
284 287 public define Maybe(Bool)
285 288 get_Bool
... ... @@ -344,7 +347,7 @@ public define One
344 347 /*************** Int *****************/
345 348  
346 349 Maybe(String) get_Int(fields, _field_name)
347   - String get_Int(fiels, _field_name, default_value)
  350 + String get_Int(fields, _field_name, default_value)
348 351  
349 352 public define Maybe(Int)
350 353 get_Int
... ... @@ -406,6 +409,71 @@ public define One
406 409 remove_any(fields, int_t, _field_name)
407 410 .
408 411  
  412 + /*************** DB_id *****************/
  413 +
  414 + Maybe(String) get_DB_id(fields, _field_name)
  415 + String get_DB_id(fields, _field_name, default_value)
  416 +
  417 +public define Maybe(DB_id)
  418 + get_DB_id
  419 + (
  420 + Var(List(WEB_Session_Field)) fields,
  421 + String _field_name,
  422 + ) =
  423 + if get_field(*fields, db_id_t, _field_name) is
  424 + {
  425 + failure then failure,
  426 + success(datum) then
  427 + if datum is db_id(value) then
  428 + success(value)
  429 + else
  430 + failure
  431 + }
  432 +.
  433 +
  434 +public define DB_id
  435 + get_DB_id
  436 + (
  437 + Var(List(WEB_Session_Field)) fields,
  438 + String _field_name,
  439 + DB_id default_value
  440 + ) =
  441 + if get_DB_id(fields, _field_name) is
  442 + {
  443 + failure then default_value
  444 + success(value) then value
  445 + }.
  446 +
  447 +public define One
  448 + put_DB_id
  449 + (
  450 + Var(List(WEB_Session_Field)) fields,
  451 + String _field_name,
  452 + DB_id _field_value
  453 + )=
  454 + fields <- [session_field(_field_name, int_t, var(db_id(_field_value))) . *fields]
  455 +.
  456 +
  457 +public define One
  458 + replace_DB_id
  459 + (
  460 + Var(List(WEB_Session_Field)) fields,
  461 + String _field_name,
  462 + DB_id _field_value
  463 + )=
  464 + replace_any(fields, db_id_t, _field_name, db_id(_field_value))
  465 +.
  466 +
  467 +
  468 +public define One
  469 + remove_DB_id
  470 + (
  471 + Var(List(WEB_Session_Field)) fields,
  472 + String _field_name
  473 + )=
  474 + remove_any(fields, db_id_t, _field_name)
  475 +.
  476 +
409 477 /*************** Message *****************/
410 478  
411 479 Maybe(String) get_Message(fields, _field_name)
... ... @@ -993,6 +1061,7 @@ public define String
993 1061 string(_string) then name+", Type = String, Value = ["+_string+"]",
994 1062 bool(_bool) then name+", Type = Bool, Value = ["+to_String(_bool)+"]",
995 1063 int(_int) then name+", Type = Int, Value = ["+_int+"]",
  1064 + db_id(_db_id) then name+", Type = DB_id, Value = ["+_db_id+"]",
996 1065 message(_message) then name+", Type = Message, Value = ["+dump(_message)+"]",
997 1066 byte_array(_byte_array) then name+", Type = ByteArray",
998 1067 float(_float) then name+", Type = Float, Value = ["+float_to_string(_float, 10)+"]",
... ...