# effective-stability-tier.rq # ----------------------------------------------------------------------------- # Compute the effective release contract of a CDS view as the MIN of all the # views it depends on, transitively. Returns the worst-case tier ("C1" if # any transitive binding lands on C1, etc.). # # Parameters: # $viewName — sap:CDSView with this name (e.g. "ZC_TopCustomersBySales") PREFIX atlas: PREFIX sap: SELECT ?view ?effectiveTier (MIN(?tierValue) AS ?effectiveTierValue) WHERE { # Map a C0/C1/C2 string to a comparable integer: C2=2, C1=1, C0=0. VALUES (?tierCode ?tierValue) { ("C2" 2) ("C1" 1) ("C0" 0) } ?root sap:hasVDMViewType ?rootType ; sap:hasField/sap:fieldRole "key" ; sap:hasField/^sap:hasField ?root . # self-match, anchors root ?root rdfs:label $viewName . # Traverse dependencies via sap:hasAssociation → sap:targetsView, # then again transitively with a SPARQL 1.1 path. ?root (sap:hasAssociation/sap:targetsView)* ?view . # Each dependency's own contract ?view sap:hasReleaseContract ?contract . ?contract sap:hasReleaseState ?tierCode . } GROUP BY ?view ?effectiveTier ORDER BY ?effectiveTierValue LIMIT 1