Class ::xo::db::CrClass

::xo::db::CrClass[i] create ... \
           [ -edit_form edit_form ] \
           [ -folder_id (default "-100") ] \
           [ -form form ] \
           [ -mime_type (default "text/plain") ] \
           [ -non_cached_instance_var_patterns (default "__*") ] \
           [ -storage_type (default "text") ] \
           [ -supertype (default "content_revision") ]

Defined in

Class Relations

  • class: ::xotcl::Class[i]
  • superclass: ::xo::db::Class[i]
  • instmixin: ::xo::db::CrCache[i]
  • mixin: ::xo::db::CrCache::Class[i]

Methods (to be applied on the object)

  • delete (scripted, public)

     xo::db::CrClass[i] delete [ -item_id item_id ]

    Delete a CrItem in the database

    Switches:
    -item_id (optional)

    Testcases:
    xotcl_core_tutorial_4
  • ensure_item_ids_instantiated (scripted, public)

     xo::db::CrClass[i] ensure_item_ids_instantiated [ -initialize on|off ] \
        -item_ids item_ids 

    Make sure, the objects all of the provided items_ids are instantiated (i.e. the same-named objects do exist as executable commands in the current thread).

    Switches:
    -initialize (optional, boolean, defaults to "true")
    -item_ids (required)

    Testcases:
    link_tests
  • get_child_item_ids (scripted, public)

     xo::db::CrClass[i] get_child_item_ids -item_id item_id 

    Return a list of content items having the provided item_id as direct or indirect parent. The method returns recursively all item_ids.

    Switches:
    -item_id (required)
    Returns:
    list of item_ids

    Testcases:
    xowiki_test_cases
  • get_instance_from_db (scripted, public)

     xo::db::CrClass[i] get_instance_from_db [ -item_id item_id ] \
        [ -revision_id revision_id ] [ -initialize on|off ]

    Instantiate the live revision or the specified revision of an CrItem. The XOTcl object is destroyed automatically on cleanup (end of a connection request).

    Switches:
    -item_id (optional, integer, defaults to "0")
    -revision_id (optional, integer, defaults to "0")
    -initialize (optional, boolean, defaults to "true")
    Returns:
    fully qualified object containing the attributes of the CrItem

    Testcases:
    test_cr_items, create_workflow_with_instance, xowiki_test_cases, link_tests, slot_interactions, path_resolve
  • get_name (scripted, public)

     xo::db::CrClass[i] get_name -item_id item_id 

    Get the name of a content item either from an already instantiated object or from the database without instantiating it. If item_id is not a valid item_id, we throw an error.

    Switches:
    -item_id (required)
    Returns:
    parent_id

    Testcases:
    xowiki_test_cases
  • get_object_type (scripted, public)

     xo::db::CrClass[i] get_object_type -item_id item_id  \
        [ -revision_id revision_id ]

    Return the object type for an item_id or revision_id.

    Switches:
    -item_id (required, integer)
    -revision_id (optional, integer, defaults to "0")
    Returns:
    object_type typically an XOTcl class

    Testcases:
    test_xo_db_object, test_cr_items
  • get_parent_id (scripted, public)

     xo::db::CrClass[i] get_parent_id -item_id item_id 

    Get the parent_id of a content item either from an already instantiated object or from the database without instantiating it. If item_id is not a valid item_id, we throw an error.

    Switches:
    -item_id (required)
    Returns:
    parent_id

    Testcases:
    xowiki_test_cases
  • id_belongs_to_package (scripted, public)

     xo::db::CrClass[i] id_belongs_to_package [ -item_id item_id ] \
        [ -revision_id revision_id ] -package_id package_id 

    Check if the provided item_id or revision_id belongs to the provided package.

    Switches:
    -item_id (optional, integer, defaults to "0")
    -revision_id (optional, integer, defaults to "0")
    -package_id (required, integer)
    Returns:
    boolean success

    Testcases:
    create_form_with_form_instance, check_page_template_constraint
  • lookup (scripted, public)

     xo::db::CrClass[i] lookup -name name  [ -parent_id parent_id ] \
        [ -content_type content_type ]

    Check, whether a content item with the given name exists. When content_type is provided (e.g. -content_type "::%") then a like operation is applied on the value.

    Switches:
    -name (required)
    -parent_id (optional, defaults to "-100")
    -content_type (optional)
    Returns:
    item_id If the item exists, return its item_id, otherwise 0.

    Testcases:
    xotcl_core_tutorial_4, create_folder_with_page, xowiki_test_cases, path_resolve

