Skip to content

Instantly share code, notes, and snippets.

View meau's full-sized avatar

Maureen Callahan meau

View GitHub Profile
@meau
meau / WhichBoxesFolder1
Created July 24, 2014 15:33
Which boxes in which collections have a "Folder 1"?
xquery version "1.0";
declare namespace ead="urn:isbn:1-931666-22-9";
declare namespace xlink = "http://www.w3.org/1999/xlink";
<root>
{
for $ead in ead:ead
let $doc := base-uri($ead)
return
@meau
meau / BiggestFolder
Created July 24, 2014 15:40
What's the largest folder number in a given finding aid?
xquery version "1.0";
declare namespace ead="urn:isbn:1-931666-22-9";
declare namespace xlink = "http://www.w3.org/1999/xlink";
<foldernum>
{
for $ead in ead:ead
let $doc := base-uri($ead)
return
@meau
meau / addTitle
Last active August 29, 2015 14:05
Update an element so that it includes a nested element
xquery version "3.0";
declare namespace ead="urn:isbn:1-931666-22-9";
declare namespace xlink = "http://www.w3.org/1999/xlink";
for $container in ead:ead//ead:dsc/ead:c[2]//ead:did/ead:container[@type eq "Box"]
let $unittitle := $container/parent::ead:did/ead:unittitle
where $container = 10
return
replace node $unittitle with <unittitle><title render="italic">{$unittitle/text()}</title></unittitle>
@meau
meau / endAccessRestrict
Created August 28, 2014 18:31
Find dates that restrictions will be lifted
xquery version "3.0";
declare namespace ead="urn:isbn:1-931666-22-9";
declare namespace xlink = "http://www.w3.org/1999/xlink";
declare namespace functx = "http://www.functx.com";
<restrictions>
{
for $ead in ead:ead
let $doc := base-uri($ead)
@meau
meau / dupe parent notes
Created September 25, 2014 13:59
getting the @ids of duplicated parent notes
xquery version "3.0";
declare namespace ead="urn:isbn:1-931666-22-9";
declare namespace xlink = "http://www.w3.org/1999/xlink";
<dupes>
{
for $ead in ead:ead
let $doc := base-uri($ead)
return
@meau
meau / updateVoyager
Created October 7, 2014 14:21
match ILS data on barcode
start transaction;
UPDATE schema.ArchDescriptionInstances AS ArchDesc
JOIN (
SELECT barcode, userDefinedString1, userDefinedString2, locationId, userDefinedBoolean1, userDefinedBoolean2
FROM schema.ArchDescriptionInstances
WHERE userDefinedString1 = "{{{bibid}}}"
)
AS newdata
ON newdata.barcode=ArchDesc.barcode
SET ArchDesc.userDefinedString1 = newdata.UserDefinedString1,
@meau
meau / dupe containers same barcode
Created October 28, 2014 15:47
tells me which containers have the same barcode
select barcode,
group_concat(distinct coalesce(container1NumericIndicator, container1AlphaNumIndicator) )
from yale.ArchDescriptionInstances
where barcode != ""
group by barcode
having count(barcode) > 1
and count(distinct coalesce(container1NumericIndicator, container1AlphaNumIndicator)) > 1
@meau
meau / badBarcodes
Last active August 29, 2015 14:08
bad barcodes -- run monthly
select
concat(r.resourceIdentifier1,
' ',
lpad(r.resourceIdentifier2, 4, '00')) 'Collection',
r.title 'Collection Title',
series.subdivisionIdentifier 'Series/Accession Number',
series.title 'Series Title',
rc.title 'Component Title',
rc.dateExpression 'Component Date',
adi.container1Type 'Container Type',
@meau
meau / barcodes2AT
Created October 28, 2014 15:52
round-tripping barcodes from EAD to AT
UPDATE ArchDescriptionInstances SET barcode = instanceType WHERE instanceType REGEXP '^[0-9]{14}$';
UPDATE ArchDescriptionInstances SET instanceType = 'Mixed materials' WHERE instanceType REGEXP '^[0-9]{14}$';
@meau
meau / DAOreport
Last active August 29, 2015 14:10
gets a bunch of information about DAOs in AT
SELECT
CONCAT(
r.resourceIdentifier1
, ' '
, LPAD(r.resourceIdentifier2, 4, '00')
) AS Collection
, r.title AS CollectionTitle
, series.subdivisionIdentifier AS SeriesTitle
, series.title AS SeriesTitle
, rc.title AS ComponentTitle