@prefix bi: <https://ggen.ai/ontology/bi-reporting#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

# Ontology Definition
bi: a owl:Ontology ;
    dcterms:title "Business Intelligence and Reporting Ontology" ;
    dcterms:description "Ontology for BI with OLAP, dashboards, KPIs, and dimensional modeling" ;
    dcterms:created "2025-01-08"^^xsd:date ;
    owl:versionInfo "1.0.0" .

# ============================================================================
# CORE CLASSES
# ============================================================================

# Data Source Classes
bi:DataSource a owl:Class ;
    rdfs:label "Data Source" ;
    rdfs:comment "Source system for data extraction" .

bi:Database a owl:Class ;
    rdfs:subClassOf bi:DataSource ;
    rdfs:label "Database" ;
    rdfs:comment "Database data source" .

bi:API a owl:Class ;
    rdfs:subClassOf bi:DataSource ;
    rdfs:label "API" ;
    rdfs:comment "API-based data source" .

bi:File a owl:Class ;
    rdfs:subClassOf bi:DataSource ;
    rdfs:label "File" ;
    rdfs:comment "File-based data source (CSV, Excel)" .

bi:CloudService a owl:Class ;
    rdfs:subClassOf bi:DataSource ;
    rdfs:label "Cloud Service" ;
    rdfs:comment "Cloud platform data source" .

bi:Connector a owl:Class ;
    rdfs:label "Connector" ;
    rdfs:comment "Data source connector configuration" .

# Data Warehouse
bi:DataWarehouse a owl:Class ;
    rdfs:label "Data Warehouse" ;
    rdfs:comment "Central data warehouse" .

bi:DataMart a owl:Class ;
    rdfs:label "Data Mart" ;
    rdfs:comment "Subject-specific data subset" .

bi:StagingArea a owl:Class ;
    rdfs:label "Staging Area" ;
    rdfs:comment "Temporary data staging area" .

# Dimensional Model
bi:DimensionalModel a owl:Class ;
    rdfs:label "Dimensional Model" ;
    rdfs:comment "Star or snowflake schema model" .

bi:FactTable a owl:Class ;
    rdfs:label "Fact Table" ;
    rdfs:comment "Central fact table with metrics" .

bi:DimensionTable a owl:Class ;
    rdfs:label "Dimension Table" ;
    rdfs:comment "Descriptive dimension table" .

bi:TimeDimension a owl:Class ;
    rdfs:subClassOf bi:DimensionTable ;
    rdfs:label "Time Dimension" ;
    rdfs:comment "Time/date dimension" .

bi:GeographyDimension a owl:Class ;
    rdfs:subClassOf bi:DimensionTable ;
    rdfs:label "Geography Dimension" ;
    rdfs:comment "Geographic dimension" .

bi:ProductDimension a owl:Class ;
    rdfs:subClassOf bi:DimensionTable ;
    rdfs:label "Product Dimension" ;
    rdfs:comment "Product dimension" .

bi:CustomerDimension a owl:Class ;
    rdfs:subClassOf bi:DimensionTable ;
    rdfs:label "Customer Dimension" ;
    rdfs:comment "Customer dimension" .

# Measures & Metrics
bi:Measure a owl:Class ;
    rdfs:label "Measure" ;
    rdfs:comment "Quantitative metric or KPI" .

bi:CalculatedMeasure a owl:Class ;
    rdfs:subClassOf bi:Measure ;
    rdfs:label "Calculated Measure" ;
    rdfs:comment "Computed measure" .

bi:Aggregation a owl:Class ;
    rdfs:label "Aggregation" ;
    rdfs:comment "Aggregation function (SUM, AVG, COUNT)" .

# OLAP
bi:OLAPCube a owl:Class ;
    rdfs:label "OLAP Cube" ;
    rdfs:comment "Multidimensional OLAP cube" .

bi:Hierarchy a owl:Class ;
    rdfs:label "Hierarchy" ;
    rdfs:comment "Dimensional hierarchy for drill-down" .

bi:Level a owl:Class ;
    rdfs:label "Level" ;
    rdfs:comment "Level in hierarchy" .

bi:DrillDown a owl:Class ;
    rdfs:label "Drill-Down" ;
    rdfs:comment "Drill-down operation" .

bi:RollUp a owl:Class ;
    rdfs:label "Roll-Up" ;
    rdfs:comment "Roll-up aggregation" .

