search-procs.tcl

Content Repository Search callbacks. These callbacks are used to implement "search" package service contracts.

Location:
packages/acs-content-repository/tcl/search-procs.tcl

Procedures in this file

Detailed information

content_search::datasource (private)

 content_search::datasource object_id

Provides data source for search interface. Used to access content items after search.

Parameters:
object_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 cr_fs_path cr_fs_path (private) db_0or1row db_0or1row (public) content_search::datasource content_search::datasource content_search::datasource->cr_fs_path content_search::datasource->db_0or1row

Testcases:
No testcase defined.

content_search::search_ids (private)

 content_search::search_ids q [ offset ] [ limit ]

Returns the object ids for a specified search.

Parameters:
q (required)
offset (optional, defaults to "0")
limit (optional, defaults to "100")

Partial Call Graph (max 5 caller/called nodes):
%3 acs_sc::invoke acs_sc::invoke (public) apm_package_id_from_key apm_package_id_from_key (public) parameter::get parameter::get (public) content_search::search_ids content_search::search_ids content_search::search_ids->acs_sc::invoke content_search::search_ids->apm_package_id_from_key content_search::search_ids->parameter::get

Testcases:
No testcase defined.

content_search::url (private)

 content_search::url object_id

Provides a URL for linking to content items which show up in a search result set.

Parameters:
object_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 image_search::url image_search::url (private) content_search::url content_search::url image_search::url->content_search::url template_search::url template_search::url (private) template_search::url->content_search::url ad_url ad_url (public) content_search::url->ad_url apm_package_id_from_key apm_package_id_from_key (public) content_search::url->apm_package_id_from_key content::item::get_path content::item::get_path (public) content_search::url->content::item::get_path content::item::get_root_folder content::item::get_root_folder (public) content_search::url->content::item::get_root_folder db_string db_string (public) content_search::url->db_string

Testcases:
No testcase defined.

image_search::datasource (private)

 image_search::datasource object_id

Provides data source for search interface. Used to access content items after search.

Parameters:
object_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 db_0or1row db_0or1row (public) image_search::datasource image_search::datasource image_search::datasource->db_0or1row

Testcases:
No testcase defined.

image_search::url (private)

 image_search::url object_id

Provides a URL for linking to content items which show up in a search result set.

Parameters:
object_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 content_search::url content_search::url (private) image_search::url image_search::url image_search::url->content_search::url

Testcases:
No testcase defined.

template_search::datasource (private)

 template_search::datasource object_id

Provides data source for search interface. Used to access content items after search.

Parameters:
object_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 cr_fs_path cr_fs_path (private) db_0or1row db_0or1row (public) template_search::datasource template_search::datasource template_search::datasource->cr_fs_path template_search::datasource->db_0or1row

Testcases:
No testcase defined.

template_search::url (private)

 template_search::url object_id

Provides a URL for linking to content items which show up in a search result set.

Parameters:
object_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 content_search::url content_search::url (private) template_search::url template_search::url template_search::url->content_search::url

Testcases:
No testcase defined.
[ hide source ] | [ make this the default ]

Content File Source

ad_library {
    Content Repository Search callbacks.

    These callbacks are used to implement "search" package service
    contracts.
}

namespace eval content_search {}

d_proc -private content_search::datasource {
    object_id
} {
    Provides data source for search interface.  Used to access content items
    after search.
} {
    set cr_fs_path [cr_fs_path]
    db_0or1row revisions_datasource {
        select r.revision_id as object_id,
               r.title,
               case i.storage_type
                    when 'lob' then cast(r.lob as text)
                    when 'file' then :cr_fs_path || r.content
                    else r.content
               end as content,
               r.mime_type as mime,
           '' as keywords,
               i.storage_type
        from cr_revisions r, cr_items i
        where revision_id = :object_id
        and i.item_id = r.item_id
    } -column_array datasource

    return [array get datasource]
}

d_proc -private content_search::url {
    object_id
} {
    Provides a URL for linking to content items which show up in a search
    result set.
} {
    set package_id [apm_package_id_from_key acs-content-repository]
    set root_url [lindex [site_node::get_url_from_object_id -object_id $package_id] 0]

    set item_id [db_string get_item_id {
        select item_id from cr_revisions
        where revision_id = :object_id}]
    set root_folder_id [content::item::get_root_folder]
    set url [content::item::get_path \
                 -item_id        $item_id \
                 -root_folder_id $root_folder_id]

    return "[ad_url][string trimright $root_url /]$url?revision_id=$object_id"
}

d_proc -private content_search::search_ids {
    q
    { offset 0 }
    { limit 100 }
} {
    Returns the object ids for a specified search.
} {
    set package_id [apm_package_id_from_key search]
    set driver [parameter::get -package_id $package_id -parameter FtsEngineDriver]
    array set result [acs_sc::invoke -contract FtsEngineDriver \
                          -operation search -call_args [list $q $offset $limit] -impl $driver]

    return $result(ids)
}


namespace eval image_search {}

d_proc -private image_search::datasource {
    object_id
} {
    Provides data source for search interface.  Used to access content items
    after search.
} {
    db_0or1row revisions_datasource {
        select r.revision_id as object_id,
               r.title as title,
               r.description as content,
               r.mime_type as mime,
               '' as keywords,
           'text' as storage_type
        from cr_revisions r
        where revision_id = :object_id

    } -column_array datasource

    return [array get datasource]
}

d_proc -private image_search::url {
    object_id
} {
    Provides a URL for linking to content items which show up in a search
    result set.
} {
    return [content_search::url $object_id]
}


namespace eval template_search {}

d_proc -private template_search::datasource {
    object_id
} {
    Provides data source for search interface.  Used to access content items
    after search.
} {
    set cr_fs_path [cr_fs_path]
    db_0or1row revisions_datasource {
        select r.revision_id as object_id,
               r.title as title,
               case i.storage_type
                    when 'lob' then cast(r.lob as text)
                    when 'file' then :cr_fs_path || r.content
                    when 'text' then r.content
                    else r.content
               end as content,
               r.mime_type as mime,
               '' as keywords,
               i.storage_type
        from cr_revisions r, cr_items i
        where revision_id = :object_id
        and i.item_id = r.item_id
    } -column_array datasource

    return [array get datasource]
}

d_proc -private template_search::url {
    object_id
} {
    Provides a URL for linking to content items which show up in a search
    result set.
} {
    return [content_search::url $object_id]
}

# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: