query-36d3c4d377e66a3a27f1abeae5a4646e
Comment causes server errorA unfortunately quite long query I am writing begins to raise a "Server error" and I don't know why … If I run the following query as is the server error appears. If I delete line 73 that is commented out anyway it runs … :-( Any hints why it behaves so strangely or simplifications of the code are very welcome!! -tags.)
Use at
- https://query.wikidata.org/sparql
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 psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT
(CONCAT(
"{{Artwork"
,"\n|artist=", IF(BOUND(?artistList), ?artistList, "")
,"\n|title="
, IF(BOUND(?titleDe),(CONCAT("{{de|", ?titleDe, "}}")), "")
, IF(BOUND(?titleEn),(CONCAT("{{en|", ?titleEn, "}}")), "")
, IF(BOUND(?titleEs),(CONCAT("{{es|", ?titleEs, "}}")), "")
, IF(BOUND(?titleFr),(CONCAT("{{fr|", ?titleFr, "}}")), "")
,"\n|date=", IF(BOUND(?inceptionStr), ?inceptionStr, "")
,"\n|medium=", ?materialList
,"\n}}"
) as ?outputStr)
?templateArtwork
# ?inceptionStr
WHERE
{{
SELECT
?item
?titleDe
?titleEn
?titleEs
?titleFr
?inception
?inceptionStr
(GROUP_CONCAT(?artistI; separator="; ") AS ?artistList)
(GROUP_CONCAT(?materialLabel; separator="; ") AS ?materialList)
WHERE
{
{
# PUT THE SEARCH QUERY HERE:
{?item wdt:P217 "CE1131"} UNION
{?item wdt:P170 wd:Q313163} . # should give 11 results
}
# artist=
OPTIONAL { ?item wdt:P170 ?artist . ?artist rdfs:label ?artistLabel . FILTER(lang(?artistLabel)="en") } .
OPTIONAL { ?artist wdt:P1472 ?creatorPage } .
BIND(IF(BOUND(?creatorPage),(CONCAT("{{Creator:", STR(?creatorPage), "}}")), ?artistLabel) as ?artistI)
# date=
# TODO: precision > 9, <6 not yet implemented
OPTIONAL { ?item wdt:P571 ?inception .
?item p:P571 ?inceptionStatement .
?inceptionStatement psv:P571/wikibase:timePrecision ?inceptionPrecision .
OPTIONAL { ?inceptionStatement pq:P1480 ?sourcingCircumstance . }
BIND(CONCAT(
"{{Complex date"
, " |date1=", CONCAT(STR(YEAR(?inception))
, " |precision1=",
IF(?inceptionPrecision = 9, "year",
IF(?inceptionPrecision = 8, "decade",
IF(?inceptionPrecision = 7, "century",
IF(?inceptionPrecision = 6, "millennium",
"PRECISION <6 IS NOT YET IMPLEMENTED!"))))
, IF(BOUND(?sourcingCircumstance) && ?sourcingCircumstance = wd:Q5727902, " |adj1=ca", "")
, "}}"
)) as ?inceptionStr)
} .
# title=
OPTIONAL { ?item rdfs:label ?titleDe . FILTER(lang(?titleDe)="de") } .
OPTIONAL { ?item rdfs:label ?titleEn . FILTER(lang(?titleEn)="en") } .
OPTIONAL { ?item rdfs:label ?titleEs . FILTER(lang(?titleEs)="es") } .
OPTIONAL { ?item rdfs:label ?titleFr . FILTER(lang(?titleFr)="fr") } .
# medium=
OPTIONAL { ?item wdt:P186 ?material . ?material rdfs:label ?materialLabel . FILTER(lang(?materialLabel)="en") } .
# institution=
OPTIONAL { ?item wdt:P195 ?institution . ?institution rdfs:label ?institutionLabel . FILTER(lang(?institutionLabel)="en") } .
OPTIONAL { ?institution wdt:P1612 ?institutionPage } .
#### BIND(IF(BOUND(?institutionPage),(CONCAT("{{Institution:", STR(?institutionPage), "}}")), ?institutionLabel) as ?institutionI)
}
GROUP BY
?item
?titleDe
?titleEn
?titleEs
?titleFr
?inception
?inceptionStr
ORDER BY ?item
}
# ?item wdt:P170 wd:Q313163 . # NO NEED FOR THIS!
SERVICE wikibase:label {bd:serviceParam wikibase:language "en,de,es,fr" .
?artist rdfs:label ?artistLabel .
}
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v9("?artist")
v11("?artistI")
v8("?artistLabel")
v20("?artistList"):::projected
v10("?creatorPage")
v12("?inception")
v14("?inceptionPrecision")
v13("?inceptionStatement")
v16("?inceptionStr"):::projected
v18("?institution")
v2("?institutionLabel")
v19("?institutionPage")
v1("?item")
v17("?material")
v3("?materialLabel")
v21("?materialList"):::projected
v22("?outputStr")
v15("?sourcingCircumstance")
v7("?titleDe"):::projected
v6("?titleEn"):::projected
v5("?titleEs"):::projected
v4("?titleFr"):::projected
a1((" "))
c8(["wd:Q313163"]):::iri
c22(["en,de,es,fr"]):::literal
c20(["bd:serviceParam"]):::iri
c6(["CE1131"]):::literal
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P170"--> c8
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v1 --"p:direct/P217"--> c6
end
union0r <== or ==> union0l
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:direct/P170".-> v9
v9 --"rdfs:label"--> v8
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v9 -."p:direct/P1472".-> v10
end
bind0[/"if(bound(?creatorPage),concat('{{Creator:',str(?creatorPage),'}}'),?artistLabel)"/]
v10 --o bind0
v8 --o bind0
bind0 --as--o v11
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:direct/P571".-> v12
v1 --"p:P571"--> v13
v13 --"p:statement/value/P571"--> a1
a1 --"wikibase:timePrecision"--> v14
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v13 -."p:qualifier/P1480".-> v15
end
bind1[/"concat('{{Complex date',' |date1=',concat(str(year-from-dateTime(?inception)),' |precision1=',if(?inceptionPrecision = '9^^xsd:integer','year',if(?inceptionPrecision = '8^^xsd:integer','decade',if(?inceptionPrecision = '7^^xsd:integer','century',if(?inceptionPrecision = '6^^xsd:integer','millennium','PRECISION <6 IS NOT YET IMPLEMENTED!')))),if(bound(?sourcingCircumstance)?sourcingCircumstance = 'wd:Q5727902',' |adj1=ca',''),'}}'))"/]
v12 --o bind1
v14 --o bind1
v15 --o bind1
bind1 --as--o v16
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v1 -."rdfs:label".-> v7
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v1 -."rdfs:label".-> v6
end
subgraph optional6["(optional)"]
style optional6 fill:#bbf,stroke-dasharray: 5 5;
v1 -."rdfs:label".-> v5
end
subgraph optional7["(optional)"]
style optional7 fill:#bbf,stroke-dasharray: 5 5;
v1 -."rdfs:label".-> v4
end
subgraph optional8["(optional)"]
style optional8 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:direct/P186".-> v17
v17 --"rdfs:label"--> v3
end
subgraph optional9["(optional)"]
style optional9 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:direct/P195".-> v18
v18 --"rdfs:label"--> v2
end
subgraph optional10["(optional)"]
style optional10 fill:#bbf,stroke-dasharray: 5 5;
v18 -."p:direct/P1612".-> v19
end
bind4[/"?artistI"/]
v11 --o bind4
bind4 --as--o v20
bind5[/"?materialLabel"/]
v3 --o bind5
bind5 --as--o v21
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c20 --"wikibase:language"--> c22
v9 --"rdfs:label"--> v8
end
bind6[/"concat('{{Artwork','
|artist=',if(bound(?artistList),?artistList,''),'
|title=',if(bound(?titleDe),concat('{{de|',?titleDe,'}}'),''),if(bound(?titleEn),concat('{{en|',?titleEn,'}}'),''),if(bound(?titleEs),concat('{{es|',?titleEs,'}}'),''),if(bound(?titleFr),concat('{{fr|',?titleFr,'}}'),''),'
|date=',if(bound(?inceptionStr),?inceptionStr,''),'
|medium=',?materialList,'
}}')"/]
v20 --o bind6
v7 --o bind6
v6 --o bind6
v5 --o bind6
v4 --o bind6
v16 --o bind6
v21 --o bind6
bind6 --as--o v22