Changeset 654 for MDRepository


Ignore:
Timestamp:
08/25/10 14:23:00 (14 years ago)
Author:
ljo
Message:

Added possibility to pass in collection=handle for operation getCollection.

Location:
MDRepository/trunk/xquery
Files:
3 edited

Legend:

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

    r571 r654  
    2222    $format := request:get-parameter("format", $cmd-model:responseFormatXml),
    2323    $collection := "/db/cmdi-mirror",
    24     $query-model-collection := fn:concat($collection, "/", if (fn:empty(request:get-parameter("collection", ()))) then "silang_data" else ""),
     24    $collection-params := request:get-parameter("collection", ()),
     25    $query-model-collection :=
     26    if (fn:empty($collection-params)) then fn:concat($collection, "/")
     27    else
     28      for $coll in $collection-params
     29      return
     30        if (starts-with($coll, "test-")) then
     31          $coll
     32        else
     33          fn:concat($collection, "/", $coll),
    2534    $query-collections :=
    26     if (fn:empty(request:get-parameter("collection", ()))) then
     35    if (fn:empty($collection-params)) then
    2736      $collection
    2837    else
    29       for $coll in request:get-parameter("collection", ())
    30       return fn:concat($collection, "/", $coll),
     38      for $coll in $collection-params
     39      return
     40        if (starts-with($coll, "test-")) then
     41          $coll
     42        else
     43          fn:concat($collection, "/", $coll),
    3144    $max-depth as xs:integer := xs:integer(request:get-parameter("maxdepth", 1))
    3245    return
  • MDRepository/trunk/xquery/cmd-model.xqm

    r626 r654  
    8484          let $child-results :=
    8585            for $child in $children
    86               let $child-doc := doc(concat(util:collection-name($child/root()), "/", $child/ResourceRef)),
     86              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 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
    8989              cmd-model:recurse-collections($child-doc, $child-name, $child-doc//Header/MdSelfLink, $child/@id, $depth - 1)
    9090          return
     
    225225
    226226
    227 
     227(:
     228  Get the resource by handle or by path.
     229:)
     230declare function cmd-model:get-resource-by-handle-or-collection-path($id as xs:string) as node()? {
     231  (: fixme! - urldecode $id when we decide to pass them encoded from the client.  :)
     232  if (starts-with($id, "test-")) then
     233    collection($cmd-model:cmdiMirrorPath)//MdSelfLink[. = $id]/ancestor::CMD
     234  else
     235    collection($id)//IsPartOf[. = "root"]/ancestor::CMD
     236};
    228237
    229238(:
     
    253262  let $names := if (exists($collections[2])) then
    254263    ($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))
    255266  else
    256267    ($collections, concat($cmd-model:collectionDocName, xs:string($max-depth))),
     
    259270        ()
    260271      else
    261         let $children := for $collection-item in $collections
    262           let $collection-item-docs := collection(concat($collection-item, "/", "Corpusstructure"))
     272        let $children :=
     273        for $collection-item in $collections
    263274        return
    264           for $collection-doc in $collection-item-docs//CMD return
     275        for $collection-doc in cmd-model:get-resource-by-handle-or-collection-path($collection-item) return
    265276          cmd-model:recurse-collections($collection-doc, ($collection-doc//Corpus/Name, $collection-doc//Session/Name, "UNKNOWN")[1], $collection-doc//MdSelfLink, "", $max-depth)
    266277          return
  • MDRepository/trunk/xquery/cmd-stats.xql

    r641 r654  
    66<item label="ResourceProxy - Resource" >count(//ResourceProxy[ResourceType='Resource'])</item>,
    77<item label="ResourceProxy - Metadata" >count(//ResourceProxy[ResourceType='Metadata'])</item>,
    8 <item label="CMD with MD, Res " >count((//CMD[.//ResourceType='Resource'], //CMD[.//ResourceType='Metadata']))</item>,
     8<item label="CMD with MD and Res (fixme!)" >count((//CMD[.//ResourceType='Resource'], //CMD[.//ResourceType='Metadata']))</item>,
    99<item label="CMD without " >count(//CMD[not(.//ResourceType='Resource')][not(.//ResourceType='Metadata')])</item>,
    1010<item label="CMD with relative Resource (starts-with('.'))" >count(//CMD[.//ResourceType='Resource'][starts-with(.//ResourceRef,'.')])</item>,
Note: See TracChangeset for help on using the changeset viewer.