Changeset 696 for MDRepository


Ignore:
Timestamp:
09/15/10 07:58:46 (14 years ago)
Author:
ljo
Message:

cmd-model.xqm -ongoing refactoring. Might not be working yet.

File:
1 edited

Legend:

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

    r695 r696  
    3636
    3737
    38 declare function cmd-model:elem($collection as xs:string, $path as xs:string, $depth as xs:integer) as element() {
    39 cmd-model:elem-r($collection, $path, $depth, $depth)
     38declare function cmd-model:elem($collections as xs:string+, $path as xs:string, $depth as xs:integer) as element() {
     39(: fixme! - handle multiple collections :)
     40cmd-model:elem-r($collections, $path, $depth, $depth)
    4041};
    4142
     
    130131
    131132:)
    132 declare function cmd-model:create-doc($collection as xs:string, $type-name as xs:string, $depth as xs:integer) as xs:string* {
     133declare function cmd-model:create-doc($collections as xs:string+, $type-name as xs:string, $depth as xs:integer) as xs:string* {
    133134  (: if newer data available :)
    134     cmd-model:store-result($collection, cmd-model:elem($collection, $type-name, $depth), $type-name, $depth)
     135    cmd-model:store-result($collections, cmd-model:elem($collections, $type-name, $depth), $type-name, $depth)
    135136  (:else () :)
    136137};
     
    139140
    140141:)
    141 declare function cmd-model:get-result-doc($collection as xs:string, $type-name as xs:string, $depth as xs:integer) as item()* {
    142   let $name-last := text:groups($type-name, "/(\w+)$")[last()],
    143     $new-name := if (fn:empty($name-last)) then $type-name else $name-last,
    144     $dummy := if (cmd-model:is-result-available($collection, fn:concat("/", $new-name, xs:string($depth)))) then
     142declare function cmd-model:get-result-doc($collections as xs:string+, $type-name as xs:string, $depth as xs:integer) as item()* {
     143  let $name := cmd-model:make-compound-doc-name($collections, "values", xs:string($depth)),
     144    $dummy := if (cmd-model:is-result-available($cmd-model:commonFreqsPath, $name))) then
    145145    ()
    146146    else
    147       cmd-model:create-doc($collection, $type-name, $depth)
    148     return
    149       fn:doc(fn:concat($collection, "/", $new-name, xs:string($depth), $cmd-model:xmlExt))
     147      cmd-model:create-doc($collections, $type-name, $depth)
     148    return
     149      cmd-model:get-doc($cmd-model:commonFreqsPath, $name)
    150150};
    151151
     
    181181    $dummy := xdb:login($cmd-model:cmdiDatabaseURI, $clarin-writer//write-user/text(), $clarin-writer//write-user-cred/text())
    182182    return
    183    
    184       if (fn:exists($coll-names[2])) then
    185         (: Det gÀller fler Àn en samling. :)
    186         xdb:store($cmd-model:commonFreqsPath, cmd-model:make-compound-doc-name($coll-names, $type-name, $depth), cmd-model:make-doc-element-of-type($type-name, $coll-names, $entries, $depth))
    187       else
    188         (: Det gÀller endast en samling. :)
    189         let $dummy := util:log('debug', fn:concat('Stores ', $type-name, ' in ', $coll-names))
    190         return xdb:store($coll-names, cmd-model:make-doc-name($coll-names, $type-name, xs:string($depth), fn:false()), cmd-model:make-doc-element-of-type($type-name, (), $entries, xs:string($depth)))
    191 };
    192 
    193 (:
    194   Store the collection listing in give collection.
     183        xdb:store($cmd-model:commonFreqsPath, cmd-model:make-compound-doc-name($coll-names, $type-name, xs:string($depth)), cmd-model:make-doc-element-of-type($type-name, $coll-names, $entries, $depth))
     184};
     185
     186(:
     187  Store the collection listing for given collection.
    195188:)
    196189declare function cmd-model:store-collection-data($data as node(), $collection-path as xs:string, $doc-name as xs:string) as xs:string? {
Note: See TracChangeset for help on using the changeset viewer.