bi:SliceAndDice a owl:Class ;
    rdfs:label "Slice and Dice" ;
    rdfs:comment "OLAP slice and dice operation" .

# Reports
bi:Report a owl:Class ;
    rdfs:label "Report" ;
    rdfs:comment "Business intelligence report" .

bi:TabularReport a owl:Class ;
    rdfs:subClassOf bi:Report ;
    rdfs:label "Tabular Report" ;
    rdfs:comment "Table-based report" .

bi:ChartReport a owl:Class ;
    rdfs:subClassOf bi:Report ;
    rdfs:label "Chart Report" ;
    rdfs:comment "Chart visualization report" .

bi:PivotReport a owl:Class ;
    rdfs:subClassOf bi:Report ;
    rdfs:label "Pivot Report" ;
    rdfs:comment "Pivot table report" .

bi:ReportTemplate a owl:Class ;
    rdfs:label "Report Template" ;
    rdfs:comment "Reusable report template" .

bi:ReportDefinition a owl:Class ;
    rdfs:label "Report Definition" ;
    rdfs:comment "Report specification and configuration" .

# Dashboards
bi:Dashboard a owl:Class ;
    rdfs:label "Dashboard" ;
    rdfs:comment "Interactive dashboard" .

bi:Widget a owl:Class ;
    rdfs:label "Widget" ;
    rdfs:comment "Dashboard widget or component" .

bi:Chart a owl:Class ;
    rdfs:subClassOf bi:Widget ;
    rdfs:label "Chart" ;
    rdfs:comment "Chart visualization" .

bi:Table a owl:Class ;
    rdfs:subClassOf bi:Widget ;
    rdfs:label "Table" ;
    rdfs:comment "Data table widget" .

bi:Gauge a owl:Class ;
    rdfs:subClassOf bi:Widget ;
    rdfs:label "Gauge" ;
    rdfs:comment "Gauge or meter widget" .

bi:Scorecard a owl:Class ;
    rdfs:subClassOf bi:Widget ;
    rdfs:label "Scorecard" ;
    rdfs:comment "KPI scorecard" .

bi:Layout a owl:Class ;
    rdfs:label "Layout" ;
    rdfs:comment "Dashboard layout configuration" .

# KPIs
bi:KPI a owl:Class ;
    rdfs:label "KPI" ;
    rdfs:comment "Key Performance Indicator" .

bi:Target a owl:Class ;
    rdfs:label "Target" ;
    rdfs:comment "KPI target value" .

bi:Threshold a owl:Class ;
    rdfs:label "Threshold" ;
    rdfs:comment "Alert threshold" .

bi:Trend a owl:Class ;
    rdfs:label "Trend" ;
    rdfs:comment "Trend analysis" .

bi:Variance a owl:Class ;
    rdfs:label "Variance" ;
    rdfs:comment "Variance from target" .

# Scheduling & Alerts
bi:Schedule a owl:Class ;
    rdfs:label "Schedule" ;
    rdfs:comment "Report or data refresh schedule" .

bi:Alert a owl:Class ;
    rdfs:label "Alert" ;
    rdfs:comment "Automated alert notification" .

bi:Subscription a owl:Class ;
    rdfs:label "Subscription" ;
    rdfs:comment "Report subscription" .

bi:Notification a owl:Class ;
    rdfs:label "Notification" ;
    rdfs:comment "Alert notification" .

# ETL Process
bi:ETLProcess a owl:Class ;
    rdfs:label "ETL Process" ;
    rdfs:comment "Extract, Transform, Load process" .

bi:Extraction a owl:Class ;
    rdfs:label "Extraction" ;
    rdfs:comment "Data extraction step" .

bi:Transformation a owl:Class ;
    rdfs:label "Transformation" ;
    rdfs:comment "Data transformation step" .

bi:Loading a owl:Class ;
    rdfs:label "Loading" ;
    rdfs:comment "Data loading step" .

bi:DataFlow a owl:Class ;
    rdfs:label "Data Flow" ;
    rdfs:comment "End-to-end data flow" .

# Analysis
bi:Analysis a owl:Class ;
    rdfs:label "Analysis" ;
    rdfs:comment "Data analysis session" .

bi:Query a owl:Class ;
    rdfs:label "Query" ;
    rdfs:comment "Data query" .

bi:Filter a owl:Class ;
    rdfs:label "Filter" ;
    rdfs:comment "Data filter criteria" .

bi:Sorting a owl:Class ;
    rdfs:label "Sorting" ;
    rdfs:comment "Sort configuration" .