Methods (to be applied on instances)

  • create_object_type (scripted, public)

     <instance of xo::db::CrClass[i]> create_object_type

    Create an oacs object_type and a table for keeping the additional attributes.

    Testcases:
    xotcl_core_tutorial_4
  • delete (scripted, public)

     <instance of xo::db::CrClass[i]> delete -item_id item_id 

    Delete a content item from the content repository.

    Switches:
    -item_id (required)
    id of the item to be deleted

    Testcases:
    xotcl_core_tutorial_4, xowiki_test_cases
  • drop_object_type (scripted, public)

     <instance of xo::db::CrClass[i]> drop_object_type

    Delete the object type and remove the table for the attributes. This method should be called when all instances are deleted. It undoes everying what create_object_type has produced.

    Testcases:
    xotcl_core_tutorial_4
  • fetch_object (scripted, public)

     <instance of xo::db::CrClass[i]> fetch_object -item_id item_id  \
        [ -revision_id revision_id ] -object object  \
        [ -initialize on|off ]

    Load a content item into the specified object. If revision_id is provided, the specified revision is returned, otherwise the live revision of the item_id. If the object does not exist, we create it.

    Switches:
    -item_id (required)
    -revision_id (optional, defaults to "0")
    -object (required)
    -initialize (optional, boolean, defaults to "true")
    Returns:
    cr item object

    Testcases:
    xotcl_core_tutorial_4, xowiki_test_cases
  • folder_type (scripted, public)

     <instance of xo::db::CrClass[i]> folder_type \
        [ -include_subtypes include_subtypes ] [ -folder_id folder_id ] \
        operation

    register the current object type for folder_id. If folder_id is not specified, use the instvar of the class instead.

    Switches:
    -include_subtypes (optional, defaults to "t")
    Boolean value (t/f) to flag whether the operation should be applied on subtypes as well
    -folder_id (optional)
    Parameters:
    operation (required)

    Testcases:
    xotcl_core_tutorial_4
  • folder_type_unregister_all (scripted, public)

     <instance of xo::db::CrClass[i]> folder_type_unregister_all \
        [ -include_subtypes include_subtypes ]

    Unregister the object type from all folders on the system

    Switches:
    -include_subtypes (optional, defaults to "t")
    Boolean value (t/f) to flag whether the operation should be applied on subtypes as well

    Testcases:
    No testcase defined.
  • get_instance_from_db (scripted, public)

     <instance of xo::db::CrClass[i]> get_instance_from_db \
        [ -item_id item_id ] [ -revision_id revision_id ] \
        [ -initialize on|off ]

    Retrieve either the live revision or a specified revision of a content item with all attributes into a newly created object. The retrieved attributes are stored in the instance variables in class representing the object_type. The XOTcl object is destroyed automatically on cleanup (end of a connection request)

    Switches:
    -item_id (optional, defaults to "0")
    id of the item to be retrieved.
    -revision_id (optional, defaults to "0")
    revision-id of the item to be retrieved.
    -initialize (optional, boolean, defaults to "true")
    Returns:
    fully qualified object

    Testcases:
    xotcl_core_tutorial_4, test_cr_items, create_folder_with_page, xowiki_test_cases, create_form_with_form_instance
  • get_instances_from_db (scripted, public)

     <instance of xo::db::CrClass[i]> get_instances_from_db \
        [ -select_attributes select_attributes ] \
        [ -from_clause from_clause ] [ -where_clause where_clause ] \
        [ -orderby orderby ] [ -with_subtypes on|off ] \
        [ -folder_id folder_id ] [ -page_size page_size ] \
        [ -page_number page_number ] [ -base_table base_table ] \
        [ -initialize initialize ]

    Returns a set (ordered composite) of the answer tuples of an 'instance_select_query' with the same attributes. The tuples are instances of the class, on which the method was called.

    Switches:
    -select_attributes (optional)
    -from_clause (optional)
    -where_clause (optional)
    -orderby (optional)
    -with_subtypes (optional, boolean, defaults to "true")
    -folder_id (optional)
    -page_size (optional, defaults to "20")
    -page_number (optional)
    -base_table (optional, defaults to "cr_revisions")
    -initialize (optional, defaults to "true")

    Testcases:
    xotcl_core_tutorial_4, create_form_with_form_instance
  • instance_select_query (scripted, public)

     <instance of xo::db::CrClass[i]> instance_select_query \
        [ -select_attributes select_attributes ] [ -orderby orderby ] \
        [ -where_clause where_clause ] [ -from_clause from_clause ] \
        [ -with_subtypes on|off ] [ -with_children on|off ] \
        [ -publish_status publish_status ] [ -count on|off ] \
        [ -folder_id folder_id ] [ -parent_id parent_id ] \
        [ -page_size page_size ] [ -page_number page_number ] \
        [ -base_table base_table ]

    returns the SQL-query to select the CrItems of the specified object_type

    Switches:
    -select_attributes (optional)
    attributes for the SQL query to be retrieved, in addition to item_id, name, publish_status, object_type, and package_id which are always returned
    -orderby (optional)
    for ordering the solution set
    -where_clause (optional)
    clause for restricting the answer set
    -from_clause (optional)
    -with_subtypes (optional, boolean, defaults to "true")
    return subtypes as well
    -with_children (optional, boolean, defaults to "false")
    return immediate child objects of all objects as well
    -publish_status (optional)
    one of 'live', 'ready', or 'production'
    -count (optional, boolean, defaults to "false")
    return the query for counting the solutions
    -folder_id (optional)
    parent_id
    -parent_id (optional)
    -page_size (optional, defaults to "20")
    -page_number (optional)
    -base_table (optional, defaults to "cr_revisions")
    typically automatic view, must contain title and revision_id
    Returns:
    SQL query

    Testcases:
    xowiki_test_cases
  • new_persistent_object (scripted, public)

     <instance of xo::db::CrClass[i]> new_persistent_object \
        [ -package_id package_id ] [ -creation_user creation_user ] \
        [ -creation_ip creation_ip ] args [ args... ]

    Create a new content item of the actual class, configure it with the given arguments and insert it into the database. The XOTcl object is destroyed automatically on cleanup (end of a connection request).

    Switches:
    -package_id (optional)
    -creation_user (optional)
    -creation_ip (optional)
    Parameters:
    args (required)
    Returns:
    fully qualified object

    Testcases:
    xotcl_core_tutorial_4