caldav::calendars proc get_calendar_and_cal_item_from_uid (public)

 caldav::calendars[i] get_calendar_and_cal_item_from_uid \
    [ -calendar_ids calendar_ids ] uid

Defined in packages/xotcl-core/tcl/01-debug-procs.tcl

Switches:
-calendar_ids (optional, integer)
Parameters:
uid (required)
unique id of an calendar item
Returns:
for a uid the cal_item_id(s?)

Testcases:
No testcase defined.
Source code:
# @return for a uid the cal_item_id(s?)
# @param uid unique id of an calendar item

#
# GN TODO:
#
# - see above... get_cal_item_from_uid
#
# The following query is tricky, since it avoids
# an error "invalid input syntax for integer" on uids like
#
#     23009F17-383F-4FBD-92D4-AB0F27CF7326
#
# needs probably work for Oracle.
#
return [::xo::dc list_of_lists query_calendar_and_cal_item {
    select c.on_which_calendar, c.cal_item_id
    from acs_events e, cal_items c
    where e.activity_id in
    (
     select CASE WHEN :uid !~ '^[0-9]+$' THEN NULL ELSE :uid ::text::integer END
     union (select on_which_activity from cal_uids where cal_uid = :uid)
    )
    and c.cal_item_id = e.event_id
    order by 2 desc
    limit 1
}]

# set e_clause [expr {[nsf::is integer $uid] ? " or e.activity_id = :uid" : ""}]
#
# - we could pass-in a calendar-clause, would save a query in
#   the PUT case
#if {[llength $calendar_ids] > 1} {
#    set calclause "in ( [ns_dbquotelist $calendar_ids] )"
#} elseif {[llength $calendar_ids] eq 0} {
#    return 0
#} else {
#    set calclause "= :calendar_ids"
#}

# return [::xo::dc list query_calendar_and_cal_item [subst {
#     select c.on_which_calendar, cal_item_id
#     from cal_items c, acs_events e
#     left outer join cal_uids u on u.on_which_activity = e.activity_id
#     where c.cal_item_id = e.event_id
#     and ( u.cal_uid = :uid $e_clause )
#     and  c.on_which_calendar $calclause
#     order by 2 desc}]]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: