fs::rss::datasource (private)

 fs::rss::datasource summary_context_id

Defined in packages/file-storage/tcl/file-storage-rss-procs.tcl

This procedure implements the "datasource" operation of the RssGenerationSubscriber service contract. Important: in this implementation, the summary_context_id is equal to the subscription_id, which we use to key into the fs_rss_subscrs table to find the folder_id.

Parameters:
summary_context_id (required)
Author:
Andrew Grumet <aegrumet@alum.mit.edu>

Partial Call Graph (max 5 caller/called nodes):
%3 AcsSc.rssgenerationsubscriber.datasource.fs_rss AcsSc.rssgenerationsubscriber.datasource.fs_rss (private) fs::rss::datasource fs::rss::datasource AcsSc.rssgenerationsubscriber.datasource.fs_rss->fs::rss::datasource fs::rss::create_rss_gen_subscr_impl fs::rss::create_rss_gen_subscr_impl (private) fs::rss::create_rss_gen_subscr_impl->fs::rss::datasource ad_system_name ad_system_name (public) fs::rss::datasource->ad_system_name ad_url ad_url (public) fs::rss::datasource->ad_url content::item::get_virtual_path content::item::get_virtual_path (public) fs::rss::datasource->content::item::get_virtual_path db_1row db_1row (public) fs::rss::datasource->db_1row db_foreach db_foreach (public) fs::rss::datasource->db_foreach

Testcases:
No testcase defined.
Source code:

    db_1row select_subscription {}

    set system_name [ad_system_name]

    set column_array(channel_title) $feed_title
    set column_array(channel_description) "Recent additions to the \"$folder_title\" folder on $system_name"

    set column_array(version) 2.0

    set folder_info [fs::get_folder_package_and_root $folder_id]
    set package_id [lindex $folder_info 0]
    set root_folder_id [lindex $folder_info 1]
    set base_url [site_node::get_url_from_object_id -object_id $package_id]
    set ad_url [ad_url]
    set folder_url "${ad_url}${base_url}?folder_id=$folder_id"

    set column_array(channel_link) $folder_url

    set image_url "/resources/dotlrn/logo-user.gif"

    if { $image_url eq "" } {
        set column_array(image) ""
    } else {
        set column_array(image) [list  url "${ad_url}$image_url"  title $folder_title  link $folder_url  width "133"  height "36"]
    }

    # We need this for enclosure URLs, which should end with an
    # actual filename so they can be downloaded cleanly.
    #
    # It looks like item::get_url returns unencoded folder paths.
    # But folder names can contain spaces, so we'll urlencode just in case.
    set pretty_folder_url "${ad_url}${base_url}"
    if { $folder_id != $root_folder_id } {
        set url_stub [content::item::get_virtual_path -root_folder_id $root_folder_id -item_id $folder_id]
        set stub_parts [split $url_stub /]
        set enc_url_stub_list [list]
        foreach part $stub_parts {
            lappend enc_url_stub_list [ns_urlencode $part]
        }
        set enc_url_stub [join $enc_url_stub_list /]
        append pretty_folder_url ${enc_url_stub}/
    }

    set items [list]
    set counter 0

    if {$descend_p == "f"} {
        set parent_clause "parent_id = :folder_id"
    } else {
        set parent_clause [db_map descend_parent_clause]
    }

    if {$include_revisions_p == "f"} {
        set revisions_clause "r.revision_id = o.live_revision"
    } else {
        set revisions_clause "r.item_id = o.object_id"
    }

    db_foreach select_files [subst -nocommands {
        select * from (
          select o.object_id as item_id,
                 o.title,
                 o.name,
                 o.file_upload_name,
                 o.type,
                 o.content_size,
                 to_char(r.publish_date,'YYYY-MM-DD HH24:MI:SS') as publish_date_ansi,
                 r.description,
                 r.revision_id
          from fs_objects o,
               cr_revisions r
          where $parent_clause
            and type != 'folder'
            and $revisions_clause
          order by last_modified desc
        ) as v fetch first :max_items rows only
    }] {
        set link "${ad_url}${base_url}file?file_id=$item_id&version_id=$revision_id"
        set content "content"
        set description $description

        if {$include_revisions_p == "t"} {
            append description "<br><br><b>Note:</b> This may be a new revision of an existing file."
        }

        # Always convert timestamp to GMT
        set publish_date_ansi [lc_time_tz_convert -from [lang::system::timezone] -to "Etc/GMT" -time_value $publish_date_ansi]
        set publish_timestamp "[clock format [clock scan $publish_date_ansi] -format "%a, %d %b %Y %H:%M:%S"] GMT"

        set iteminfo [list  link $link  title $title  description $description  timestamp $publish_timestamp ]

        if { $enclosure_match_patterns ne "" } {
            foreach pattern $enclosure_match_patterns {
                if { [string match $pattern $title] } {
                    lappend iteminfo  enclosure_url "${pretty_folder_url}$file_upload_name"  enclosure_type $type  enclosure_length $content_size
                    break
                }
            }
        }

        lappend items $iteminfo

        if { $counter == 0 } {
            set column_array(channel_lastBuildDate) $publish_timestamp
            incr counter
        }
    }

    set column_array(items) $items
    set column_array(channel_language)               ""
    set column_array(channel_copyright)              ""
    set column_array(channel_managingEditor)         ""
    set column_array(channel_webMaster)              ""
    set column_array(channel_rating)                 ""
    set column_array(channel_skipDays)               ""
    set column_array(channel_skipHours)              ""

    return [array get column_array]
Generic XQL file:
<fullquery name="fs::rss::datasource.select_subscription">
    <querytext>
	    select s.subscr_id,
                   s.folder_id,
                   s.feed_title,
                   s.max_items,
                   s.descend_p,
                   s.include_revisions_p,
                   s.enclosure_match_patterns,
                   f.label as folder_title
            from fs_rss_subscrs s, cr_folders f
            where s.subscr_id = :summary_context_id
              and f.folder_id = s.folder_id
        </querytext>
</fullquery>
packages/file-storage/tcl/file-storage-rss-procs.xql

PostgreSQL XQL file:
<fullquery name="fs::rss::datasource.descend_parent_clause">
    <querytext>
    parent_id in (select children.item_id
                  from cr_items parent,
                       cr_items children
                  where parent.item_id = :folder_id
                    and children.content_type = 'content_folder'
                    and children.tree_sortkey
                      between parent.tree_sortkey
                      and tree_right(parent.tree_sortkey)) 
    </querytext>
</fullquery>
packages/file-storage/tcl/file-storage-rss-procs-postgresql.xql

Oracle XQL file:
<fullquery name="fs::rss::datasource.descend_parent_clause">
    <querytext>
	parent_id in (select item_id from cr_items
                      where content_type = 'content_folder'
                      connect by prior item_id = parent_id
                      start with item_id = :folder_id)
    </querytext>
</fullquery>
packages/file-storage/tcl/file-storage-rss-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: