User:Dipsode87

From Wikidata
Jump to navigation Jump to search

SPARQL queries[edit]

Mapping WD properties for software to PREMIS[edit]

Objective: retrieve WD data (canonical properties for software described at https://www.wikidata.org/wiki/Wikidata:WikiProject_Informatics/Software/Properties) and map it with a CONSTRUCT query to PREMIS RDF recommended constructs in version 3, described at http://www.loc.gov/standards/premis/ontology/owl-version3.html.

The following query uses these:

  • Properties: operating system (P306) View with Reasonator View with SQID, developer (P178) View with Reasonator View with SQID, depends on software (P1547) View with Reasonator View with SQID, GUI toolkit or framework (P1414) View with Reasonator View with SQID, input method (P479) View with Reasonator View with SQID, platform (P400) View with Reasonator View with SQID, software engine (P408) View with Reasonator View with SQID, follows (P155) View with Reasonator View with SQID, followed by (P156) View with Reasonator View with SQID, source code repository (P1324) View with Reasonator View with SQID, has part (P527) View with Reasonator View with SQID, part of (P361) View with Reasonator View with SQID, software version identifier (P348) View with Reasonator View with SQID, Digital Rights Management system (P1032) View with Reasonator View with SQID, Debian stable package (P3442) View with Reasonator View with SQID, formatter URL (P1630) View with Reasonator View with SQID, Fedora package (P3463) View with Reasonator View with SQID, Framalibre ID (P4107) View with Reasonator View with SQID, creator (P170) View with Reasonator View with SQID, inception (P571) View with Reasonator View with SQID, publication date (P577) View with Reasonator View with SQID, license (P275) View with Reasonator View with SQID, copyright holder (P3931) View with Reasonator View with SQID
      1 prefix relSubType: <http://id.loc.gov/vocabulary/preservation/relationshipSubType/>
      2 prefix envFuncType: <http://id.loc.gov/vocabulary/preservation/environmentFunctiontype/>
      3 prefix evType: <http://id.loc.gov/vocabulary/preservation/eventType/>
      4 prefix rightsRelAgRole: <http://id.loc.gov/vocabulary/preservation/rightsRelatedAgentRole/>
      5 prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
      6 prefix dct: <http://purl.org/dc/terms/>
      7 prefix foaf: <http://xmlns.com/foaf/0.1/>
      8 prefix skos: <http://www.w3.org/2004/02/skos/core#>
      9 prefix premis: <http://www.loc.gov/premis/rdf/v3/>
     10 prefix prov: <http://www.w3.org/ns/prov#>
     11 
     12 CONSTRUCT {
     13   wd:Q698 rdf:type envFuncType:soa;
     14             rdfs:label ?itemLabel;
     15           premis:hasVersion ?version;
     16             dct:creator ?creator;
     17             relSubType:idp ?operatingSystem;
     18             relSubType:idp ?platform;
     19             relSubType:idp ?softwareEngine;
     20             relSubType:req ?requiredSoftware;
     21             relSubType:req ?gui;
     22             relSubType:req ?inputDevice;
     23     relSubType:isr ?debianPackage;
     24     relSubType:isr ?fedoraPackage;
     25             relSubType:isr ?sourceCodeRepo;
     26             relSubType:isr ?distributedRepresentation;
     27             relSubType:sup ?predecessor;
     28             relSubType:iss ?successor;
     29             relSubType:isp ?whole;
     30             relSubType:hsp ?part;
     31     skos:exactMatch ?framalibreID;
     32             prov:wasGeneratedBy ?publicationEvent;
     33             prov:wasGeneratedBy ?inceptionEvent;
     34           dct:rights ?license;
     35           dct:rights ?copyright.
     36   ?copyright rightsRelAgRole:rig ?copyrightOwner.
     37   ?operatingSystem rdf:type envFuncType:ops;
     38                    rdfs:label ?operatingSystemLabel.
     39   ?requiredSoftware rdf:type envFuncType:sof;
     40                     rdfs:label ?requiredSoftwareLabel.
     41   ?gui rdf:type envFuncType:sol;
     42        rdfs:label ?guiLabel.
     43   ?inputDevice rdf:type envFuncType:hap;
     44        rdfs:label ?inputDeviceLabel.
     45   ?platform rdf:type envFuncType:haa;
     46        rdfs:label ?platformLabel.
     47   ?software rdf:type envFuncType:soa;
     48        rdfs:label ?softwareEngineLabel.
     49   ?predecessor rdf:type envFuncType:sof;
     50                rdfs:label ?predecessorLabel.
     51   ?successor rdf:type envFuncType:sof;
     52              rdfs:label ?successorLabel.
     53   ?debianPackage rdf:type premis:Representation.
     54   ?sourceCodeRepo rdf:type premis:Representation.
     55   ?fedoraPackage rdf:type premis:Representation.
     56   ?distributedRepresentation rdf:type premis:Representation;
     57                              premis:storedAt ?distributedRepresentationLocation.
     58   ?distributedRepresentationLocation rdf:type premis:StorageLocation;
     59                                      premis:hasMedium ?physicalMedium.
     60   ?publicationEvent rdf:type evType:cre;
     61                  dct:date ?publicationDate;
     62                  prov:wasAssociatedWith ?creationAgent.
     63   ?inceptionEvent rdf:type evType:cre;
     64                  dct:date ?inceptionDate;
     65                  prov:wasAssociatedWith ?creationAgent.
     66   ?creationAgent rdf:type premis:Agent;
     67                  foaf:name ?creationAgentLabel.
     68 }
     69 WHERE
     70 {VALUES ?environment {wd:Q698}
     71   ?environment rdfs:label ?itemLabel.
     72   FILTER (lang(?itemLabel)="en")
     73   OPTIONAL{?environment wdt:P306 ?operatingSystem.
     74            ?operatingSystem rdfs:label ?operatingSystemLabel.
     75   FILTER (lang(?operatingSystemLabel)="en")}
     76   OPTIONAL{?environment wdt:P178 ?creator.}
     77   OPTIONAL{?environment wdt:P1547 ?requiredSoftware.
     78            ?requiredSoftware rdfs:label ?requiredSoftwareLabel.
     79   FILTER (lang(?requiredSoftwareLabel)="en")}
     80   OPTIONAL{?environment wdt:P1414 ?gui.
     81            ?gui rdfs:label ?guiLabel.
     82   FILTER (lang(?guiLabel)="en")}
     83   OPTIONAL{?environment wdt:P479 ?inputDevice.
     84            ?inputDevice rdfs:label ?inputDeviceLabel.
     85   FILTER (lang(?inputDeviceLabel)="en")}
     86   OPTIONAL{?environment wdt:P400 ?platform.
     87            ?platform rdfs:label ?platformLabel.
     88   FILTER (lang(?platformLabel)="en")}
     89   OPTIONAL{?environment wdt:P408 ?softwareEngine.
     90            ?softwareEngine rdfs:label ?softwareEngineLabel.
     91   FILTER (lang(?softwareEngineLabel)="en")}
     92   OPTIONAL{?environment wdt:P155 ?predecessor.
     93            ?predecessor rdfs:label ?predecessorLabel.
     94   FILTER (lang(?predecessorLabel)="en")}
     95   OPTIONAL{?environment wdt:P156 ?successor.
     96            ?predecessor rdfs:label ?successorLabel.
     97   FILTER (lang(?successorLabel)="en")}
     98   OPTIONAL{?environment wdt:P1324 ?sourceCodeRepo}
     99  OPTIONAL{?environment wdt:P527 ?part}
    100  OPTIONAL{?environment wdt:P361 ?whole}
    101  OPTIONAL{?environment wdt:P348 ?version}
    102  OPTIONAL{SELECT ?physicalMedium (UUID() As ?distributedRepresentation) (UUID() As ?distributedRepresentationLocation)
    103                                 WHERE {wd:Q698 wdt:P1032 ?physicalMedium.}
    104           }
    105  OPTIONAL{
    106    SELECT (IRI(REPLACE(?debianPackageBaseURI, '\\$1', ?debianPackageString)) AS ?debianPackage) WHERE {wd:Q698 wdt:P3442 ?debianPackageString.
    107           wd:P3442 wdt:P1630 ?debianPackageBaseURI.} }
    108   OPTIONAL{
    109    SELECT (IRI(REPLACE(?fedoraPackageBaseURI, '\\$1', ?fedoraPackageString)) AS ?fedoraPackage) WHERE {wd:Q698 wdt:P3463 ?fedoraPackageString.
    110           wd:P3463 wdt:P1630 ?fedoraPackageBaseURI.} }
    111   OPTIONAL{
    112    SELECT (IRI(REPLACE(?framalibreIDBaseURI, '\\$1', ?framalibreIDString)) AS ?framalibreID) WHERE {wd:Q698 wdt:P4107 ?framalibreIDString.
    113           wd:P4107 wdt:P1630 ?framalibreIDBaseURI.} }
    114    OPTIONAL{wd:Q698 wdt:P170 ?creationAgent.
    115            ?creationAgent rdfs:label ?creationAgentLabel.
    116            FILTER (lang(?creationAgentLabel)="en") }
    117    OPTIONAL{SELECT (UUID() as ?publicationEvent) ?publicationDate WHERE {wd:Q698 wdt:P571 ?publicationDate.} }
    118 OPTIONAL{SELECT (UUID() as ?inceptionEvent) ?inceptionDate WHERE {wd:Q698 wdt:P577 ?inceptionDate.} }
    119 OPTIONAL{?environment wdt:P275 ?license}
    120 OPTIONAL{?environment wdt:P3931 ?copyrightOwner}
    121   }