@prefix owl:  <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> .
@prefix bv: <https://magnowlia.com/ontology/business-vocabulary#> .
@prefix m:  <https://magnowlia.com/ontology/mapping#> .

<https://magnowlia.com/ontology/business-vocabulary> a owl:Ontology ;
    rdfs:label "Magnowlia Business Vocabulary" ;
    rdfs:comment "Framework vocabulary for defining business metrics, time dimensions, constants, and access control policies in the Magnowlia ontology framework." .

bv:Metric a owl:Class ;
    rdfs:label "Metric" ;
    rdfs:comment "A time-series business metric computed from SQL expressions." .

bv:BusinessConstant a owl:Class ;
    rdfs:label "Business Constant" ;
    rdfs:comment "A fixed numeric value used in calculations and conversions." .

bv:timeDimension a owl:ObjectProperty ;
    rdfs:label "time dimension" ;
    rdfs:comment "Associates a metric with the date or timestamp property used as its primary time dimension." ;
    rdfs:domain bv:Metric ;
    rdfs:range owl:DatatypeProperty .

bv:dependsOnProperty a owl:ObjectProperty ;
    rdfs:label "depends on property" ;
    rdfs:comment "Indicates that a metric depends on a given attribute." ;
    rdfs:domain bv:Metric ;
    rdfs:range owl:DatatypeProperty .

bv:dependsOnRelationship a owl:ObjectProperty ;
    rdfs:label "depends on relationship" ;
    rdfs:comment "Indicates that a metric depends on a particular business relationship." ;
    rdfs:domain bv:Metric ;
    rdfs:range owl:ObjectProperty .

bv:dependsOnConstant a owl:ObjectProperty ;
    rdfs:label "depends on constant" ;
    rdfs:comment "Indicates that a metric depends on a business constant value used in its calculation." ;
    rdfs:domain bv:Metric ;
    rdfs:range bv:BusinessConstant .

bv:constantValue a owl:DatatypeProperty ;
    rdfs:label "constant value" ;
    rdfs:comment "The numeric value of a business constant." ;
    rdfs:domain bv:BusinessConstant ;
    rdfs:range xsd:decimal .

bv:enumType a owl:DatatypeProperty ;
    rdfs:label "enum type" ;
    rdfs:comment "Marks a property as an enumeration. Use "dynamic" to query distinct values from the property's own column, or a well-known type ("country", "currency", "boolean", "month") for system-provided values." ;
    rdfs:domain owl:DatatypeProperty ;
    rdfs:range xsd:string .

bv:metricExpression a owl:DatatypeProperty ;
    rdfs:label "metric expression" ;
    rdfs:comment "SQL aggregation expression using b:propertyName references (e.g., "SUM(b:orderTotal)"). Property references are resolved to physical columns at parse time." ;
    rdfs:domain bv:Metric ;
    rdfs:range xsd:string .

bv:sourceEntity a owl:ObjectProperty ;
    rdfs:label "source entity" ;
    rdfs:comment "The primary business entity this metric aggregates over. The physical table is resolved via the entity's m:mapsToTable mapping." ;
    rdfs:domain bv:Metric ;
    rdfs:range owl:Class .

bv:metricPreFilter a owl:DatatypeProperty ;
    rdfs:label "metric pre-filter" ;
    rdfs:comment "Optional WHERE clause conditions applied before aggregation. Supports b:propertyName references (e.g., "b:orderStatus = 'completed'")." ;
    rdfs:domain bv:Metric ;
    rdfs:range xsd:string .

bv:metricSql a owl:DatatypeProperty ;
    rdfs:label "metric sql" ;
    rdfs:comment "Full parameterized SQL template using physical table/column names. Overrides metricExpression+sourceEntity when present. Does not support b:propertyName references." ;
    rdfs:domain bv:Metric ;
    rdfs:range xsd:string .

bv:metricCategory a owl:DatatypeProperty ;
    rdfs:label "metric category" ;
    rdfs:comment "Taxonomy path for sidebar categorization. A metric may have 0..N categories." ;
    rdfs:domain bv:Metric ;
    rdfs:range xsd:string .

bv:AccessPolicy a owl:Class ;
    rdfs:label "Access Policy" ;
    rdfs:comment "Reusable access control policy attachable to metrics, classes, or properties. Grants access to specified roles and groups." .

bv:RowFilter a owl:Class ;
    rdfs:label "Row Filter" ;
    rdfs:comment "Row-level security filter applied to metrics or classes. Uses SQL expressions with {{user.*}} placeholders resolved at query time." .

