Skip to content

Commit

Permalink
add a mess of files -- not untangling this mess immediately.
Browse files Browse the repository at this point in the history
  • Loading branch information
CanOfBees committed May 6, 2017
1 parent 0652a41 commit 2558b0e
Show file tree
Hide file tree
Showing 8 changed files with 16,466 additions and 0 deletions.
44 changes: 44 additions & 0 deletions add-country-qdc-to-db.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
declare namespace oai = "http://www.openarchives.org/OAI/2.0/";

(: Retrieves metadata records for an entire OAI-PMH collection :)
(: Adds records to BaseX database:)

declare function local:request($base-url as xs:string, $verb as xs:string, $set-spec as xs:string) as document-node()*
{
let $request := $base-url || $verb || $set-spec
let $response := fn:doc($request)
let $token := $response//oai:resumptionToken/text()
return
if (fn:empty($token)) then
$response
else
($response,
local:resume($base-url, $token))
};

declare function local:resume($base-url as xs:string, $token as xs:string) as document-node()*
{
let $verb := "?verb=ListRecords&resumptionToken="
let $request := $base-url || $verb || $token
let $response := fn:doc($request)
let $new-token := $response//oai:resumptionToken/text()
return
if (fn:empty($new-token)) then
$response
else
($response,
local:resume($base-url, $new-token))
};

(: for $set in db:open('repox-sets')/set/spec/text()[fn:starts-with(., 'utk_')] :)
(: fn:doc('http://digi.countrymusichalloffame.org/oai/oai.php?verb=ListRecords&metadataPrefix=oai_qdc') :)
let $base-url := "http://digi.countrymusichalloffame.org/oai/oai.php"
let $verb := "?verb=ListRecords&metadataPrefix=oai_qdc"
let $set-spec := "&set=musicaudio"
let $response := local:request($base-url, $verb, $set-spec)
for $record in $response//oai:record
let $id := $record/oai:header/oai:identifier/text()
return(
db:add('country_music_qdc', $record, $id, map { 'addcache': true() }),
db:optimize('country_music_qdc', true())
)
21 changes: 21 additions & 0 deletions canned-queries.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(: some helpful queries :)

for $name in db:open('repox-sets')/set/spec/text() return db:open($name)/*:record[//@*='deleted']/*:header/*:identifier/text(),

for $name in db:open('repox-sets')/set/spec/text() return db:open($name)/*:record[*:header/*:identifier[fn:contains(.,'p265301coll005/7')]],

for $name in db:open('repox-sets')/set/spec/text() return db:open($name)/*:record[*:header/*:identifier[fn:contains(.,'p18877coll16/24')]],

for $record in db:open('utc_p16877coll16')/record[not(header/identifier[contains(., 'p18877coll16/24')])] return (1 to 3),

let $target := '/tmp/utk_p16877coll16'
for $record in db:open('utc_p16877coll16')/record[not(header/identifier[contains(., 'p16877coll16/24')])]
let $path := $target || db:path($record)
return (
file:create-dir(file:parent($path)),
file:write($path, $record)
),

for $name in db:open('repox-sets')/set/spec/text() return db:open($name)/record/header/identifier/text(),

//record[descendant::*:format[matches(., '17 inch metal-based acetate disc')] and descendant::*:format[matches(., '33 1/3 rpm; 78 rpm')]]
16,327 changes: 16,327 additions & 0 deletions deleted-records-list

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions serialization-test-dbexport.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let $target := '/tmp/utc_p16877coll16_2/'
for $record in db:open('utc_p16877coll16')/record[not(header/identifier[contains(., 'p16877coll16/24')])]
let $path := $target || db:path($record) || '.xml'
return
db:export('utc_p16877coll16', $path, map { 'method': 'xml', 'encoding': 'UTF-8', 'indent': 'yes', 'omit-xml-declaration': 'no' })
15 changes: 15 additions & 0 deletions serialization-test.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import module namespace functx = 'http://www.functx.com';

let $target := '/tmp/utc_p16877coll16/'
for $record in db:open('utc_p16877coll16')/record[not(header/identifier[contains(., 'p16877coll16/24')])]
let $file-full := functx:substring-after-last(db:path($record), ':')
let $file := if (fn:contains($file-full, '/'))
then (fn:replace($file-full, '/', '_'))
else $file-full
let $path := $target || $file || '.xml'(: db:path($record) :)
return (
(: file:create-dir(file:parent($path)),
file:write($path, $record) :)
file:create-dir(file:parent($path)),
file:write($path, $record)
)
18 changes: 18 additions & 0 deletions serialize-country_music.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import module namespace functx = 'http://www.functx.com';

let $target := '/mnt/gwork/repox-data/'
let $coll := 'country_music'

for $record in db:open($coll)/record[descendant::*:format[contains(., '6.5 inch metal-based acetate disc')
or contains(., '10 inch metal-based acetate disc')
or contains(., '8 inch metal-based acetate disc')]]

let $file-full := functx:substring-after-last(db:path($record), ':')
let $file := if (fn:contains($file-full, '/'))
then (fn:replace($file-full, '/', '_'))
else $file-full
let $path := $target || $coll || '/' || $file || '.xml'(: db:path($record) :)
return (
file:create-dir(file:parent($path)),
file:write($path, $record)
)
18 changes: 18 additions & 0 deletions serialize-country_music_qdc.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import module namespace functx = 'http://www.functx.com';

let $target := '/mnt/gwork/repox-data/'
let $coll := 'country_music'

for $record in db:open($coll)/record[descendant::*:format[fn:contains(., '6.5 inch metal-based acetate disc')
or fn:contains(., '10 inch metal-based acetate disc')
or fn:contains(., '8 inch metal-based acetate disc')]]

let $file-full := functx:substring-after-last(db:path($record), ':')
let $file := if (fn:contains($file-full, '/'))
then (fn:replace($file-full, '/', '_'))
else $file-full
let $path := $target || $coll || '/' || $file || '.xml'
return (
file:create-dir(file:parent($path)),
file:write($path, $record)
)
18 changes: 18 additions & 0 deletions serialize-crossroadsfreedom.xq
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import module namespace functx = 'http://www.functx.com';

let $target := '/mnt/gwork/repox-data/'
let $coll := 'crossroadsfreedom'

for $record in db:open($coll)/record[descendant::*:format[contains(., '6.5 inch metal-based acetate disc')
or contains(., '10 inch metal-based acetate disc')
or contains(., '8 inch metal-based acetate disc')]]

let $file-full := functx:substring-after-last(db:path($record), ':')
let $file := if (fn:contains($file-full, '/'))
then (fn:replace($file-full, '/', '_'))
else $file-full
let $path := $target || $coll || '/' || $file || '.xml'(: db:path($record) :)
return (
file:create-dir(file:parent($path)),
file:write($path, $record)
)

0 comments on commit 2558b0e

Please sign in to comment.