Project:Type Complete Query

From DiSSCo Modelling Framework
Revision as of 15:21, 25 April 2022 by Jgrieb (talk | contribs) (Merge with https://modelling.dissco.tech/w/index.php?title=Project:Secondary_Type_Query so that query is generic for all types (with overtaking attributes from up to one parent type ("subclass of")))
Jump to navigation Jump to search

SELECT ?section ?sectionLabel ?item ?itemLabel ?itemDescription ?example ?dataType ?min ?max ?mandatory WHERE {

 #the type to export is ODStype1802
 BIND(wd:Q29 as $type).
 
 {
   #get all of the statements that are not sections
   ?type wdt:P14?/p:P44 ?statement.
   ?statement ps:P44 ?item.
   OPTIONAL{
     ?statement pqv:P45/wikibase:quantityAmount ?order.
   }
   MINUS {?item wdt:P1 wd:Q28}.
 }UNION{
   #get all of the sections
   ?type p:P44 ?statement.
   ?statement ps:P44 ?section.
   ?statement pqv:P45/wikibase:quantityAmount ?order.
   ?section wdt:P1 wd:Q28.
 
   #get the items of the section
   ?item p:P4 ?sectionStatement.
   ?sectionStatement ps:P4 ?section.
   OPTIONAL{
     ?sectionStatement pqv:P9/wikibase:quantityAmount ?mandatoryInternal.
     
   }
 }
 #additional optional properties
 OPTIONAL {?item wdt:P18 ?example}
 OPTIONAL {?item wdt:P10 ?dataType}
 OPTIONAL {?item wdt:P37 ?min}
 OPTIONAL {?item wdt:P38 ?max}
 BIND(IF(BOUND(?mandatoryInternal),?mandatoryInternal,"0") AS ?mandatory)
 SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
 
}ORDER BY ?order