bv:accessPolicy a owl:ObjectProperty ;
    rdfs:label "access policy" ;
    rdfs:comment "Links a metric, class, or property to an access policy that controls who can see it." ;
    rdfs:range bv:AccessPolicy .

bv:rowFilter a owl:ObjectProperty ;
    rdfs:label "row filter" ;
    rdfs:comment "Links a metric or class to a row-level security filter that restricts which rows are visible." ;
    rdfs:range bv:RowFilter .

bv:allowRole a owl:DatatypeProperty ;
    rdfs:label "allow role" ;
    rdfs:comment "Organization role granted access by this policy or exempted from this row filter (repeatable). Values: "admin", "user"." ;
    rdfs:range xsd:string .

bv:allowGroup a owl:DatatypeProperty ;
    rdfs:label "allow group" ;
    rdfs:comment "User group granted access by this policy or exempted from this row filter (repeatable)." ;
    rdfs:range xsd:string .

bv:filterExpression a owl:DatatypeProperty ;
    rdfs:label "filter expression" ;
    rdfs:comment "SQL WHERE clause with {{user.*}} placeholders for row-level security. Resolved server-side against user attributes." ;
    rdfs:domain bv:RowFilter ;
    rdfs:range xsd:string .

bv:sensitivityLevel a owl:DatatypeProperty ;
    rdfs:label "sensitivity level" ;
    rdfs:comment "Data classification level for a property. Values: "Public", "Internal", "Confidential", "Restricted"." ;
    rdfs:domain owl:DatatypeProperty ;
    rdfs:range xsd:string .

bv:complianceCategory a owl:DatatypeProperty ;
    rdfs:label "compliance category" ;
    rdfs:comment "Regulatory/compliance tag for a property (repeatable). Values: "PII" (Personally Identifiable Information), "PHI" (Protected Health Information — HIPAA), "PCI" (Payment Card Industry data — PCI DSS)." ;
    rdfs:domain owl:DatatypeProperty ;
    rdfs:range xsd:string .

bv:maskingRule a owl:DatatypeProperty ;
    rdfs:label "masking rule" ;
    rdfs:comment "How to mask values when user lacks full access. Values: "redact", "hash", "partial", "round"." ;
    rdfs:domain owl:DatatypeProperty ;
    rdfs:range xsd:string .

bv:masterProperty a owl:ObjectProperty ;
    rdfs:label "master property" ;
    rdfs:comment "Links a denormalized property to its master source property in another class." ;
    rdfs:domain owl:DatatypeProperty ;
    rdfs:range owl:DatatypeProperty .

bv:MetricCorrelation a owl:Class ;
    rdfs:label "Metric Correlation" ;
    rdfs:comment "A statistical or causal relationship between two metrics." .

bv:sourceMetric a owl:ObjectProperty ;
    rdfs:label "source metric" ;
    rdfs:comment "The source (from) metric in this correlation." ;
    rdfs:domain bv:MetricCorrelation ;
    rdfs:range bv:Metric .

bv:targetMetric a owl:ObjectProperty ;
    rdfs:label "target metric" ;
    rdfs:comment "The target (to) metric in this correlation." ;
    rdfs:domain bv:MetricCorrelation ;
    rdfs:range bv:Metric .

bv:correlationType a owl:DatatypeProperty ;
    rdfs:label "correlation type" ;
    rdfs:comment "Type of metric relationship. Values: "statistical" (with numeric strength) or "causal" (directional driver with qualitative strength)." ;
    rdfs:domain bv:MetricCorrelation ;
    rdfs:range xsd:string .

bv:correlationStrength a owl:DatatypeProperty ;
    rdfs:label "correlation strength" ;
    rdfs:comment "For statistical: Spearman rank correlation coefficient from -1.0 to 1.0 (recommended over Pearson as it handles both linear and non-linear monotonic relationships). For causal: one of "strong", "moderate", "weak", "none", "unknown"." ;
    rdfs:domain bv:MetricCorrelation ;
    rdfs:range xsd:string .

bv:correlationCurve a owl:DatatypeProperty ;
    rdfs:label "correlation curve" ;
    rdfs:comment "Optional functional shape. Values: "linear", "logarithmic", "exponential", "s-curve", "step", "inverse", "parabolic", "unknown"." ;
    rdfs:domain bv:MetricCorrelation ;
    rdfs:range xsd:string .

