Changeset 709 for MDRepository


Ignore:
Timestamp:
09/20/10 15:24:19 (14 years ago)
Author:
ljo
Message:

cmd-model - some initial cleanup before new refactoring.

Location:
MDRepository/trunk/xquery
Files:
2 edited

Legend:

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

    r708 r709  
    2222    $format := request:get-parameter("format", $cmd-model:responseFormatXml),
    2323    $collection := "/db/cmdi-mirror",
    24     $collection-params := request:get-parameter("collection", ()),
     24    $collection-params := request:get-parameter("collection", $cmd-model:collectionRoot),
    2525    $query-model-collection :=
    2626    if (fn:empty($collection-params)) then fn:concat($collection, "/")
     
    3333          fn:concat($collection, "/", $coll),
    3434    $query-collections :=
    35     if (fn:empty($collection-params) or $collection-params='') then
     35    if (matches($collection-params, "^root$") or $collection-params eq "") then
    3636      $cmd-model:collectionRoot
    3737    else
  • MDRepository/trunk/xquery/cmd-model.xqm

    r707 r709  
    8787
    8888:)
    89 declare function cmd-model:recurse-collections-model($collection as xs:string, $type-name as xs:string, $depth as xs:integer) as item()* {
     89declare function cmd-model:recurse-collections-model($collection as xs:string, $type-name as xs:string, $depth as xs:integer, $name as xs:string) as item()* {
    9090    let $children := xdb:get-child-collections($collection)
    9191    return
     
    9494            for $child in $children
    9595            return
    96               cmd-model:recurse-collections-model(fn:concat($collection, '/', xs:string($child)), $type-name, $depth),
    97               $current := cmd-model:create-doc($collection, $type-name, $depth)
     96              cmd-model:recurse-collections-model(fn:concat($collection, '/', xs:string($child)), $type-name, $depth, $name),
     97              $current := cmd-model:create-doc($collection, $type-name, $depth, $name)
    9898          return ($current, $child-results)
    9999      else
    100         cmd-model:create-doc($collection, $type-name, $depth)
     100        cmd-model:create-doc($collection, $type-name, $depth, $name)
    101101};
    102102
     
    139139
    140140:)
    141 declare function cmd-model:create-doc($collections as xs:string+, $type-name as xs:string, $depth as xs:integer) as xs:string* {
     141declare function cmd-model:create-doc($collections as xs:string+, $type-name as xs:string, $depth as xs:integer, $name as xs:string) as xs:string* {
    142142  (: if newer data available :)
    143     cmd-model:store-result($collections, cmd-model:elem($collections, $type-name, $depth), $type-name, $depth)
     143    cmd-model:store-result($collections, cmd-model:elem($collections, $type-name, $depth), $name, $depth)
    144144  (:else () :)
    145145};
     
    153153    ()
    154154    else
    155       cmd-model:create-doc($collections, $type-name, $depth)
     155      cmd-model:create-doc($collections, $type-name, $depth, $name)
    156156    return
    157157      cmd-model:get-doc($cmd-model:commonFreqsPath, $name)
     
    223223:)
    224224declare function cmd-model:make-compound-doc-name($coll-names as xs:string+, $type-name as xs:string, $depth as xs:string) as xs:string {
    225   let $name-prefix := fn:concat($type-name, $depth)
    226     return
    227     fn:concat($name-prefix, "-", util:hash(string-join($coll-names, ""), "MD5"), $cmd-model:xmlExt)
     225  let $name-prefix := fn:concat($type-name, $depth),
     226    $sorted-names := for $coll in $coll-names order by $coll ascending return $coll
     227    return
     228    fn:concat($name-prefix, "-", util:hash(string-join($sorted-names, ""), "MD5"), $cmd-model:xmlExt)
    228229};
    229230
     
    322323:)
    323324declare function cmd-model:search-retrieve($cql-query as xs:string, $collection as xs:string+, $format as xs:string, $start-item as xs:integer, $end-item as xs:integer) as item()* {
    324   (:  let $results := for $coll in $collection return util:eval(fn:concat("collection('", xdb:decode($coll), "')", xdb:decode($cql-query), "/ancestor::CMD")), :)
    325         let $results :=
    326                 if ($collection[1]=$cmd-model:collectionRoot) then
    327                                 util:eval(fn:concat("collection('", $cmd-model:cmdiMirrorPath, "')", xdb:decode($cql-query), "/ancestor::CMD"))
    328                         else
    329                                 for $coll in $collection return util:eval(fn:concat("collection('", $cmd-model:cmdiMirrorPath, "')", xdb:decode($cql-query), "/ancestor::CMD", "[.//IsPartOf='", xdb:decode($coll) ,"']"))
     325  let $results :=
     326    if ($collection[1] = $cmd-model:collectionRoot) then
     327      util:eval(fn:concat("collection('", $cmd-model:cmdiMirrorPath, "')", xdb:decode($cql-query), "/ancestor::CMD"))
     328    else
     329      for $coll in $collection return util:eval(fn:concat("collection('", $cmd-model:cmdiMirrorPath, "')", xdb:decode($cql-query), "/ancestor::CMD[descendant::IsPartOf = '", xdb:decode($coll) ,"']"))
    330330
    331331    let $result-count := fn:count($results),
Note: See TracChangeset for help on using the changeset viewer.