query-98d35100d9370dacd06429aeff59dbce

rq turtle/ttl

TODO

Use at

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 pqv: <http://www.wikidata.org/prop/qualifier/value/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?IMO_number ?event ?eventLabel ?eventdate WHERE {
  ?item wdt:P8047 wd:Q20.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "nb". }
  OPTIONAL { ?item p:P793 ?stat .
             ?stat ps:P793 ?event. 
             OPTIONAL {?stat pqv:P585 [
                wikibase:timePrecision ?precision ;
                wikibase:timeValue ?date_ ].
                BIND(IF(strlen(str(month(?date_)))=2,str(month(?date_)),concat("0",str(month(?date_)))) as ?month) 
                BIND(IF(strlen(str(day(?date_)))=2,str(day(?date_)),concat("0",str(day(?date_)))) as ?day) 
                BIND(IF(?precision=9,year(?date_),
                       IF(?precision=10,concat(str(year(?date_)),":",?month),
                         IF(?precision=11,concat(str(year(?date_)),":",?month,":",?day),""))) as ?date)                      
             }
             ?event rdfs:label ?eventLabel . filter(lang(?eventLabel)="nb")
             BIND(CONCAT(?eventLabel," ",str(?date)) as ?eventdate) 

            FILTER(?event IN (wd:Q906512, wd:Q1786766, wd:Q336332))
           }
  OPTIONAL { ?item wdt:P458 ?IMO_number. }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v11("?IMO_number"):::projected v9("?date") v6("?date_") v8("?day") v2("?event"):::projected v1("?eventLabel"):::projected v10("?eventdate"):::projected v3("?item"):::projected v7("?month") v5("?precision") v4("?stat") a1((" ")) c6(["wd:Q20"]):::iri c8(["bd:serviceParam"]):::iri c1(["nb"]):::literal v3 --"p:direct/P8047"--> c6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c1 end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:P793".-> v4 v4 --"p:statement/P793"--> v2 v2 --"rdfs:label"--> v1 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; a1 -."wikibase:timePrecision".-> v5 a1 --"wikibase:timeValue"--> v6 v4 --"p:qualifier/value/P585"--> a1 bind0[/"if(string-length(str(month-from-dateTime(?date_))) = '2^^xsd:integer',str(month-from-dateTime(?date_)),concat('0',str(month-from-dateTime(?date_))))"/] v6 --o bind0 bind0 --as--o v7 bind1[/"if(string-length(str(day-from-dateTime(?date_))) = '2^^xsd:integer',str(day-from-dateTime(?date_)),concat('0',str(day-from-dateTime(?date_))))"/] v6 --o bind1 bind1 --as--o v8 bind2[/"if(?precision = '9^^xsd:integer',year-from-dateTime(?date_),if(?precision = '10^^xsd:integer',concat(str(year-from-dateTime(?date_)),':',?month),if(?precision = '11^^xsd:integer',concat(str(year-from-dateTime(?date_)),':',?month,':',?day),'')))"/] v5 --o bind2 v6 --o bind2 v7 --o bind2 v8 --o bind2 bind2 --as--o v9 end bind3[/"concat(?eventLabel,' ',str(?date))"/] v1 --o bind3 v9 --o bind3 bind3 --as--o v10 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P458".-> v11 end