DS Catalog:SPARQL Query Service/example queries: Difference between revisions

Jump to navigation Jump to search
Line 109: Line 109:
==Receipt Generator==
==Receipt Generator==
This query generates a list of DS Wikibase items which shows successful ingest of DS Records, creation of Manuscript items / DS IDs, and assignment of Holding information for an institution, to serve as a receipt for data contributions made to the DS Catalog.
This query generates a list of DS Wikibase items which shows successful ingest of DS Records, creation of Manuscript items / DS IDs, and assignment of Holding information for an institution, to serve as a receipt for data contributions made to the DS Catalog.
<syntaxhighlight lang="SPARQL>
SELECT
  # Variables for holding values used in the construction of the receipt
  (?holderName as ?holding_institution)
  (?holder as ?ds_holding_inst_url)
  (?dsid as ?ds_id)
  (?manuscript as ?ds_manuscript_url)
  (?shelfmark as ?holding_inst_shelfmark)
  (?institutionalID as ?holding_inst_id)
  (?linkToRecord as ?holding_inst_link)
  (?iiifManifest as ?iiif_manifest)
  (?holdingLabel as ?ds_holding)
  (?holding as ?ds_holding_info_url)
  (?dateAdded as ?date_added_to_ds)
  (?ds20RecordLabel as ?ds_record)
  (?ds20Record as ?ds_record_url)
  (?lastUpdated as ?ds_record_last_updated)
{
  # Specify a holding institution (remove comment tag)
#  BIND (wd:Q16442 as ?holder) # bpl - Boston Public Library
#  BIND (wd:Qxxxx as ?holder) # columbia - Columbia University
#  BIND (wd:Q667 as ?holder) # conception - Conception Abbey
#  BIND (wd:Q825 as ?holder) # csl - State of Calfornia Library
#  BIND (wd:Q858 as ?holder) # cuny - City College of New York
#  BIND (wd:Q18629 as ?holder) # flp - Free Library of Philadelphia
#  BIND (wd:Q868 as ?holder) # grolier - Grolier Club
#  BIND (wd:Q1487 as ?holder) # gts - General Theological Seminary
#  BIND (wd:Q17632 as ?holder) # hrc - Harry Ransom Center
#  BIND (wd:Qxxxx as ?holder) # huntington - The Huntington
#  BIND (wd:Q1521 as ?holder) # indiana - Indiana University
#  BIND (wd:Q6060 as ?holder) # kansas - University of Kansas
#  BIND (wd:Q1123 as ?holder) # nelsonatkins - Nelson-Atkins Museum of Art
#  BIND (wd:Q1914 as ?holder) # nyu - New York University
#  BIND (wd:Q10856 as ?holder) # oregon - University of Oregon
#  BIND (wd:Q374 as ?holder) # penn - University of Pennsylvania
#  BIND (wd:Q12264 as ?holder) # princeton - Princeton University
#  BIND (wd:Q801 as ?holder) # providence - Providence Public Library
#  BIND (wd:Q1101 as ?holder) # rome - American Academy in Rome
#  BIND (wd:Q1936 as ?holder) # rutgers - Rutgers University
#  BIND (wd:Qxxxx as ?holder) # shi - Science History Institute
#  BIND (wd:Q1247 as ?holder) # smith - Smith College
#  BIND (wd:Qxxxx as ?holder) # wmu - Western Michigan University
 
  # holding and holding properties
  BIND ( wd:Q2 as ?holdingType )
  BIND ( wdt:P16 as ?instanceOf )
  BIND ( wdt:P2 as ?hasHolding )
  BIND ( pq:P4 as ?qualifierHoldingInstInAuthFile )
  BIND ( p:P5 as ?holdingInstitutionAsRecStmt )
  BIND ( ps:P5 as ?holdingInstAsRecValue )
  BIND ( wdt:P7 as ?hasInstID )
  BIND ( wdt:P8 as ?hasShelfmark )
  BIND ( wdt:P9 as ?hasLinkToInstRecord )
  BIND ( wdt:P38 as ?hasHoldingAddedDate )
  BIND ( wdt:P39 as ?hasHoldingEndDate )
 
  # manuscript properties
  BIND ( wdt:P1 as ?hasDSID )
 
  # DS 2.0 Record properties
  BIND ( wdt:P3 as ?describesManuscript )
  BIND ( wdt:P35 as ?hasDateLastUpdated )
  BIND ( wdt:P41 as ?hasIIIFManifest )
  # holding information
  ?holding ?instanceOf ?holdingType ;
          ?holdingInstitutionAsRecStmt ?holdingInstStatement ;
          ?hasHoldingAddedDate ?dateAdded .
                     
  OPTIONAL { ?holding ?hasInstID ?institutionalID }
  OPTIONAL { ?holding ?hasShelfmark ?shelfmark }
  OPTIONAL { ?holding ?hasLinkToInstRecord ?linkToRecord }
  ?holdingInstStatement ?qualifierHoldingInstInAuthFie ?holder .
  ?holder rdfs:label ?holderName .
 
  # finding linked manuscript objects to holding information patterns above
  ?manuscript ?hasHolding ?holding ;
              ?hasDSID ?dsid .
  ?holding rdfs:label ?holdingLabel .
 
  # finding linked DS records to manuscript object patterns above
  ?ds20Record ?describesManuscript ?manuscript ;
              ?hasDateLastUpdated ?lastUpdated ;
              rdfs:label ?ds20RecordLabel .
 
  OPTIONAL { ?ds20Record ?hasIIIFManifest ?iiifManifest }
  # get alphanumerical IDs from Wikibase URIs
  BIND (STRDT(REPLACE(STR(?holder), "http.+/entity/", ""), xsd:integer) as ?holderQID)
  BIND (STRDT(REPLACE(STR(?holding), "http.+/entity/", ""), xsd:integer) as ?holdingQID)
  BIND (STRDT(REPLACE(STR(?manuscript), "http.+/entity/", ""), xsd:integer) as ?manuscriptQID)
 
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en" .
      # allows English language labels to be returned for Wikibase items
  }
} ORDER BY DESC(?lastUpdated) ASC(?shelfmark)
  # sort results by date updated in Wikibase and then by shelfmark
</syntaxhighlight>


==Statement Count Generator==
==Statement Count Generator==
Bots, Bureaucrats, emailconfirmed, Administrators
30,537

edits

Navigation menu