Class ::xo::db::Object

::xo::db::Object[i] create ...

Defined in

Class Relations

  • class: ::xo::db::Class[i]
  • superclass: ::xotcl::Object[i]
  • subclass: ::xo::Package[i], ::xo::db::apm_parameter[i], ::xo::db::chat_room[i], ::xo::db::chat_transcript[i], ::xo::db::CrItem[i]
::xo::db::Class create ::xo::db::Object \
     -superclass ::xotcl::Object

Methods (to be applied on instances)

  • delete (scripted, public)

     <instance of xo::db::Object[i]> delete

    Delete the object from the database and from memory

    Testcases:
    xotcl_core_tutorial_1, test_xo_db_object
    ::acs::dc call acs_object delete -object_id ${:object_id}
    :destroy
  • save (scripted, public)

     <instance of xo::db::Object[i]> save [ -package_id package_id ] \
        [ -modifying_user modifying_user ] [ -context_id context_id ]

    Save the current object in the database

    Switches:
    -package_id (optional)
    -modifying_user (optional)
    -context_id (optional)

    Testcases:
    xotcl_core_tutorial_2, test_xo_db_object
    set cmd [list :update]
    if {[info exists package_id]} {lappend cmd -package_id $package_id}
    if {[info exists modifying_user]} {lappend cmd -modifying_user $modifying_user}
    if {[info exists context_id]} {lappend cmd -context_id $context_id}
    {*}$cmd
  • save_new (scripted, public)

     <instance of xo::db::Object[i]> save_new [ -package_id package_id ] \
        [ -creation_user creation_user ] [ -creation_ip creation_ip ] \
        [ -context_id context_id ]

    Save the XOTcl Object with a fresh acs_object in the database.

    Switches:
    -package_id (optional)
    -creation_user (optional)
    -creation_ip (optional)
    -context_id (optional)
    Returns:
    new object id

    Testcases:
    test_xo_db_object
    if {![info exists package_id] && [info exists :package_id]} {
      set package_id ${:package_id}
    }
    if {![info exists context_id]} {
      set context_id [expr {[info exists :context_id] ? ${:context_id} : ""}]
    }
    [:info class] get_context package_id creation_user creation_ip
    ::xo::dc transaction {
      set id [[:info class] new_acs_object  -package_id $package_id  -creation_user $creation_user  -creation_ip $creation_ip  -context_id $context_id  ""]
      [:info class] initialize_acs_object [self$id
      :insert
    }
    return $id
  • update (scripted, public)

     <instance of xo::db::Object[i]> update [ -package_id package_id ] \
        [ -modifying_user modifying_user ] [ -context_id context_id ]

    Update the current object in the database

    Switches:
    -package_id (optional)
    -modifying_user (optional)
    -context_id (optional)

    Testcases:
    xotcl_core_tutorial_2, test_xo_db_object
    set object_id ${:object_id}
    if {![info exists package_id] && [info exists :package_id]} {
      set package_id ${:package_id}
    }
    if {![info exists context_id]} {
      set context_id [expr {[info exists :context_id] ? ${:context_id} : ""}]
    }
    [:info class] get_context package_id modifying_user modifying_ip
    set title ${:object_title}
    ::xo::dc dml update_object {
      update acs_objects set
         title          = :title,
         modifying_user = :modifying_user,
         modifying_ip   = :modifying_ip,
         context_id     = :context_id
      where object_id = :object_id
    }
    # Make sure object memory image reflects db values
    foreach att {modifying_user modifying_ip context_id} {
      set :${att} [set $att]
    }
    set :last_modified [::xo::dc get_value -prepare integer  get_last_modified {
      select last_modified from acs_objects
      where object_id = :object_id
    }]