Dreams:projecttype

From DREAMS
Revision as of 17:49, 8 December 2022 by Fnielsen (talk | contribs) (→‎Patterns)
Jump to navigation Jump to search

Project type data

PREFIX target: <https://dreams.wikibase.cloud/entity/Q264>
PREFIX dreams: <https://dreams.wikibase.cloud/entity/>
PREFIX dreamst: <https://dreams.wikibase.cloud/prop/direct/>

SELECT DISTINCT ?description ?value ?valueLabel ?valueUrl
WHERE {
  BIND(target: AS ?effect)
  {
    BIND(1 AS ?order)
    BIND("Project type" AS ?description)
    BIND(target: AS ?value) .
  }
  UNION
  {
    BIND(5 AS ?order)
    BIND("Supertype" AS ?description)
    target: dreamst:P10 ?value .
    BIND(SUBSTR(STR(?value), 38) AS ?q) 
    BIND(CONCAT("#projecttype/", ?q) AS ?valueUrl)
  }
  UNION
  {
    BIND(6 AS ?order)
    BIND("Subtype" AS ?description)
    target: ^dreamst:P10 ?value .
    BIND(SUBSTR(STR(?value), 38) AS ?q) 
    BIND(CONCAT("#projecttype/", ?q) AS ?valueUrl)
  }
  UNION
  {
    BIND(10 AS ?order)
    BIND("External description" AS ?description)
    target: dreamst:P29 ?value .
    BIND(?value AS ?valueUrl)
  }
  UNION
  {
    BIND(100 AS ?order)
    BIND("Reports" AS ?description)
    BIND("🔍" AS ?value)
    BIND(CONCAT("#projecttype/", SUBSTR(STR(target:), 38), "/report") AS ?valueUrl)
  }
  UNION
  {
    BIND(101 AS ?order)
    BIND("Effects" AS ?description)
    BIND("🔍" AS ?value)
    BIND(CONCAT("#projecttype/", SUBSTR(STR(target:), 38), "/effect") AS ?valueUrl)
  }

  SERVICE wikibase:label { bd:serviceParam wikibase:language "da,en". }
}
ORDER BY ?order


Patterns

PREFIX target: <https://dreams.wikibase.cloud/entity/Q321>
PREFIX dreams: <https://dreams.wikibase.cloud/entity/>
PREFIX dreamst: <https://dreams.wikibase.cloud/prop/direct/>
PREFIX dreamsp: <https://dreams.wikibase.cloud/prop/>
PREFIX dreamspsv: <https://dreams.wikibase.cloud/prop/statement/value/> 

SELECT
  DISTINCT
  ?pattern ?patternLabel
  (CONCAT("#pattern/", SUBSTR(STR(?pattern), 38)) AS ?patternUrl)  

  ?subject ?subjectLabel ?subjectUrl

  ?impact ?impactLabel ?impactUrl

  ?recipient ?recipientLabel ?recipientUrl

  ?significance ?significanceLabel
 
  ?mitigation ?mitigationLabel ?mitigationUrl

  ?quote 

  ?project_phase ?project_phaseLabel
  (CONCAT("#projectphase/", SUBSTR(STR(?project_phase), 38)) AS ?project_phaseUrl)  

  ?report ?reportLabel
  (CONCAT("#report/", SUBSTR(STR(?report), 38)) AS ?reportUrl)  

  ?link ?linkUrl

WHERE {
  ?pattern dreamst:P2 dreams:Q263 ;
           dreamst:P20? / dreamst:P16 / dreamst:P10* target: .

  OPTIONAL {
    ?pattern dreamst:P33 ?subject .
    ?subject rdfs:label ?subject_label .
    FILTER(LANG(?subject_label) = 'da')
    BIND(CONCAT("#effect/", SUBSTR(STR(?subject), 38)) AS ?subjectUrl)
  }
  OPTIONAL { ?pattern dreamst:P47 ?subject_text }
  BIND(COALESCE(?subject, ?subject_text, "") AS ?subject)
  BIND(CONCAT(?subject_text, " (", COALESCE(?subject_label, ""), ")") AS ?subjectLabel)
    
  OPTIONAL {
    ?pattern dreamst:P34 ?impact . 
    ?impact rdfs:label ?impact_label .
    FILTER (LANG(?impact_label) = 'da')
    BIND(CONCAT("#effect/", SUBSTR(STR(?impact), 38)) AS ?impactUrl)
  }
  OPTIONAL { ?pattern dreamst:P49 ?impact_text }
  BIND(COALESCE(?impact, ?impact_text) AS ?impact)
  BIND(CONCAT(?impact_text, " (", COALESCE(?impact_label, ""), ")") AS ?impactLabel)

  OPTIONAL {
    ?pattern dreamst:P55 ?recipient .
    ?recipient rdfs:label ?recipient_label .
    FILTER (LANG(?recipient_label) = 'da')
    BIND(CONCAT("#effect/", SUBSTR(STR(?recipient), 38)) AS ?recipientUrl)
  }
  OPTIONAL { ?pattern dreamst:P54 ?recipient_text }
  BIND(COALESCE(?recipient, ?recipient_text) AS ?recipient)
  BIND(CONCAT(?recipient_text, " (", COALESCE(?recipient_label, ""), ")") AS ?recipientLabel)

  OPTIONAL {
    ?pattern dreamst:P56 ?mitigation .
    ?mitigation rdfs:label ?mitigation_label .
    FILTER (LANG(?mitigation_label) = 'da')
    BIND(CONCAT("#effect/", SUBSTR(STR(?mitigation), 38)) AS ?mitigationUrl)
  }
  OPTIONAL { ?pattern dreamst:P53 ?mitigation_text }
  BIND(COALESCE(?mitigation, ?mitigation_text) AS ?mitigation)
  BIND(CONCAT(?mitigation_text, " (", COALESCE(?mitigation_label, ""), ")") AS ?mitigationLabel)

  OPTIONAL { ?pattern dreamst:P18 ?quote . }
  OPTIONAL { ?pattern dreamst:P19 ?project_phase . }
  OPTIONAL { ?pattern dreamst:P20 ?report . }

  OPTIONAL { ?pattern dreamst:P21 / dreamst:P44 ?symbol . }
  BIND(IF(BOUND(?symbol), ?symbol, "❓") AS ?significance)

  OPTIONAL {
    ?pattern dreamst:P21 ?significance .
    ?significance rdfs:label ?significance_text .
    FILTER (LANG(?significance_text) = 'da')
    OPTIONAL { ?significance dreamst:P44 ?symbol . }
    BIND(IF(BOUND(?symbol), ?symbol, "❓") AS ?significance_symbol)
    BIND(CONCAT(?significance_symbol, " ", ?significance_text) AS ?significanceLabel)
  }


  SERVICE wikibase:label { bd:serviceParam wikibase:language "da,en". }
}