Changeset 657 for MDRepository


Ignore:
Timestamp:
08/26/10 13:39:21 (14 years ago)
Author:
ljo
Message:

cmd-model.xqm - added count of sub collections. All calculated collection docs go into the same collection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • MDRepository/trunk/xquery/cmd-model.xqm

    r654 r657  
    8686              let $child-doc := if (empty($child/unresolvable-uri)) then doc(concat(util:collection-name($child/root()), "/", $child/ResourceRef)) else (),
    8787                $child-name := ($child-doc//Corpus/Name, $child-doc//Session/Name, "UNKNOWN")[1]
    88             return if (empty($child-doc)) then () (:<no-target proxy-id="{$child/@id}">{<proxy>{$child}</proxy>, <in-document>{concat(util:collection-name($child/root()), "/", util:document-name($child/root()))}</in-document>}</no-target> :) else
     88            return
     89              if (empty($child-doc)) then () (:<no-target proxy-id="{$child/@id}">{<proxy>{$child}</proxy>, <in-document>{concat(util:collection-name($child/root()), "/", util:document-name($child/root()))}</in-document>}</no-target> :)
     90             else
    8991              cmd-model:recurse-collections($child-doc, $child-name, $child-doc//Header/MdSelfLink, $child/@id, $depth - 1)
    9092          return
    91           <c n="{$parent}" handle="{$handle}" proxy-id="{$proxy-id}" cnt="{sum($child-results/*:c/@cnt)}">{$child-results}</c>
     93          <c n="{$parent}" handle="{$handle}" proxy-id="{$proxy-id}" cnt="{sum($child-results/*:c/@cnt)}" sub-colls="{count($child-results)}" >{$child-results}</c>
    9294      else
    9395      <c n="{$parent}" handle="{$handle}" proxy-id="{$proxy-id}" cnt="{count(collection(concat(util:collection-name($collection/CMD[1]/root()), "/../"))//CMD[not(//ResourceType[. = "Metadata"])])}"></c>
     
    228230  Get the resource by handle or by path.
    229231:)
    230 declare function cmd-model:get-resource-by-handle-or-collection-path($id as xs:string) as node()? {
     232declare function cmd-model:get-resource-by-handle-or-collection-path($id as xs:string) as node()* {
    231233  (: fixme! - urldecode $id when we decide to pass them encoded from the client.  :)
    232234  if (starts-with($id, "test-")) then
    233     collection($cmd-model:cmdiMirrorPath)//MdSelfLink[. = $id]/ancestor::CMD
     235    collection($cmd-model:cmdiMirrorPath)//MdSelfLink[. = xdb:decode($id)]/ancestor::CMD
    234236  else
    235237    collection($id)//IsPartOf[. = "root"]/ancestor::CMD
     
    260262:)
    261263declare function cmd-model:get-collections($collections as xs:string+, $format as xs:string, $max-depth as xs:integer) as item() {
    262   let $names := if (exists($collections[2])) then
    263     ($cmd-model:commonFreqsPath, cmd-model:make-compound-doc-name($collections, "collection", $max-depth))
    264   else if (starts-with($collections, "test-")) then
    265     ($cmd-model:commonFreqsPath, cmd-model:make-compound-doc-name($collections, "collection", $max-depth))
    266   else
    267     ($collections, concat($cmd-model:collectionDocName, xs:string($max-depth))),
    268  $dummy :=   
     264  let $names := ($cmd-model:commonFreqsPath, cmd-model:make-compound-doc-name($collections, "collection", $max-depth)),
     265 $dummy :=
    269266      if (cmd-model:is-doc-available($names[1], $names[2])) then
    270267        ()
Note: See TracChangeset for help on using the changeset viewer.