Changeset 670 for MDRepository


Ignore:
Timestamp:
09/06/10 10:32:40 (14 years ago)
Author:
ljo
Message:

cmd-model.xqm - externalised the frequency generation for getCollections changed last Friday.

File:
1 edited

Legend:

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

    r657 r670  
    9191              cmd-model:recurse-collections($child-doc, $child-name, $child-doc//Header/MdSelfLink, $child/@id, $depth - 1)
    9292          return
    93           <c n="{$parent}" handle="{$handle}" proxy-id="{$proxy-id}" cnt="{sum($child-results/*:c/@cnt)}" sub-colls="{count($child-results)}" >{$child-results}</c>
     93          <c n="{$parent}" handle="{$handle}" proxy-id="{$proxy-id}" cnt="-1" sub-colls="{count($child-results)}" >{$child-results}</c>
    9494      else
    9595      <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>
     
    165165declare function cmd-model:store-collection-data($data as node(), $collection-path as xs:string, $doc-name as xs:string) as xs:string? {
    166166  let $clarin-writer := fn:doc("/db/clarin/writer.xml"),
    167   $dummy := xdb:login($cmd-model:cmdiDatabaseURI, $clarin-writer//write-user/text(), $clarin-writer//write-user-cred/text())
     167  $dummy := xdb:login($cmd-model:cmdiDatabaseURI, $clarin-writer//write-user/text(), $clarin-writer//write-user-cred/text()),
     168  $store := (: util:catch("org.exist.xquery.XPathException", :) xdb:store($collection-path, $doc-name, $data),(: , ()) :)
     169  $stored-doc := doc(concat($collection-path, "/", $doc-name)),
     170  $coll-count := update value $stored-doc/Collections/@count with sum($stored-doc//c[not(c)]/@cnt)
    168171  return
    169       (: util:catch("org.exist.xquery.XPathException", :) xdb:store($collection-path, $doc-name, $data)(: , ()) :)
     172  for $i in $stored-doc//c[c]
     173  return update value $i/@cnt with sum($i//c[not(c)]/@cnt)
     174
    170175};
    171176
     
    273278          cmd-model:recurse-collections($collection-doc, ($collection-doc//Corpus/Name, $collection-doc//Session/Name, "UNKNOWN")[1], $collection-doc//MdSelfLink, "", $max-depth)
    274279          return
    275             cmd-model:store-collection-data(<Collections count="{count($children/@cnt)}" root="{$collections}">{$children}</Collections>, $names[1], $names[2])
     280            cmd-model:store-collection-data(<Collections count="-1" sub-colls="{count($children)}" root="{$collections}">{$children}</Collections>, $names[1], $names[2])
    276281return
    277282  cmd-model:serialise-as(cmd-model:get-doc($names[1], $names[2]), $format)
Note: See TracChangeset for help on using the changeset viewer.