query-61d9c33ad78a4d0a068bcecb732de024

rq turtle/ttl

Requête SparQL

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:ImageGrid
SELECT distinct 
?numCatalogue ?item ?itemLabel 
(GROUP_CONCAT(distinct ?nature_label; separator=" - ") as ?type) 
(GROUP_CONCAT(distinct ?crea_label; separator=" - ") as ?crea)
(GROUP_CONCAT(distinct ?date; separator=" ; ") as ?dates)
(GROUP_CONCAT(distinct ?coll_label; separator=" - ") as ?collection)
(GROUP_CONCAT(distinct ?ninv; separator=" - ") as ?inv)
(SAMPLE(?img) as ?image) 
(SAMPLE(?url) as ?URL)
WHERE {
  BIND (wd:Q28043290 as ?expo) # élément exposition
  ?item wdt:P608 ?expo. 
  OPTIONAL { ?expo wdt:P972 ?catalogue.
           ?item p:P528 [ ps:P528 ?numCatalogue ;
                   pq:P972 ?catalogue ]
           }
  ?item wdt:P31 ?nature.
  OPTIONAL{?nature rdfs:label ?nature_labelfr. filter (lang(?nature_labelfr) = "fr")}
  OPTIONAL{?nature rdfs:label ?nature_labelen. filter (lang(?nature_labelen) = "en")}
  BIND(COALESCE(?nature_labelfr,?nature_labelen) AS ?nature_label)
  OPTIONAL { ?item wdt:P170 ?crea.
           OPTIONAL{?crea rdfs:label ?crea_labelfr filter (lang(?crea_labelfr) = "fr")}
           OPTIONAL{?crea rdfs:label ?crea_labelen filter (lang(?crea_labelen) = "en")}
           BIND(COALESCE(?crea_labelfr,?crea_labelen) AS ?crea_label)
           }
  OPTIONAL { ?item wdt:P195 ?coll.
           OPTIONAL{?coll rdfs:label ?coll_labelfr filter (lang(?coll_labelfr) = "fr")}
           OPTIONAL{?coll rdfs:label ?coll_labelen filter (lang(?coll_labelen) = "en")}
           BIND(COALESCE(?coll_labelfr,?coll_labelen) AS ?coll_label)
           }
  OPTIONAL { ?item wdt:P18 ?img }
  OPTIONAL { ?item wdt:P217 ?ninv }
  OPTIONAL { ?item p:P571 ?declarationdate }
  # date de publication
  OPTIONAL { ?item wdt:P577 ?datepubli
             BIND (year(?datepubli) AS ?date)}
  # date unique
  OPTIONAL { MINUS {?declarationdate pq:P1319 ?pasavant }
             MINUS {?declarationdate pq:P1480 wd:Q5727902 }
             ?declarationdate ps:P571 ?dateunique .
             BIND (year(?dateunique) AS ?date)}
  # date unique environ
  OPTIONAL { MINUS {?declarationdate pq:P1319 ?pasavant }
             ?declarationdate pq:P1480 wd:Q5727902. 
             ?declarationdate ps:P571 ?dateunique . 
             BIND (CONCAT("c.",STR(year(?dateunique))) AS ?date)}
  # période pas avant / pas apres
  OPTIONAL { ?declarationdate pq:P1319 ?pasavant . 
             ?declarationdate pq:P1326 ?pasapres.
             BIND (CONCAT(STR(year(?pasavant)),"-",STR(year(?pasapres))) AS ?date)}
  # URL vedette
  # Cas n°1, une URL via un identifiant spécifique à la collection
  OPTIONAL {
    ?item p:P195 ?declarationlcoll.
    ?declarationlcoll ps:P195 ?coll.

    {?Qprop wdt:P2378 ?coll.}
    UNION{
      ?coll  wdt:P361 ?Topcoll.
      ?Qprop wdt:P2378 ?Topcoll. 
    }
    ?Qprop wdt:P31/wdt:P279* wd:Q18618644. 
    ?Qprop wikibase:directClaim ?prop.        
    ?item ?prop ?id .
    ?Qprop wdt:P1630 ?formatterurl .  
    BIND(IRI(REPLACE(?id, '^(.+)$', ?formatterurl)) AS ?urlColl)
  }
  # Cas n°2, une URL via la propriété P973/"décrit à l'URL"
  OPTIONAL {
    ?item wdt:P973 ?urlP973.
  }
  # Cas n°3, une URL via une propriété identifant d'œuvre d'art
  OPTIONAL {
    ?Qprop wikibase:directClaim ?prop.     
    ?Qprop wdt:P31/wdt:P279* wd:Q18618644. 
    ?item ?prop ?id .
    ?Qprop wdt:P1630 ?formatterurl .  
    BIND(IRI(REPLACE(?id, '^(.+)$', ?formatterurl)) AS ?urlID)
  }
  # cas n°1 l'emporte sur cas n°2 qui l'emporte sur cas n°3
  BIND(COALESCE(COALESCE(?urlColl, ?urlP973),?urlID) AS ?url)
  SERVICE wikibase:label {bd:serviceParam wikibase:language "[AUTO_LANGUAGE],fr,en"}

} GROUP BY ?numCatalogue ?item ?itemLabel 
ORDER BY xsd:integer(?numCatalogue)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v26("?Qprop") v27("?Topcoll") v40("?URL") v6("?catalogue") v15("?coll") v16("?coll_label"):::projected v13("?coll_labelen") v14("?coll_labelfr") v37("?collection") v36("?crea") v12("?crea_label"):::projected v9("?crea_labelen") v10("?crea_labelfr") v25("?date"):::projected v20("?datepubli") v36("?dates") v23("?dateunique") v19("?declarationdate") v25("?declarationlcoll") v4("?expo") v30("?formatterurl") v29("?id") v39("?image") v17("?img"):::projected v38("?inv") v5("?item"):::projected v7("?nature") v8("?nature_label"):::projected v2("?nature_labelen") v3("?nature_labelfr") v18("?ninv"):::projected v1("?numCatalogue"):::projected v24("?pasapres") v22("?pasavant") v28("?prop") v35("?type") v34("?url"):::projected v31("?urlColl") v33("?urlID") v32("?urlP973") a1((" ")) a2((" ")) a3((" ")) c33(["#91;AUTO_LANGUAGE#93;,fr,en"]):::literal c26(["wd:Q18618644"]):::iri c31(["bd:serviceParam"]):::iri c18(["wd:Q5727902"]):::iri bind0[/"'wd:Q28043290'"/] bind0 --as--o v4 v5 --"p:direct/P608"--> v4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P972".-> v6 a1 --"p:statement/P528"--> v1 a1 --"p:qualifier/P972"--> v6 v5 --"p:P528"--> a1 end v5 --"p:direct/P31"--> v7 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v7 -."rdfs:label".-> v3 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v7 -."rdfs:label".-> v2 end bind1[/"?nature_labelfr?nature_labelen"/] v3 --o bind1 v2 --o bind1 bind1 --as--o v8 subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P170".-> v36 subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v36 -."rdfs:label".-> v10 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v36 -."rdfs:label".-> v9 end bind2[/"?crea_labelfr?crea_labelen"/] v10 --o bind2 v9 --o bind2 bind2 --as--o v12 end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P195".-> v15 subgraph optional7["(optional)"] style optional7 fill:#bbf,stroke-dasharray: 5 5; v15 -."rdfs:label".-> v14 end subgraph optional8["(optional)"] style optional8 fill:#bbf,stroke-dasharray: 5 5; v15 -."rdfs:label".-> v13 end bind3[/"?coll_labelfr?coll_labelen"/] v14 --o bind3 v13 --o bind3 bind3 --as--o v16 end subgraph optional9["(optional)"] style optional9 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P18".-> v17 end subgraph optional10["(optional)"] style optional10 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P217".-> v18 end subgraph optional11["(optional)"] style optional11 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:P571".-> v19 end subgraph optional12["(optional)"] style optional12 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P577".-> v20 bind4[/"year-from-dateTime(?datepubli)"/] v20 --o bind4 bind4 --as--o v25 end subgraph optional13["(optional)"] style optional13 fill:#bbf,stroke-dasharray: 5 5; subgraph minus5["MINUS"] style minus5 stroke-width:6px,fill:pink,stroke:red; v19 -."p:qualifier/P1319".-> v22 end subgraph minus6["MINUS"] style minus6 stroke-width:6px,fill:pink,stroke:red; v19 --"p:qualifier/P1480"--> c18 end v19 --"p:statement/P571"--> v23 bind7[/"year-from-dateTime(?dateunique)"/] v23 --o bind7 bind7 --as--o v25 end subgraph optional14["(optional)"] style optional14 fill:#bbf,stroke-dasharray: 5 5; subgraph minus8["MINUS"] style minus8 stroke-width:6px,fill:pink,stroke:red; v19 -."p:qualifier/P1319".-> v22 end v19 --"p:qualifier/P1480"--> c18 v19 --"p:statement/P571"--> v23 bind9[/"concat('c.',str(year-from-dateTime(?dateunique)))"/] v23 --o bind9 bind9 --as--o v25 end subgraph optional15["(optional)"] style optional15 fill:#bbf,stroke-dasharray: 5 5; v19 -."p:qualifier/P1319".-> v22 v19 --"p:qualifier/P1326"--> v24 bind10[/"concat(str(year-from-dateTime(?pasavant)),'-',str(year-from-dateTime(?pasapres)))"/] v22 --o bind10 v24 --o bind10 bind10 --as--o v25 end subgraph optional16["(optional)"] style optional16 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:P195".-> v25 v25 --"p:statement/P195"--> v15 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v15 --"p:direct/P361"--> v27 v26 --"p:direct/P2378"--> v27 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v26 --"p:direct/P2378"--> v15 end union0r <== or ==> union0l end v26 --"p:direct/P31"--> a2 a2 --"p:direct/P279"--> c26 v26 --"wikibase:directClaim"--> v28 v5 -->v28--> v29 v26 --"p:direct/P1630"--> v30 bind11[/"replace(?id,'^(.+)$',?formatterurl)"/] v29 --o bind11 v30 --o bind11 bind11 --as--o v31 end subgraph optional17["(optional)"] style optional17 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P973".-> v32 end subgraph optional18["(optional)"] style optional18 fill:#bbf,stroke-dasharray: 5 5; v26 -."wikibase:directClaim".-> v28 v26 --"p:direct/P31"--> a3 a3 --"p:direct/P279"--> c26 v5 -->v28--> v29 v26 --"p:direct/P1630"--> v30 bind12[/"replace(?id,'^(.+)$',?formatterurl)"/] v29 --o bind12 v30 --o bind12 bind12 --as--o v33 end bind13[/"?urlColl?urlP973?urlID"/] v31 --o bind13 v32 --o bind13 v33 --o bind13 bind13 --as--o v34 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c31 --"wikibase:language"--> c33 end bind21[/"?nature_label"/] v8 --o bind21 bind21 --as--o v35 bind22[/"?crea_label"/] v12 --o bind22 bind22 --as--o v36 bind23[/"?date"/] v25 --o bind23 bind23 --as--o v36 bind24[/"?coll_label"/] v16 --o bind24 bind24 --as--o v37 bind25[/"?ninv"/] v18 --o bind25 bind25 --as--o v38 bind26[/"sample(?img)"/] v17 --o bind26 bind26 --as--o v39 bind27[/"sample(?url)"/] v34 --o bind27 bind27 --as--o v40