bi:Grouping a owl:Class ;
    rdfs:label "Grouping" ;
    rdfs:comment "Data grouping" .

# ============================================================================
# PROPERTIES
# ============================================================================

# Data Source Properties
bi:sourceName a owl:DatatypeProperty ;
    rdfs:domain bi:DataSource ;
    rdfs:range xsd:string ;
    rdfs:label "source name" .

bi:connectionString a owl:DatatypeProperty ;
    rdfs:domain bi:DataSource ;
    rdfs:range xsd:string ;
    rdfs:label "connection string" .

bi:sourceType a owl:DatatypeProperty ;
    rdfs:domain bi:DataSource ;
    rdfs:range xsd:string ;
    rdfs:label "source type" .

bi:lastRefresh a owl:DatatypeProperty ;
    rdfs:domain bi:DataSource ;
    rdfs:range xsd:dateTime ;
    rdfs:label "last refresh" .

bi:refreshFrequency a owl:DatatypeProperty ;
    rdfs:domain bi:DataSource ;
    rdfs:range xsd:duration ;
    rdfs:label "refresh frequency" .

bi:hasConnector a owl:ObjectProperty ;
    rdfs:domain bi:DataSource ;
    rdfs:range bi:Connector ;
    rdfs:label "has connector" .

# Dimensional Model Properties
bi:hasFactTable a owl:ObjectProperty ;
    rdfs:domain bi:DimensionalModel ;
    rdfs:range bi:FactTable ;
    rdfs:label "has fact table" .

bi:hasDimension a owl:ObjectProperty ;
    rdfs:domain bi:DimensionalModel ;
    rdfs:range bi:DimensionTable ;
    rdfs:label "has dimension" .

bi:tableName a owl:DatatypeProperty ;
    rdfs:domain [owl:unionOf (bi:FactTable bi:DimensionTable)] ;
    rdfs:range xsd:string ;
    rdfs:label "table name" .

bi:primaryKey a owl:DatatypeProperty ;
    rdfs:domain bi:DimensionTable ;
    rdfs:range xsd:string ;
    rdfs:label "primary key" .

bi:foreignKey a owl:DatatypeProperty ;
    rdfs:domain bi:FactTable ;
    rdfs:range xsd:string ;
    rdfs:label "foreign key" .

# Measure Properties
bi:hasMeasure a owl:ObjectProperty ;
    rdfs:domain bi:FactTable ;
    rdfs:range bi:Measure ;
    rdfs:label "has measure" .

bi:measureName a owl:DatatypeProperty ;
    rdfs:domain bi:Measure ;
    rdfs:range xsd:string ;
    rdfs:label "measure name" .

bi:measureValue a owl:DatatypeProperty ;
    rdfs:domain bi:Measure ;
    rdfs:range xsd:decimal ;
    rdfs:label "measure value" .

bi:aggregationType a owl:DatatypeProperty ;
    rdfs:domain bi:Measure ;
    rdfs:range xsd:string ;
    rdfs:label "aggregation type" .

bi:formula a owl:DatatypeProperty ;
    rdfs:domain bi:CalculatedMeasure ;
    rdfs:range xsd:string ;
    rdfs:label "formula" .

bi:dataType a owl:DatatypeProperty ;
    rdfs:domain bi:Measure ;
    rdfs:range xsd:string ;
    rdfs:label "data type" .

# OLAP Properties
bi:hasCube a owl:ObjectProperty ;
    rdfs:domain bi:DataWarehouse ;
    rdfs:range bi:OLAPCube ;
    rdfs:label "has cube" .

bi:cubeName a owl:DatatypeProperty ;
    rdfs:domain bi:OLAPCube ;
    rdfs:range xsd:string ;
    rdfs:label "cube name" .

bi:hasHierarchy a owl:ObjectProperty ;
    rdfs:domain bi:DimensionTable ;
    rdfs:range bi:Hierarchy ;
    rdfs:label "has hierarchy" .

bi:hierarchyName a owl:DatatypeProperty ;
    rdfs:domain bi:Hierarchy ;
    rdfs:range xsd:string ;
    rdfs:label "hierarchy name" .

bi:hasLevel a owl:ObjectProperty ;
    rdfs:domain bi:Hierarchy ;
    rdfs:range bi:Level ;
    rdfs:label "has level" .

bi:levelOrder a owl:DatatypeProperty ;
    rdfs:domain bi:Level ;
    rdfs:range xsd:integer ;
    rdfs:label "level order" .

bi:parentLevel a owl:ObjectProperty ;
    rdfs:domain bi:Level ;
    rdfs:range bi:Level ;
    rdfs:label "parent level" .

# Report Properties
bi:reportName a owl:DatatypeProperty ;
    rdfs:domain bi:Report ;
    rdfs:range xsd:string ;
    rdfs:label "report name" .

bi:reportDescription a owl:DatatypeProperty ;
    rdfs:domain bi:Report ;
    rdfs:range xsd:string ;
    rdfs:label "report description" .

bi:createdDate a owl:DatatypeProperty ;
    rdfs:domain bi:Report ;
    rdfs:range xsd:dateTime ;
    rdfs:label "created date" .

bi:lastModified a owl:DatatypeProperty ;
    rdfs:domain bi:Report ;
    rdfs:range xsd:dateTime ;
    rdfs:label "last modified" .

bi:createdBy a owl:ObjectProperty ;
    rdfs:domain bi:Report ;
    rdfs:range foaf:Person ;
    rdfs:label "created by" .

bi:hasDefinition a owl:ObjectProperty ;
    rdfs:domain bi:Report ;
    rdfs:range bi:ReportDefinition ;
    rdfs:label "has definition" .

bi:usesDataSource a owl:ObjectProperty ;
    rdfs:domain bi:Report ;
    rdfs:range bi:DataSource ;
    rdfs:label "uses data source" .

# Dashboard Properties
bi:dashboardName a owl:DatatypeProperty ;
    rdfs:domain bi:Dashboard ;
    rdfs:range xsd:string ;
    rdfs:label "dashboard name" .

bi:hasWidget a owl:ObjectProperty ;
    rdfs:domain bi:Dashboard ;
    rdfs:range bi:Widget ;
    rdfs:label "has widget" .

bi:hasLayout a owl:ObjectProperty ;
    rdfs:domain bi:Dashboard ;
    rdfs:range bi:Layout ;
    rdfs:label "has layout" .

bi:widgetTitle a owl:DatatypeProperty ;
    rdfs:domain bi:Widget ;
    rdfs:range xsd:string ;
    rdfs:label "widget title" .

bi:widgetType a owl:DatatypeProperty ;
    rdfs:domain bi:Widget ;
    rdfs:range xsd:string ;
    rdfs:label "widget type" .

bi:position a owl:DatatypeProperty ;
    rdfs:domain bi:Widget ;
    rdfs:range xsd:string ;
    rdfs:label "position" .

bi:size a owl:DatatypeProperty ;
    rdfs:domain bi:Widget ;
    rdfs:range xsd:string ;
    rdfs:label "size" .

# Chart Properties
bi:chartType a owl:DatatypeProperty ;
    rdfs:domain bi:Chart ;
    rdfs:range xsd:string ;
    rdfs:label "chart type" .

bi:xAxis a owl:DatatypeProperty ;
    rdfs:domain bi:Chart ;
    rdfs:range xsd:string ;
    rdfs:label "X axis" .

bi:yAxis a owl:DatatypeProperty ;
    rdfs:domain bi:Chart ;
    rdfs:range xsd:string ;
    rdfs:label "Y axis" .

bi:series a owl:DatatypeProperty ;
    rdfs:domain bi:Chart ;
    rdfs:range xsd:string ;
    rdfs:label "series" .

# KPI Properties
bi:hasKPI a owl:ObjectProperty ;
    rdfs:domain bi:Dashboard ;
    rdfs:range bi:KPI ;
    rdfs:label "has KPI" .

bi:kpiName a owl:DatatypeProperty ;
    rdfs:domain bi:KPI ;
    rdfs:range xsd:string ;
    rdfs:label "KPI name" .

bi:currentValue a owl:DatatypeProperty ;
    rdfs:domain bi:KPI ;
    rdfs:range xsd:decimal ;
    rdfs:label "current value" .

bi:hasTarget a owl:ObjectProperty ;
    rdfs:domain bi:KPI ;
    rdfs:range bi:Target ;
    rdfs:label "has target" .

bi:targetValue a owl:DatatypeProperty ;
    rdfs:domain bi:Target ;
    rdfs:range xsd:decimal ;
    rdfs:label "target value" .

bi:hasThreshold a owl:ObjectProperty ;
    rdfs:domain bi:KPI ;
    rdfs:range bi:Threshold ;
    rdfs:label "has threshold" .

bi:thresholdValue a owl:DatatypeProperty ;
    rdfs:domain bi:Threshold ;
    rdfs:range xsd:decimal ;
    rdfs:label "threshold value" .

bi:hasTrend a owl:ObjectProperty ;
    rdfs:domain bi:KPI ;
    rdfs:range bi:Trend ;
    rdfs:label "has trend" .

bi:trendDirection a owl:DatatypeProperty ;
    rdfs:domain bi:Trend ;
    rdfs:range xsd:string ;
    rdfs:label "trend direction" .

bi:percentageChange a owl:DatatypeProperty ;
    rdfs:domain bi:Trend ;
    rdfs:range xsd:decimal ;
    rdfs:label "percentage change" .

# Scheduling Properties
bi:hasSchedule a owl:ObjectProperty ;
    rdfs:domain bi:Report ;
    rdfs:range bi:Schedule ;
    rdfs:label "has schedule" .

bi:scheduleName a owl:DatatypeProperty ;
    rdfs:domain bi:Schedule ;
    rdfs:range xsd:string ;
    rdfs:label "schedule name" .

bi:frequency a owl:DatatypeProperty ;
    rdfs:domain bi:Schedule ;
    rdfs:range xsd:string ;
    rdfs:label "frequency" .

bi:nextRun a owl:DatatypeProperty ;
    rdfs:domain bi:Schedule ;
    rdfs:range xsd:dateTime ;
    rdfs:label "next run" .

bi:enabled a owl:DatatypeProperty ;
    rdfs:domain bi:Schedule ;
    rdfs:range xsd:boolean ;
    rdfs:label "enabled" .

bi:hasAlert a owl:ObjectProperty ;
    rdfs:domain bi:KPI ;
    rdfs:range bi:Alert ;
    rdfs:label "has alert" .

bi:alertCondition a owl:DatatypeProperty ;
    rdfs:domain bi:Alert ;
    rdfs:range xsd:string ;
    rdfs:label "alert condition" .

bi:notifyUsers a owl:ObjectProperty ;
    rdfs:domain bi:Alert ;
    rdfs:range foaf:Person ;
    rdfs:label "notify users" .

# ETL Properties
bi:hasETLProcess a owl:ObjectProperty ;
    rdfs:domain bi:DataWarehouse ;
    rdfs:range bi:ETLProcess ;
    rdfs:label "has ETL process" .

bi:processName a owl:DatatypeProperty ;
    rdfs:domain bi:ETLProcess ;
    rdfs:range xsd:string ;
    rdfs:label "process name" .

bi:hasExtraction a owl:ObjectProperty ;
    rdfs:domain bi:ETLProcess ;
    rdfs:range bi:Extraction ;
    rdfs:label "has extraction" .

bi:hasTransformation a owl:ObjectProperty ;
    rdfs:domain bi:ETLProcess ;
    rdfs:range bi:Transformation ;
    rdfs:label "has transformation" .

bi:hasLoading a owl:ObjectProperty ;
    rdfs:domain bi:ETLProcess ;
    rdfs:range bi:Loading ;
    rdfs:label "has loading" .

bi:stepOrder a owl:DatatypeProperty ;
    rdfs:domain [owl:unionOf (bi:Extraction bi:Transformation bi:Loading)] ;
    rdfs:range xsd:integer ;
    rdfs:label "step order" .

# Query & Filter Properties
bi:hasQuery a owl:ObjectProperty ;
    rdfs:domain bi:Report ;
    rdfs:range bi:Query ;
    rdfs:label "has query" .

bi:queryText a owl:DatatypeProperty ;
    rdfs:domain bi:Query ;
    rdfs:range xsd:string ;
    rdfs:label "query text" .

bi:hasFilter a owl:ObjectProperty ;
    rdfs:domain bi:Query ;
    rdfs:range bi:Filter ;
    rdfs:label "has filter" .

bi:filterField a owl:DatatypeProperty ;
    rdfs:domain bi:Filter ;
    rdfs:range xsd:string ;
    rdfs:label "filter field" .

bi:filterOperator a owl:DatatypeProperty ;
    rdfs:domain bi:Filter ;
    rdfs:range xsd:string ;
    rdfs:label "filter operator" .

bi:filterValue a owl:DatatypeProperty ;
    rdfs:domain bi:Filter ;
    rdfs:range xsd:string ;
    rdfs:label "filter value" .
